/* ============ 518 Colonie — Admin App Styles ============ */
:root {
  --accent: #3b5bdb;
  --accent-600: #2f4cbf;
  --accent-50: #eef2ff;
  --accent-100: #e0e7ff;

  --bg: #f8f9fb;
  --surface: #ffffff;
  --surface-2: #f1f3f7;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;

  --success: #059669;
  --success-bg: #ecfdf5;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --info: #0284c7;
  --info-bg: #eff6ff;
  --danger: #dc2626;
  --danger-bg: #fef2f2;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04), 0 1px 1px rgba(15,23,42,0.03);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-lg: 0 12px 32px rgba(15,23,42,0.08), 0 2px 6px rgba(15,23,42,0.04);

  --row-h: 44px;
  --pad-y: 14px;
  --pad-x: 16px;
  --font-sm: 13px;
  --font-base: 14px;
  --font-md: 15px;

  --sidebar-w: 248px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 56px;

  --currency: "$";
}

[data-theme="dark"] {
  --bg: #0b0d12;
  --surface: #11141a;
  --surface-2: #161a22;
  --border: #1f2530;
  --border-strong: #2a3140;
  --text: #e6e8ee;
  --text-muted: #93a0b3;
  --text-soft: #6b7686;

  --accent-50: #1a2148;
  --accent-100: #232c5e;

  --success-bg: #0a2a1f;
  --warn-bg: #2a1f0a;
  --info-bg: #0a1f2a;
  --danger-bg: #2a0f0f;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
}

[data-density="compact"] {
  --row-h: 36px;
  --pad-y: 9px;
  --pad-x: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: var(--font-base);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

input, textarea, select {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 12px;
  height: 36px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 18%, transparent);
}
textarea { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  font-size: var(--font-sm);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-600); border-color: var(--accent-600); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-icon { width: 36px; padding: 0; justify-content: center; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }

/* === LAYOUT === */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.app[data-sidebar="collapsed"] { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-text {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
}
.brand-text small {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 1px;
}
[data-sidebar="collapsed"] .brand-text { display: none; }

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--font-sm);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: all 0.12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-50); color: var(--accent); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item-label { flex: 1; }
.nav-item-badge {
  font-size: 11px;
  background: var(--surface-2);
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--text-muted);
  font-weight: 500;
}
.nav-item.active .nav-item-badge { background: var(--accent-100); color: var(--accent); }
[data-sidebar="collapsed"] .nav-item-label,
[data-sidebar="collapsed"] .nav-item-badge { display: none; }
[data-sidebar="collapsed"] .nav-item { justify-content: center; padding: 0; }

.sidebar-section-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  padding: 14px 12px 6px;
}
[data-sidebar="collapsed"] .sidebar-section-label { display: none; }

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-600));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 500; font-size: var(--font-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }
[data-sidebar="collapsed"] .user-info,
[data-sidebar="collapsed"] .sidebar-footer .btn-icon { display: none; }
[data-sidebar="collapsed"] .sidebar-footer { justify-content: center; padding: 10px 0; }

/* Main */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title { font-weight: 600; font-size: 15px; }
.topbar-spacer { flex: 1; }
.topbar-search {
  position: relative;
  width: 280px;
}
.topbar-search input {
  padding-left: 34px;
  height: 34px;
  background: var(--surface-2);
  border-color: transparent;
}
.topbar-search svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--text-soft);
}

.kbd {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-muted);
}

