/* ==========================================================================
   Loomstead admin — design tokens
   ========================================================================== */
:root {
  --bg: #f3f4f1;
  --sidebar: #eaece7;
  --surface: #ffffff;
  --surface-2: #f8f9f7;
  --surface-3: #f1f2ef;
  --border: #e2e4df;
  --border-strong: #cdd1ca;
  --text: #1b201e;
  --text-2: #565e5a;
  --text-3: #838a86;
  --ink: #1f2b3d;
  --ink-hover: #2d3d55;
  --link: #2a5c9e;
  --focus: #3b6fd8;

  --success: #24704a;  --success-soft: #dff1e6;
  --warning: #8a5a00;  --warning-soft: #fcefd2;
  --attention: #8f4b00; --attention-soft: #fde4c8;
  --critical: #ad2330; --critical-soft: #fbe3e4;
  --info: #2d55a0;     --info-soft: #e2eafa;
  --neutral: #4d5551;  --neutral-soft: #eaece8;

  --chart-1: #2f6f8f;
  --chart-2: #b7bdb8;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-xs: 0 1px 0 rgba(20, 28, 24, .05);
  --shadow-sm: 0 1px 2px rgba(20, 28, 24, .06), 0 0 0 1px rgba(20, 28, 24, .04);
  --shadow-lg: 0 12px 40px rgba(20, 28, 24, .18), 0 2px 6px rgba(20, 28, 24, .08);

  --font-head: "Manrope", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;

  --sidebar-w: 240px;
  --topbar-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
body.has-modal { overflow: hidden; }
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 800; }
h2 { font-size: 15px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
code, .mono { font-family: var(--font-mono); font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

.icon {
  width: 18px; height: 18px; flex: none;
  stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 28px; height: 28px; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; text-decoration: none;
}
.skip-link:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.subtle { color: var(--text-2); }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-critical { color: var(--critical); }
.text-warning { color: var(--warning); }

/* ==========================================================================
   App shell
   ========================================================================== */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 12px 16px;
  background: var(--sidebar); border-right: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 10px; text-decoration: none; color: var(--text);
  font-family: var(--font-head); font-weight: 800; font-size: 17px; letter-spacing: -0.02em;
}
.brand-mark { width: 28px; height: 28px; }
.store-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 6px;
}
.store-chip-avatar {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none;
  background: #2f6f5e; color: #fff; font-weight: 700; font-size: 12px; font-family: var(--font-head);
}
.store-chip-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.store-chip-text strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.store-chip-text small { color: var(--text-3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px;
  color: var(--text-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: rgba(20, 28, 24, .05); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.nav a[aria-current="page"] .icon { color: var(--ink); }
.nav .count {
  margin-left: auto; font-size: 11.5px; font-weight: 600; line-height: 18px; min-width: 20px; text-align: center;
  padding: 0 6px; border-radius: 999px; background: var(--ink); color: #fff;
}
.nav-label {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); padding: 16px 10px 4px;
}
.sidebar-foot { margin-top: auto; padding-top: 12px; }
.sidebar-note { font-size: 11.5px; color: var(--text-3); padding: 10px 10px 0; line-height: 1.4; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h); padding: 0 24px;
  background: rgba(243, 244, 241, .88); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.menu-btn { display: none; }
main { flex: 1; padding: 24px 28px 64px; outline: none; }

.search { position: relative; flex: 1; max-width: 520px; }
.search input {
  width: 100%; height: 36px; padding: 0 34px 0 36px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface);
}
.search input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(59, 111, 216, .18); }
.search-icon { position: absolute; left: 11px; top: 9px; color: var(--text-3); pointer-events: none; }
.search-kbd {
  position: absolute; right: 9px; top: 8px; font: 11px var(--font-mono); color: var(--text-3);
  border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; line-height: 18px; background: var(--surface-2);
}
.search input:focus ~ .search-kbd { display: none; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 6px; max-height: 70vh; overflow-y: auto;
}
.search-group { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); padding: 8px 10px 4px; }
.search-option {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px;
  color: var(--text); text-decoration: none; cursor: pointer;
}
.search-option[aria-selected="true"], .search-option:hover { background: var(--surface-3); }
.search-option small { color: var(--text-3); margin-left: auto; white-space: nowrap; }
.search-empty { padding: 18px 12px; color: var(--text-2); text-align: center; }

.scrim { display: none; }

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 276px; z-index: 60;
    transform: translateX(-100%); visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s; box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; visibility: visible; transition: transform .22s ease; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(20, 24, 22, .38); z-index: 55; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; gap: 8px; }
  main { padding: 18px 16px 56px; }
}
@media (max-width: 520px) { .hide-xs { display: none !important; } }

