/* ──────────────────────────────────────────────────────────────────────────
   BSP Studio Manager — application styles. Built on tokens.css.
   Order: base → shell → components → page-specific → responsive
   ────────────────────────────────────────────────────────────────────────── */

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: var(--lh-base);
  min-height: 100vh;
  display: flex;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); }
code { color: var(--text); font-family: var(--font-mono); font-size: 0.92em; background: var(--surface-3); padding: 1px 6px; border-radius: var(--r-sm); }
kbd {
  font-family: var(--font-ui); font-size: 11px; font-weight: var(--fw-medium); color: var(--text-muted);
  border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; line-height: 17px;
}
.num { font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Focus: visible for keyboard users, quiet for mouse users */
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }
input:focus-visible, select:focus-visible, textarea:focus-visible { box-shadow: 0 0 0 3px var(--accent-ring); }

.skip-link {
  position: fixed; left: 12px; top: -48px; z-index: var(--z-toast);
  background: var(--accent); color: var(--text-on-accent); padding: 8px 14px; border-radius: var(--r-md);
  font-weight: var(--fw-medium); text-decoration: none; transition: top var(--dur-fast) var(--ease);
}
.skip-link:focus { top: 12px; }

/* ── App shell: sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: var(--z-drawer);
  transition: width var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.sidebar-head {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  padding: 0 var(--sp-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: var(--text); }
.brand-mark {
  width: 32px; height: 32px; flex-shrink: 0; display: grid; place-items: center;
}
.brand-mark img { width: 32px; height: 32px; object-fit: contain; display: block; }
.brand-text { min-width: 0; line-height: 1.15; }
.brand-name { font-family: var(--font-brand); font-size: 18px; letter-spacing: 0.09em; white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.icon-btn {
  width: 32px; height: 32px; flex-shrink: 0;
  display: inline-grid; place-items: center;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-md);
  color: var(--text-muted); font-size: 17px; cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.sidebar-nav { flex: 1; padding: var(--sp-3) var(--sp-3) var(--sp-4); overflow-y: auto; overflow-x: hidden; }
.nav-section { margin-bottom: var(--sp-4); }
.nav-label {
  display: block; padding: 6px 10px 6px; font-size: 11px; font-weight: var(--fw-semibold);
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-subtle); white-space: nowrap;
}
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: 36px; padding: 0 10px; margin-bottom: 2px;
  border: 0; border-radius: var(--r-md); background: transparent;
  color: var(--text-muted); font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium);
  text-align: left; cursor: pointer; white-space: nowrap;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.nav-item .icon { font-size: 18px; width: 20px; display: inline-grid; place-items: center; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text); }
.nav-item.active .icon { color: var(--accent-text); }
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}

.sidebar-footer { padding: var(--sp-3); border-top: 1px solid var(--border); flex-shrink: 0; }
.sidebar-footer .nav-item { margin-bottom: 0; }
.account-row { display: flex; align-items: center; gap: 10px; padding: 6px 10px 10px; min-width: 0; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-muted); font-size: 12px; font-weight: var(--fw-semibold);
}
.account-meta { min-width: 0; line-height: 1.2; }
.account-meta strong { display: block; font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-meta span { font-size: 11px; color: var(--text-muted); }

/* Collapsed (icon rail) — user-toggled on desktop, automatic on tablet */
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-item .label,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .account-meta { display: none; }
body.sidebar-collapsed .sidebar-head { justify-content: center; padding: 0; }
body.sidebar-collapsed .sidebar-head .brand { display: none; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 0; }
body.sidebar-collapsed .nav-section { margin-bottom: var(--sp-2); padding-bottom: var(--sp-2); border-bottom: 1px solid var(--border); }
body.sidebar-collapsed .nav-section:last-child { border-bottom: 0; }
body.sidebar-collapsed .account-row { justify-content: center; padding: 6px 0 10px; }
body.sidebar-collapsed .nav-item.active::before { left: -12px; }

.mobile-nav-overlay {
  display: none; position: fixed; inset: 0; background: var(--overlay); z-index: calc(var(--z-drawer) - 1);
  opacity: 0; pointer-events: none; transition: opacity var(--dur);
}
.mobile-nav-overlay.open { opacity: 1; pointer-events: all; }