.content {
  padding: 24px;
  flex: 1;
}
.content-narrow { max-width: 1100px; margin: 0 auto; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-title { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 4px; }
.page-sub { color: var(--text-muted); font-size: var(--font-sm); margin: 0; }
.page-actions { display: flex; gap: 8px; }

/* === CARDS === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-weight: 600; font-size: var(--font-md); }
.card-body { padding: 18px; }
.card-body-flush { padding: 0; }

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.stat-label svg { width: 14px; height: 14px; }
.stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 8px;
  font-feature-settings: 'tnum';
}
.stat-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  margin-top: 6px;
  color: var(--text-muted);
}
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* === TABLE === */
.table-wrap { overflow-x: auto; }
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-base);
}
.tbl th {
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-muted);
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.tbl td {
  padding: var(--pad-y) var(--pad-x);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.clickable { cursor: pointer; transition: background 0.12s; }
.tbl tr.clickable:hover td { background: var(--surface-2); }
.tbl td.num, .tbl th.num { text-align: right; font-feature-settings: 'tnum'; }
.tbl td.muted { color: var(--text-muted); }

/* Avatar in cell */
.cell-user {
  display: flex; align-items: center; gap: 10px;
}
.cell-user .avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}
.cell-user-meta { line-height: 1.25; }
.cell-user-name { font-weight: 500; }
.cell-user-sub { color: var(--text-muted); font-size: 12px; }

/* === STATUS BADGES === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  text-transform: capitalize;
}
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.pending { color: var(--warn); background: var(--warn-bg); }
.badge.in-progress { color: var(--info); background: var(--info-bg); }
.badge.completed { color: var(--success); background: var(--success-bg); }
.badge.approved { color: var(--success); background: var(--success-bg); }
.badge.rejected { color: var(--danger); background: var(--danger-bg); }
.badge.draft { color: var(--text-muted); background: var(--surface-2); }
.badge.invoiced { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.badge::before { display: inline-block; }
.badge.no-dot::before { display: none; }

/* === FILTER BAR === */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.filter-search {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}
.filter-search input { padding-left: 32px; height: 32px; }
.filter-search svg {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--text-soft);
}
.tabs {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 7px;
  padding: 2px;
  gap: 1px;
}
.tab {
  padding: 5px 12px;
  border-radius: 5px;
  border: none;
  background: transparent;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* === MODAL / DRAWER === */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.40);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.15s ease;
}
[data-theme="dark"] .modal-backdrop { background: rgba(0,0,0,0.6); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  animation: slideUp 0.18s ease;
}
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title { font-weight: 600; font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Drawer (slide-in from right) */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.30);
  z-index: 90;
  animation: fadeIn 0.15s ease;
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 91;
  display: flex;
  flex-direction: column;
  animation: slideLeft 0.22s ease;
}
@keyframes slideLeft { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* === FORM GRID === */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }

