/* ---------- Fonts ---------- */
@font-face { font-family: "Vazirmatn"; font-weight: 400; font-display: swap; src: url("../fonts/Vazirmatn-Regular.woff2") format("woff2"); }
@font-face { font-family: "Vazirmatn"; font-weight: 500; font-display: swap; src: url("../fonts/Vazirmatn-Medium.woff2") format("woff2"); }
@font-face { font-family: "Vazirmatn"; font-weight: 600; font-display: swap; src: url("../fonts/Vazirmatn-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Vazirmatn"; font-weight: 700; font-display: swap; src: url("../fonts/Vazirmatn-Bold.woff2") format("woff2"); }

/* ---------- Design tokens ---------- */
:root {
  --bg: #ffffff;
  --surface: #f5f7fa;
  --surface-2: #e3e8ef;
  --border: #c9d2de;
  --border-soft: #e3e8ef;
  --text: #17315c;
  --text-muted: #5b6b85;
  --primary: #1e6fd9;
  --primary-hover: #1457b8;
  --primary-soft: #e6f0fc;
  --success: #15803d; --success-soft: #dcfce7;
  --warning: #b45309; --warning-soft: #fef3c7;
  --danger: #b91c1c;  --danger-soft: #fee2e2;
  --info: #0e7490;    --info-soft: #cffafe;
  --shadow: 0 1px 2px rgba(23, 49, 92, .06), 0 4px 16px rgba(23, 49, 92, .06);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 250px;
  --topbar-h: 60px;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --border: #334155;
  --border-soft: #273449;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --primary: #4f9bff;
  --primary-hover: #7ab4ff;
  --primary-soft: #1a2f4f;
  --success: #4ade80; --success-soft: #14321f;
  --warning: #fbbf24; --warning-soft: #3a2a08;
  --danger: #f87171;  --danger-soft: #3f1515;
  --info: #22d3ee;    --info-soft: #0b2a30;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.3);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Vazirmatn", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  font-size: 14px; line-height: 1.7;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.4; }
img { max-width: 100%; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Boot splash ---------- */
.boot { height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; color: var(--text-muted); }
.boot-icon { width: 64px; height: 64px; }
.boot-bar { width: 180px; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.boot-bar-fill { height: 100%; width: 40%; background: var(--primary); border-radius: 99px; animation: boot 1.2s ease-in-out infinite; }
@keyframes boot { 0% { transform: translateX(120%); } 100% { transform: translateX(-260%); } }
#blazor-error-ui { display: none; position: fixed; bottom: 0; right: 0; left: 0; padding: 12px 20px; background: var(--danger-soft); color: var(--danger); border-top: 1px solid var(--danger); z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; left: 16px; top: 10px; }
#blazor-error-ui .reload { margin-inline-start: 12px; }

/* ---------- Shell / layout ---------- */
.shell { min-height: 100vh; }
.topbar {
  position: fixed; top: 0; right: 0; left: 0; height: var(--topbar-h); z-index: 40;
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
  background: var(--bg); border-bottom: 1px solid var(--border-soft);
}
.topbar-spacer { flex: 1; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand-logo { height: 36px; width: auto; }
/* One logo per theme. !important so later display rules (.auth-logo, .brand-logo) can not re-show the hidden one. */
html:not([data-theme="dark"]) .logo-dark { display: none !important; }
html[data-theme="dark"] .logo-light { display: none !important; }
.brand-sub { font-size: 12px; color: var(--text-muted); border-inline-start: 1px solid var(--border); padding-inline-start: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 99px; background: var(--surface); }
.user-name { font-weight: 600; font-size: 13px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text);
}
.icon-btn:hover { background: var(--surface); border-color: var(--border-soft); }
.menu-toggle { display: none; }

.sidebar {
  position: fixed; top: var(--topbar-h); right: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--surface); border-inline-start: 1px solid var(--border-soft);
  overflow-y: auto; padding: 14px 10px; z-index: 30;
}
.content { margin-right: var(--sidebar-w); padding: calc(var(--topbar-h) + 20px) 24px 40px; min-height: 100vh; }
.backdrop { display: none; }

.nav { display: flex; flex-direction: column; gap: 2px; min-height: 100%; }
.nav-section { font-size: 11px; font-weight: 600; color: var(--text-muted); padding: 12px 12px 4px; letter-spacing: .02em; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  color: var(--text); font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link.subtle { color: var(--text-muted); font-weight: 400; }
.nav-icon { width: 20px; text-align: center; opacity: .8; }
.nav-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border-soft); }

@media (max-width: 899px) {
  .menu-toggle { display: inline-flex; }
  .brand-sub, .user-name { display: none; }
  .sidebar {
    top: var(--topbar-h); right: 0; left: 0; bottom: auto; width: auto; max-height: calc(100vh - var(--topbar-h));
    transform: translateY(-110%); transition: transform .2s ease; box-shadow: var(--shadow);
    border-bottom: 1px solid var(--border);
  }
  .menu-open .sidebar { transform: translateY(0); }
  .menu-open .backdrop { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0,0,0,.35); z-index: 25; }
  .content { margin-right: 0; padding: calc(var(--topbar-h) + 14px) 14px 32px; }
  .nav { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; }
  .nav-section { grid-column: 1 / -1; }
  .nav-footer { grid-column: 1 / -1; }
}

/* ---------- Auth shell ---------- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--surface); position: relative; }
.auth-theme { position: absolute; top: 14px; left: 14px; }
.auth-card { width: 100%; max-width: 420px; background: var(--bg); border: 1px solid var(--border-soft); border-radius: 16px; box-shadow: var(--shadow); padding: 28px; }
.auth-logo { display: block; height: 56px; width: auto; max-width: 100%; margin: 0 auto 18px; }
.auth-title { text-align: center; font-size: 18px; margin-bottom: 4px; }
.auth-sub { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }
.otp-input { text-align: center; letter-spacing: .5em; font-size: 24px; font-weight: 600; direction: ltr; }
.auth-meta { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-muted); margin-top: 10px; }

/* ---------- Page ---------- */
.page { max-width: 1280px; margin: 0 auto; }
.page-center { min-height: 60vh; display: flex; align-items: center; justify-content: center; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 20px; outline: none; }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-soft { background: var(--surface); box-shadow: none; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 899px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; direction: ltr; unicode-bidi: embed; }
.ltr { direction: ltr; unicode-bidi: embed; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.divider { height: 1px; background: var(--border-soft); margin: 16px 0; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; border-inline-start: 4px solid var(--border); }
.stat-card.tone-primary { border-inline-start-color: var(--primary); }
.stat-card.tone-success { border-inline-start-color: var(--success); }
.stat-card.tone-warning { border-inline-start-color: var(--warning); }
.stat-card.tone-danger { border-inline-start-color: var(--danger); }
.stat-card.tone-info { border-inline-start-color: var(--info); }
.stat-label { font-size: 12px; color: var(--text-muted); }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat-hint { font-size: 12px; color: var(--text-muted); }
.stat-link { font-size: 12px; position: absolute; left: 14px; top: 14px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 899px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 600; }
.field .help { font-size: 12px; color: var(--text-muted); }
.req::after { content: " *"; color: var(--danger); }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input:disabled { background: var(--surface); color: var(--text-muted); }
.input.lg { font-size: 20px; padding: 14px 16px; }
textarea.input { resize: vertical; min-height: 90px; }
select.input { appearance: auto; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.input-error { border-color: var(--danger) !important; }
.error-text { color: var(--danger); font-size: 12px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; justify-content: flex-start; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 13px; line-height: 1.4; white-space: nowrap;
  background: var(--surface-2); color: var(--text); transition: background .15s, color .15s;
}
.btn:hover { background: var(--border); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface); }
.btn-outline { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: var(--primary); padding: 0; font-weight: 500; }
.btn-link:disabled { color: var(--text-muted); }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { min-width: 160px; flex: 1 1 160px; }
.filters .field.grow { flex: 2 1 240px; }
.filters .btn { height: 40px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-soft); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 8px 14px; border: none; background: none; color: var(--text-muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--bg); box-shadow: var(--shadow); }
table.table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table th, .table td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table th { background: var(--surface); font-size: 12px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.table tbody tr:hover { background: var(--surface); }
.table tbody tr:last-child td { border-bottom: none; }
.table td.actions { white-space: nowrap; }
.table td.actions .btn { margin-inline-end: 4px; }
.table .thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.table .nowrap { white-space: nowrap; }
.table .num { font-variant-numeric: tabular-nums; }
.table-footer { padding: 10px 12px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--text); }
.badge-sm { padding: 1px 8px; font-size: 11px; }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-neutral { background: var(--surface-2); color: var(--text-muted); }

/* ---------- Paginator ---------- */
.paginator { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 4px 0; }
.paginator-info { font-size: 12px; color: var(--text-muted); }
.paginator-pages { display: flex; gap: 4px; }
.pg-btn { min-width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border-soft); background: var(--bg); color: var(--text); font-size: 13px; }
.pg-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pg-btn:disabled { opacity: .4; cursor: default; }
.pg-gap { padding: 0 4px; color: var(--text-muted); line-height: 32px; }

