/* ==========================================================================
   bigskuai design system
   ========================================================================== */
:root {
  --brand: #4f46e5;
  --brand-600: #4338ca;
  --brand-50: #eef2ff;
  --brand-100: #e0e7ff;
  --accent: #06b6d4;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #6b7280;
  --green: #059669; --green-bg: #ecfdf5;
  --amber: #b45309; --amber-bg: #fffbeb;
  --red: #dc2626;   --red-bg: #fef2f2;
  --blue: #2563eb;  --blue-bg: #eff6ff;
  --gray-bg: #f3f4f6;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.14);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #818cf8; --brand-600: #6366f1; --brand-50: #1e1b4b; --brand-100: #312e81;
    --bg: #0b0f19; --surface: #111827; --surface-2: #0f1522; --border: #1f2937;
    --text: #f3f4f6; --text-2: #d1d5db; --muted: #9ca3af;
    --green: #34d399; --green-bg: #052e22; --amber: #fbbf24; --amber-bg: #2d2006;
    --red: #f87171; --red-bg: #2c0b0b; --blue: #60a5fa; --blue-bg: #0b1d3a; --gray-bg: #1f2937;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #818cf8; --brand-600: #6366f1; --brand-50: #1e1b4b; --brand-100: #312e81;
  --bg: #0b0f19; --surface: #111827; --surface-2: #0f1522; --border: #1f2937;
  --text: #f3f4f6; --text-2: #d1d5db; --muted: #9ca3af;
  --green: #34d399; --green-bg: #052e22; --amber: #fbbf24; --amber-bg: #2d2006;
  --red: #f87171; --red-bg: #2c0b0b; --blue: #60a5fa; --blue-bg: #0b1d3a; --gray-bg: #1f2937;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
img { max-width: 100%; }
.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .nowrap { white-space: nowrap; }
.text-right { text-align: right; } .text-center { text-align: center; }
.text-green { color: var(--green); } .text-red { color: var(--red); } .text-amber { color: var(--amber); }
.mt-0 { margin-top: 0 } .mt-1 { margin-top: .5rem } .mt-2 { margin-top: 1rem } .mt-3 { margin-top: 1.5rem }
.mb-0 { margin-bottom: 0 } .mb-1 { margin-bottom: .5rem } .mb-2 { margin-bottom: 1rem }
.flex { display: flex; gap: .5rem; align-items: center; } .flex-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; } .grow { flex: 1; } .hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 40;
  transition: transform .25s ease;
}
.sidebar-brand { height: var(--topbar-h); display: flex; align-items: center; gap: .6rem; padding: 0 1.1rem; border-bottom: 1px solid var(--border); }
.sidebar-brand img { height: 30px; width: auto; }
.sidebar-brand .name { font-weight: 750; font-size: 1.1rem; letter-spacing: -.02em; color: var(--text); }
.sidebar-brand .name b { color: var(--brand); }
.sidebar nav { flex: 1; overflow-y: auto; padding: .75rem .6rem 1.5rem; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 1rem .7rem .35rem; font-weight: 600; }
.nav-link {
  display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; margin-bottom: 1px;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--brand-50); color: var(--brand); }