/* ==========================================================================
   Page structure
   ========================================================================== */
.page { max-width: 1180px; margin: 0 auto; }
.page-narrow { max-width: 1000px; }
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-header .subtle { margin-top: 4px; }
.page-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back-link {
  display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px;
  color: var(--text-2); text-decoration: none; font-weight: 500; font-size: 13px;
}
.back-link:hover { color: var(--text); }

.layout-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.layout-even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
@media (max-width: 1080px) { .layout-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) { .layout-even { grid-template-columns: minmax(0, 1fr); } }

/* ==========================================================================
   Cards
   ========================================================================== */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; flex-wrap: wrap; }
.card-header .subtle { font-size: 13px; }
.card-body { padding: 16px 18px; }
.card-body + .card-body, .card-section + .card-section { border-top: 1px solid var(--border); }
.card-section { padding: 14px 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.card-title-row { display: flex; align-items: center; gap: 8px; }
.card-link { font-size: 13px; font-weight: 500; text-decoration: none; }
.card-link:hover { text-decoration: underline; }

/* KPI tiles */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
@media (max-width: 1080px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .kpi-grid { grid-template-columns: minmax(0, 1fr); } }
.kpi { padding: 16px 18px 12px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; }
a.kpi:hover { box-shadow: var(--shadow-sm), 0 0 0 1px var(--border-strong); }
.kpi-label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.kpi-value { font-family: var(--font-head); font-size: 26px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-foot .muted { font-size: 12px; }
.spark { width: 96px; height: 30px; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta .icon { width: 14px; height: 14px; stroke-width: 2.2; }
.delta.up { color: var(--success); }
.delta.down { color: var(--critical); }
.delta.flat { color: var(--text-3); }

/* ==========================================================================
   Buttons & form controls
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn .icon { width: 16px; height: 16px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #fff; box-shadow: inset 0 -1px 0 rgba(0,0,0,.25); }
.btn-primary:hover:not(:disabled) { background: var(--ink-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: rgba(20, 28, 24, .06); color: var(--text); }
.btn-danger { background: var(--critical); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #921d28; }
.btn-danger-ghost { background: transparent; color: var(--critical); border-color: #efc3c6; }
.btn-danger-ghost:hover { background: var(--critical-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; color: var(--link); font-weight: 500; cursor: pointer; text-decoration: none; }
.btn-link:hover { text-decoration: underline; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field + .field { margin-top: 14px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.field-row + .field, .field + .field-row, .field-row + .field-row { margin-top: 14px; }
.label { font-weight: 500; font-size: 13px; color: var(--text); }
.label .muted { font-weight: 400; }
.help { font-size: 12.5px; color: var(--text-3); }
.error-text { font-size: 12.5px; color: var(--critical); display: flex; gap: 4px; align-items: center; }
.input, .select, .textarea {
  width: 100%; min-height: 36px; padding: 7px 11px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px;
  transition: border-color .12s, box-shadow .12s;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23565e5a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 16px;
}
.input:hover, .select:hover, .textarea:hover { border-color: #b6bbb3; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(59, 111, 216, .18); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--critical); background: #fffafa; }
.input-sm, .select-sm { min-height: 32px; padding-top: 5px; padding-bottom: 5px; font-size: 13px; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .prefix, .input-group .suffix { position: absolute; color: var(--text-3); pointer-events: none; font-size: 13.5px; }
.input-group .prefix { left: 11px; }
.input-group .suffix { right: 11px; }
.input-group .prefix ~ .input { padding-left: calc(18px + var(--pw, 1) * 0.6em); }
.input-group .input:has(~ .suffix) { padding-right: 34px; }
.input-with-icon { position: relative; }
.input-with-icon .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-with-icon .input { padding-left: 34px; }
.input-color { display: flex; gap: 8px; align-items: center; }
.input-color input[type="color"] {
  width: 38px; height: 36px; padding: 3px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); cursor: pointer; flex: none;
}

.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; line-height: 1.4; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--ink); flex: none; cursor: pointer; }
.check + .check { margin-top: 10px; }
.check-desc { display: block; color: var(--text-3); font-size: 12.5px; }
input[type="checkbox"].cb { width: 16px; height: 16px; accent-color: var(--ink); cursor: pointer; margin: 0; vertical-align: middle; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--ink); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 10px; }
.segmented button {
  border: 0; background: transparent; height: 30px; padding: 0 12px; border-radius: 7px;
  font-weight: 500; font-size: 13px; color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.choice {
  position: relative; display: flex; flex-direction: column; gap: 4px; padding: 12px 14px;
  border: 1px solid var(--border-strong); border-radius: 10px; cursor: pointer; background: var(--surface);
}
.choice input { position: absolute; opacity: 0; }
.choice:hover { border-color: #aab0a8; }
.choice:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); background: #f7f8fb; }
.choice:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.choice-title { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.choice-desc { font-size: 12.5px; color: var(--text-3); }

.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; background: var(--surface); }
.stepper button { width: 34px; border: 0; background: var(--surface-2); cursor: pointer; font-size: 16px; color: var(--text-2); }
.stepper button:hover { background: var(--surface-3); color: var(--text); }
.stepper input { width: 70px; border: 0; text-align: center; border-left: 1px solid var(--border); border-right: 1px solid var(--border); min-height: 34px; font-variant-numeric: tabular-nums; }
.stepper input:focus { outline: none; box-shadow: inset 0 0 0 2px rgba(59,111,216,.35); }

/* ==========================================================================
   Badges, chips, avatars, thumbnails
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--neutral-soft); color: var(--neutral);
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-attention { background: var(--attention-soft); color: var(--attention); }
.badge-critical { background: var(--critical-soft); color: var(--critical); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); }
.badge-outline .badge-dot { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 10px;
  border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border); font-size: 12.5px; font-weight: 500;
}
.chip button { border: 0; background: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--text-3); padding: 0; }
.chip button:hover { background: var(--border); color: var(--text); }
.chip button .icon { width: 12px; height: 12px; }
.chip-static { padding-right: 10px; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: hsl(var(--h, 200) 40% 88%); color: hsl(var(--h, 200) 45% 28%);
  font-weight: 700; font-size: 13px; font-family: var(--font-head);
}
.avatar-sm { width: 30px; height: 30px; font-size: 11.5px; }
.avatar-lg { width: 52px; height: 52px; font-size: 17px; }
#owner-avatar { --h: 214; }

.thumb {
  display: inline-grid; place-items: center; flex: none; overflow: hidden; position: relative;
  border-radius: 8px; border: 1px solid rgba(0,0,0,.06);
  background: linear-gradient(140deg, hsl(var(--h, 200) 38% 88%), hsl(var(--h, 200) 30% 76%));
  color: hsl(var(--h, 200) 35% 30%); font-weight: 700; font-family: var(--font-head);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb svg { width: 72%; height: 72%; }
.thumb-sm { width: 36px; height: 36px; font-size: 11px; }
.thumb-md { width: 44px; height: 44px; font-size: 13px; border-radius: 9px; }
.thumb-lg { width: 100%; aspect-ratio: 1; font-size: 28px; border-radius: 12px; }

/* ==========================================================================
   Tabs, toolbars, tables
   ========================================================================== */
.tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0; background: none; padding: 8px 12px 10px; cursor: pointer; white-space: nowrap;
  font-weight: 500; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 6px; border-radius: 6px 6px 0 0;
}
.tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs button[aria-pressed="true"] { color: var(--text); font-weight: 600; border-bottom-color: var(--ink); }
.tab-count { font-size: 11.5px; color: var(--text-3); font-weight: 500; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; gap: 8px; padding: 12px; flex-wrap: wrap; align-items: center; border-bottom: 1px solid var(--border); }
.toolbar .input-with-icon { flex: 1 1 240px; }
.toolbar .select { width: auto; flex: 0 1 auto; }

.bulkbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px;
  background: #f5f7fb; border-bottom: 1px solid var(--border); font-size: 13px;
}
.bulkbar strong { margin-right: 6px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 600; font-size: 12.5px; color: var(--text-2); white-space: nowrap;
  padding: 9px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table tbody tr.is-selected td { background: #f5f7fb; }
.table .col-check { width: 40px; padding-right: 0; }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-link { color: var(--text); font-weight: 600; text-decoration: none; }
.row-link:hover { text-decoration: underline; }
.cell-product { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.cell-product .grow { display: flex; flex-direction: column; }
.cell-sub { color: var(--text-3); font-size: 12.5px; }
.table-foot { padding: 10px 14px; color: var(--text-3); font-size: 12.5px; border-top: 1px solid var(--border); }
@media (max-width: 860px) { .hide-md { display: none; } }
@media (max-width: 640px) { .hide-sm { display: none; } }

/* Simple list rows */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-top: 1px solid var(--border); }
.list-item:first-child { border-top: 0; }
a.list-item { color: inherit; text-decoration: none; }
a.list-item:hover { background: var(--surface-2); }
.attention-item { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-top: 1px solid var(--border); color: inherit; text-decoration: none; }
.attention-item:first-child { border-top: 0; }
.attention-item:hover { background: var(--surface-2); }
.attention-item .icon-badge { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.attention-item .chev { margin-left: auto; color: var(--text-3); }

.summary-rows { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; font-variant-numeric: tabular-nums; }
.summary-rows .total { font-weight: 700; font-size: 15px; padding-top: 8px; border-top: 1px solid var(--border); }
.summary-rows .label-sub { color: var(--text-3); }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13.5px; }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; }

.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 8px 18px; }
.bar-track { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; background: var(--chart-1); border-radius: inherit; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 0 0 16px 28px; }
.timeline li::before { content: ""; position: absolute; left: 1px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.timeline li.is-comment::before { background: var(--ink); border-color: var(--ink); }
.timeline .when { color: var(--text-3); font-size: 12px; }
.timeline .bubble { margin-top: 4px; padding: 8px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; white-space: pre-wrap; }
.timeline-day { font-size: 12px; font-weight: 600; color: var(--text-3); padding: 0 0 8px 28px; position: relative; }

/* Charts */
.chart { position: relative; }
.chart svg { display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--text-3); font-size: 11px; font-family: var(--font-body); }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 2; min-width: 150px;
  background: var(--ink); color: #fff; border-radius: 9px; padding: 8px 10px; font-size: 12.5px; box-shadow: var(--shadow-lg);
  transform: translate(-50%, calc(-100% - 12px));
}
.chart-tip .tip-row { display: flex; align-items: center; gap: 6px; justify-content: space-between; font-variant-numeric: tabular-nums; }
.chart-tip .tip-date { opacity: .7; margin-bottom: 2px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 3px; display: inline-block; }
.legend i.dashed { background: repeating-linear-gradient(90deg, var(--chart-2) 0 4px, transparent 4px 7px) !important; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

/* Empty states */
.empty-state { text-align: center; padding: 48px 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-state h2, .empty-state h3 { font-size: 16px; }
.empty-state p { color: var(--text-2); max-width: 400px; }
.empty-art { width: 120px; height: 96px; margin-bottom: 6px; }
.empty-state .page-actions { margin-top: 6px; justify-content: center; }
.empty-inline { padding: 22px 18px; color: var(--text-2); text-align: center; font-size: 13.5px; }

/* Onboarding checklist */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border); }
.checklist .tick { width: 22px; height: 22px; border-radius: 50%; border: 2px dashed var(--border-strong); display: grid; place-items: center; flex: none; }
.checklist li.done .tick { border: 0; background: var(--success); color: #fff; }
.checklist li.done .tick .icon { width: 14px; height: 14px; stroke-width: 2.6; }
.checklist li.done .check-title { text-decoration: line-through; color: var(--text-3); }

/* Save bar */
.savebar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0; height: var(--topbar-h); z-index: 45;
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: var(--ink); color: #fff; box-shadow: 0 4px 20px rgba(0,0,0,.2);
  animation: slideDown .18s ease;
}
.savebar[hidden] { display: none; }
.savebar .msg { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.savebar .actions { margin-left: auto; display: flex; gap: 8px; }
.savebar .btn-secondary { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); box-shadow: none; }
.savebar .btn-secondary:hover { background: rgba(255,255,255,.1); }
.savebar .btn-primary { background: #fff; color: var(--ink); }
.savebar .btn-primary:hover { background: #e9edf3; }
@media (max-width: 960px) { .savebar { left: 0; padding: 0 16px; } }
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: none; } }