/* ---------- Loading / empty ---------- */
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 32px; color: var(--text-muted); }
.loading.inline { padding: 0; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--surface-2); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 40px 16px; color: var(--text-muted); }
.empty-icon { font-size: 36px; opacity: .5; }
.empty-title { font-weight: 700; color: var(--text); margin-top: 6px; }
.empty-text { font-size: 13px; margin-top: 4px; }
.empty-actions { margin-top: 16px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid transparent; font-size: 13px; }
.alert-info { background: var(--info-soft); color: var(--info); border-color: var(--info); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning); }
.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); border-color: var(--success); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 16px; left: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); cursor: pointer; animation: toast-in .2s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast-icon { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; color: #fff; }
.toast-success .toast-icon { background: var(--success); }
.toast-error .toast-icon { background: var(--danger); }
.toast-warning .toast-icon { background: var(--warning); }
.toast-info .toast-icon { background: var(--info); }
.toast-text { font-size: 13px; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100; }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100vw - 32px)); background: var(--bg); border-radius: 14px; border: 1px solid var(--border-soft); box-shadow: var(--shadow); padding: 22px; z-index: 101; }
.modal-title { font-weight: 700; font-size: 16px; margin-bottom: 8px; }
.modal-text { color: var(--text-muted); font-size: 13px; margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal-lg { width: min(720px, calc(100vw - 32px)); max-height: 90vh; overflow-y: auto; }

/* ---------- Uploader / tags ---------- */
.uploader { display: flex; flex-direction: column; gap: 10px; }
.uploader-drop { display: flex; align-items: center; justify-content: center; min-height: 80px; border: 2px dashed var(--border); border-radius: var(--radius); padding: 14px; cursor: pointer; color: var(--text-muted); background: var(--surface); position: relative; }
.uploader-drop:hover { border-color: var(--primary); }
.uploader-drop input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.uploader-drop.busy { pointer-events: none; }
.uploader-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.uploader-item { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--border-soft); background: var(--surface); }
.uploader-item img { width: 100%; height: 100%; object-fit: cover; }
.uploader-remove { position: absolute; top: 6px; left: 6px; width: 26px; height: 26px; border-radius: 50%; border: none; background: rgba(0,0,0,.6); color: #fff; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
.tags:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); font-size: 12px; }
.tag-x { border: none; background: none; color: inherit; font-size: 11px; padding: 0; }
.tag-input { flex: 1; min-width: 140px; border: none; outline: none; background: transparent; padding: 4px; }