.nav-link .tag { margin-left: auto; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 99px; background: linear-gradient(90deg, var(--brand), var(--accent)); color: #fff; }
details.nav-group > summary { list-style: none; cursor: pointer; }
details.nav-group > summary::-webkit-details-marker { display: none; }
details.nav-group > summary .chev { margin-left: auto; transition: transform .2s; width: 14px; height: 14px; }
details.nav-group[open] > summary .chev { transform: rotate(90deg); }
.nav-sub { padding-left: 1.85rem; }
.nav-sub .nav-link { padding: .4rem .7rem; font-size: 13.5px; }
.sidebar-foot { border-top: 1px solid var(--border); padding: .75rem; }
.plan-card { background: linear-gradient(135deg, var(--brand), #7c3aed); color: #fff; border-radius: var(--radius); padding: .8rem .9rem; font-size: 12.5px; }
.plan-card a { color: #fff; font-weight: 600; text-decoration: underline; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem;
}
.topbar .search { flex: 1; max-width: 460px; position: relative; }
.topbar .search input { padding-left: 2.2rem; background: var(--surface-2); }
.topbar .search .ico { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); }
.menu-toggle { display: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-100); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.content { padding: 1.5rem; max-width: 1400px; width: 100%; margin: 0 auto; flex: 1; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin: .2rem 0 0; }
.breadcrumb { font-size: 12.5px; color: var(--muted); margin-bottom: .25rem; }
.breadcrumb a { color: var(--muted); }
.backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }

/* dropdown */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .35rem; display: none; z-index: 50; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button { display: flex; gap: .6rem; align-items: center; width: 100%; padding: .5rem .65rem; border-radius: 6px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--border); margin: .3rem 0; }

/* mobile bottom bar */
.bottom-nav { display: none; }

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop { display: block; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-grid; }
}
@media (max-width: 640px) {
  .content { padding: 1rem; padding-bottom: 5.5rem; }
  .topbar { padding: 0 .75rem; }
  .topbar .search { display: none; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--border); padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; color: var(--muted); padding: .25rem; text-decoration: none; }
  .bottom-nav a.active { color: var(--brand); }
  .bottom-nav a.fab .ico { background: var(--brand); color: #fff; border-radius: 12px; width: 40px; height: 32px; padding: 6px 10px; }
  h1 { font-size: 1.3rem; }
}

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 1.15rem 1.25rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .9rem 1.25rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-foot { padding: .8rem 1.25rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 420px) { .grid-4 { grid-template-columns: 1fr; } }

.stat { padding: 1.1rem 1.2rem; display: flex; gap: .9rem; align-items: flex-start; }
.stat .stat-ico { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); flex: none; }
.stat .stat-ico.green { background: var(--green-bg); color: var(--green); }
.stat .stat-ico.amber { background: var(--amber-bg); color: var(--amber); }
.stat .stat-ico.red { background: var(--red-bg); color: var(--red); }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; height: 38px; padding: 0 1rem;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: 600 13.5px var(--font); cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 32px; padding: 0 .7rem; font-size: 12.5px; }
.btn-lg { height: 46px; padding: 0 1.4rem; font-size: 15px; }
.btn-block { width: 100%; }
.btn-ai { background: linear-gradient(90deg, var(--brand), #7c3aed 60%, var(--accent)); color: #fff; border: 0; }
.btn-ai:hover { filter: brightness(1.08); background: linear-gradient(90deg, var(--brand), #7c3aed 60%, var(--accent)); }
.btn[disabled] { opacity: .6; pointer-events: none; }

.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge-gray { background: var(--gray-bg); color: var(--text-2); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }

/* forms */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: .3rem; color: var(--text-2); }
.form-control, input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=url], input[type=search], select, textarea {
  width: 100%; height: 40px; padding: 0 .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: 14px var(--font); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 90px; padding: .6rem .75rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
input[type=file] { font: 13px var(--font); }
.field { margin-bottom: 1rem; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: .25rem; }
.field .error { font-size: 12px; color: var(--red); margin-top: .25rem; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1rem; }
@media (max-width: 640px) { .form-grid, .form-grid-3 { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); padding: .65rem .9rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: .7rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.actions { text-align: right; white-space: nowrap; }
.table tfoot td { font-weight: 700; background: var(--surface-2); }
.thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; background: var(--gray-bg); display: inline-grid; place-items: center; color: var(--muted); }
.cell-title { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--muted); }

/* Responsive table -> cards on phones */
@media (max-width: 640px) {
  table.table.stack thead { display: none; }
  table.table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { border-bottom: 1px solid var(--border); padding: .6rem .9rem; }
  .table.stack td { border: 0; padding: .2rem 0; display: block; text-align: right; overflow: hidden; }
  .table.stack td::before { content: attr(data-label); float: left; margin-right: 1rem; font-weight: 600; color: var(--muted); font-size: 12px; text-align: left; line-height: 1.9; }
  .table.stack td.actions { padding-top: .4rem; }
  .table.stack td.actions::before { content: none; }
  .table.stack td.primary { font-size: 15px; text-align: left; }
  .table.stack td.primary::before { content: none; }
}

.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; padding: .9rem 1.25rem; border-bottom: 1px solid var(--border); }
.toolbar input[type=search] { max-width: 300px; }
.toolbar select { width: auto; min-width: 150px; }
.pagination { display: flex; gap: .3rem; align-items: center; justify-content: space-between; padding: .8rem 1.25rem; border-top: 1px solid var(--border); flex-wrap: wrap; }

.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid; display: flex; gap: .6rem; align-items: flex-start; }
.alert-success { background: var(--green-bg); color: var(--green); border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.alert-error { background: var(--red-bg); color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.alert-warning { background: var(--amber-bg); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 30%, transparent); }
.alert-info { background: var(--blue-bg); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 30%, transparent); }

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty > .ico { width: 44px; height: 44px; color: var(--brand); opacity: .6; margin-bottom: .5rem; }
.empty h3 { color: var(--text); }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs a { padding: .6rem .9rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; }
.tabs a.active { color: var(--brand); border-color: var(--brand); }