/* Empty state */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-icon {
  width: 44px; height: 44px;
  margin: 0 auto 14px;
  border-radius: 10px;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-soft);
}
.empty-icon svg { width: 20px; height: 20px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-sub { font-size: 13px; }

/* Skeleton */
.skel {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* === ESTIMATE BUILDER === */
.estimate-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1100px) {
  .estimate-layout { grid-template-columns: 1fr; }
}
.line-row {
  display: grid;
  grid-template-columns: 2fr 90px 110px 110px 36px;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.line-row:last-child { border-bottom: none; }
.line-row input { height: 34px; }
.line-row .lbl-only {
  font-size: 11px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.line-row.headers { padding: 0 0 8px; border-bottom: 1px solid var(--border); }
.line-row.headers > div { font-size: 11px; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }

.summary-card {
  position: sticky;
  top: calc(var(--topbar-h) + 24px);
}
.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  font-feature-settings: 'tnum';
  font-size: var(--font-sm);
}
.summary-row.total {
  font-size: 18px;
  font-weight: 600;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 14px;
}
.summary-row .label { color: var(--text-muted); }

/* PDF preview */
.pdf-shell {
  background: var(--surface-2);
  padding: 32px;
  display: flex;
  justify-content: center;
}
.pdf-page {
  width: 8.5in;
  min-height: 11in;
  background: white;
  color: #0f172a;
  box-shadow: var(--shadow-lg);
  padding: 0.65in 0.7in;
  font-size: 11pt;
  line-height: 1.5;
}

@media print {
  body { background: white; }
  .sidebar, .topbar, .no-print { display: none !important; }
  .main, .content, .pdf-shell { padding: 0 !important; background: white !important; }
  .pdf-page { box-shadow: none; padding: 0.5in; width: 100%; min-height: auto; }
  .app { grid-template-columns: 1fr !important; }
}

/* === CLIENT PICKER === */
.client-picker { position: relative; width: 100%; }
.client-picker-trigger {
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--font-base);
  color: var(--text);
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.client-picker-trigger:hover { border-color: var(--text-soft); }
.client-picker-trigger.open,
.client-picker-trigger:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 18%, transparent);
}
.client-picker-trigger svg { color: var(--text-soft); flex-shrink: 0; }
.client-picker-value { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.client-picker-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-picker-placeholder { color: var(--text-soft); }

.client-picker-pop {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  z-index: 60;
  display: flex;
  flex-direction: column;
  max-height: 360px;
  overflow: hidden;
  animation: slideUp 0.14s ease;
}
.client-picker-search {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.client-picker-search svg { color: var(--text-soft); flex-shrink: 0; }
.client-picker-search input {
  flex: 1;
  border: none;
  height: auto;
  padding: 0;
  background: transparent;
  font-size: var(--font-base);
}
.client-picker-search input:focus { box-shadow: none; }

.client-picker-list { overflow-y: auto; flex: 1; padding: 4px; }
.client-picker-empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.client-picker-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  font-size: var(--font-base);
  color: var(--text);
}
.client-picker-item:hover { background: var(--surface-2); }
.client-picker-item.selected { background: var(--accent-50); color: var(--accent); }
.client-picker-item.selected svg { color: var(--accent); }
.client-picker-item-info { flex: 1; min-width: 0; }
.client-picker-item-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-picker-item-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-picker-item.selected .client-picker-item-sub { color: var(--accent); opacity: 0.85; }

.client-picker-add {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 12px 14px;
  background: var(--accent-50);
  color: var(--accent);
  border: none;
  border-top: 1px solid var(--border);
  font-size: var(--font-sm);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.client-picker-add:hover { background: var(--accent-100); }

.client-picker-create { display: flex; flex-direction: column; }
.client-picker-create-head {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.client-picker-create-title { font-weight: 600; font-size: 14px; }
.client-picker-create-body {
  padding: 14px;
  display: flex; flex-direction: column; gap: 4px;
  overflow-y: auto;
}
.client-picker-create-body label { margin-top: 8px; }
.client-picker-create-body label:first-child { margin-top: 0; }
.client-picker-create-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}

/* Material picker */
.mat-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
}
.mat-pick:hover { background: var(--surface-2); }
.mat-pick-swatch {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.mat-pick-info { flex: 1; min-width: 0; }
.mat-pick-name { font-weight: 500; font-size: var(--font-sm); }
.mat-pick-meta { font-size: 11.5px; color: var(--text-muted); }

/* === MOBILE === */
.mobile-menu-btn { display: none; }
.sidebar-mobile-logout { display: none; }
.mobile-backdrop { display: none; }
.mobile-bottom-nav { display: none; }

/* Tablet & smaller */
@media (max-width: 1100px) {
  .content { padding: 20px; }
  .topbar { padding: 0 16px; }
  .topbar-search { width: 200px; }
  .topbar-search .kbd { display: none; }
}

/* Mobile */
@media (max-width: 880px) {
  :root { --topbar-h: 56px; }

  .app { grid-template-columns: 1fr !important; }

  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    height: 100vh;
    height: 100dvh; /* shrinks with Safari's bottom toolbar */
    width: 86vw; max-width: 320px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.24s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-nav { padding-bottom: 4px; }
  .sidebar-footer {
    padding: 10px;
    /* Push the user row above iOS Safari's bottom toolbar / home indicator */
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
  /* The icon-only logout button in the footer can be blocked by Safari's
     bottom toolbar — hide it and use the top-of-sidebar one instead. */
  .sidebar-footer .btn-icon { display: none; }

  /* Top-of-sidebar Sign out — always visible the moment the menu opens */
  .sidebar-brand {
    height: auto;
    padding: 14px 16px;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: space-between;
  }
  .sidebar-mobile-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    margin-left: auto;
  }
  .sidebar-mobile-logout:hover { background: var(--surface-2); }
  .sidebar-mobile-logout:active { background: var(--accent-50); color: var(--accent); border-color: var(--accent); }
  .app[data-mobile-nav="open"] .sidebar { transform: translateX(0); }
  .app[data-mobile-nav="open"] .mobile-backdrop {
    display: block; position: fixed; inset: 0;
    background: rgba(15,23,42,0.5); z-index: 199;
    backdrop-filter: blur(2px);
  }

  .mobile-menu-btn { display: inline-flex; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-search { display: none; }
  .topbar-title { font-size: 16px; flex: 1; }
  .topbar > .btn-icon:not(.mobile-menu-btn) { display: none; }

  .content { padding: 16px; padding-bottom: 80px; }

  /* Stack page header on mobile */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }
  .page-title { font-size: 22px; }
  .page-actions { width: 100%; flex-wrap: wrap; }
  .page-actions .btn { flex: 1; justify-content: center; min-width: 120px; }

  /* Stack 2-col split layouts on mobile (specific patterns used in screens) */
  .content > div[style*="1fr 380px"],
  .content > div[style*="1fr 360px"],
  .content > div[style*="1fr 320px"],
  .content > div[style*="1fr 280px"],
  .content > div[style*="1fr 240px"] {
    grid-template-columns: 1fr !important;
  }
  .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .stats-grid[style*="grid-template-columns"] { grid-template-columns: 1fr 1fr !important; }
  /* 3-col stat grids → 1 row of small cards on small screens */
  .content .stats-grid[style*="repeat(3"] { grid-template-columns: repeat(3, 1fr) !important; }
  .stat { padding: 14px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 11px; }

  /* Forms */
  .form-grid { grid-template-columns: 1fr; gap: 12px; }

  /* Detail hero stack */
  .detail-hero {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 16px 18px;
  }
  .detail-hero h2 { font-size: 19px; }
  .detail-hero > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; }
  .detail-hero > div:last-child .btn { flex: 1; justify-content: center; min-width: 100px; }
  .detail-hero > div:last-child select { flex: 1; min-width: 120px; }
  .detail-meta { gap: 8px 12px; flex-direction: column; align-items: flex-start; }

  /* Modals as bottom sheets */
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
    overscroll-behavior: contain;
  }
  .modal {
    max-width: 100% !important;
    width: 100%;
    max-height: 92dvh;
    height: auto;
    border-radius: 18px 18px 0 0;
    border: none;
    border-top: 1px solid var(--border);
    animation: slideUpSheet 0.26s cubic-bezier(0.32, 0.72, 0, 1);
    overflow: hidden;
  }
  @keyframes slideUpSheet {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  /* Sticky header with grab handle */
  .modal-header {
    padding: 8px 14px 12px;
    flex-shrink: 0;
    position: relative;
  }
  .modal-header::before {
    content: '';
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 36px; height: 4px;
    border-radius: 2px;
    background: var(--border-strong);
  }
  .modal-title { padding-top: 10px; font-size: 17px; }
  .modal-header .btn-icon { margin-top: 6px; }

  /* Body fills remaining space, scrolls on its own */
  .modal-body {
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    flex: 1 1 auto;
    min-height: 0;
  }

  /* Sticky footer with safe-area inset */
  .modal-footer {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    background: var(--surface);
  }
  .modal-footer .btn { flex: 1; justify-content: center; min-height: 46px; }

  /* Drawer = full width */
  .drawer { max-width: 100%; }

  /* Cards a bit tighter */
  .card-header { padding: 12px 14px; }
  .card-body { padding: 14px; }

  /* Filter bar — stack vertical */
  .filter-bar {
    padding: 10px 12px;
    gap: 8px;
  }
  .filter-search { max-width: none; width: 100%; }
  .tabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .tab { white-space: nowrap; }

  /* Table cells tighter */
  .tbl th, .tbl td { padding: 10px 12px; }
  .tbl th { font-size: 11px; }

  /* Bigger touch targets */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 32px; }
  .btn-icon { width: 40px; }
  .btn-icon.btn-sm { width: 32px; }
  /* 16px font-size on inputs is the iOS Safari threshold below which it auto-zooms */
  input, select { height: 44px; font-size: 16px; }
  textarea { font-size: 16px; }
  label { font-size: 12.5px; }

  /* Client picker fills more space + bigger touch */
  .client-picker-trigger { height: 44px; }
  .client-picker-pop { max-height: 60vh; }
  .client-picker-item { padding: 10px 10px; }

  /* Mobile bottom nav */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 80;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    gap: 2px;
    box-shadow: 0 -1px 3px rgba(15,23,42,0.04);
  }
  .mobile-bottom-nav button {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px 4px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    min-height: 52px;
  }
  .mobile-bottom-nav button.active { color: var(--accent); }
  .mobile-bottom-nav button.active svg { color: var(--accent); }
  .mobile-bottom-nav svg { width: 20px; height: 20px; }

  /* Sticky sidebar on mobile shouldn't push content */
  .sidebar { height: 100vh; position: fixed; }

  /* Calendar shrinks on mobile */
  .content div[style*="grid-auto-rows"] { grid-auto-rows: 64px !important; }

  /* Estimate builder lines stack on mobile */
  .line-row {
    grid-template-columns: 1fr 1fr 36px;
    grid-template-areas:
      "desc desc desc"
      "surface price del"
      "subtotal subtotal subtotal";
    gap: 8px;
    padding: 12px 0;
  }
  .line-row.headers { display: none; }
  .line-row > :nth-child(1) { grid-area: desc; }
  .line-row > :nth-child(2) { grid-area: surface; }
  .line-row > :nth-child(3) { grid-area: price; }
  .line-row > :nth-child(4) { grid-area: subtotal; text-align: right; font-weight: 500; }
  .line-row > :nth-child(5) { grid-area: del; }

  /* Timeline tighter */
  .timeline { padding-left: 18px; }

  /* Tweaks panel becomes a sheet */
  .tweaks-panel {
    max-width: 100% !important;
    width: 100% !important;
    bottom: 0; top: auto; right: 0;
    border-radius: 16px 16px 0 0 !important;
    border-left: none !important;
    border-top: 1px solid var(--border) !important;
    max-height: 80vh;
  }
}

