:root {
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --primary-color: #6366f1;
  --secondary-color: #a855f7;
  
  --status-active: #10b981;
  --status-warning: #f59e0b;
  --status-danger: #ef4444;
  --status-none: #64748b;
  
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  --font-mono: "SF Mono", "Menlo", "Consolas", monospace;
  
  --card-base-h: 208px;
  --card-pad-y: 16px;
  --card-pad-x: 16px;
  --card-meta-h: 20px;
  --card-title-h: 20px;
  --card-field-row-h: 15px;
  --card-field-gap: 2px;
  --card-fields-h: calc((var(--card-field-row-h) * 5) + (var(--card-field-gap) * 4));
  --card-actions-h: calc(var(--control-h) + 3px);
  --grid-gap-desktop: 16px;
  --grid-gap-mobile: 10px;

  /* Dark Theme (Default) */
  --bg-color: #080c14;
  --bg-gradient-1: rgba(99, 102, 241, 0.12);
  --bg-gradient-2: rgba(168, 85, 247, 0.08);
  --panel-bg: rgba(18, 25, 41, 0.75);
  --modal-bg: #121929;
  --modal-overlay-bg: rgba(3, 7, 18, 0.84);
  --card-bg: rgba(22, 32, 53, 0.6);
  --card-hover-bg: rgba(28, 41, 68, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover-color: rgba(99, 102, 241, 0.45);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --input-bg: rgba(10, 15, 26, 0.8);
  --sub-item-bg: rgba(10, 15, 25, 0.4);
  --btn-secondary-bg: rgba(255, 255, 255, 0.05);
  --card-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  --card-shadow-hover: 0 8px 24px rgba(99, 102, 241, 0.18);
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --control-h: 32px;
}

:root.light-theme {
  /* Light Theme */
  --bg-color: #f1f5f9;
  --bg-gradient-1: rgba(99, 102, 241, 0.06);
  --bg-gradient-2: rgba(168, 85, 247, 0.04);
  --panel-bg: rgba(255, 255, 255, 0.85);
  --modal-bg: #ffffff;
  --modal-overlay-bg: rgba(15, 23, 42, 0.42);
  --card-bg: rgba(255, 255, 255, 0.7);
  --card-hover-bg: rgba(255, 255, 255, 0.98);
  --border-color: rgba(15, 23, 42, 0.08);
  --border-hover-color: rgba(99, 102, 241, 0.4);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --input-bg: rgba(255, 255, 255, 0.95);
  --sub-item-bg: rgba(15, 23, 42, 0.03);
  --btn-secondary-bg: rgba(15, 23, 42, 0.05);
  --card-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  --card-shadow-hover: 0 10px 25px rgba(99, 102, 241, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  background-image: 
    radial-gradient(at 0% 0%, var(--bg-gradient-1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, var(--bg-gradient-2) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.1);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Authentication Screen */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-card {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary-gradient);
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 28px;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
  letter-spacing: 0;
}

.brand-logo {
  display: block;
  flex: 0 0 auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 6px 14px rgba(15, 23, 42, 0.18));
}

:root:not(.light-theme) .brand-logo {
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.34)) drop-shadow(0 0 10px rgba(14, 165, 233, 0.18));
}

.brand-logo-auth {
  width: 58px;
  height: 58px;
}

.brand-logo-header {
  width: 34px;
  height: 34px;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  padding: 12px 16px;
  font-size: 14px;
  transition: all 0.3s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}

.form-checkbox input {
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  padding: 12px 24px;
  cursor: pointer;
  width: 100%;
  transition: opacity 0.2s, transform 0.1s;
  gap: 8px;
}

.btn:hover {
  opacity: 0.95;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--border-color);
  box-shadow: none;
}

.btn-danger {
  background: var(--status-danger);
}