.dl { display: grid; grid-template-columns: 160px 1fr; gap: .5rem 1rem; margin: 0; }
.dl dt { color: var(--muted); font-weight: 500; }
.dl dd { margin: 0; }
@media (max-width: 640px) { .dl { grid-template-columns: 1fr; } .dl dt { margin-top: .4rem; } }

/* line items editor */
.lines td { padding: .4rem .5rem; }
.lines input, .lines select { height: 36px; }
.lines .w-qty { width: 110px; } .lines .w-price { width: 130px; }
.stock-lines th.w-qty { width: 150px; }
.qty-step { display: flex; align-items: center; gap: .25rem; width: 150px; }
.qty-step input { text-align: center; min-width: 0; flex: 1; padding-left: .3rem; padding-right: .3rem; }
.qty-step .btn { width: 32px; height: 36px; padding: 0; justify-content: center; flex: none; font-size: 16px; }
.lines-empty { display: none; }
.stock-lines + .lines-empty:not(.hidden) { display: flex; gap: .8rem; align-items: center; justify-content: center; padding: 2rem 1rem; color: var(--muted); }
.lines-empty > .ico { width: 28px; height: 28px; color: var(--brand); opacity: .6; }
.stock-lines:has(+ .lines-empty:not(.hidden)) thead { display: none; }
.line-warn td { background: var(--amber-bg); }
.line-warn-text { color: var(--amber); font-size: 12px; font-weight: 600; margin-top: .15rem; }
@keyframes line-flash { from { background: var(--brand-50, #eef2ff); } to { background: transparent; } }
.line-flash td { animation: line-flash 1.2s ease-out; }
@media (max-width: 640px) {
  .stock-lines td .qty-step { margin-left: auto; }
  .stock-lines td [data-item-display] { text-align: left; }
  .stock-lines td.actions { text-align: right; }
}

/* item picker suggestions (attached to <body>, never clipped) */
.picker-menu { position: fixed; z-index: 1000; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .3rem; }
.picker-menu button { display: flex; gap: .75rem; align-items: center; width: 100%; padding: .5rem .65rem; border-radius: 6px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.picker-menu button:hover, .picker-menu button.active { background: var(--surface-2); }
.picker-menu button.active { box-shadow: inset 3px 0 0 var(--brand); }
.picker-menu .cell-sub { display: block; }
.picker-qty { font-size: 12px; font-weight: 600; color: var(--green); white-space: nowrap; font-variant-numeric: tabular-nums; }
.picker-qty.out { color: var(--red); }
.picker-empty { padding: .6rem .7rem; color: var(--muted); font-size: 13px; }
.totals { margin-left: auto; max-width: 340px; }
.totals .row { display: flex; justify-content: space-between; padding: .3rem 0; }
.totals .row.grand { font-size: 1.1rem; font-weight: 700; border-top: 1px solid var(--border); padding-top: .6rem; margin-top: .3rem; }

/* progress / meters */
.meter { height: 6px; background: var(--gray-bg); border-radius: 99px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }

/* modal */
dialog.modal { border: 0; border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 2rem)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog.modal::backdrop { background: rgba(0,0,0,.45); }

/* toast */
.toast-stack { position: fixed; right: 1rem; top: 1rem; z-index: 100; display: grid; gap: .5rem; }
.toast { background: var(--text); color: var(--surface); padding: .7rem 1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-weight: 500; animation: toastIn .25s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- Auth & marketing ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: radial-gradient(1200px 600px at -10% -10%, #6366f1 0%, transparent 60%), radial-gradient(900px 500px at 120% 120%, #06b6d4 0%, transparent 55%), #1e1b4b; color: #e0e7ff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h2 { color: #fff; font-size: 2rem; letter-spacing: -.02em; max-width: 440px; }
.auth-side ul { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .8rem; }
.auth-side li { display: flex; gap: .6rem; align-items: center; }
.auth-main { display: grid; place-items: center; padding: 2rem 1.25rem; background: var(--surface); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .logo { height: 38px; margin-bottom: 1.5rem; }
@media (max-width: 900px) { .auth { grid-template-columns: minmax(0, 1fr); } .auth-side { display: none; } }
.auth-main, .auth-card { min-width: 0; }
.hero p.small { font-size: 13px; margin: .75rem auto 0; }
html, body { max-width: 100%; overflow-x: hidden; }

.landing-nav { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.5rem; max-width: 1200px; margin: 0 auto; }
.hero { text-align: center; padding: 4.5rem 1.25rem 3rem; max-width: 900px; margin: 0 auto; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.4rem); letter-spacing: -.035em; line-height: 1.08; }
.hero h1 .grad { background: linear-gradient(90deg, var(--brand), #7c3aed, var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { font-size: 1.15rem; color: var(--text-2); max-width: 640px; margin: 1rem auto 1.75rem; }
.features { max-width: 1200px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.feature .stat-ico { margin-bottom: .75rem; }
.price-card { max-width: 420px; margin: 0 auto; text-align: center; padding: 2rem; }
.price { font-size: 3rem; font-weight: 800; letter-spacing: -.03em; }
.footer { text-align: center; color: var(--muted); padding: 2rem 1rem; border-top: 1px solid var(--border); }

/* AI import */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 2.5rem 1rem; text-align: center; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-50); }
.ai-glow { position: relative; }
.ai-glow::before { content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; background: linear-gradient(90deg, var(--brand), #7c3aed, var(--accent)); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

@media print {
  .sidebar, .topbar, .bottom-nav, .no-print, .toolbar, .pagination { display: none !important; }
  .main { margin: 0; } .content { padding: 0; } .card { border: 0; box-shadow: none; }
  body { background: #fff; color: #000; }
}

/* charts: single-series bars (validated: #4f46e5 light, #6366f1 dark) */
:root { --chart-1: #4f46e5; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --chart-1: #6366f1; } }
:root[data-theme="dark"] { --chart-1: #6366f1; }
.chart svg { display: block; overflow: visible; }
.chart-bar { fill: var(--chart-1); }
.chart-hit:hover .chart-bar { filter: brightness(1.15); }
.chart-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 4; vector-effect: non-scaling-stroke; }
.chart-axis { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.tip { position: fixed; z-index: 120; pointer-events: none; background: var(--text); color: var(--surface); font-size: 12px; font-weight: 600; padding: .35rem .6rem; border-radius: 6px; box-shadow: var(--shadow-lg); transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap; }

/* analytics */
a.link-card { color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
a.link-card:hover { border-color: var(--brand); box-shadow: var(--shadow-lg); text-decoration: none; }
.stat .value.small-value { font-size: 1.05rem; }
.seg-filters { display: flex; flex-wrap: wrap; gap: .5rem; padding: .9rem 1.25rem; border-bottom: 1px solid var(--border); }
.seg-filters a { display: flex; flex-direction: column; gap: .1rem; min-width: 130px; padding: .55rem .8rem; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); text-decoration: none; background: var(--surface); }
.seg-filters a:hover { border-color: var(--brand); text-decoration: none; }
.seg-filters a.active { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: var(--brand-50); }
.seg-filters .seg-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.seg-filters .seg-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.seg-filters .seg-sub { font-size: 12px; color: var(--muted); }
.cls { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; font-weight: 700; font-size: 13px; }
.cls-A, .cls-F { background: var(--blue-bg); color: var(--blue); }
.cls-B, .cls-S { background: var(--amber-bg); color: var(--amber); }
.cls-C, .cls-N { background: var(--gray-bg); color: var(--text-2); }
.meter.meter-inline { width: 90px; display: inline-block; vertical-align: middle; margin-left: .4rem; }

/* ---------- Support tickets ---------- */
.topbar-support { position: relative; display: inline-flex; align-items: center; gap: .4rem; height: 38px; padding: 0 .75rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 600; font-size: 13.5px; text-decoration: none; white-space: nowrap; }
.topbar-support:hover { background: var(--surface-2); color: var(--text); }
.topbar-support.active { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 45%, transparent); background: var(--brand-50); }
.topbar-support .count { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
@media (max-width: 640px) { .topbar-support { width: 38px; padding: 0; justify-content: center; } .topbar-support .label { display: none; } }
.nav-link .tag.tag-alert { background: var(--red); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-right: .45rem; vertical-align: 1px; }
.ico-xs { width: 13px; height: 13px; vertical-align: -2px; }

.support-layout { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
.support-layout.has-side { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
@media (max-width: 1024px) { .support-layout.has-side { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) { .msg-head { flex-wrap: wrap; } .msg-head time { width: 100%; padding-left: calc(30px + .6rem); } .msg { padding: .8rem .9rem; } }

.thread { display: flex; flex-direction: column; gap: .75rem; }
.msg { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1.1rem; }
.msg-staff { border-left: 3px solid var(--brand); background: color-mix(in srgb, var(--brand) 4%, var(--surface)); }
.msg-internal { background: var(--amber-bg); border: 1px dashed color-mix(in srgb, var(--amber) 50%, transparent); }
.msg-head { display: flex; gap: .6rem; align-items: center; margin-bottom: .55rem; }
.msg-head .avatar { width: 30px; height: 30px; font-size: 12px; flex: none; }
.msg-head .grow { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .45rem; min-width: 0; }
.msg-body { line-height: 1.6; color: var(--text); overflow-wrap: anywhere; }
.msg-files { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.msg-thumb img { display: block; max-width: 180px; max-height: 130px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.msg-file { display: inline-flex; gap: .5rem; align-items: center; max-width: 260px; padding: .5rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font-size: 13px; text-decoration: none; overflow-wrap: anywhere; }
.thread-event { text-align: center; font-size: 12px; color: var(--muted); }
.thread-event span { display: inline-block; padding: 2px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); }

.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.seg label { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .75rem; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 1px; }
.reply-box.is-internal { border-color: color-mix(in srgb, var(--amber) 55%, transparent); }
.reply-box.is-internal textarea { background: var(--amber-bg); }