/* Very small phones */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .page-title { font-size: 20px; }
  .topbar-title { font-size: 15px; }
  .content { padding: 12px; padding-bottom: 80px; }
  .detail-hero { padding: 14px; }
  .card-header { padding: 12px; }
  .card-body { padding: 12px; }
  .modal-body { padding: 14px; }
  .filter-bar { padding: 8px 10px; }
}

/* ============================================================
   Tables → cards on phones (every list screen)
   ============================================================ */
@media (max-width: 600px) {
  .card .filter-bar + .table-wrap,
  .card > .table-wrap { overflow: visible; }

  .tbl,
  .tbl thead,
  .tbl tbody,
  .tbl tr,
  .tbl td { display: block; width: 100%; }
  .tbl thead { display: none; }

  .tbl tbody { padding: 8px; display: flex; flex-direction: column; gap: 8px; }

  .tbl tr {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    margin: 0;
  }
  .tbl tr.clickable:hover td { background: transparent; }
  .tbl tr.clickable:active { background: var(--surface-2); }

  .tbl td {
    padding: 2px 0 !important;
    border: none !important;
    font-size: 13.5px;
    text-align: left !important;
  }
  .tbl td.num {
    text-align: left !important;
    font-weight: 500;
  }
  .tbl td:first-child {
    font-weight: 600;
    font-size: 15.5px;
    color: var(--text);
    margin-bottom: 4px;
  }
  /* Pin cells that contain buttons (action cells) to top-right */
  .tbl tr:has(td:last-child button) td:first-child { padding-right: 90px !important; }
  .tbl tr td:has(button) {
    position: absolute;
    top: 8px; right: 8px;
    width: auto !important;
    margin: 0;
    padding: 0 !important;
  }
  .tbl tr td:has(button) > div {
    justify-content: flex-end !important;
  }
  .tbl tr td:has(button):empty { display: none; }
  /* Numeric cells stand out as small chips */
  .tbl td.num:not(:first-child) {
    display: inline-block;
    width: auto !important;
    background: var(--surface-2);
    padding: 2px 8px !important;
    border-radius: 6px;
    margin-right: 6px;
    font-size: 13px;
    color: var(--text);
  }
  /* Status badge sits flush */
  .tbl td .badge { vertical-align: middle; }

  /* Status / muted secondary lines styled subtler */
  .tbl td.muted { color: var(--text-muted); font-size: 12.5px; }

  /* Estimate-detail "Painting work" + materials tables stay tabular,
     so opt them back in by giving them a dedicated parent class. */
  .keep-table-mobile .tbl,
  .keep-table-mobile .tbl thead,
  .keep-table-mobile .tbl tbody,
  .keep-table-mobile .tbl tr,
  .keep-table-mobile .tbl td,
  .keep-table-mobile .tbl th { display: revert; }
  .keep-table-mobile .tbl thead { display: table-header-group; }
  .keep-table-mobile .tbl tbody { display: table-row-group; padding: 0; }
  .keep-table-mobile .tbl tr { display: table-row; border: none; padding: 0; }
  .keep-table-mobile .tbl td,
  .keep-table-mobile .tbl th { display: table-cell; }
}