/* Media dropzone */
.dropzone {
  display: flex; align-items: center; gap: 16px; padding: 14px; border: 1.5px dashed var(--border-strong); border-radius: 12px; background: var(--surface-2);
}
.dropzone.is-over { border-color: var(--focus); background: #f1f5fd; }
.dropzone .thumb { width: 96px; height: 96px; font-size: 22px; }

/* ==========================================================================
   Modal & toast
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px;
  background: rgba(18, 22, 20, .45); animation: fadeIn .15s ease;
}
.modal {
  width: 100%; max-width: 520px; max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); animation: popIn .18s ease;
}
.modal-lg { max-width: 760px; }
.modal-sm { max-width: 420px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 16px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.toast-region { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px;
  background: #18202c; color: #fff; padding: 10px 12px 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg);
  font-weight: 500; animation: popIn .18s ease;
}
.toast.critical { background: var(--critical); }
.toast a, .toast button { color: #fff; font-weight: 600; background: rgba(255,255,255,.14); border: 0; border-radius: 6px; padding: 4px 9px; cursor: pointer; text-decoration: none; font-size: 13px; }
.toast .toast-close { background: none; padding: 2px; opacity: .7; display: grid; }
.toast .toast-close:hover { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ==========================================================================
   Theme editor
   ========================================================================== */
body.is-editor main { padding: 0; }
.editor { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: calc(100vh - var(--topbar-h)); }
.editor-panel { border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.editor-panel-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--border); }
.editor-panel-head h1 { font-size: 18px; }
.editor-scroll { overflow-y: auto; flex: 1; min-height: 0; }
.editor-panel details { border-bottom: 1px solid var(--border); }
.editor-panel summary {
  list-style: none; cursor: pointer; padding: 14px 18px; font-weight: 700; font-family: var(--font-head);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.editor-panel summary::-webkit-details-marker { display: none; }
.editor-panel summary .icon { transition: transform .15s; color: var(--text-3); }
.editor-panel details[open] summary .icon { transform: rotate(180deg); }
.editor-panel summary:hover { background: var(--surface-2); }
.editor-section { padding: 2px 18px 18px; }
.editor-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.editor-foot .btn { flex: 1; }
.editor-canvas { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #e6e8e3; }
.canvas-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; flex-wrap: wrap; }
.canvas-bar .status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.canvas-stage { flex: 1; min-height: 0; overflow: auto; padding: 0 16px 16px; display: flex; justify-content: center; }
.device {
  width: 100%; max-width: 1280px; background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden;
  display: flex; flex-direction: column; transition: max-width .25s ease; height: 100%; min-height: 480px;
}
.device-chrome { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: #f4f4f2; border-bottom: 1px solid #e3e3df; flex: none; }
.device-chrome i { width: 9px; height: 9px; border-radius: 50%; background: #d6d6d1; }
.device-url { margin-left: 10px; flex: 1; max-width: 340px; background: #fff; border: 1px solid #e3e3df; border-radius: 6px; font-size: 11.5px; color: #777; padding: 2px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-screen { flex: 1; overflow-y: auto; min-height: 0; }
.device.tablet { max-width: 780px; }
.device.mobile { max-width: 390px; border-radius: 26px; border: 8px solid #1d2229; }
.device.mobile .device-chrome { display: none; }

.preset-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.preset {
  border: 1px solid var(--border-strong); border-radius: 10px; padding: 8px; background: var(--surface); cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 12.5px;
}
.preset:hover { border-color: #aab0a8; }
.preset[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.preset-swatches { display: flex; height: 26px; border-radius: 6px; overflow: hidden; border: 1px solid rgba(0,0,0,.06); }
.preset-swatches span { flex: 1; }
.editor-mobile-toggle { display: none; }

@media (max-width: 960px) {
  .editor { grid-template-columns: minmax(0, 1fr); height: auto; }
  .editor-mobile-toggle { display: flex; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .editor-mobile-toggle .segmented { width: 100%; }
  .editor-mobile-toggle .segmented button { flex: 1; justify-content: center; }
  .editor[data-pane="preview"] .editor-panel { display: none; }
  .editor[data-pane="settings"] .editor-canvas { display: none; }
  .editor-panel { border-right: 0; }
  .editor-scroll { overflow: visible; }
  .canvas-stage { height: calc(100vh - 190px); }
}

/* Full storefront preview */
body.is-preview .sidebar, body.is-preview .topbar { display: none; }
body.is-preview .app { grid-template-columns: minmax(0, 1fr); }
body.is-preview main { padding: 0; }
.preview-bar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 16px; background: var(--ink); color: #fff; font-size: 13px;
}
.preview-bar .btn-secondary { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); box-shadow: none; }
.preview-bar .btn-secondary:hover { background: rgba(255,255,255,.1); }
.preview-bar .spacer { flex: 1; }

/* Search engine listing preview (product editor) */
.seo-preview { padding: 14px 16px; margin-bottom: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-family: Arial, var(--font-body); }
.seo-url { font-size: 12.5px; color: #3c4043; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seo-title { font-size: 18px; line-height: 1.35; color: #1a0dab; margin: 2px 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seo-desc { font-size: 13.5px; line-height: 1.5; color: #4d5156; }

/* Product options, gallery */
.option-row { align-items: end; margin-bottom: 12px; }
.gallery { display: flex; flex-wrap: wrap; gap: 8px; }
.gallery-item { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.gallery-item img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