/* ── App shell: main + top bar ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; min-height: 100vh;
  transition: margin-left var(--dur) var(--ease);
}
body.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }

.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  min-height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-6);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.hamburger-btn { display: none; }

.crumbs { min-width: 0; flex: 0 1 auto; }
.crumbs ol { display: flex; align-items: center; gap: 6px; list-style: none; font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; }
.crumbs li { display: flex; align-items: center; gap: 6px; min-width: 0; }
.crumbs li + li::before { content: '/'; color: var(--text-subtle); }
.crumbs a, .crumbs button { color: inherit; background: none; border: 0; font: inherit; cursor: pointer; text-decoration: none; padding: 2px 4px; border-radius: var(--r-sm); }
.crumbs a:hover, .crumbs button:hover { color: var(--text); background: var(--surface-2); }
.page-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--text); overflow: hidden; text-overflow: ellipsis; }

.global-search-wrap { position: relative; flex: 1 1 360px; max-width: 420px; margin-left: auto; min-width: 0; }
.global-search-wrap .search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-subtle); font-size: 15px; pointer-events: none; }
.global-search-wrap .search-kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); pointer-events: none; display: flex; gap: 3px; }
.global-search-wrap input {
  height: var(--control-h); padding: 0 44px 0 34px; border-radius: var(--r-md);
  background: var(--surface-1); border: 1px solid var(--border-strong); font-size: var(--fs-sm);
}
.global-search-wrap input::placeholder { color: var(--text-subtle); }
.search-dropdown {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0; max-height: 400px; overflow-y: auto;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); z-index: var(--z-menu);
}

.topbar-actions { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; padding: 6px;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); z-index: var(--z-menu); display: none;
}
.menu.open { display: block; }
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px;
  background: none; border: 0; border-radius: var(--r-sm); color: var(--text); font: inherit; font-size: var(--fs-sm); cursor: pointer; text-align: left;
}
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); }
.menu button i { color: var(--text-muted); font-size: 16px; }

.content { padding: var(--sp-6); flex: 1; min-width: 0; max-width: 1600px; width: 100%; }
.content:focus { outline: none; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: var(--control-h); padding: 0 14px;
  border-radius: var(--r-md); border: 1px solid transparent;
  font-family: var(--font-ui); font-size: var(--fs-sm); font-weight: var(--fw-medium); line-height: 1;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--text-on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn-danger:hover:not(:disabled) { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { height: var(--control-h-sm); padding: 0 10px; font-size: var(--fs-xs); }

/* ── Cards ── */
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.card-header {
  min-height: 52px; padding: 12px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
}
.card-title { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--text); letter-spacing: 0; }
.card-body { padding: 0; }

/* ── Stat tiles ── */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.stat-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); min-width: 0; }
.stat-label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: var(--fs-3xl); font-weight: var(--fw-semibold); letter-spacing: -0.02em; line-height: 1.1; color: var(--text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-sub { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 4px; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); margin-bottom: var(--sp-5); }
.dash-charts-row { display: grid; grid-template-columns: 1fr 340px; gap: var(--sp-5); margin-bottom: var(--sp-5); }
.dash-tax-bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  margin-top: var(--sp-8); padding: var(--sp-5) var(--sp-6);
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg);
}

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 10px 16px; text-align: left; white-space: nowrap;
  font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--text-muted);
  border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 55%, transparent);
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); cursor: pointer; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: var(--fw-medium); letter-spacing: 0.01em; text-transform: capitalize; white-space: nowrap;
  color: var(--c, var(--text-muted));
  background: color-mix(in srgb, var(--c, var(--text-muted)) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c, var(--text-muted)) 28%, transparent);
}
.badge-inquiry { --c: var(--st-inquiry); }
.badge-booked { --c: var(--st-booked); }
.badge-prep { --c: var(--st-prep); }
.badge-shot { --c: var(--st-shot); }
.badge-editing { --c: var(--st-editing); }
.badge-delivered { --c: var(--st-delivered); }
.badge-archived { --c: var(--st-archived); }
.badge-unpaid { --c: var(--danger); }
.badge-deposit_paid { --c: var(--warning); }
.badge-paid { --c: var(--success); }

/* ── Forms ── */
.form-group { margin-bottom: var(--sp-4); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-4); }
label { display: block; font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--text-muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; min-height: var(--control-h); padding: 8px 12px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  font-family: var(--font-ui); font-size: var(--fs-sm); transition: border-color var(--dur-fast), background var(--dur-fast);
}
input::placeholder, textarea::placeholder { color: var(--text-subtle); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--text) 30%, transparent); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--accent); }
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
select option { background: var(--surface-1); color: var(--text); }
.form-hint { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 4px; }