/* ============================================================
   ClientPicker → fullscreen sheet on mobile
   ============================================================ */
@media (max-width: 880px) {
  .client-picker-pop {
    position: fixed;
    inset: 0;
    top: 0; left: 0; right: 0; bottom: 0;
    max-height: none;
    border-radius: 0;
    border: none;
    z-index: 300;
    animation: pickerSlideIn 0.22s cubic-bezier(0.32, 0.72, 0, 1);
  }
  @keyframes pickerSlideIn {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
  }
  .client-picker-mobile-head {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
  }
  .client-picker-mobile-title { font-weight: 600; font-size: 16px; }
  .client-picker-search { padding: 14px; }
  .client-picker-search input { font-size: 16px; }
  .client-picker-list { padding: 8px; }
  .client-picker-item { padding: 12px 12px; min-height: 52px; }
  .client-picker-add {
    padding: 16px;
    font-size: 15px;
  }
  .client-picker-create-body { padding: 16px; gap: 6px; }
  .client-picker-create-body input { height: 46px; font-size: 16px; }
  .client-picker-create-foot {
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  }
  .client-picker-create-foot .btn { flex: 1; justify-content: center; min-height: 46px; }
}

/* On desktop the mobile head is hidden */
@media (min-width: 881px) {
  .client-picker-mobile-head { display: none; }
}

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
}
@media (max-width: 880px) {
  .login-page { grid-template-columns: 1fr; }
  .login-art { display: none; }
}
.login-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.login-form {
  width: 100%;
  max-width: 360px;
}
.login-art {
  background: var(--accent);
  background-image:
    radial-gradient(circle at 20% 30%, color-mix(in oklch, white 18%, transparent), transparent 50%),
    radial-gradient(circle at 80% 70%, color-mix(in oklch, white 12%, transparent), transparent 50%),
    linear-gradient(135deg, var(--accent) 0%, var(--accent-600) 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 48px;
  color: white;
}
.login-art::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(135deg, rgba(255,255,255,0.04) 0 2px, transparent 2px 80px);
}
.login-art-content { position: relative; }
.login-art h2 { font-family: 'Fraunces', serif; font-size: 32px; line-height: 1.15; margin: 0 0 12px; max-width: 380px; font-weight: 500; }
.login-art p { color: rgba(255,255,255,0.8); margin: 0; font-size: 15px; }