/* ---------- Spec rows / key-value ---------- */
.kv { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
.kv + .kv { margin-top: 8px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.dl dt { color: var(--text-muted); }
.dl dd { margin: 0; }
@media (max-width: 599px) { .dl { grid-template-columns: 1fr; gap: 2px; } .dl dd { margin-bottom: 8px; } }

/* ---------- Gallery ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.gallery a { display: block; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--border-soft); }
.gallery img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Tree ---------- */
.tree { list-style: none; margin: 0; padding: 0; }
.tree ul { list-style: none; margin: 0; padding-inline-start: 22px; border-inline-start: 1px dashed var(--border); margin-inline-start: 10px; }
.tree-node { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; flex-wrap: wrap; }
.tree-node:hover { background: var(--surface); }
.tree-name { font-weight: 600; }
.tree-meta { color: var(--text-muted); font-size: 12px; }
.tree-actions { margin-inline-start: auto; display: flex; gap: 4px; }
.tree-form { padding: 8px; margin: 4px 0 8px; background: var(--surface); border-radius: 10px; }
.tree-img { width: 28px; height: 28px; object-fit: cover; border-radius: 6px; }

/* ---------- Misc ---------- */
.avatar { width: 72px; height: 72px; border-radius: 16px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--border-soft); }
.code-big { font-size: 28px; font-weight: 700; letter-spacing: .08em; direction: ltr; text-align: center; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--border-soft); display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.list li:last-child { border-bottom: none; }
.banner-thumb { width: 120px; height: 56px; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form .input { width: 110px; }

/* ---------- Phase 2: charts ---------- */
.chart { width: 100%; display: block; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-title { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.chart-grid { stroke: var(--border-soft); stroke-width: 1; }
.chart-axis { fill: var(--text-muted); font-size: 10px; font-family: inherit; }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: var(--primary); opacity: .12; }
.chart-dot { fill: var(--bg); stroke: var(--primary); stroke-width: 2; }
.chart-dot:hover { fill: var(--primary); }
.chart-bar { fill: var(--primary); opacity: .85; }
.chart-bar:hover { opacity: 1; }
.chart-empty { padding: 32px; text-align: center; color: var(--text-muted); font-size: 13px; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--primary); margin-inline-end: 4px; vertical-align: middle; }

/* ---------- Phase 2: segmented tabs (login) & switch ---------- */
.seg { display: flex; background: var(--surface); border-radius: 10px; padding: 4px; gap: 4px; margin-bottom: 18px; }
.seg button { flex: 1; border: none; background: transparent; padding: 8px 10px; border-radius: 8px; font-weight: 600; color: var(--text-muted); }
.seg button.active { background: var(--bg); color: var(--primary); box-shadow: var(--shadow); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 99px; background: var(--surface-2); position: relative; transition: background .15s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 3px; right: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + .track { background: var(--success); }
.switch input:checked + .track::after { transform: translateX(-16px); }
.switch input:disabled + .track { opacity: .5; }

/* ---------- Phase 2: drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(560px, 100vw); background: var(--bg); border-inline-end: 1px solid var(--border-soft); box-shadow: var(--shadow); z-index: 101; overflow-y: auto; padding: 20px; animation: drawer-in .2s ease; }
@keyframes drawer-in { from { transform: translateX(-30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.drawer-title { font-weight: 700; font-size: 16px; }

/* ---------- Phase 2: diff view (vendor pending changes) ---------- */
.diff { display: grid; grid-template-columns: max-content 1fr 1fr; gap: 0; border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; font-size: 13px; }
.diff > div { padding: 8px 12px; border-bottom: 1px solid var(--border-soft); }
.diff > div:nth-last-child(-n+3) { border-bottom: none; }
.diff .diff-head { background: var(--surface); font-weight: 600; color: var(--text-muted); font-size: 12px; }
.diff .diff-key { color: var(--text-muted); background: var(--surface); }
.diff .diff-old { color: var(--text-muted); }
.diff .diff-new { font-weight: 600; }
.diff .changed.diff-old { background: var(--danger-soft); text-decoration: line-through; }
.diff .changed.diff-new { background: var(--success-soft); color: var(--success); }
@media (max-width: 599px) { .diff { grid-template-columns: 1fr; } .diff .diff-head { display: none; } .diff .diff-key { font-weight: 600; } }

/* ---------- Phase 2: tickets ---------- */
.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 82%; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border-soft); align-self: flex-start; }
.msg.staff { align-self: flex-end; background: var(--primary-soft); border-color: transparent; }
.msg-head { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; flex-wrap: wrap; }
.msg-head strong { color: var(--text); }
.msg-body { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; }
.msg-files { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.msg-files a { display: block; width: 72px; height: 72px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border-soft); }
.msg-files img { width: 100%; height: 100%; object-fit: cover; }
.composer { border-top: 1px solid var(--border-soft); padding-top: 14px; margin-top: 16px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border-soft); font-size: 13px; cursor: pointer; }
.chip.active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.chip b { font-weight: 700; }