/* ── Modal (short actions; complex records move to routed pages in a later slice) ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center; padding: var(--sp-5);
  background: var(--overlay); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity var(--dur);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  width: 100%; max-width: 580px; max-height: 90vh; overflow-y: auto;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  transform: translateY(12px) scale(0.99); transition: transform var(--dur) var(--ease);
}
.modal-overlay.open .modal { transform: none; }
.modal:focus { outline: none; }
.modal-header {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: 14px 20px; background: var(--surface-1); border-bottom: 1px solid var(--border);
}
.modal-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); letter-spacing: 0; }
.modal-close { width: 32px; height: 32px; display: grid; place-items: center; background: none; border: 0; border-radius: var(--r-md); color: var(--text-muted); font-size: 16px; cursor: pointer; }
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: var(--sp-5); }
.modal-footer {
  position: sticky; bottom: 0; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--sp-2);
  padding: 14px 20px; background: var(--surface-1); border-top: 1px solid var(--border);
}

/* ── Empty / skeleton / toast ── */
.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty .empty-icon { font-size: 34px; margin-bottom: 10px; color: var(--text-subtle); }
.empty p { font-size: var(--fs-md); margin-bottom: var(--sp-4); }

.toast {
  position: fixed; bottom: var(--sp-6); right: var(--sp-6); z-index: var(--z-toast); max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px; border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: var(--fw-medium);
  background: var(--surface-1); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(8px); transition: opacity var(--dur), transform var(--dur); pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.success { border-color: color-mix(in srgb, var(--success) 45%, transparent); }
.toast.success::before { content: '✓ '; color: var(--success); font-weight: 700; }
.toast.error { border-color: color-mix(in srgb, var(--danger) 55%, transparent); }
.toast.error::before { content: '! '; color: var(--danger); font-weight: 700; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp 0.22s var(--ease) forwards; }

/* ── Page-specific blocks (carried over; now themed through tokens) ── */
/* ── Pipeline ── */
  .pipeline {
    display: flex;
    overflow-x: auto;
    padding: 20px;
    gap: 8px;
  }

  .pipeline-col {
    min-width: 160px;
    flex: 1;
  }

  .pipeline-col-header {
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .pipeline-count {
    background: var(--surface2);
    color: var(--muted);
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 10px;
  }

  .pipeline-item {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.15s;
  }

  .pipeline-item:hover { border-color: var(--accent-bright); }
  .pipeline-item .pi-title { font-size: 12px; font-weight: 500; color: var(--white); margin-bottom: 3px; }
  .pipeline-item .pi-client { font-size: 11px; color: var(--muted); }
  .pipeline-item .pi-date { font-size: 10px; color: var(--muted); margin-top: 6px; }
  .pipeline-item[draggable="true"] { cursor: grab; }
  .pipeline-item[draggable="true"]:active { cursor: grabbing; }
  .pipeline-item.dragging { opacity: 0.35; border-style: dashed; }
  .pipeline-col.drag-over { background: rgba(37,99,168,0.1); outline: 2px dashed var(--accent-bright); outline-offset: -4px; border-radius: var(--radius); }
  .pipeline-more { font-size:10px; color:var(--muted); text-align:center; padding:6px 0; cursor:pointer; }
  .pipeline-more:hover { color:var(--accent-text); }

/* ── Detail View ── */
  .detail-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
  }

  .detail-field { margin-bottom: 16px; }
  .detail-label { font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
  .detail-value { font-size: 14px; color: var(--white); }

/* ── Checklist ── */
  .checklist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
  }

  .checklist-item:last-child { border-bottom: none; }

  .checklist-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-bright);
    flex-shrink: 0;
  }

  .checklist-item label {
    font-size: 13px;
    color: var(--white);
    letter-spacing: 0;
    text-transform: none;
    font-weight: 400;
    cursor: pointer;
    margin: 0;
    text-decoration: none;
    transition: color 0.15s;
  }

  .checklist-item.done label { color: var(--muted); text-decoration: line-through; }

/* ── Invoice Line Items ── */
  .line-items { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
  .line-items th { font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--border); }
  .line-items td { padding: 6px 4px; vertical-align: middle; }
  .line-items td input { padding: 6px 8px; font-size: 13px; }
  .line-items .remove-line { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 16px; padding: 4px 6px; }
  .invoice-totals { text-align: right; }
  .invoice-totals .total-row { display: flex; justify-content: flex-end; gap: 24px; padding: 4px 0; font-size: 13px; color: var(--muted); }
  .invoice-totals .total-row.grand { color: var(--white); font-weight: 600; font-size: 15px; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; }

