/* EMS — visual system ported from v2 design */
* { margin:0; padding:0; box-sizing:border-box; }

/* Alpine.js — hide any element marked x-cloak until Alpine has booted
   and taken over its x-show / x-if visibility. Without this rule,
   modals and dropdowns declared with x-show flash visible on page
   load before Alpine's defer'd script initialises. */
[x-cloak] { display: none !important; }

:root {
    --bg:#0B0E15; --panel:#11161F; --panel2:#161D29; --line:#222B3B; --line2:#2C3850;
    --accent:#F5A524; --accent-dim:rgba(245,165,36,.13); --accent-br:rgba(245,165,36,.32);
    --violet:#9B7BF7; --blue:#5B9DF7; --green:#2DD4A0; --red:#F8736A; --amber:#F5A524; --pink:#F472B6;
    --text:#E9EDF5; --muted:#7E8AA0; --subtle:#A8B3C7;
    --shadow: 0 8px 28px rgba(0,0,0,.35);
    /* Z-index scale. Kept as a small stepped set instead of ad-hoc numbers
       so stacking order is legible at a glance. Callers should reference
       --z-* rather than hardcoded values. */
    --z-sidebar:  30;
    --z-popover:  60;
    --z-drawer:   70;
    --z-overlay:  90;
    --z-modal:    91;
    --z-toast:   200;
    --z-picker:  200;   /* autocomplete .ac-menu, row-actions */
    --z-editor:  300;   /* TinyMCE / editor popups */
    --z-external:100000;/* Google Places, other third-party <body>-appended UI */
}
html[data-theme="light"] {
    --bg:#F3F4F7; --panel:#FFFFFF; --panel2:#F7F8FB; --line:#E3E7EE; --line2:#D4DAE5;
    --accent:#C07F0E; --accent-dim:rgba(192,127,14,.10); --accent-br:rgba(192,127,14,.30);
    --text:#16202E; --muted:#6B7686; --subtle:#4B5768;
    --shadow: 0 6px 20px rgba(20,30,50,.08);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg); color: var(--text);
    height: 100vh; display: flex; overflow: hidden; font-size: 13.5px;
}
.mono { font-family: 'JetBrains Mono', monospace; }
h1, h2, h3, .display { font-family: 'Space Grotesk', sans-serif; }
::-webkit-scrollbar { width:6px; height:6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 3px; }
a { color: inherit; text-decoration: none; }

/* SIDEBAR */
.sidebar {
    width: 230px; background: var(--panel); border-right: 1px solid var(--line);
    display: flex; flex-direction: column; flex-shrink: 0; z-index: 30;
}
.sidebar-header { padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.logo {
    font-family: 'Space Grotesk'; font-size: 18px; font-weight: 700;
    letter-spacing: .5px; display: flex; align-items: center; gap: 8px;
    text-decoration: none; color: var(--text);
    line-height: 1.15;
}
.logo .mark {
    width: 26px; height: 26px; border-radius: 7px;
    background: linear-gradient(135deg, var(--accent), #E0762B);
    display: flex; align-items: center; justify-content: center;
    color: #16110A; font-size: 13px; font-weight: 800;
    flex-shrink: 0;
}
.logo-text {
    min-width: 0;                 /* lets ellipsis truncate rather than force-wrap */
    display: flex; flex-direction: column; gap: 2px;
}
.logo-wordmark {
    display: inline-flex; gap: 5px; white-space: nowrap;
}
.logo small {
    display: block; font-family: 'Inter'; font-size: 9.5px; color: var(--muted);
    font-weight: 500; letter-spacing: 1.5px; text-transform: uppercase;
    white-space: nowrap;
    line-height: 1.25;
}
.nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav-sec {
    font-size: 9.5px; font-weight: 700; color: var(--muted); letter-spacing: 1.6px;
    padding: 14px 12px 5px; text-transform: uppercase;
}
.nav-item {
    display: flex; align-items: center; gap: 9px; padding: 7.5px 11px;
    border-radius: 8px; cursor: pointer; transition: .13s;
    color: var(--subtle); font-size: 13px; margin-bottom: 1px;
    border: 1px solid transparent; user-select: none;
}
.nav-item:hover { background: var(--panel2); color: var(--text); }
.nav-item.active {
    background: var(--accent-dim); color: var(--accent);
    border-color: var(--accent-br); font-weight: 600;
}
.nav-item .ic { width: 17px; text-align: center; font-size: 14px; opacity: .9; }
.nav-item.locked { opacity: .35; pointer-events: none; }
.sidebar-footer { padding: 10px; border-top: 1px solid var(--line); }

/* Responsive collapse — mirrors the design HTML: full sidebar > 900px,
   icon-only rail below. Labels + section headers + footer chips hide;
   the mark stays as the tap-target back to Dashboard. */
@media (max-width: 900px) {
    .sidebar                    { width: 62px; }
    .sidebar-header             { padding: 14px 8px; text-align: center; }
    .logo                       { justify-content: center; gap: 0; }
    .logo-text                  { display: none; }
    .nav                        { padding: 10px 6px; }
    .nav-sec                    { display: none; }
    .nav-item                   { justify-content: center; padding: 9px 4px; }
    .nav-item .lbl              { display: none; }
    .nav-item .ic               { width: auto; font-size: 16px; }
    .sidebar-footer             { padding: 8px 6px; }
    .sync-status-label,
    .user-name-truncate         { display: none; }
    .sync-status,
    .user-chip                  { justify-content: center; padding: 8px 4px; }
}
.sync-chip {
    display: flex; align-items: center; gap: 8px; padding: 8px 11px;
    background: rgba(45,212,160,.07); border: 1px solid rgba(45,212,160,.22);
    border-radius: 8px; font-size: 11px; color: var(--green);
}
.sync-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--green); animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

/* MAIN */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
    height: 58px; background: var(--panel); border-bottom: 1px solid var(--line);
    display: flex; align-items: center; padding: 0 20px; gap: 12px; flex-shrink: 0;
}
.tb-title { font-family: 'Space Grotesk'; font-size: 16px; font-weight: 600; white-space: nowrap; }
.tb-title small { font-size: 11.5px; color: var(--muted); font-weight: 400; margin-left: 8px; font-family: 'Inter'; }
.tb-ctl { display: flex; align-items: center; gap: 9px; }
.content { flex: 1; overflow-y: auto; padding: 20px 22px 60px; }

