/* ===========================================================================
   MultichannelTheme — multi-channel e-commerce admin dashboard theme
   One CSS file, no build step. Kept deliberately plain so you can drop the
   files on a server and they just run.

   Every colour lives in a custom property: edit the :root block alone and the
   whole theme takes on your brand.

   The dark blocks below read from --d-* first and fall back to the defaults.
   That is what lets assets/palettes.css swap the whole palette — light and
   dark — from a single rule per palette. Delete palettes.css and this file
   still works on its own.
   =========================================================================== */

:root {
  /* --- brand colours: this is the block you edit --- */
  --brand:        #4F46E5;
  --brand-ink:    #FFFFFF;
  --brand-soft:   #EEF2FF;

  /* --- status colours --- */
  --ok:      #059669;  --ok-soft:   #ECFDF5;
  --warn:    #D97706;  --warn-soft: #FFFBEB;
  --bad:     #DC2626;  --bad-soft:  #FEF2F2;
  --info:    #0284C7;  --info-soft: #F0F9FF;

  /* --- surfaces --- */
  --bg:      #F6F7F9;
  --panel:   #FFFFFF;
  --ink:     #0F172A;
  --muted:   #64748B;
  --line:    #E2E8F0;
  --line-2:  #CBD5E1;

  --radius:  12px;
  --radius-s: 8px;
  --shadow:  0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
  --shadow-s: 0 1px 2px rgba(15,23,42,.06);

  --sidebar: 244px;
  --topbar:  60px;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* Dark theme. Follows the system; an explicit data-theme choice wins. */
/* The doubled :root is deliberate. A palette rule in palettes.css is
   :root[data-palette="…"], which has the same specificity as a plain
   :root[data-theme="dark"] — and because palettes.css loads afterwards its
   light values would win in dark mode. Repeating :root outranks it, so these
   blocks stay in charge no matter which file loads first. */
@media (prefers-color-scheme: dark) {
  :root:root:not([data-theme="light"]) {
    --brand:      var(--d-brand,      #6366F1);
    --brand-ink:  var(--d-brand-ink,  #FFFFFF);
    --brand-soft: var(--d-brand-soft, #1E1B4B);
    --ok-soft: #052E24; --warn-soft: #2A1C05; --bad-soft: #2C0F0F; --info-soft: #082F49;
    --bg:     var(--d-bg,     #0B1120);
    --panel:  var(--d-panel,  #111827);
    --ink:    var(--d-ink,    #E6EAF2);
    --muted:  var(--d-muted,  #94A3B8);
    --line:   var(--d-line,   #1F2937);
    --line-2: var(--d-line-2, #334155);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    --shadow-s: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root:root[data-theme="dark"] {
  --brand:      var(--d-brand,      #6366F1);
  --brand-ink:  var(--d-brand-ink,  #FFFFFF);
  --brand-soft: var(--d-brand-soft, #1E1B4B);
  --ok-soft: #052E24; --warn-soft: #2A1C05; --bad-soft: #2C0F0F; --info-soft: #082F49;
  --bg:     var(--d-bg,     #0B1120);
  --panel:  var(--d-panel,  #111827);
  --ink:    var(--d-ink,    #E6EAF2);
  --muted:  var(--d-muted,  #94A3B8);
  --line:   var(--d-line,   #1F2937);
  --line-2: var(--d-line-2, #334155);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --shadow-s: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

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

/* ============================================================ layout */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px; height: var(--topbar);
  border-bottom: 1px solid var(--line);
  font-weight: 700; letter-spacing: -.02em; font-size: 15.5px;
  flex: none;
}
.brand .logo {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
}

.nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.nav-label {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 14px 10px 6px;
}
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--radius-s);
  color: var(--muted); font-weight: 500;
  transition: background .12s, color .12s;
}
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav .count {
  margin-left: auto; font-size: 11.5px; font-weight: 700;
  background: var(--line); color: var(--muted);
  padding: 1px 7px; border-radius: 999px;
}
.nav a.on .count { background: var(--brand); color: var(--brand-ink); }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); flex: none; }

/* ============================================================ top bar */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar); flex: none;
  background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 20px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 16.5px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.topbar .spacer { flex: 1; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px; min-width: 240px;
}
.search svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.search input {
  border: 0; background: none; outline: none; font: inherit; color: var(--ink);
  width: 100%;
}
.search input::placeholder { color: var(--muted); }

.icobtn {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--panel);
  border-radius: var(--radius-s); color: var(--muted); cursor: pointer;
  transition: background .12s, color .12s;
}
.icobtn:hover { background: var(--bg); color: var(--ink); }
.icobtn svg { width: 17px; height: 17px; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}

.page { padding: 22px; overflow-x: hidden; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { margin: 0 0 4px; font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--muted); font-size: 13.5px; }
.page-head .spacer { flex: 1; }

/* ============================================================ components */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-s);
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 700; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }

.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-21 { grid-template-columns: 2fr 1fr; }

/* --- stat cards --- */
.stat { padding: 16px 18px; }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 25px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 2px;
  font-variant-numeric: tabular-nums; }
.stat .d { font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.stat .d.up { color: var(--ok); }
.stat .d.down { color: var(--bad); }
.stat .d svg { width: 13px; height: 13px; }

/* --- badges --- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .01em;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-ok   { background: var(--ok-soft);   color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-bad  { background: var(--bad-soft);  color: var(--bad); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-mut  { background: var(--bg);        color: var(--muted); }

/* --- channel tag --- */
.chan {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.chan i {
  width: 18px; height: 18px; border-radius: 5px; flex: none;
  display: grid; place-items: center; font-style: normal;
  font-size: 9.5px; font-weight: 800; color: #fff;
}
.chan.amazon  i { background: #FF9900; color: #201A15; }
.chan.aliexp  i { background: #E62E04; }
.chan.trendy  i { background: #F27A1A; }
.chan.ozon    i { background: #005BFF; }
.chan.site    i { background: var(--brand); }

/* --- tables --- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; font-size: 11.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--bg); }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tbl a.ref { font-weight: 600; color: var(--brand); }

/* --- buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 600; font-size: 13.5px;
  padding: 8px 15px; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .1s;
}
.btn:hover { background: var(--bg); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--brand); border-color: transparent; color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand); filter: brightness(1.08); }
.btn-danger { color: var(--bad); border-color: var(--line); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* --- forms --- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.input, select.input, textarea.input {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line-2);
  border-radius: var(--radius-s); padding: 9px 12px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea.input { min-height: 96px; resize: vertical; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* --- progress bar --- */
.bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.bar.ok > i   { background: var(--ok); }
.bar.warn > i { background: var(--warn); }
.bar.bad > i  { background: var(--bad); }

/* --- empty state --- */
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; opacity: .4; margin-bottom: 12px; }
.empty h4 { margin: 0 0 6px; color: var(--ink); font-size: 15px; }
.empty p { margin: 0 auto 16px; max-width: 340px; font-size: 13.5px; }

/* ============================================================ responsive */
@media (max-width: 1100px) {
  .g-4 { grid-template-columns: repeat(2, 1fr); }
  .g-21, .g-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar);
    z-index: 60; transform: translateX(-100%); transition: transform .22s;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .menu-toggle { display: grid !important; }
  .scrim {
    position: fixed; inset: 0; background: rgba(15,23,42,.45);
    opacity: 0; pointer-events: none; transition: opacity .22s; z-index: 50;
  }
  .scrim.on { opacity: 1; pointer-events: auto; }
  .search { min-width: 0; }
}
@media (max-width: 620px) {
  .g-4, .g-2 { grid-template-columns: 1fr; }
  .page { padding: 16px; }
  .search { display: none; }
  .row-2 { grid-template-columns: 1fr; }

  /* Keep the top bar inside a narrow viewport: tighter gaps, the page title
     truncates, the bell is dropped. Menu, theme and language stay. */
  .topbar { gap: 8px; padding: 0 14px; }
  .topbar h1 {
    min-width: 0; flex: 0 1 auto; font-size: 15px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .topbar select { max-width: 84px; }
  .topbar [aria-label="Notifications"] { display: none; }
}
.menu-toggle { display: none; }