/* ── Product Cards ── */
  .products-category { margin-bottom: 32px; }
  .products-category-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
  .products-category-label { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
  .products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
  .product-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 10px; transition: border-color .15s, box-shadow .15s; }
  .product-card:hover { border-color: var(--accent-bright); box-shadow: 0 4px 16px rgba(37,99,168,0.1); }
  .product-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
  .product-card-name { font-size: 14px; font-weight: 600; color: var(--white); }
  .product-card-price { font-size: 18px; font-weight: 700; color:var(--accent-text); white-space: nowrap; }
  .product-card-desc { font-size: 12px; color: var(--muted); line-height: 1.5; flex: 1; }
  .product-card-badges { display: flex; gap: 6px; flex-wrap: wrap; }
  .prod-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 10px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
  .prod-badge-package { background: rgba(37,99,168,0.18); color:var(--accent-text); border: 1px solid rgba(37,99,168,0.3); }
  .prod-badge-addon { background: rgba(255,255,255,0.06); color: var(--muted); border: 1px solid var(--border); }
  .prod-badge-cf { background: rgba(26,122,74,0.08); color: var(--success); border: 1px solid rgba(26,122,74,0.3); }
  .product-card-actions { display: flex; gap: 6px; margin-top: 4px; }

/* ── Portal Link ── */
  .portal-link {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 12px;
    color: var(--muted);
    word-break: break-all;
  }

  .portal-link button {
    flex-shrink: 0;
    background: var(--accent);
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 11px;
    padding: 3px 8px;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
  }

/* ── Calendar ── */
  .cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
  }
  .cal-header-cell {
    background: var(--surface2);
    padding: 8px;
    text-align: center;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .cal-cell {
    background: var(--surface);
    min-height: 90px;
    padding: 6px;
    vertical-align: top;
  }
  .cal-cell.cal-empty { background: var(--bg); }
  .cal-cell.cal-today { background: rgba(58,130,214,0.06); }
  .cal-day-num {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
    font-weight: 500;
  }
  .cal-today-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--accent-bright);
    border-radius: 50%;
    color: #fff;
    font-size: 11px;
  }
  .cal-event {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 2px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
  }
  .cal-event.badge-inquiry { background: color-mix(in srgb, var(--st-inquiry) 15%, transparent); color: var(--st-inquiry); }
  .cal-event.badge-booked { background: color-mix(in srgb, var(--st-booked) 15%, transparent); color: var(--st-booked); }
  .cal-event.badge-prep { background: color-mix(in srgb, var(--st-prep) 15%, transparent); color: var(--st-prep); }
  .cal-event.badge-shot { background: color-mix(in srgb, var(--st-shot) 15%, transparent); color: var(--st-shot); }
  .cal-event.badge-editing { background: color-mix(in srgb, var(--st-editing) 15%, transparent); color: var(--st-editing); }
  .cal-event.badge-delivered { background: color-mix(in srgb, var(--st-delivered) 15%, transparent); color: var(--st-delivered); }
  .cal-event.badge-archived { background: color-mix(in srgb, var(--st-archived) 15%, transparent); color: var(--st-archived); }