.btn-danger:hover {
  opacity: 0.9;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.auth-switch {
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-switch a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* Dashboard Layout */
.dashboard {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header Area */
header {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-title {
  font-size: 20px;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--btn-secondary-bg);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  border: 1px solid var(--border-color);
}

.user-badge i {
  color: var(--primary-color);
}

/* Main Dashboard Area */
main {
  flex: 1;
  padding: 16px 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Top bar filters and actions */
.top-filter-bar {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.filter-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 500px;
}

.search-wrapper i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
}

.search-input {
  width: 100%;
  height: 36px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 10px 16px 10px 42px;
  font-size: 14px;
  transition: all 0.3s;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.add-item-btn {
  height: 36px;
  width: 36px !important;
  padding: 0 !important;
  flex: 0 0 36px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.add-plus {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-family: var(--font-sans);
  font-size: 23px;
  font-weight: 600;
  line-height: 1;
  transform: translateY(-1px);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Filter Tags Groups */
.filter-tags-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.filter-tags-group::-webkit-scrollbar {
  display: none;
}

.filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-right: 8px;
  letter-spacing: 0.5px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.tag-btn {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  min-height: var(--control-h);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.header-controls .tag-btn {
  height: var(--control-h);
  align-items: center;
}

.theme-toggle-btn {
  width: var(--control-h);
  padding: 0 !important;
  justify-content: center;
}

.tag-btn:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.tag-btn.active {
  background: var(--type-bg-strong, var(--primary-color));
  border-color: var(--type-border, var(--primary-color));
  color: var(--type-fg-active, #fff);
  font-weight: 500;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.3);
}

.tag-btn[data-color-index],
.type-badge[data-color-index] {
  background: var(--type-bg);
  border-color: var(--type-border);
  color: var(--type-fg, #0f172a);
}

.tag-btn[data-color-index].active {
  background: var(--type-bg-strong);
  color: var(--type-fg-active, #0f172a);
  box-shadow: 0 0 8px var(--type-shadow);
}

[data-color-index="0"] { --type-bg: #fecaca; --type-bg-strong: #fca5a5; --type-border: rgba(248, 113, 113, 0.72); --type-shadow: rgba(248, 113, 113, 0.22); }
[data-color-index="1"] { --type-bg: #fed7aa; --type-bg-strong: #fdba74; --type-border: rgba(251, 146, 60, 0.72); --type-shadow: rgba(251, 146, 60, 0.22); }
[data-color-index="2"] { --type-bg: #fef08a; --type-bg-strong: #fde047; --type-border: rgba(234, 179, 8, 0.72); --type-shadow: rgba(234, 179, 8, 0.22); }
[data-color-index="3"] { --type-bg: #bbf7d0; --type-bg-strong: #86efac; --type-border: rgba(74, 222, 128, 0.7); --type-shadow: rgba(74, 222, 128, 0.2); }
[data-color-index="4"] { --type-bg: #a5f3fc; --type-bg-strong: #67e8f9; --type-border: rgba(6, 182, 212, 0.7); --type-shadow: rgba(6, 182, 212, 0.2); }
[data-color-index="5"] { --type-bg: #c7d2fe; --type-bg-strong: #a5b4fc; --type-border: rgba(99, 102, 241, 0.7); --type-shadow: rgba(99, 102, 241, 0.22); }
[data-color-index="6"] { --type-bg: #fda4af; --type-bg-strong: #fb7185; --type-border: rgba(244, 63, 94, 0.7); --type-shadow: rgba(244, 63, 94, 0.2); }
[data-color-index="7"] { --type-bg: #fdba74; --type-bg-strong: #fb923c; --type-border: rgba(249, 115, 22, 0.7); --type-shadow: rgba(249, 115, 22, 0.2); }
[data-color-index="8"] { --type-bg: #d9f99d; --type-bg-strong: #bef264; --type-border: rgba(132, 204, 22, 0.7); --type-shadow: rgba(132, 204, 22, 0.18); }
[data-color-index="9"] { --type-bg: #99f6e4; --type-bg-strong: #5eead4; --type-border: rgba(20, 184, 166, 0.7); --type-shadow: rgba(20, 184, 166, 0.18); }
[data-color-index="10"] { --type-bg: #bae6fd; --type-bg-strong: #7dd3fc; --type-border: rgba(14, 165, 233, 0.7); --type-shadow: rgba(14, 165, 233, 0.18); }
[data-color-index="11"] { --type-bg: #ddd6fe; --type-bg-strong: #c4b5fd; --type-border: rgba(139, 92, 246, 0.7); --type-shadow: rgba(139, 92, 246, 0.2); }
[data-color-index="12"] { --type-bg: #fca5a5; --type-bg-strong: #f87171; --type-border: rgba(220, 38, 38, 0.72); --type-shadow: rgba(220, 38, 38, 0.22); }
[data-color-index="13"] { --type-bg: #fcd34d; --type-bg-strong: #fbbf24; --type-border: rgba(217, 119, 6, 0.72); --type-shadow: rgba(217, 119, 6, 0.2); }
[data-color-index="14"] { --type-bg: #bef264; --type-bg-strong: #a3e635; --type-border: rgba(101, 163, 13, 0.7); --type-shadow: rgba(101, 163, 13, 0.18); }
[data-color-index="15"] { --type-bg: #6ee7b7; --type-bg-strong: #34d399; --type-border: rgba(5, 150, 105, 0.7); --type-shadow: rgba(5, 150, 105, 0.18); }
[data-color-index="16"] { --type-bg: #93c5fd; --type-bg-strong: #60a5fa; --type-border: rgba(37, 99, 235, 0.7); --type-shadow: rgba(37, 99, 235, 0.18); }
[data-color-index="17"] { --type-bg: #d8b4fe; --type-bg-strong: #c084fc; --type-border: rgba(126, 34, 206, 0.7); --type-shadow: rgba(126, 34, 206, 0.2); }

.more-types-dropdown {
  position: relative;
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  grid-auto-rows: var(--card-base-h);
  gap: var(--grid-gap-desktop);
  overflow-anchor: none;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.cards-grid.is-repairing-layout {
  pointer-events: none;
}

@media (min-width: 1600px) {
  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
  }
  main, .header-container {
    max-width: 1600px;
  }
}

@media (min-width: 1200px) and (max-width: 1599px) {
  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
  }
  main, .header-container {
    max-width: 1350px;
  }
}

@media (min-width: 768px) and (max-width: 1199px) {
  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 12px;
  }
  main {
    padding: 16px;
  }
}

/* Main Card Styling */
.item-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--card-pad-y) var(--card-pad-x);
  display: grid;
  grid-template-rows: var(--card-meta-h) var(--card-title-h) var(--card-fields-h) minmax(0, 1fr) var(--card-actions-h);
  align-content: start;
  row-gap: 4px;
  position: relative;
  transition: box-shadow 0.22s ease, border-color 0.22s ease, background-color 0.22s ease;
  overflow: hidden;
  min-width: 0;
  box-shadow: var(--card-shadow);
  height: 100%;
  transform: translateZ(0);
  backface-visibility: hidden;
  overflow-anchor: none;
}

.item-card:hover {
  border-color: var(--border-hover-color);
  background: var(--card-hover-bg);
  box-shadow: var(--card-shadow-hover);
}

/* Card Header (Row 1) */
.card-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  height: var(--card-meta-h);
  margin-bottom: 0;
  min-width: 0;
  white-space: nowrap;
}

.item-card.is-expanded {
  animation: card-expand-pop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: visible;
}

.item-card.is-wide-expanded {
  grid-column: span 2;
}

.badge-group {
  display: flex;
  align-items: center;
  gap: 1px;
  min-width: 0;
  overflow: visible;
}

.type-badge {
  background: var(--type-bg, rgba(99, 102, 241, 0.15));
  color: var(--type-fg, #818cf8);
  padding: 2px 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--type-border, rgba(99, 102, 241, 0.2));
  flex: 0 0 auto;
}

.custom-tag {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  padding: 2px 5px;
  border-radius: var(--radius-md);
  min-width: 0;
  overflow: visible;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  padding: 2px 8px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.status-badge.status-expired {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
  animation: pulse-red 2s infinite;
}

.status-badge.status-imminent {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-badge.status-active {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.status-none {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
}

/* Card Name (Row 2) */
.card-title-row {
  height: var(--card-title-h);
  margin-bottom: 0;
  display: flex;
  align-items: center;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Card Info fields (Rows 3-5) */
.card-fields-list {
  display: grid;
  grid-template-rows: repeat(5, var(--card-field-row-h));
  gap: var(--card-field-gap);
  height: var(--card-fields-h);
  overflow: visible;
  align-content: start;
  grid-row: 3;
}

.expanded-content-area {
  grid-row: 4;
}

.field-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.25;
  gap: 6px;
  height: var(--card-field-row-h);
  min-height: 0;
  min-width: 0;
}

.field-label {
  color: var(--text-muted);
  flex: 0 0 4.6em;
  max-width: 4.6em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-value-wrapper {
  display: flex;
  align-items: center;
  overflow: hidden;
  width: 100%;
  justify-content: flex-start;
  min-width: 0;
  cursor: pointer;
}

.field-value {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  direction: ltr;
  max-width: 100%;
}

.field-item-multiline {
  align-items: flex-start;
}

.field-item-multiline .field-value {
  white-space: pre-wrap;
  word-break: break-word;
  overflow: visible;
  text-overflow: clip;
}

.clickable-value:hover {
  color: var(--primary-color);
}

.clickable-value,
.field-value-wrapper,
.item-card .card-btn {
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.field-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
}

.field-action-btn:hover {
  color: var(--primary-color);
  background: var(--btn-secondary-bg);
}

/* Card Actions (Row 6) */
.card-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 0;
  border-top: 0;
  padding-top: 3px;
  flex-shrink: 0;
  height: var(--card-actions-h);
  min-height: var(--card-actions-h);
  align-self: end;
  grid-row: 5;
}

.card-actions-left {
  display: flex;
  gap: 5px;
  min-width: 0;
  flex: 1 1 auto;
  flex-wrap: nowrap;
}

.expand-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

.card-btn {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  min-height: var(--control-h);
  padding: 0 10px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 0 0 auto;
  line-height: 1;
  white-space: nowrap;
}

.expand-icon-btn {
  width: var(--control-h);
  height: var(--control-h);
  min-height: var(--control-h);
  padding: 0;
  font-size: 12px;
}

.card-actions-row .card-actions-left .card-btn:not(.card-btn-primary) {
  width: var(--control-h);
  padding: 0;
}

.card-actions-row .card-btn {
  width: var(--control-h);
  padding: 0;
}

.card-btn:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.card-btn-primary {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.25);
  color: #818cf8;
}

.card-btn-primary:hover {
  background: rgba(99, 102, 241, 0.3);
  color: #fff;
}

.card-btn-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.2);
}

.modal-action-btn {
  min-height: var(--control-h);
  padding: 0 12px;
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-md);
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.1s;
}

.modal-action-btn:hover {
  background: rgba(99, 102, 241, 0.28);
  color: #fff;
}

.modal-action-btn:active {
  transform: scale(0.98);
}

.modal-action-btn i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  line-height: 1;
  margin: 0;
}

/* Expanded Card Content Area */
.expanded-content-area {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0;
  border-top: 0;
  margin-top: 3px;
  overflow: visible;
  flex: 0 0 auto;
  animation: expanded-content-in 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: top center;
}

.expand-field-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.expanded-block {
  display: contents;
}

@keyframes card-expand-pop {
  from {
    opacity: 0.96;
  }
  to {
    opacity: 1;
  }
}

@keyframes expanded-content-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.expand-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.sub-items-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sub-item-box {
  display: contents;
}

.sub-item-header {
  display: contents;
}

.sub-item-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.sub-item-fields {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sub-item-display-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 5px;
  margin-top: 2px;
  border-top: 1px solid var(--border-color);
}

.sub-item-display-title {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 18px;
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1;
}

.sub-item-display-title strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memo-box {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.35;
  white-space: pre-wrap;
}

.record-logs-list {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.renewal-inline {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
  border-top: 1px dashed var(--border-color);
  padding-top: 8px;
}

.trash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.trash-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 12px;
  min-width: 0;
  box-shadow: var(--card-shadow);
}

.trash-title {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 8px;
}

.trash-meta {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
  margin-bottom: 10px;
}

.trash-actions {
  display: flex;
  justify-content: flex-end;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--modal-overlay-bg);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--modal-bg);
  background-clip: padding-box;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 650px;
  max-height: calc(100vh - 40px);
  overflow: hidden;
  margin: 0;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.72), 0 0 0 1px rgba(255, 255, 255, 0.04);
  transform: scale(0.95);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.modal-content > form {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--modal-bg);
  z-index: 10;
  flex: 0 0 auto;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  flex: 1 1 auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.modal-body .form-group {
  margin-bottom: 12px;
}

.modal-body .flex-row {
  gap: 10px;
}

.modal-body .settings-section-title {
  margin-bottom: 10px;
  padding-bottom: 6px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--modal-bg);
  z-index: 10;
  flex: 0 0 auto;
}

.confirm-overlay {
  z-index: 3000;
}

.confirm-modal {
  max-width: 420px;
}

.confirm-message {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

/* Lock & Privacy Screen Overlay */
.lock-screen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-color);
  backdrop-filter: blur(16px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.lock-screen-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.lock-box {
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.lock-icon {
  font-size: 48px;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 20px;
}

/* Success Copy Tooltip */
.copy-tooltip {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16, 185, 129, 0.9);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 20px;
  z-index: 2000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  pointer-events: none;
  animation: fade-in-out 1.5s forwards;
}

/* Form Custom styles inside modals */
.fields-builder-row {
  display: grid;
  grid-template-columns: 14px minmax(72px, 92px) minmax(0, 1fr) 18px;
  gap: 4px;
  margin-bottom: 8px;
  align-items: center;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.field-drag-handle {
  width: 14px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  cursor: grab;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-y;
}

.fields-builder-row > .field-drag-handle,
.sub-item-field-row > .field-drag-handle {
  margin-left: -4px;
}

.field-drag-handle:active,
.fields-builder-row.is-dragging .field-drag-handle {
  cursor: grabbing;
  color: var(--primary-color);
  background: rgba(99, 102, 241, 0.12);
}

.fields-builder-row.is-dragging {
  opacity: 0.9;
  z-index: 10001;
  pointer-events: none;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
}

.fields-builder-row[data-template-field="true"] {
  grid-template-columns: 14px minmax(72px, 92px) minmax(0, 1fr) 18px;
}

.field-row-placeholder {
  margin-bottom: 8px;
  border: 1px dashed rgba(99, 102, 241, 0.45);
  border-radius: var(--radius-md);
  background: rgba(99, 102, 241, 0.08);
}

.date-input {
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.date-picker-popup {
  position: fixed;
  width: min(280px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  background: var(--modal-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  padding: 12px;
  z-index: 10000;
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.date-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.date-picker-head button,
.date-picker-actions button,
.date-picker-grid button {
  border: 1px solid var(--border-color);
  background: var(--btn-secondary-bg);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.date-picker-head button {
  width: 30px;
  height: 30px;
}

.date-picker-week,
.date-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.date-picker-week span {
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 0;
}

.date-picker-grid button {
  height: 30px;
  min-width: 0;
  font-size: 12px;
}

.date-picker-grid button:hover,
.date-picker-grid button.selected {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #fff;
}

.date-picker-grid button.today:not(.selected) {
  color: var(--primary-color);
  border-color: rgba(99, 102, 241, 0.35);
}

.date-picker-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.date-picker-actions button {
  padding: 6px 10px;
  font-size: 12px;
}

.field-name-cell {
  min-width: 0;
}

.field-template-name {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  background: var(--sub-item-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-sensitive-cell {
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--btn-secondary-bg);
}

.field-sensitive-cell span {
  font-size: 11px;
}

.field-row-spacer,
.field-remove-btn,
.field-delete-btn {
  width: 18px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.field-delete-btn {
  margin-right: -4px;
}

.field-delete-btn:hover,
.sub-item-move-down-btn:hover {
  color: var(--primary-color);
  background: rgba(99, 102, 241, 0.12);
}

.sub-item-builder-box {
  margin-bottom: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.sub-item-field-row {
  display: grid;
  grid-template-columns: 14px minmax(72px, 92px) minmax(0, 1fr) 18px;
  gap: 4px;
  align-items: center;
  margin-bottom: 8px;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.sub-item-field-row .field-template-name {
  min-height: 36px;
  margin: 0;
}

.sub-item-builder-title {
  min-height: 36px;
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: var(--control-h) minmax(0, 1fr) var(--control-h);
  gap: 5px;
  align-items: center;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.sub-item-add-field-btn {
  width: var(--control-h);
  height: var(--control-h);
  min-height: var(--control-h);
  margin-right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: var(--radius-md);
  background: rgba(99, 102, 241, 0.16);
  color: #818cf8;
  cursor: pointer;
}

.sub-item-add-field-btn:hover {
  background: rgba(99, 102, 241, 0.28);
  color: #fff;
}

.sub-item-move-down-btn {
  width: var(--control-h);
  height: var(--control-h);
  min-height: var(--control-h);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.sub-item-move-down-btn:disabled {
  opacity: 0.28;
  cursor: default;
  pointer-events: none;
}

.sub-item-builder-title .sub-name-input {
  font-weight: 700;
}

.sub-item-builder-remove {
  min-height: 30px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--btn-secondary-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  gap: 5px;
  font-size: 12px;
}

.sub-item-remove-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.sub-item-builder-remove:hover {
  color: var(--status-danger);
  border-color: rgba(239, 68, 68, 0.35);
}

.sub-item-builder-box.is-dragging {
  opacity: 0.9;
  z-index: 10001;
  pointer-events: none;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
}

.sub-item-field-row.is-dragging {
  opacity: 0.9;
  z-index: 10001;
  pointer-events: none;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
}

.sub-item-placeholder {
  margin-bottom: 14px;
  border: 1px dashed rgba(99, 102, 241, 0.45);
  border-radius: var(--radius-md);
  background: rgba(99, 102, 241, 0.08);
}

.sub-field-placeholder {
  margin-bottom: 8px;
  border: 1px dashed rgba(99, 102, 241, 0.45);
  border-radius: var(--radius-md);
  background: rgba(99, 102, 241, 0.08);
}

/* Settings Sections */
.settings-section {
  margin-bottom: 24px;
  background: var(--sub-item-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.settings-section-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.settings-help-text {
  margin: 8px 0 16px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.security-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

@media (min-width: 768px) {
  .security-form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    align-items: center;
  }
}

/* Custom device lists */
.device-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--sub-item-bg);
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.device-info h4 {
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.device-info p {
  font-size: 11px;
  color: var(--text-muted);
}

/* Animations */
@keyframes pulse-red {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

@keyframes fade-in-out {
  0% { opacity: 0; transform: translate(-50%, 10px); }
  15% { opacity: 1; transform: translate(-50%, 0); }
  85% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}

/* Helper utility classes */
.flex-row {
  display: flex;
  gap: 12px;
}

.flex-row > * {
  flex: 1;
}

.text-danger {
  color: var(--status-danger);
}

.text-success {
  color: var(--status-active);
}

.m-t-20 {
  margin-top: 20px;
}

/* --- MOBILE SPECIFIC LAYOUT DIFFERENCES --- */
@media (max-width: 767px) {
  :root {
    --card-base-h: 180px;
    --control-h: 28px;
    --card-pad-y: 10px;
    --card-pad-x: 10px;
    --card-meta-h: 18px;
    --card-title-h: 18px;
    --card-field-row-h: 14px;
    --card-field-gap: 2px;
    --card-actions-h: 30px;
  }

  body {
    font-size: 14px;
  }

  main {
    padding: 12px;
  }

  header {
    padding: 12px 16px;
  }

  .app-title {
    font-size: 16px;
  }

  .user-badge {
    padding: 4px 8px;
    font-size: 11px;
  }

  .top-filter-bar {
    padding: 12px;
    gap: 12px;
    border-radius: var(--radius-md);
  }

  .filter-row-top {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .search-wrapper {
    max-width: none;
  }

  .filter-actions {
    justify-content: flex-end;
  }

  .filter-tags-group {
    gap: 6px;
  }

  .tag-btn {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: var(--radius-md);
  }

  /* 2 Columns on Mobile as required! */
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--grid-gap-mobile);
  }

  .item-card {
    padding: var(--card-pad-y) var(--card-pad-x);
    border-radius: var(--radius-lg);
  }

  .item-card.is-wide-expanded {
    grid-column: 1 / -1;
  }

  .card-meta-row {
    font-size: 9px;
    gap: 4px;
    margin-bottom: 0;
    height: var(--card-meta-h);
    line-height: 1;
  }

  .badge-group {
    gap: 1px;
  }

  .type-badge {
    padding: 2px 6px;
    border-radius: var(--radius-md);
    height: 18px;
    display: inline-flex;
    align-items: center;
    line-height: 1;
  }

  .custom-tag {
    padding: 2px 4px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    line-height: 1;
  }

  .status-badge {
    padding: 2px 6px;
    border-radius: var(--radius-md);
    height: 18px;
    line-height: 1;
  }

  .card-title {
    font-size: 13px;
    font-weight: 600;
  }

  .card-title-row {
    margin-top: 0;
    margin-bottom: 0;
    height: var(--card-title-h);
    display: flex;
    align-items: center;
  }

  .card-fields-list {
    gap: var(--card-field-gap);
    height: var(--card-fields-h);
    min-height: 0;
  }

  .field-item {
    font-size: 10.5px;
    gap: 5px;
    height: var(--card-field-row-h);
  }

  .field-label {
    flex-basis: 4.6em;
    max-width: 4.6em;
  }

  .field-value {
    font-size: 11px;
  }

  .field-action-btn {
    font-size: 10px;
    padding: 1px 2px;
  }

  .card-actions-row {
    gap: 4px;
    margin-top: 0;
    padding-top: 2px;
    height: var(--card-actions-h);
    min-height: var(--card-actions-h);
  }

  .item-card.is-expanded .card-actions-row {
    flex-wrap: nowrap;
    align-items: flex-end;
    margin-top: auto;
  }

  .item-card.is-expanded .card-actions-left {
    flex: 0 1 auto;
    flex-wrap: nowrap;
  }

  .item-card.is-expanded:not(.is-wide-expanded) .expand-actions {
    flex-basis: auto;
    justify-content: flex-end;
    margin-left: auto;
  }

  .item-card.is-wide-expanded .expand-actions {
    margin-left: auto;
  }

  .item-card .card-btn {
    width: 28px;
    min-width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0;
    font-size: 10px;
    border-radius: var(--radius-sm);
  }

  .card-actions-left,
  .expand-actions {
    gap: 4px;
  }

  .expand-icon-btn {
    width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0;
  }

  /* Sub-items box resizing on mobile */
  .sub-item-box {
    padding: 6px;
  }

  .sub-item-name {
    font-size: 11px;
  }

  /* Modals sizing */
  .modal-content {
    border-radius: var(--radius-lg);
    max-height: 95vh;
  }

  .modal-body {
    padding: 16px;
  }

  .fields-builder-row {
    grid-template-columns: 10px minmax(54px, 62px) minmax(0, 1fr) 16px;
    gap: 3px;
  }

  .fields-builder-row[data-template-field="true"] {
    grid-template-columns: 10px minmax(54px, 62px) minmax(0, 1fr) 16px;
  }

  .fields-builder-row .form-input {
    min-height: 32px;
    padding: 6px 8px;
    font-size: 12px;
  }

  .field-drag-handle {
    width: 14px;
    height: 32px;
  }

  .field-template-name {
    min-height: 32px;
    padding: 0 6px;
    font-size: 12px;
  }

  .field-sensitive-cell {
    min-height: 32px;
    padding: 0;
    gap: 0;
  }

  .field-sensitive-cell span {
    font-size: 0;
  }

  .field-sensitive-cell span::after {
    content: "敏";
    font-size: 11px;
  }

  .settings-tabs {
    margin: -2px -2px 10px;
    padding: 2px 2px 10px;
  }

  .settings-tab {
    min-height: 30px;
    padding: 0 10px;
    font-size: 11px;
  }

  .type-editor-head {
    align-items: stretch;
    flex-direction: column;
  }

  .type-editor-actions {
    justify-content: flex-start;
  }

  .field-row-spacer,
  .field-remove-btn,
  .field-delete-btn {
    width: 16px;
    height: 32px;
  }

  .sub-item-field-row {
    grid-template-columns: 10px minmax(54px, 62px) minmax(0, 1fr) 16px;
    gap: 3px;
  }

  .sub-item-builder-title {
    grid-template-columns: var(--control-h) minmax(0, 1fr) var(--control-h);
    gap: 4px;
    min-height: 32px;
  }

  .sub-item-add-field-btn,
  .sub-item-move-down-btn {
    width: var(--control-h);
    height: var(--control-h);
    min-height: var(--control-h);
  }

  .sub-item-builder-remove {
    min-height: 30px;
  }

  .sub-item-builder-title .form-input,
  .sub-item-field-row .form-input {
    min-height: 32px;
    padding: 6px 8px;
    font-size: 12px;
  }
}

/* Custom Dropdown Styling */
.custom-dropdown {
  position: relative;
  display: inline-block;
  min-width: 140px;
  user-select: none;
}

.dropdown-trigger {
  height: 36px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 10px 16px;
  font-size: 13.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.dropdown-trigger:hover {
  border-color: var(--border-hover-color);
}

.custom-dropdown.active .dropdown-trigger {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.custom-dropdown .dropdown-menu {
  display: block;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  z-index: 200;
  min-width: 140px;
  box-shadow: var(--card-shadow-hover);
  overflow: hidden;
  padding: 4px 0;
  transform: translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.custom-dropdown.active .dropdown-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.dropdown-item {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.dropdown-item.active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-color);
  font-weight: 600;
}

.settings-tabs {
  display: flex;
  gap: 8px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.settings-tabs::-webkit-scrollbar {
  display: none;
}

.settings-tab {
  min-height: 32px;
  padding: 0 12px;
}

.settings-tab.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #fff;
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: block;
}

.settings-panel .settings-section:last-child {
  margin-bottom: 0;
}

.trash-toolbar {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.renewal-date-summary {
  margin-top: 10px;
  background: var(--sub-item-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 10px;
}

.type-editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.type-editor-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.type-editor-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.types-list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.type-form-panel {
  background: var(--sub-item-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 8px;
}

.type-form-panel .form-input {
  min-height: 36px;
}

.type-form-panel textarea.form-input {
  min-height: 72px;
}

@media (max-width: 767px) {
  main {
    padding: 8px 10px;
  }

  header {
    padding: 8px 12px;
  }

  .header-container {
    gap: 8px;
  }

  .logo-section {
    flex: 0 0 auto;
    gap: 5px;
  }

  .brand-logo-header {
    width: 28px;
    height: 28px;
  }

  .app-title {
    display: inline;
    max-width: none;
    font-size: 15px;
  }

  .app-title::after {
    content: none;
  }

  .header-controls {
    flex: 1;
    justify-content: flex-end;
    gap: 5px;
    min-width: 0;
  }

  .header-controls .tag-btn {
    width: 30px;
    height: 30px;
    padding: 0 !important;
    justify-content: center;
    flex: 0 0 30px;
    border-radius: var(--radius-md);
    background: var(--input-bg);
    border-color: var(--border-hover-color);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  }

  .header-controls .tag-btn i {
    color: var(--text-primary);
    font-size: 13px;
  }

  .hide-mobile {
    display: none;
  }

  .user-badge {
    display: none;
  }

  .top-filter-bar {
    padding: 8px;
    gap: 6px;
  }

  .filter-row-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(88px, 104px) 36px;
    align-items: center;
    gap: 6px;
  }

  .filter-row-top .search-wrapper {
    min-width: 0;
  }

  .filter-row-top .search-input,
  .filter-row-top .dropdown-trigger {
    height: 34px;
  }

  .filter-row-top .search-input {
    padding: 7px 10px 7px 34px;
    text-overflow: ellipsis;
  }

  .filter-row-top .search-wrapper i {
    left: 12px;
    font-size: 14px;
  }

  .filter-actions {
    display: contents;
  }

  .filter-actions .custom-dropdown {
    min-width: 0;
    width: 100%;
  }

  .filter-actions .dropdown-trigger {
    padding: 0 10px;
    gap: 6px;
    font-size: 12px;
  }

  .add-item-btn {
    width: 36px !important;
    height: 36px;
    flex: 0 0 36px;
    padding: 0 !important;
    border-radius: var(--radius-md);
    font-size: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    position: relative;
    overflow: hidden;
  }

  .add-item-btn .add-plus {
    font-size: 23px;
    transform: translateY(-1px);
  }

  .filter-tags-group {
    min-height: 34px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    align-items: center;
    gap: 6px;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .filter-tags-group::-webkit-scrollbar {
    display: none;
  }

  .filter-label,
  .filter-tags-group .tag-btn,
  .more-types-dropdown {
    flex: 0 0 auto;
  }

  .filter-label {
    margin-right: 0;
    white-space: nowrap;
  }

  .filter-tags-group .tag-btn {
    height: 30px;
    white-space: nowrap;
  }
}