/* ---------- Phase 2: search pickers ---------- */
.picker { position: relative; }
.picker-menu { position: absolute; top: 100%; right: 0; left: 0; z-index: 50; margin-top: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; }
.picker-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.picker-item:last-child { border-bottom: none; }
.picker-item:hover { background: var(--surface); }
.picker-item img { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.picker-item .muted { margin-inline-start: auto; }
.picker-selected { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: 13px; }
.picker-selected .tag-x { margin-inline-start: auto; }

/* ---------- Phase 2: marketplace ---------- */
.channels { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 20px; }
.channel { background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.channel.disabled { opacity: .75; }
.channel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.channel-name { font-weight: 700; font-size: 15px; }
.channel-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }
.channel-meta b { color: var(--text); }
.inline-edit { display: inline-flex; gap: 4px; align-items: center; }
.inline-edit .input { width: 110px; padding: 4px 8px; }
.err-inline { color: var(--danger); font-size: 12px; max-width: 260px; white-space: normal; }

/* ---------- Phase 2: discount codes ---------- */
.codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; max-height: 260px; overflow-y: auto; padding: 8px; background: var(--surface); border-radius: var(--radius-sm); }
.codes span { font-family: ui-monospace, Consolas, monospace; direction: ltr; font-size: 12px; padding: 4px 8px; background: var(--bg); border: 1px solid var(--border-soft); border-radius: 6px; text-align: center; }
.code-pill { font-family: ui-monospace, Consolas, monospace; direction: ltr; unicode-bidi: embed; font-weight: 700; letter-spacing: .04em; background: var(--surface); padding: 2px 8px; border-radius: 6px; border: 1px dashed var(--border); }

/* ---------- Phase 2: misc ---------- */
.row-click { cursor: pointer; }
.hint-box { background: var(--surface); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 12.5px; color: var(--text-muted); line-height: 1.8; }
.hint-box code { font-family: ui-monospace, Consolas, monospace; direction: ltr; unicode-bidi: embed; background: var(--bg); padding: 0 4px; border-radius: 4px; border: 1px solid var(--border-soft); }
.nav-icon svg { width: 18px; height: 18px; display: block; }
.text-warning { color: var(--warning); }
.table td.wrap-col { white-space: normal; min-width: 180px; }
.price-stack { display: flex; flex-direction: column; line-height: 1.4; }
.price-stack s { color: var(--text-muted); font-size: 11px; }