/* ── Contract template editor ── */
  .ct-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .ct-md {
    width: 100%; min-height: 460px; height: 60vh; resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.6; tab-size: 2;
  }
  .ct-preview {
    background: #fff; color: #222; border-radius: var(--radius); padding: 22px 24px;
    height: 60vh; min-height: 460px; overflow-y: auto; font-size: 13px; line-height: 1.7;
  }
  .ct-preview h1, .ct-preview h2, .ct-preview h3 { color: #1b4775; font-size: 14px; margin: 18px 0 6px; }
  .ct-preview > :first-child { margin-top: 0; }
  .ct-preview p { margin: 0 0 10px; }
  .ct-preview ul, .ct-preview ol { margin: 0 0 10px 20px; }
  .ct-preview hr { border: none; border-top: 1px solid #ddd; margin: 18px 0; }
  .ct-preview table { border-collapse: collapse; width: 100%; margin-bottom: 12px; }
  .ct-preview th, .ct-preview td { border: 1px solid #e0e0e0; padding: 6px 9px; text-align: left; font-size: 12.5px; }
  .ct-preview th { background: #f5f6f8; }
  .ct-preview blockquote { border-left: 3px solid #2563a8; margin: 0 0 10px; padding: 2px 12px; color: #555; background: #f8fafc; }
  .ct-pill {
    display: inline-block; padding: 0 8px; border-bottom: 2px solid #2563a8; background: #eaf2fc; color: #1b4775;
    border-radius: 3px 3px 0 0; font-size: 12px; font-weight: 600; line-height: 1.5;
  }
  .ct-pill.req::after { content: ' *'; color: #c0392b; }
  .ct-var { background: #fff6dd; border-bottom: 2px solid #d4a017; color: #7a5a00; padding: 0 4px; border-radius: 3px 3px 0 0; }
  .ct-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; padding: 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; }
  .ct-toolbar .tb-group { display: flex; flex-direction: column; gap: 4px; }
  .ct-toolbar label { margin: 0; }
  .ct-chip { display: inline-flex; gap: 6px; align-items: center; padding: 3px 10px; margin: 0 6px 6px 0; border-radius: 20px; font-size: 12px; background: var(--surface2); border: 1px solid var(--border); }
  .ct-chip b { color:var(--accent-text); font-weight: 600; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }
  .ct-chip i { color: #e06050; font-style: normal; }

/* ── Responsive ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* Tablet: sidebar is always the icon rail */
@media (max-width: 1023px) and (min-width: 641px) {
  .sidebar { width: var(--sidebar-w-collapsed); }
  .sidebar .brand-text, .sidebar .nav-item .label, .sidebar .nav-label, .sidebar .account-meta, .sidebar .sidebar-head .brand, .sidebar #sidebarToggle { display: none; }
  .sidebar .sidebar-head { justify-content: center; padding: 0; }
  .sidebar .nav-item { justify-content: center; padding: 0; }
  .sidebar .account-row { justify-content: center; }
  .main, body.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-charts-row, .dash-grid, .detail-grid, .form-row { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
  .ct-grid { grid-template-columns: 1fr; }
}

/* Phone: off-canvas drawer */
@media (max-width: 640px) {
  html, body { overflow-x: hidden; max-width: 100vw; }
  .sidebar { width: 280px; transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  body.sidebar-collapsed .sidebar { width: 280px; }
  body.sidebar-collapsed .brand-text, body.sidebar-collapsed .nav-item .label, body.sidebar-collapsed .nav-label, body.sidebar-collapsed .account-meta { display: revert; }
  body.sidebar-collapsed .sidebar-head { justify-content: space-between; padding: 0 var(--sp-4); }
  body.sidebar-collapsed .sidebar-head .brand { display: flex; }
  body.sidebar-collapsed .nav-item { justify-content: flex-start; padding: 0 10px; }
  .sidebar #sidebarToggle { display: none; }
  .mobile-nav-overlay { display: block; }
  .hamburger-btn { display: inline-grid; }
  .main, body.sidebar-collapsed .main { margin-left: 0; }

  .topbar { flex-wrap: wrap; padding: 10px var(--sp-4); gap: var(--sp-2); }
  .crumbs { flex: 1 1 0; }
  .crumbs ol li:not(:last-child) { display: none; }
  .crumbs li + li::before { content: none; }
  .topbar-actions { margin-left: auto; }
  .global-search-wrap { order: 3; flex: 1 1 100%; max-width: none; margin-left: 0; }
  .search-kbd { display: none !important; }

  .content { padding: var(--sp-4); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: var(--sp-4); }
  .stat-card { padding: 14px; }
  .stat-label { font-size: var(--fs-xs); }
  .stat-value { font-size: 22px; }
  .stat-value span { font-size: 11px !important; }
  .dash-charts-row, .dash-grid { grid-template-columns: 1fr; gap: 12px; }
  .detail-grid, .form-row, .form-row-3, .ct-grid { grid-template-columns: 1fr; }
  .dash-tax-bar { flex-direction: column; align-items: stretch; text-align: center; padding: var(--sp-4); }
  .dash-tax-bar > div:last-child { justify-content: center; }
  .pipeline { scroll-snap-type: x proximity; padding: 14px; }
  .pipeline-col { min-width: 68vw; scroll-snap-align: start; }
  .ct-md, .ct-preview { height: 320px; min-height: 320px; }

  .modal-overlay { padding: 0; align-items: stretch; }
  .modal { max-width: 100% !important; height: 100%; max-height: 100%; border-radius: 0; border: 0; }
  .card-header { flex-wrap: wrap; }
  .btn { height: 40px; }
  .btn-sm { height: 34px; }
  .toast { left: var(--sp-4); right: var(--sp-4); bottom: var(--sp-4); max-width: none; }
}