.login-brand {
  display: inline-flex; align-items: center; gap: 12px; margin-bottom: 36px;
}
.login-brand .brand-mark { width: 40px; height: 40px; border-radius: 10px; }
.login-brand .brand-text { font-size: 17px; }
.login-brand .brand-text small { font-size: 11px; }

/* Misc utility */
.hstack { display: flex; align-items: center; gap: 8px; }
.vstack { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--text-muted); }
.text-mono { font-feature-settings: 'tnum'; font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.tag {
  display: inline-flex; align-items: center;
  font-size: 11.5px; font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-muted);
}

/* Detail header */
.detail-hero {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.detail-hero h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.detail-meta { color: var(--text-muted); font-size: var(--font-sm); margin-top: 4px; display: flex; gap: 14px; flex-wrap: wrap; }
.detail-meta-item { display: inline-flex; align-items: center; gap: 5px; }
.detail-meta-item svg { width: 13px; height: 13px; }

/* Section header */
.section-h {
  font-weight: 600; font-size: 13px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin: 24px 0 10px;
}

/* Pill toggle */
.pill-toggle {
  display: inline-flex; padding: 2px;
  background: var(--surface-2); border-radius: 8px;
}
.pill-toggle button {
  padding: 6px 14px; border: none; background: transparent;
  border-radius: 6px; font-size: var(--font-sm); font-weight: 500;
  color: var(--text-muted); cursor: pointer;
}
.pill-toggle button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* === TIMELINE === */
.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px;
  width: 2px; background: var(--border);
}
.tl-event { position: relative; padding-bottom: 18px; }
.tl-event:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -22px; top: 4px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.tl-dot svg { width: 10px; height: 10px; }
.tl-event[data-type="approved"] .tl-dot,
.tl-event[data-type="deposit"] .tl-dot { border-color: var(--success); color: var(--success); }
.tl-event[data-type="sent"] .tl-dot { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.tl-event[data-type="viewed"] .tl-dot { border-color: var(--text-muted); color: var(--text-muted); }
.tl-event[data-type="rejected"] .tl-dot { border-color: var(--danger); color: var(--danger); }
.tl-head {
  display: flex; justify-content: space-between; gap: 8px;
  align-items: baseline; font-size: 13px;
}
.tl-head .who { font-weight: 500; }
.tl-head .when { color: var(--text-soft); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-note { font-size: 13px; color: var(--text-muted); margin-top: 2px; line-height: 1.5; }

/* === SECONDARY TABS (inside detail) === */
.subtabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.subtab {
  padding: 10px 14px; background: none; border: none; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 6px;
}
.subtab:hover { color: var(--text); }
.subtab.active { color: var(--accent); border-bottom-color: var(--accent); }
.subtab .count {
  background: var(--surface-2); color: var(--text-muted);
  padding: 1px 6px; border-radius: 999px; font-size: 11px; font-weight: 600;
}
.subtab.active .count { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }

/* === ACTION DROPDOWN === */
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  min-width: 220px; padding: 6px; z-index: 50;
}
.menu-item {
  width: 100%; text-align: left; background: none; border: none;
  padding: 9px 10px; border-radius: 6px; font-size: 13px; color: var(--text);
  cursor: pointer; display: flex; align-items: center; gap: 10px;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }
.menu-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* === SEND MODAL === */
.send-recipient {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--surface-2);
  border-radius: 8px; border: 1px solid var(--border);
}
.send-recipient .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}
.field-label {
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 6px; display: block;
}