/* CARDS + KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 13px; margin-bottom: 18px; }
.kpi {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 12px; padding: 14px 16px; position: relative; overflow: hidden;
}
.kpi::after {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0;
    width: 3px; background: var(--accent);
}
.kpi.g::after { background: var(--green); }
.kpi.b::after { background: var(--blue); }
.kpi.v::after { background: var(--violet); }
.kpi.r::after { background: var(--red); }
.kpi.p::after { background: var(--pink); }
.kpi-l { font-size: 10.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .7px; margin-bottom: 7px; }
.kpi-v { font-family: 'Space Grotesk'; font-size: 23px; font-weight: 700; letter-spacing: -.3px; }
.kpi-s { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

/* .grid2 is defined once, further down as 2fr 1fr (main + sidebar), which
   is what every detail page consumes. The old 1fr 1fr definition here was
   silently overridden and is intentionally removed. */
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 15px; }
@media (max-width: 900px) { .grid3 { grid-template-columns: 1fr; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 15px; overflow: hidden; }
.card-h { padding: 13px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.card-h h3 { font-size: 13.5px; font-weight: 600; }
.card-h .sub { font-size: 11px; color: var(--muted); font-weight: 400; }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-b { padding: 15px 16px; }
/* Danger-zone card — same shape as .card but tinted so admin-only
   destructive actions stand out from routine edits. */
.card-danger        { border-color: rgba(248,115,106,.35); background: rgba(248,115,106,.04); }
.card-danger .card-h{ border-bottom-color: rgba(248,115,106,.25); }
.card-danger .card-h h3 { color: var(--red); }

/* BUTTONS */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 13px; border-radius: 8px; font-size: 12px; font-weight: 600;
    cursor: pointer; border: 1px solid transparent; transition: .13s;
    font-family: 'Inter'; text-decoration: none;
}
.btn-p { background: var(--accent); color: #1A1206; }
.btn-p:hover { filter: brightness(1.08); }
.btn-g { background: var(--panel2); color: var(--subtle); border-color: var(--line); }
.btn-g:hover { color: var(--text); border-color: var(--line2); }
.btn-ok { background: rgba(45,212,160,.13); color: var(--green); border-color: rgba(45,212,160,.3); }
.btn-no { background: rgba(248,115,106,.12); color: var(--red); border-color: rgba(248,115,106,.3); }
.btn-sm { padding: 4.5px 9px; font-size: 11px; border-radius: 7px; }
.btn:disabled, .btn[disabled] { opacity: .4; pointer-events: none; }

/* Form used purely to hold a single POST button inline in an action bar. */
.inline-form { display: inline; margin: 0; }

/* UTILITY CLASSES — small, reusable, add rather than inline. */
.mb-16    { margin-bottom: 16px; }
.mt-4     { margin-top: 4px; }
.mt-12    { margin-top: 12px; }
.mt-16    { margin-top: 16px; }
.p0       { padding: 0; }
.pad-20   { padding: 20px; }
.muted    { color: var(--muted); }
.subtle   { color: var(--subtle); }
.red      { color: var(--red); }
.small    { font-size: 12px; }
.text-center { text-align: center; }
.inline   { display: inline; }
.grid2    { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
.stat-list .stat-row { padding: 10px 0; }
.stat-list .stat-row a { color: var(--accent); text-decoration: none; }
.notes-form textarea { min-height: 60px; }

/* LIST-PAGE FILTER ROW — compact: fields at their natural width, no forced columns.
   Wraps on narrow screens; search stays a tidy 240px instead of stretching. */
.filter-row {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
}
.filter-row .fld               { margin-bottom: 0; min-width: 0; }
.filter-row .fld input.inp     { width: 240px; max-width: 100%; }
.filter-row .fld select.inp    { width: auto; min-width: 140px; }
.filter-row .btn               { align-self: end; }
.filter-row .btn-active        { border-color: var(--accent-br); color: var(--accent); }

/* Second-row 'Advanced' panel — wraps under the filter row inside the same
   flex container by force-breaking with flex-basis:100%. Date inputs are
   compact so 4 fit comfortably beside each other on a normal display. */
.filter-adv                    {
    flex-basis: 100%;
    display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
    padding-top: 10px; margin-top: 4px; border-top: 1px dashed var(--line);
}
.filter-adv .fld input.inp     { width: 170px; }

/* PRODUCTS LIST — bulk selection + thumbnails */
.col-check        { width: 32px; padding-right: 0; }
.col-thumb        { width: 48px; padding-right: 0; }
.cb               { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.product-thumb    { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; display: block; }
.product-thumb-placeholder {
    background: var(--panel2); color: var(--muted);
    display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.row-selected     { background: var(--accent-dim); }
.row-selected td  { border-color: var(--accent-br); }

/* Bulk actions bar — appears above the table when rows are selected.
   Every child (spans + buttons) gets vertical-align:middle by flex, and
   line-height:1 on text keeps small spans from sitting lower than the
   button when their intrinsic baseline differs. */
.bulk-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; margin-bottom: 12px;
    background: var(--accent-dim); border: 1px solid var(--accent-br); border-radius: 8px;
    font-size: 12.5px; color: var(--text);
    min-height: 40px;
}
.bulk-bar > *         { line-height: 1; display: inline-flex; align-items: center; }
.bulk-count           { color: var(--muted); }
.bulk-count b         { color: var(--text); }
.bulk-status-select   { width: auto; min-width: 170px; }
/* Shrink the Clear (and any future) buttons in the bulk bar so they
   don't tower over the message text. Overrides the default .btn size. */
.bulk-bar .btn        { padding: 5px 10px; font-size: 11.5px; height: 26px; }

/* Empty-state block for list pages with no rows. */
.empty-state    { text-align: center; padding: 32px 20px; color: var(--muted); font-size: 14px; }
.empty-icon     { font-size: 36px; margin-bottom: 8px; }

/* Small helpers */
.ml-6           { margin-left: 6px; }
.no-underline   { text-decoration: none; }
.mono-small     { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11px; color: var(--muted); }

/* PRODUCT READINESS DOTS — 4 tiny circles: price · image · stock · QA */
.readiness           { display: inline-flex; gap: 3px; align-items: center; }
.ready-dot           { width: 8px; height: 8px; border-radius: 50%; background: var(--line2); display: inline-block; }
.ready-dot.on        { background: var(--green); }

/* PRODUCT EDITOR */
.ml-auto             { margin-left: auto; }
/* Reset every property .fld label imposes on this <label> — it's a wrapper
   for an inline checkbox + text, not a field label, so it should read like
   body text (mixed-case, no uppercase, no muted colour) and stay flex on
   one line even when it sits directly inside a .fld. */
.checkbox-row        {
    display: flex; flex-wrap: nowrap; align-items: center; gap: 8px;
    cursor: pointer; font-size: 13px; font-weight: 400; color: var(--text);
    text-transform: none; letter-spacing: 0; margin-bottom: 0;
    line-height: 1;
}
/* Fix a fixed checkbox size + zero margins so its box aligns with the text
   baseline. Without this, browsers add their own default vertical margin
   and the checkbox floats above the label text. */
.checkbox-row input  {
    width: 16px; height: 16px; margin: 0; flex-shrink: 0;
    accent-color: var(--accent); vertical-align: middle;
}
.checkbox-row span   {
    text-transform: none; letter-spacing: 0; font-weight: 400;
    white-space: nowrap; line-height: 1;
}
/* Checkbox-row used as an .inp-style field — matches height of neighbouring
   inputs/selects so it lines up in a two-column .frow row. */
.inp-checkbox {
    background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
    /* Match .inp: 7px vertical + 12.5px font → same rendered height as the
       neighbouring select in a .frow. Height was previously a fixed 38px
       which made this box ~6px taller than the select next to it. */
    padding: 7px 12px; font-size: 12.5px; line-height: 1.35;
}
/* Option rows: two flexible fields + a fixed-width remove button on the same line.
   Uses flexbox to avoid inheriting .frow's grid template (which put the ✕
   on its own row). Flexbox with flex:1 on the fields + min-width:0 also
   prevents the inputs from pushing the button out of the card. */
.opt-row             { display: flex !important; align-items: end; gap: 10px; }
.opt-row > .fld      { flex: 1 1 0; min-width: 0; }
.opt-remove          { width: 34px; height: 34px; padding: 0; justify-content: center; flex: 0 0 auto; }

/* Metafield rows — grid so namespace / key / type / value / remove line up
   perfectly across all rows regardless of content length. Tuned column
   widths: namespace + type narrow (short values), key medium, value wide. */
.mf-row {
    display: grid;
    grid-template-columns: 140px 160px 180px 1fr 32px;
    gap: 8px; align-items: center; margin-bottom: 8px;
}
.mf-row > input, .mf-row > select { width: 100%; }
/* Header row (column labels) — no inputs, just muted small text. */
.mf-head              { padding: 0 2px 4px; font-size: 11px; }
.mf-head > div        { padding-left: 2px; }
/* Read-only reserved rows (shopify.*, judgeme.*, etc.) — dim + lock feel. */
.mf-row-locked        { opacity: .65; }
.mf-row-locked .inp   { background: var(--panel); cursor: not-allowed; }
.mf-remove            { padding: 0; height: 32px; justify-content: center; }
/* Narrow-screen fallback: stack fields for readability. */
@media (max-width: 800px) {
    .mf-row       { grid-template-columns: 1fr; }
    .mf-head      { display: none; }
}

/* Toast UI Editor — ships its own dark theme; these overrides tighten
   the default sizing so the editor matches the app's compact look
   (Toast's out-of-the-box toolbar is roomy + big-bordered). */
.toastui-editor-defaultUI {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--line) !important;
    background: var(--panel) !important;
}
.toastui-editor-defaultUI:focus-within { border-color: var(--accent) !important; }

/* Toolbar: shorter, tighter icons, matches .card-h padding rhythm. */
.toastui-editor-toolbar {
    background: var(--panel2) !important;
    border-bottom: 1px solid var(--line) !important;
}
.toastui-editor-defaultUI-toolbar { padding: 2px 6px !important; }
/* Slightly reduced from Toast's native 32x32 → 28x28. Any smaller and
   the sprite icons anti-alias into a fuzzy mess. */
.toastui-editor-toolbar-icons {
    width: 28px !important;
    height: 28px !important;
    margin: 0 !important;
    border-radius: 5px !important;
}
.toastui-editor-toolbar-group { margin: 0 !important; }
.toastui-editor-toolbar-divider {
    height: 16px !important; margin: 0 3px !important;
    background-color: var(--line) !important;
}
/* Toast UI's toolbar tooltip renders in an absolute-positioned <div>
   with a stale position that lingers over other cards after clicking
   or scrolling. The icons are self-explanatory — hide the tooltip. */
.toastui-editor-tooltip { display: none !important; }

/* Colour-picker plugin popover — sits above cards + tables. */
.tui-colorpicker-container,
.toastui-editor-popup-add-color { z-index: 300 !important; }
.toastui-editor-popup-add-color { background: var(--panel) !important; border-color: var(--line2) !important; }

/* Editing surface: sensible min-height (not the default 400+), padding
   that matches .card-b, softer typography. */
.toastui-editor-main .toastui-editor-ww-container,
.toastui-editor-main .toastui-editor-md-container {
    background: var(--panel) !important;
}
.toastui-editor-contents {
    padding: 10px 14px !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 13px !important;
    line-height: 1.55 !important;
    color: var(--text) !important;
    min-height: 180px !important;
}
.toastui-editor-contents p { margin: 0 0 8px !important; }
.toastui-editor-contents a { color: var(--accent) !important; }
.toastui-editor-contents blockquote {
    border-left: 3px solid var(--accent) !important;
    background: var(--panel2) !important;
    padding: 6px 12px !important;
    margin: 8px 0 !important;
    color: var(--subtle) !important;
}

/* Bottom mode-switch bar — the 'Markdown / WYSIWYG' toggle. Reduce its
   height so it doesn't look like a whole second toolbar. */
.toastui-editor-mode-switch {
    height: 28px !important;
    background: var(--panel2) !important;
    border-top: 1px solid var(--line) !important;
}
.toastui-editor-mode-switch .tab-item {
    height: 26px !important; line-height: 26px !important;
    font-size: 11px !important;
    padding: 0 12px !important;
}

/* ── Shopify-style variant editor ────────────────────────────────────── */
.single-variant      { max-width: 640px; }

.option-editor       {
    background: var(--panel2); border: 1px solid var(--line);
    border-radius: 10px; padding: 14px 14px 12px;
}
.option-editor-h     { display: flex; align-items: end; gap: 12px; }

/* Chip input — pill-shaped value tags + inline entry field, all in a
   wrapper that mimics the .inp style so it reads as one control. */
.chip-input          {
    display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
    padding: 6px; min-height: 38px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.chip-input:focus-within { border-color: var(--accent); }
.chip                {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--panel2); border: 1px solid var(--line2);
    padding: 4px 4px 4px 10px; border-radius: 999px;
    font-size: 12px; color: var(--text);
}
.chip-x              {
    width: 18px; height: 18px; border-radius: 50%; border: 0;
    background: rgba(255,255,255,.06); color: var(--muted);
    font-size: 10px; cursor: pointer; display: inline-flex;
    align-items: center; justify-content: center;
}
.chip-x:hover        { background: var(--red); color: #fff; }
.chip-entry          {
    flex: 1; min-width: 140px; background: transparent; border: 0; outline: 0;
    color: var(--text); font-size: 13px; padding: 4px 6px;
}

/* Bulk-edit toolbar sitting above the variants table on the product form.
   Renamed from .bulk-bar to avoid colliding with the list-page bulk-actions
   bar (line 232) — same class name was silently overriding rules depending
   on stylesheet load order. */
.variants-bulk-bar   {
    display: flex; align-items: end; gap: 12px;
    padding: 12px 14px; background: var(--panel2);
    border: 1px solid var(--line); border-radius: 10px;
}
.bulk-inputs         { display: flex; gap: 8px; }
.bulk-inputs .inp    { max-width: 140px; }

/* Grouped variant table — group header collapses/expands the rows underneath. */
.variants-table      { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.variant-group + .variant-group { border-top: 1px solid var(--line); }
.variant-group-h     {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; background: var(--panel2); cursor: pointer;
    user-select: none;
}
.variant-group-h:hover { background: rgba(255,255,255,.03); }
.variant-caret       { display: inline-block; width: 12px; color: var(--muted); }
.variant-row         {
    display: grid;
    grid-template-columns: 1fr 120px 100px 180px;
    gap: 10px; align-items: center;
    padding: 8px 14px; border-top: 1px solid var(--line);
}
.variant-row:first-child { border-top: 0; }
.variant-label       { color: var(--text); font-size: 13px; font-weight: 500; }
.variant-row .inp    { padding: 6px 8px; }
.attached-media      { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; }
.attached-tile       { position: relative; }
.attached-tile img   { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; }
.attached-remove     {
    position: absolute; top: 4px; right: 4px;
    width: 20px; height: 20px; border-radius: 50%;
    background: rgba(0,0,0,.7); color: #fff; border: none;
    font-size: 11px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.picker-grid         { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; max-height: 60vh; overflow-y: auto; position: relative; transition: opacity .12s; }
/* Dim results during a re-fetch so users see something's happening
   without the grid disappearing (prevents scroll jump). */
.picker-grid-loading { opacity: .5; pointer-events: none; }
.picker-tile         {
    position: relative;
    padding: 0; background: var(--panel2); border: 2px solid var(--line); border-radius: 6px;
    cursor: pointer; overflow: hidden; transition: .1s; text-align: left;
}
.picker-tile:hover   { border-color: var(--line2); }
.picker-tile-selected { border-color: var(--accent); }
.picker-tile-selected img { opacity: .8; }
.picker-tile img     { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.picker-name         { display: block; padding: 4px 6px; font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Selected-tile check badge — overlays the thumbnail so users can spot
   selections at a glance without inspecting border colour. */
.picker-tile-check   {
    position: absolute; top: 4px; right: 4px;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--accent); color: #0B0E15;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 800; box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.picker-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* DROPZONE — click OR drag-drop to upload straight into the product form. */
.dropzone {
    position: relative; border: 2px dashed var(--line2); border-radius: 10px;
    padding: 28px 16px; text-align: center; cursor: pointer;
    background: var(--panel2); transition: .12s;
}
.dropzone:hover      { border-color: var(--accent); background: rgba(245, 165, 36, .04); }
.dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone-hot        { border-color: var(--accent); background: rgba(245, 165, 36, .08); }
.dz-input            { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dz-inner            { pointer-events: none; }
.dz-icon             { font-size: 22px; color: var(--accent); margin-bottom: 4px; }
.dz-title            { font-weight: 600; margin-bottom: 2px; }
.dz-sub              { font-size: 11px; color: var(--muted); }

/* Upload progress + error overlays on attached-tile */
.tile-overlay        {
    position: absolute; inset: 0; border-radius: 6px;
    background: rgba(0, 0, 0, .5);
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
}
.tile-pct            {
    color: #fff; font-weight: 700; font-size: 14px;
    text-shadow: 0 1px 2px rgba(0,0,0,.6); font-variant-numeric: tabular-nums;
}
.tile-pct.spin       { animation: tile-spin 1s linear infinite; font-size: 18px; }
@keyframes tile-spin { to { transform: rotate(360deg); } }

.tile-progress       {
    position: absolute; left: 0; right: 0; bottom: 0; height: 6px;
    background: rgba(0, 0, 0, .55);
    border-bottom-left-radius: 6px; border-bottom-right-radius: 6px;
    overflow: hidden;
}
.tile-progress-bar   {
    height: 100%; background: var(--accent);
    transition: width .15s linear;
    box-shadow: 0 0 8px rgba(245, 165, 36, .6);
}
.tile-err            { outline: 2px solid var(--red); }
.tile-err-msg        {
    position: absolute; left: 0; right: 0; bottom: 0;
    background: rgba(248, 115, 106, .9); color: #fff;
    font-size: 10px; line-height: 1.2; padding: 3px 4px; text-align: center;
    border-bottom-left-radius: 6px; border-bottom-right-radius: 6px;
}

/* MEDIA LIBRARY */
.media-grid           { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.media-tile           { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.media-tile:hover     { border-color: var(--line2); }
.media-thumb-btn      { padding: 0; border: none; background: none; cursor: pointer; display: block; }
.media-thumb          { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.media-thumb-file     { display: flex; align-items: center; justify-content: center; font-size: 36px; background: var(--panel2); color: var(--muted); }
.media-tile-meta      { padding: 8px 10px; }
.media-tile-name      { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-tile-sub       { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 4px; }
.media-detail         { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
@media (max-width: 700px) { .media-detail { grid-template-columns: 1fr; } }
.media-detail-preview { background: var(--panel2); border-radius: 6px; padding: 16px; display: flex; align-items: center; justify-content: center; min-height: 200px; }
.media-detail-img     { max-width: 100%; max-height: 60vh; object-fit: contain; display: block; }

/* Native <dialog> defaults to top-anchored auto margins, which look off in
   this app where every other modal is viewport-centered. Force centered
   placement with a max height so scroll goes inside .modal-b, not the page. */
.upload-dialog        {
    background: var(--panel); color: var(--text); border: 1px solid var(--line);
    border-radius: 12px; padding: 0; max-width: 640px; width: 90vw;
    max-height: 90vh;
    position: fixed; inset: 0; margin: auto;
}
.upload-dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(2px); }
.upload-form          { display: flex; flex-direction: column; }

/* FLATPICKR — shrink the default sizing so the calendar reads at the
   same weight as the rest of the app (13-13.5px body, ~11px labels).
   Dark theme's default is closer to 16-18px which felt oversized. */
.flatpickr-calendar         { font-size: 13px; }
.flatpickr-current-month    { font-size: 14px; padding-top: 4px; }
.flatpickr-current-month .cur-month,
.flatpickr-current-month input.cur-year { font-size: 14px; font-weight: 600; }
.flatpickr-monthDropdown-months { font-size: 13px; }
span.flatpickr-weekday      { font-size: 11px; font-weight: 600; }
.flatpickr-day              { font-size: 12.5px; height: 34px; line-height: 34px; }
.flatpickr-time input,
.flatpickr-time .flatpickr-time-separator,
.flatpickr-time .flatpickr-am-pm { font-size: 13px; }

/* ✕ clear button rendered by the Flatpickr auto-init next to every
   date input. Positioned inside the .fld so it overlays the right
   edge of the input. Kept subtle — only visible when the field has
   a value (see :has selector below). */
.fld { position: relative; }
.fp-clear {
    position: absolute; right: 8px; top: 50%;
    transform: translateY(-25%);
    width: 20px; height: 20px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--muted); background: var(--panel);
    font-size: 11px; cursor: pointer; user-select: none;
    border: 1px solid var(--line);
    opacity: .6; transition: opacity .12s;
}
.fp-clear:hover { color: var(--text); border-color: var(--line2); opacity: 1; }

/* Rich text output (product/store description saved from Toast UI editor).
   Named .prose so we could later swap in a Tailwind Typography plugin
   without touching consumers. Keeps line-height + spacing readable and
   contains images/tables so they never overflow the card. */
.prose               { font-size: 13.5px; line-height: 1.65; color: var(--text); }
.prose > * + *       { margin-top: 12px; }
.prose h1, .prose h2, .prose h3, .prose h4 {
    line-height: 1.3; color: var(--text); font-weight: 700; margin-top: 20px;
}
.prose h1            { font-size: 20px; }
.prose h2            { font-size: 17px; }
.prose h3            { font-size: 15px; }
.prose h4            { font-size: 13.5px; }
.prose p             { margin: 0; }
.prose a             { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li + li       { margin-top: 4px; }
.prose blockquote    {
    border-left: 3px solid var(--line2); padding: 4px 0 4px 12px;
    color: var(--subtle); font-style: italic;
}
.prose hr            { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.prose code          {
    background: var(--panel2); border: 1px solid var(--line); border-radius: 4px;
    padding: 1px 6px; font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.prose pre           {
    background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
    padding: 12px; overflow-x: auto;
}
.prose pre code      { background: transparent; border: 0; padding: 0; }
.prose img           { max-width: 100%; height: auto; border-radius: 6px; }
.prose table         { width: 100%; border-collapse: collapse; }
.prose table th, .prose table td {
    border: 1px solid var(--line); padding: 6px 10px; text-align: left; font-size: 13px;
}
.prose table th      { background: var(--panel2); font-weight: 600; }

/* SETTINGS > SYNC */
.sync-header  { display: flex; align-items: center; gap: 16px; }
.flex-1       { flex: 1; }

/* SIDEBAR FOOTER — sync status chip + user chip */
.sync-status {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 11px; margin-bottom: 8px;
    border-radius: 8px; border: 1px solid var(--line);
    background: var(--panel2); text-decoration: none;
    font-size: 11px; color: var(--muted);
    transition: .13s;
}
.sync-status:hover { color: var(--text); border-color: var(--line2); }
.sync-status-dot   { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.sync-status-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-status--ok       { color: var(--green);  border-color: rgba(45,212,160,.22); background: rgba(45,212,160,.07); }
.sync-status--ok  .sync-status-dot { background: var(--green); animation: pulse 2s infinite; }
.sync-status--bad      { color: var(--red);    border-color: rgba(248,115,106,.3);  background: rgba(248,115,106,.08); }
.sync-status--bad .sync-status-dot { background: var(--red); }
.sync-status--warn     { color: var(--accent); border-color: rgba(245,165,36,.3);   background: rgba(245,165,36,.08); }
.sync-status--warn .sync-status-dot { background: var(--accent); }
.sync-status--idle .sync-status-dot { background: var(--muted); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.user-chip           { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); font-size: 12px; color: var(--subtle); }
.user-chip-link      { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; text-decoration: none; color: inherit; }
.user-avatar         { width: 20px; height: 20px; border-radius: 50%; }
.user-name-truncate  { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-link           { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0; }
.icon-link:hover     { color: var(--text); }

/* PRODUCT DETAIL */
.image-grid    { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.product-image { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }

/* TIMELINE */
.tl-when-col  { width: 130px; }
.tl-who-col   { width: 150px; }
.tl-on-col    { width: 140px; }
.tl-when      { font-size: 12px; }
.tl-who       { font-size: 12px; }
.tl-what      { font-size: 13px; }
.tl-on        { font-size: 12px; }
.tl-summary   { margin-left: 6px; }

/* ALERTS — inline banners for form errors + successes. Use .alert-err / .alert-ok. */
.alert {
    padding: 8px 12px; border-radius: 6px; font-size: 12px;
    margin-bottom: 12px; border: 1px solid transparent; text-align: left;
}
.alert-err { background: rgba(248, 115, 106, .08); border-color: rgba(248, 115, 106, .3); color: var(--red); }
.alert-ok  { background: rgba( 45, 212, 160, .08); border-color: rgba( 45, 212, 160, .3); color: var(--green); }
.alert-warn{ background: rgba(245, 165,  36, .08); border-color: rgba(245, 165,  36, .3); color: var(--accent); }
.alert-info{ background: rgba( 91, 157, 247, .08); border-color: rgba( 91, 157, 247, .3); color: var(--blue); }

/* FORM */
.inp, input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], textarea, select {
    background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
    padding: 7px 10px; color: var(--text); font-size: 12.5px; outline: none;
    font-family: 'Inter'; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-br); box-shadow: 0 0 0 3px var(--accent-dim); }
/* Client-side validation-failure highlight. Applied by JS guards on
   submit (see stores modal sConfirmSave) so the user sees which
   field failed instead of just getting a toast. Cleared as soon as
   the field is edited or corrected. */
.inp-err, .inp-err:focus {
    border-color: rgba(248,115,106,.6);
    box-shadow: 0 0 0 3px rgba(248,115,106,.15);
}
textarea { resize: vertical; min-height: 60px; }
.fld { margin-bottom: 13px; }
.fld label {
    display: block; font-size: 10.5px; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .7px; margin-bottom: 5px;
}
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* On narrow screens collapse two-column form rows to a single column so
   inputs don't squash to ~100px. Same breakpoint as .grid2/.grid3 for
   visual consistency. */
@media (max-width: 640px) { .frow { grid-template-columns: 1fr; } }

/* Empty-state variants:
   - .empty       — large hero (icon 48px, 40px padding) for full-card
                    "no rows yet" states on list pages (clients/stores).
   - .empty-state — compact (icon 36px, 32px padding) for smaller cards
                    or inline sections (products/media/notes-form).
   Keeping both — they're the same idea at two different visual weights. */
.help {
    font-size: 11px; color: var(--muted); margin-top: 4px;
    margin-bottom: 10px;
    line-height: 1.5;
}

/* Any collapsible <details> block between fields gets breathing space
   underneath so its summary text doesn't touch the label of the next
   field (e.g. 'Customs information' summary against 'Country of
   origin' label on the shipping card). */
details            { margin-bottom: 10px; }
details summary    { padding: 4px 0; }
/* Give the disclosed content a small gap so it doesn't collide with
   its own summary either. */
details[open] > *:not(summary) { margin-top: 4px; }

/* TABLES */
table.dt { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.dt th {
    text-align: left; padding: 9px 12px; font-size: 10.5px; font-weight: 700;
    color: var(--muted); text-transform: uppercase; letter-spacing: .7px;
    border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel);
}
.dt td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dt tbody tr { transition: .1s; }
.dt tbody tr:hover { background: var(--panel2); }
/* Rows wired with an onclick handler carry .click — show the pointer
   cursor so users know the whole row is a link, matching Shopify's
   list behaviour. Applies globally to every clickable row.
   Keyboard: rows get tabindex=0 by the global row-nav script (see
   layouts/app.blade.php) so Tab focuses them and Enter navigates. */
.dt tbody tr.click { cursor: pointer; }
.dt tbody tr.click:focus-visible {
    outline: 2px solid var(--accent-br);
    outline-offset: -2px;
    background: var(--panel2);
}
.dt .num { text-align: right; font-family: 'JetBrains Mono'; font-size: 12px; }

/* PILLS + TAGS */
.pill {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 10.5px; font-weight: 600; padding: 2.5px 9px; border-radius: 20px;
}
.pill.ok { background: rgba(45,212,160,.12); color: var(--green); }
.pill.warn { background: rgba(245,165,36,.13); color: var(--amber); }
.pill.bad { background: rgba(248,115,106,.12); color: var(--red); }
.pill.info { background: rgba(91,157,247,.13); color: var(--blue); }
.pill.mut { background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }
.pill.vio { background: rgba(155,123,247,.13); color: var(--violet); }
/* .pill-btn — same shape as .pill but for actual clickable links/buttons.
   .pill on <a> or <button> is a semantics conflict; use this variant for
   links so hover state signals interactivity. */
.pill-btn { cursor: pointer; text-decoration: none; transition: filter .12s; }
.pill-btn:hover { filter: brightness(1.15); }
.tag {
    font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 5px;
    background: var(--panel2); border: 1px solid var(--line); color: var(--subtle);
    margin-right: 4px; display: inline-block;
}

/* EMPTY STATES */
.empty {
    padding: 40px; text-align: center; color: var(--muted); font-size: 12.5px;
    background: var(--panel2); border-radius: 10px; border: 1px dashed var(--line);
}
.empty .big { font-size: 48px; margin-bottom: 12px; opacity: .3; }

/* MODAL */
.overlay {
    position: fixed; inset: 0; background: rgba(5,8,14,.55);
    backdrop-filter: blur(2px); z-index: 90;
}
.modal-card {
    background: var(--panel); border: 1px solid var(--line2);
    border-radius: 14px; width: 640px; max-width: 96vw; max-height: 90vh;
    display: flex; flex-direction: column; box-shadow: var(--shadow);
    z-index: 91; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
}
/* Wider variant — used by content-heavy modals (media picker, detail views). */
.modal-card.wide { width: 900px; }
.modal-h {
    padding: 14px 20px; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 10px;
}
.modal-h h3 { font-size: 15px; flex: 1; }
.modal-b { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-f { padding: 13px 20px; border-top: 1px solid var(--line); display: flex; gap: 9px; justify-content: flex-end; }
.close-x { background: transparent; border: none; color: var(--muted); font-size: 20px; cursor: pointer; }

/* GUEST / LOGIN */
.guest-card {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 14px; padding: 40px; width: 420px; max-width: 92vw;
    box-shadow: var(--shadow);
}
.guest-card h1 { font-size: 20px; text-align: center; margin-bottom: 8px; }
.guest-card p.lead { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 26px; }
.google-btn {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 12px 16px; background: #fff; color: #1F1F1F;
    border-radius: 8px; font-weight: 600; font-size: 14px; border: none;
    cursor: pointer; transition: .15s; text-decoration: none;
}
.google-btn:hover { background: #F1F3F4; }
.google-btn svg { width: 20px; height: 20px; }

/* TOAST */
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
    background: var(--panel); border: 1px solid var(--line2);
    border-left: 3px solid var(--green); border-radius: 10px;
    padding: 11px 16px; font-size: 12.5px; box-shadow: var(--shadow);
    animation: fadeUp .2s ease; max-width: 340px;
}
.toast.warn { border-left-color: var(--amber); }
.toast.err { border-left-color: var(--red); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* MISC */
.stat-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.stat-row:last-child { border-bottom: none; }
.stat-row b { font-family: 'JetBrains Mono'; font-size: 12px; }
.toolbar { display: flex; gap: 9px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }

/* ── Tranche E navigation shell ─────────────────────────────────────── */

/* Bottom-left System button + popover (Shopify-style admin picker) */
.system-pill {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 9px 11px; margin-top: 8px;
    background: var(--panel2); border: 1px solid var(--line);
    border-radius: 8px; color: var(--subtle);
    font-size: 12px; font-weight: 500; cursor: pointer;
    text-align: left;
}
.system-pill:hover { color: var(--text); border-color: var(--line2); }
.system-pill .ic { font-size: 14px; }
.system-pill .caret { margin-left: auto; color: var(--muted); }

.system-popover {
    position: fixed; bottom: 12px; left: 246px; z-index: 60;
    width: 260px; padding: 6px;
    background: var(--panel); border: 1px solid var(--line2);
    border-radius: 10px; box-shadow: var(--shadow);
}
@media (max-width: 900px) {
    .system-popover { left: 70px; }
}
.system-popover-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 6px;
    color: var(--subtle); font-size: 12.5px; text-decoration: none;
}
.system-popover-item:hover { background: var(--panel2); color: var(--text); }
.system-popover-item.locked { opacity: .45; pointer-events: none; }
.system-popover-sep {
    height: 1px; background: var(--line); margin: 4px 0;
}

/* Top-right user menu (in the topbar) */
.tb-user {
    position: relative;
}
.tb-user-trigger {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px 6px 6px;
    background: var(--panel2); border: 1px solid var(--line);
    border-radius: 999px; color: var(--text);
    font-size: 12px; font-weight: 500; cursor: pointer;
}
.tb-user-trigger:hover { border-color: var(--line2); }
.tb-user-avatar {
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--accent-dim); color: var(--accent);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 11px; overflow: hidden;
}
.tb-user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.tb-user-menu {
    position: absolute; top: calc(100% + 6px); right: 0;
    min-width: 220px; padding: 6px; z-index: 60;
    background: var(--panel); border: 1px solid var(--line2);
    border-radius: 10px; box-shadow: var(--shadow);
}
.tb-user-menu-h {
    padding: 8px 10px 10px; border-bottom: 1px solid var(--line);
    margin-bottom: 4px;
}
.tb-user-menu-h b { display: block; font-size: 13px; }
.tb-user-menu-h small { color: var(--muted); font-size: 11px; }
.tb-user-menu-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 6px;
    color: var(--subtle); font-size: 12.5px; text-decoration: none;
    background: none; border: 0; width: 100%; text-align: left; cursor: pointer;
    font-family: inherit;
}
.tb-user-menu-item:hover { background: var(--panel2); color: var(--text); }

/* Row-actions 3-dot menu */
.row-actions {
    position: relative; display: inline-block;
}
.ra-trigger {
    width: 28px; height: 28px; border-radius: 6px;
    background: transparent; border: 1px solid transparent;
    color: var(--muted); font-size: 16px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    line-height: 1;
}
.ra-trigger:hover {
    color: var(--text); border-color: var(--line); background: var(--panel2);
}
.ra-menu {
    /* position:fixed so the menu escapes any overflow:hidden on ancestor
       containers (cards, tables, drawers). Coords are set inline by the
       Alpine component from the trigger's bounding rect. */
    position: fixed; min-width: 200px;
    padding: 4px; z-index: 200;
    background: var(--panel); border: 1px solid var(--line2);
    border-radius: 8px; box-shadow: var(--shadow);
}
.ra-item {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 7px 10px; border: 0; background: transparent;
    color: var(--subtle); font-size: 12.5px; text-align: left; cursor: pointer;
    border-radius: 5px; text-decoration: none;
    font-family: inherit;
}
.ra-item:hover  { background: var(--panel2); color: var(--text); }
.ra-item.ra-danger { color: var(--red); }
.ra-item.ra-danger:hover { background: rgba(248,115,106,.1); }
.ra-sep { height: 1px; background: var(--line); margin: 4px 0; }

/* Slide-out drawer */
.drawer {
    position: fixed; inset: 0; z-index: 70;
}
.drawer-backdrop {
    position: absolute; inset: 0; background: rgba(0, 0, 0, .5);
}
.drawer-panel {
    position: absolute; top: 0; right: 0; bottom: 0;
    max-width: 96vw;
    background: var(--panel); border-left: 1px solid var(--line2);
    box-shadow: -8px 0 24px rgba(0,0,0,.4);
    display: flex; flex-direction: column;
    transform: translateX(0);
    transition: transform .18s ease-out;
}
.drawer-out { transform: translateX(100%); }
.drawer-h {
    display: flex; align-items: center;
    padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.drawer-h h3 { flex: 1; font-size: 14px; font-weight: 600; }
.drawer-b   { flex: 1; overflow-y: auto; padding: 16px 18px; }
.drawer-f   { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* Sortable table headers */
.sortable-th { padding: 0; }
.sortable-th-link {
    display: flex; align-items: center; gap: 4px;
    padding: 10px 12px;
    color: var(--muted); text-decoration: none;
    font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em;
}
.sortable-th.num .sortable-th-link { justify-content: flex-end; }
/* Hover only changes colour + background — the padding/margin stays
   the same as the base state so the column doesn't visibly shift as
   the pointer moves across headers. The 4px radius is applied always
   too, since it's only visible when a background paints on hover. */
.sortable-th-link {
    border-radius: 4px;
    transition: background .12s, color .12s;
}
.sortable-th-link:hover {
    color: var(--text);
    background: var(--panel2);
}
.sortable-th.sorted .sortable-th-link { color: var(--accent); }
.sort-caret { font-size: 10px; opacity: .7; }
.sortable-th.sorted .sort-caret { opacity: 1; }

/* Load-more button under a table */
.load-more-wrap {
    display: flex; justify-content: center; padding: 12px 0;
}
.load-more-btn {
    padding: 8px 16px; font-size: 12px; font-weight: 500;
    background: var(--panel2); color: var(--subtle);
    border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.load-more-btn:hover { color: var(--text); border-color: var(--line2); }
.load-more-btn:disabled { opacity: .4; pointer-events: none; }

/* Themed autocomplete popover — used by <x-data="autocomplete"> fields.
   Replaces native <datalist> which the browser styles inconsistently.
   position:fixed so it escapes the filter card's overflow:hidden — the
   Alpine component sets top/left inline from the input's boundingRect. */
.ac-menu {
    position: fixed;
    max-height: 260px; overflow-y: auto; z-index: 200;
    background: var(--panel); border: 1px solid var(--line2);
    border-radius: 8px; box-shadow: var(--shadow);
    padding: 4px;
}
.ac-item {
    display: block; width: 100%; text-align: left;
    padding: 7px 10px; border: 0; background: transparent;
    color: var(--subtle); font-size: 12.5px; cursor: pointer;
    border-radius: 5px; font-family: inherit;
}
.ac-item:hover, .ac-item-hot { background: var(--panel2); color: var(--text); }

/* Google Places suggestion dropdown — sits above the modal overlay
   (Google injects .pac-container into <body>, so the default z-index
   loses to our modals). */
.pac-container { z-index: 100000 !important; }