/* === DEPOSIT BAR === */
.deposit-bar {
  height: 8px; background: var(--surface-2);
  border-radius: 999px; overflow: hidden; margin: 6px 0 4px;
}
.deposit-bar > span {
  display: block; height: 100%;
  background: var(--success);
  border-radius: 999px;
}

/* === CLIENT-FACING PREVIEW === */
.client-preview {
  margin: -24px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 6%, var(--surface-2)) 0%, var(--surface-2) 280px);
  min-height: calc(100vh - var(--topbar-h));
  padding: 32px 24px;
}
.client-card {
  max-width: 720px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-md);
  overflow: hidden;
}
.client-card-head {
  padding: 28px 32px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
}
.client-card-body { padding: 28px 32px; }
.client-cta {
  display: flex; gap: 10px; padding: 16px 32px;
  background: var(--surface-2); border-top: 1px solid var(--border);
}

/* === SETTINGS === */
.settings-page { max-width: 1100px; }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin: 4px 0 0; max-width: 560px; }

.settings-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: start;
}

.settings-tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 80px;
}
.settings-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: all 0.12s;
}
.settings-tab:hover { background: var(--surface-2); color: var(--text); }
.settings-tab.active {
  background: var(--accent-50);
  color: var(--accent);
}
.settings-tab svg { width: 16px; height: 16px; flex-shrink: 0; }

.settings-content { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
}
.settings-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
.settings-card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 3px;
  letter-spacing: -0.01em;
}
.settings-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
  max-width: 560px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 18px;
}

.settings-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 0; }
.settings-field.full { grid-column: 1 / -1; }
.settings-field-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.settings-field .input {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 12px;
  height: 36px;
  font-size: 13px;
  color: var(--text);
  width: 100%;
  font-family: inherit;
}
.settings-field textarea.input { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.settings-field .input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 18%, transparent);
}

.settings-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 16px;
}
.settings-section:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}
.settings-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.settings-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.settings-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
  cursor: pointer;
}
.settings-toggle:last-child { border-bottom: none; }
.settings-toggle-text { flex: 1; min-width: 0; }
.settings-toggle-label { font-size: 13.5px; font-weight: 500; color: var(--text); }
.settings-toggle-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.45; }

/* Saving indicator dot */
.spin-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--text-muted);
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Editable list (settings-style) === */
.edit-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.edit-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.edit-row .input { flex: 1; height: 38px; }
.edit-row.hidden .input {
  color: var(--text-soft);
  background: var(--surface-2);
  text-decoration: line-through;
  text-decoration-color: var(--text-soft);
}
.edit-list-empty {
  padding: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.edit-list-add {
  align-self: flex-start;
  margin-top: 4px;
  color: var(--accent);
}
.edit-list-add:hover { background: var(--accent-50); }

/* Object list (e.g. services / gallery / process) */
.object-list { display: flex; flex-direction: column; gap: 12px; }
.object-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0;
  overflow: hidden;
}
.object-row-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.object-row-num {
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.object-row-body {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px;
}
.object-field { display: flex; flex-direction: column; gap: 4px; }
.object-field > label {
  font-size: 11px; font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin: 0;
}

/* Section visibility pill (in card titles) */
.section-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  vertical-align: middle;
  text-transform: none;
  letter-spacing: 0;
}
.section-toggle.on {
  background: var(--accent-50);
  border-color: var(--accent);
  color: var(--accent);
}
.section-toggle.off { background: var(--surface-2); }
.section-toggle:hover { filter: brightness(0.97); }

/* === Expiry picker (chip-based) === */
.expiry-field { display: flex; flex-direction: column; gap: 8px; }
.expiry-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.expiry-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.expiry-custom svg { color: var(--text-muted); flex-shrink: 0; }
.expiry-custom input {
  border: none;
  background: transparent;
  flex: 1;
  height: 40px;
  padding: 0;
}
.expiry-custom input:focus { box-shadow: none; }
.expiry-result {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--accent-50);
  color: var(--accent);
  border-radius: 6px;
  font-size: 13px;
  align-self: flex-start;
}
.expiry-result strong { font-weight: 600; }

/* Selectable chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}
.chip:hover { background: var(--surface-2); }
.chip.on {
  background: var(--accent-50);
  border-color: var(--accent);
  color: var(--accent);
}
.chip.on svg { color: var(--accent); }

/* Switch */
.switch {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--border-strong);
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.18s;
}
.switch.on { background: var(--accent); }
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.18s;
}
.switch.on .switch-thumb { transform: translateX(16px); }

.settings-callout {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--accent-50);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.5;
}
.settings-callout svg { color: var(--accent); flex-shrink: 0; margin-top: 2px; }

@media (max-width: 880px) {
  .settings-shell { grid-template-columns: 1fr; }
  .settings-tabs {
    flex-direction: row;
    overflow-x: auto;
    position: static;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
  }
  .settings-tab { white-space: nowrap; }
  .settings-grid { grid-template-columns: 1fr; }
}
