:root{
  --bg:#f6f8fc;
  --bg-2:#eef1f7;
  --card:#ffffff;
  --card-2:#f6f8fb;
  --text:#0f172a;
  --muted:#64748b;
  --line:rgba(15,23,42,.10);

  --green:#16a34a;
  --yellow:#f59e0b;
  --red:#ef4444;
  --blue:#2563eb;

  --shadow: 0 12px 30px rgba(15,23,42,.08);
  --radius: 18px;

  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji","Segoe UI Emoji";

  --rowh: 40px;
  --cellh: 40px;

  /* ✅ если есть фикс-шапка сайта — укажи её высоту */
  --dash-sticky-top: 0px;

  /* ✅ высота липкой панели (card-header + filters). Без JS задаём руками */
  --dash-sticky-offset: 0px;
}

/* Light theme (explicit) */
html[data-theme="light"]{
  --bg:#f7f7fb;
  --bg-2:#eef1f7;
  --card:#ffffff;
  --card-2:#f6f8fb;
  --text:#0f172a;
  --muted:#4b5563;
  --line:rgba(15,23,42,.08);

  --green:#0ea5e9;
  --yellow:#f59e0b;
  --red:#ef4444;
  --blue:#2563eb;

  --shadow: 0 18px 32px rgba(15,23,42,.10);
}

/* Dark theme */
html[data-theme="dark"]{
  --bg:#0f1117;
  --bg-2:#131825;
  --card:#171c2a;
  --card-2:#1f2638;
  --text:#eef2ff;
  --muted:#9aa4bf;
  --line:rgba(255,255,255,.06);

  --green:#2dd4bf;
  --yellow:#fbbf24;
  --red:#f97316;
  --blue:#38bdf8;

  --shadow: 0 20px 40px rgba(0,0,0,.35);
}

*{box-sizing:border-box}
html, body{height:100%}

body{
  margin:0;
  font-family: var(--font);
  background:
    radial-gradient(900px 480px at 15% 0%, rgba(37,99,235,.12), transparent 60%),
    radial-gradient(900px 480px at 85% 0%, rgba(22,163,74,.10), transparent 60%),
    var(--bg);
  color:var(--text);
}
html[data-theme="dark"] body{
  background:
    radial-gradient(900px 480px at 15% 0%, rgba(56,189,248,.20), transparent 60%),
    radial-gradient(900px 480px at 85% 0%, rgba(45,212,191,.18), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}
html[data-theme="light"] body{
  background:
    radial-gradient(900px 480px at 15% 0%, rgba(37,99,235,.10), transparent 60%),
    radial-gradient(900px 480px at 85% 0%, rgba(14,165,233,.08), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

a{color:inherit; text-decoration:none}
a:hover{opacity:.92}

.page{ min-height: 100%; padding: 0 18px; }
.container{
  max-width: 1800px;
  margin: 0 auto;
  padding: 28px 0 64px;
}

/* Header */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  margin-bottom:18px;
  padding-top: 14px;
}
.brand{display:flex; align-items:center; gap:12px;}
.logo{
  width:46px;height:46px;border-radius:16px;
  background: linear-gradient(135deg, rgba(37,99,235,1), rgba(22,163,74,1));
  box-shadow: var(--shadow);
}
.brand h1{ font-size:20px; line-height:1.2; margin:0; letter-spacing:-.02em; }
.brand p{ margin:4px 0 0; color:var(--muted); font-size:13px; }
.nav{ display:flex; align-items:center; gap:12px; margin-left:auto; margin-right:12px; }
.nav-link{
  color: var(--muted);
  font-size:13px;
  text-transform:uppercase;
  letter-spacing:.06em;
  padding:8px 10px;
  border-radius: 10px;
  border:1px solid transparent;
}
.nav-link:hover{
  color: var(--text);
  background: rgba(15,23,42,.04);
  border-color: var(--line);
}
.userbar{ display:flex; align-items:center; gap:10px; color:var(--muted); font-size:14px; }
.user-pill{
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--line);
  background: var(--card-2);
}

/* Card */
.card{
  background: var(--card);
  border:1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: visible; /* ✅ важно для sticky */
}
.card-soft{ background: var(--card-2); }

/* ==== STICKY PANEL (header + filters) ==== */
.dash-sticky{
  position: sticky;
  top: var(--dash-sticky-top);
  z-index: 60;
  background: var(--card);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  box-shadow:none;
  border-bottom:none;
}

/* Card header inside sticky */
.card-header{
  padding:18px 18px 14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.card-header h2{ margin:0; font-size:18px; letter-spacing:-.02em; }
.card-header .sub{ margin:6px 0 0; color:var(--muted); font-size:13px; }

.bulkbar{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Buttons */
.btn{
  border:none;
  border-radius: 14px;
  padding:12px 16px;
  cursor:pointer;
  font-weight:700;
  font-size:14px;
  background: rgba(15,23,42,.06);
  color: var(--text);
}
.btn:hover{opacity:.95}
.btn:active{opacity:1}

.btn-primary{
  background: linear-gradient(135deg, rgba(37,99,235,1), rgba(37,99,235,.85));
  color:#fff;
  box-shadow: 0 10px 22px rgba(37,99,235,.20);
}
.btn-ghost{
  background: #fff;
  color: var(--text);
  border:1px solid var(--line);
}
.btn-danger{
  background: rgba(239,68,68,.10);
  color: #991b1b;
  border:1px solid rgba(239,68,68,.25);
}
.btn-success{
  background: rgba(22,163,74,.10);
  color: #14532d;
  border:1px solid rgba(22,163,74,.25);
}

/* icon mini buttons */
.btn-mini{
  padding:6px 8px;
  border-radius:10px;
  font-size:12px;
  line-height:1;
  white-space: nowrap;
}
.btn-sm{
  padding:8px 12px;
  border-radius:10px;
  font-size:12px;
}

/* Filters */
.filters-v3{
  padding: 14px 18px 10px;
  background: rgba(255,255,255,.55);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(15,23,42,.06);
}

.filters-v3 .f3-row{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  align-items:flex-end;
  margin-bottom:10px;
}
.filters-v3 .f3-actions{
  margin-left:auto;
  flex:0 0 auto;
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:flex-end;
  white-space: nowrap;
}
.filters-v3 .f3-search{
  position:relative;
  display:flex;
  align-items:center;
  gap:10px;
  height:44px;
  border:1px solid var(--line);
  background:#fff;
  border-radius: 14px;
  padding: 0 12px;
  flex: 1 1 240px;
  min-width: 240px;
}
.filters-v3 .f3-search:focus-within{
  border-color: rgba(37,99,235,.55);
  box-shadow: 0 0 0 4px rgba(37,99,235,.14);
}
.f3-ico{ color: var(--muted); font-size:16px; line-height:1; user-select:none; }
.f3-input{
  border:none;
  outline:none;
  font-size:14px;
  width:100%;
  background:transparent;
  color: var(--text);
}
.f3-clear{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:26px;
  height:26px;
  border-radius: 10px;
  border:1px solid var(--line);
  color: var(--muted);
  background:#fff;
}
.f3-clear:hover{ background: rgba(15,23,42,.03); }

.f3-field{ display:flex; flex-direction:column; gap:8px; flex: 0 0 200px; min-width: 180px; }
.f3-label{ font-size:12px; color: var(--muted); }

.f3-select{
  height:44px;
  padding: 0 12px;
  border-radius: 14px;
  border:1px solid var(--line);
  background:#fff;
  font-size:14px;
  outline:none;
}
.f3-select:focus{
  border-color: rgba(37,99,235,.55);
  box-shadow: 0 0 0 4px rgba(37,99,235,.14);
}

@media (max-width: 760px){
  .filters-v3 .f3-actions{ justify-content:stretch; width:100%; }
  .filters-v3 .f3-actions .btn{ flex:1; }
  .filters-v3 .f3-search{ min-width: 100%; }
  .filters-v3 .f3-field{ flex:1 1 220px; min-width: 180px; }
}

.f3-chips{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top:10px;
  min-height: 18px;
}
.chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border-radius: 999px;
  border:1px solid var(--line);
  background: rgba(15,23,42,.03);
  font-size:12px;
  color: var(--muted);
}

/* Table wrap */
.table-wrap{
  overflow: visible;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

/* горизонтальный скролл отдельно */
.table-scroll-x{
  overflow-x: auto;
  overflow-y: visible;
}

/* Table */
table.dashboard-table{
  width:100%;
  border-collapse: separate;
  border-spacing:0;
  min-width: 1200px;
}

table.dashboard-table.log-table{
  min-width: 1600px;
}

/* ✅ THEAD sticky: прилипает под dash-sticky */
table.dashboard-table thead th{
  position: sticky;
  top: calc(var(--dash-sticky-top) + var(--dash-sticky-offset));
  z-index: 40; /* ниже dash-sticky (60), выше tbody */
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);

  text-align:left;
  font-size:12px;
  letter-spacing:.01em;
  color:var(--muted);
  padding:10px 10px;
  border-bottom:1px solid var(--line);
  white-space: normal;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

table.dashboard-table tbody td{
  padding: 8px 10px;
  border-bottom:1px solid var(--line);
  font-size:13px;
  vertical-align: middle;
  text-overflow: clip;
  color: var(--text);
}

table.dashboard-table tbody tr:hover{
  background: rgba(37,99,235,.04);
}

/* widths */
th.col-product, td.col-product{ width:300px; min-width:220px; }
th.col-key,     td.col-key    { width:180px; min-width:140px; }

th.col-cpm, td.col-cpm        { width:75px; }
th.col-pos, td.col-pos        { width:85px; }
th.col-req, td.col-req        { width:85px; }
th.col-drrd, td.col-drrd      { width:75px; }
th.col-drrw, td.col-drrw      { width:75px; }
th.col-thrday, td.col-thrday  { width:80px; }
th.col-thrweek, td.col-thrweek{ width:80px; }
th.col-max, td.col-max        { width:70px; }

th.col-status, td.col-status  { width:90px; }
th.actions-col, td.actions-col{ width:180px; }

th.col-an, td.col-an          { width:90px; }

/* alignment */
td.num, th.num{ text-align:center; font-variant-numeric: tabular-nums; }

/* Logs table columns */
.log-table th.col-date, .log-table td.col-date      { width: 10%; }
.log-table th.col-action, .log-table td.col-action  { width: 7%; }
.log-table th.col-camp, .log-table td.col-camp      { width: 16%; }
.log-table th.col-key, .log-table td.col-key        { width: 14%; }
.log-table th.col-result, .log-table td.col-result  { width: 6%; }
.log-table th.col-target, .log-table td.col-target  { width: 6%; }
.log-table th.col-error, .log-table td.col-error    { width: 16%; }
.log-table th.col-info, .log-table td.col-info      { width: 12%; }

td.col-error, td.col-info{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* wrapping */
td.col-product, th.col-product,
td.col-key, th.col-key{
  white-space: normal;
  overflow-wrap: break-word;
}

/* single-line */
td.num, th.num,
td.small, th.small,
td.col-cpm, th.col-cpm,
td.col-pos, th.col-pos,
td.col-req, th.col-req,
td.col-drrd, th.col-drrd,
td.col-drrw, th.col-drrw,
td.col-thrday, th.col-thrday,
td.col-thrweek, th.col-thrweek,
td.col-max, th.col-max,
td.col-an, th.col-an,
td.col-status, th.col-status,
td.actions-col, th.actions-col{
  white-space: nowrap;
}

/* hierarchy */
.group-row td{ background: rgba(15,23,42,.02); font-weight: 800; }
.product-row td{ background: rgba(15,23,42,.02); }

.level{
  display:flex;
  align-items:center;
  gap:10px;
}
.indent-0{ padding-left: 6px; }
.indent-1{ padding-left: 42px; }
.indent-2{ padding-left: 42px; }

.muted{ color: var(--muted); }
.mono{ font-variant-numeric: tabular-nums; }

.prod-img{
  width: 26px;
  height: 26px;
  object-fit: cover;
  border-radius: 8px;
  border:1px solid var(--line);
  flex: 0 0 26px;
  display:block;
}

.prod-title{ min-width: 0; }
.prod-name{ font-size: 12.5px; font-weight:800; line-height:1.15; }
.prod-sub{ font-size:11.5px; margin-top:2px; color: var(--muted); }

td.col-key{ font-size: 12.5px; line-height: 1.25; }

/* leaderboard tooltip on position cell */
td.col-pos{ position: relative; }
.pos-val{ vertical-align: middle; }
.lb-hint{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1px solid var(--muted);
  font-size: 10px;
  color: var(--muted);
  cursor: help;
  margin-left: 3px;
  vertical-align: middle;
  position: relative;
  text-transform: none;
}
.lb-tooltip{
  display: none;
  position: fixed;
  z-index: 9999;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  padding: 8px 0;
  min-width: 160px;
  max-height: 320px;
  overflow-y: auto;
  white-space: nowrap;
}
.lb-tooltip-title{
  font-size: 11px;
  font-weight: 700;
  padding: 0 12px 6px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
.lb-tooltip-row{
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text);
}
.lb-tooltip-row.is-current{
  background: rgba(37,99,235,.08);
  font-weight: 700;
}
.lb-tooltip-pos{ color: var(--muted); }
.lb-tooltip-cpm{ font-variant-numeric: tabular-nums; }

/* actions */
.actions{
  display:flex;
  gap:6px;
  flex-wrap: nowrap;
  align-items:center;
  justify-content:flex-start;
}
.actions form{ margin:0; }
.actions .btn-mini{
  padding: 0;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size: 13px;
  line-height: 1;
}

.is-hidden{ display:none !important; }
.is-row-hidden{ display:none !important; }

/* Bulk edit: fixed height + overlay switch */
.cell-stack{
  position: relative;
  height: var(--cellh);
  width: 100%;
}
.cell-stack .cell-val,
.cell-stack .cell-edit{
  position: absolute;
  inset: 0;
  margin: 0;
}
.cell-stack .cell-val{
  display:flex;
  align-items:center;
  justify-content:center;
  height: 100%;
}
.inline-input{
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  font-size: 12px;
  text-align: center;
  outline: none;
  line-height: 1.2;
}
.inline-input:focus{
  border-color: rgba(37,99,235,.55);
  box-shadow: 0 0 0 4px rgba(37,99,235,.14);
}

/* remove number spinners */
.inline-input[type="number"]{
  -webkit-appearance: textfield;
  appearance: textfield;
  -moz-appearance: textfield;
}
.inline-input[type="number"]::-webkit-outer-spin-button,
.inline-input[type="number"]::-webkit-inner-spin-button{
  -webkit-appearance: none;
  margin: 0;
}

/* default: show value */
.cell-stack .cell-edit{
  opacity: 0;
  pointer-events: none;
}
body.is-bulk-on .cell-stack .cell-val{ opacity: 0; }
body.is-bulk-on .cell-stack .cell-edit{
  opacity: 1;
  pointer-events: auto;
}

/* CPM static cell */
.cell-static{
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--cellh);
  width: 100%;
  line-height: 1;
}

/* Toggle button */
.toggle{
  width:22px;
  height:22px;
  border-radius:8px;
  border:1px solid var(--line);
  background:#fff;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  user-select:none;
  font-size:16px;
  font-weight:900;
  line-height:1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color: var(--muted);
  flex: 0 0 22px;
}
.toggle:hover{ background: rgba(15,23,42,.03); }
.toggle[data-state="open"]::before{ content:"−"; }
.toggle[data-state="closed"]::before{ content:"+"; }

/* Pager */
.pager{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 16px 18px 18px;
  color: var(--muted);
  font-size: 13px;
  gap: 12px;
}
.pager-info{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding: 8px 12px;
  border:1px solid var(--line);
  border-radius: 999px;
  background: rgba(15,23,42,.03);
}
.pager-info b{ color: var(--text); }
.pager-actions{ display:flex; gap:10px; }

/* row highlight */
tr.row-green td  { background: rgba(22,163,74,.06) !important; }
tr.row-yellow td { background: rgba(245,158,11,.10) !important; }
tr.row-red td    { background: rgba(239,68,68,.10) !important; }

/* Modal */
.modal{
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.is-hidden{ display: none !important; }
.modal-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.35);
}
.modal-card{
  position: relative;
  width: min(520px, 92vw);
  background: #fff;
  border-radius: 18px;
  border: 1px solid rgba(15,23,42,.10);
  box-shadow: 0 12px 30px rgba(15,23,42,.18);
}
.modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:14px 16px;
  border-bottom:1px solid rgba(15,23,42,.10);
}
.modal-title{ font-weight:800; }
.modal-sub{ font-size:13px; }
.modal-body{ padding:14px 16px; }
.modal-actions{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  padding:14px 16px;
  border-top:1px solid rgba(15,23,42,.10);
}

/* Campaign checkbox */
.camp-check{
  transform: translateY(1px);
  margin-right: 10px;
}

/* iOS switch */
.ios-switch{
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  cursor: pointer;
  vertical-align: middle;
}
.ios-switch input{
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.ios-switch .track{
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(15,23,42,.14);
  border: 1px solid var(--line);
  transition: background .15s ease, border-color .15s ease;
}
.ios-switch .thumb{
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(15,23,42,.10);
  box-shadow: 0 4px 10px rgba(15,23,42,.18);
  transition: transform .15s ease;
}
.ios-switch input:checked ~ .track{
  background: rgba(22,163,74,.55);
  border-color: rgba(22,163,74,.35);
}
.ios-switch input:checked ~ .thumb{
  transform: translateX(18px);
}
.ios-switch input:focus-visible ~ .track{
  box-shadow: 0 0 0 4px rgba(37,99,235,.14);
}
.ios-switch-text{
  margin-left: 8px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  user-select: none;
}

@media (max-width: 1200px){
  table.dashboard-table thead th{ padding:8px 8px; font-size:11px; }
  table.dashboard-table tbody td{ padding:8px 8px; font-size:12px; }
  .actions .btn-mini{ width: 26px; height: 26px; }
}

/* ==== SORTABLE HEADERS (без конфликтов) ==== */
.th-sort{
  display:inline-flex;
  align-items:center;
  gap:6px;
  cursor:pointer;
  user-select:none;
}
th.num .th-sort, th.small .th-sort{ justify-content:center; width:100%; }

.th-arrow{
  font-size: 12px;
  color: currentColor;
  opacity: .65;
}
table.dashboard-table thead th:hover .th-arrow,
table.dashboard-table thead th.is-sorted .th-arrow{
  opacity: 1;
}
table.dashboard-table thead th:hover{
  background: rgba(15,23,42,.04);
  color: var(--text);
}
table.dashboard-table thead th.is-sorted{
  background: rgba(15,23,42,.06);
  color: var(--text);
}

/* липкая строка заголовка таблицы */
.table-head{
  position: sticky;
  top: calc(var(--dash-sticky-top) + var(--dash-sticky-offset));
  z-index: 55;
  background: var(--card);
  overflow: hidden; /* скрыть горизонтальный "перелив" */
  border-bottom: 1px solid var(--line);
}

/* в header-таблице th уже НЕ sticky */
.dashboard-head thead th{
  position: static !important;
}

/* скролл только у body */
#tableScroll{
  overflow-x: auto;
  overflow-y: visible;
}

/* чтобы ширины совпали */
.dashboard-head, .dashboard-body{
  width: 100%;
  table-layout: fixed;
}

/* ======================================================
   MULTI-ACCOUNT UI & LAYOUT HELPERS (from local)
   ====================================================== */

.grid-two{
  display:grid;
  grid-template-columns: 1.2fr 1fr;
  gap:18px;
}
@media (max-width: 980px){
  .grid-two{ grid-template-columns: 1fr; }
}

.form-stack{ display:flex; flex-direction:column; gap:14px; padding:4px 18px 18px; }
.field{ display:flex; flex-direction:column; gap:6px; }
.field label{ font-size:12px; color:var(--muted); text-transform:uppercase; letter-spacing:.08em; }
.field input, .field select, .field textarea{
  height:42px;
  padding: 0 12px;
  border-radius: 12px;
  border:1px solid var(--line);
  background: var(--card);
  color: var(--text);
  outline:none;
}
.field textarea{ height:auto; padding:10px 12px; }
.field input:focus, .field select:focus, .field textarea:focus{
  border-color: rgba(37,99,235,.55);
  box-shadow: 0 0 0 4px rgba(37,99,235,.14);
}

.form-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
}
@media (max-width: 640px){
  .form-grid{ grid-template-columns: 1fr; }
}

.field.full input{ width:100%; }
.field input::placeholder{
  color: var(--muted);
  opacity: .7;
}

.actions-row{ display:flex; gap:10px; flex-wrap:wrap; }
.actions-wrap{ flex-wrap:wrap; }

.hint-wrap{ position:relative; display:inline-flex; margin-left:4px; vertical-align:middle; }
.hint-wrap .hint-icon{
  display:inline-flex; align-items:center; justify-content:center;
  width:15px; height:15px; border-radius:50%;
  background:var(--line, #e2e8f0); color:var(--muted, #64748b);
  font-size:9px; font-weight:700; cursor:help;
  text-transform:none; letter-spacing:0;
}
.hint-wrap:hover .hint-icon{ background:var(--accent, #3b82f6); color:#fff; }
.hint-wrap .hint-text{
  display:none; position:absolute; left:0; bottom:calc(100% + 8px);
  width:260px; padding:10px 12px;
  background:#1e293b; color:#f1f5f9; font-size:12px; font-weight:400;
  line-height:1.5; border-radius:8px; text-transform:none; letter-spacing:0;
  z-index:100; box-shadow:0 4px 12px rgba(0,0,0,.15);
  pointer-events:none;
}
.hint-wrap .hint-text::after{
  content:''; position:absolute; left:12px; top:100%;
  border:6px solid transparent; border-top-color:#1e293b;
}
.hint-wrap:hover .hint-text{ display:block; }

.table-wrap.compact{ padding: 0 16px 16px; }
.simple-table{
  width:100%;
  border-collapse: collapse;
  font-size:14px;
}
.simple-table th, .simple-table td{
  padding:10px 10px;
  border-bottom:1px solid var(--line);
  text-align:left;
}
.simple-table th{
  color: var(--muted);
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.08em;
}
.simple-table tr:hover td{ background: rgba(15,23,42,.03); }

.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 8px;
  border-radius: 999px;
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.08em;
  border:1px solid var(--line);
}
.badge-green{ background: rgba(22,163,74,.10); color:#14532d; }
.badge-blue{ background: rgba(37,99,235,.10); color:#1e3a8a; }
.badge-red{ background: rgba(239,68,68,.10); color:#991b1b; }
.badge.green{ background: rgba(22,163,74,.10); color:#14532d; border-color: rgba(22,163,74,.3); }
.badge.red{ background: rgba(239,68,68,.10); color:#991b1b; border-color: rgba(239,68,68,.3); }

.msg{
  padding:10px 12px;
  border-radius: 12px;
  background: rgba(37,99,235,.08);
  border:1px solid rgba(37,99,235,.18);
  color: var(--text);
  margin: 0 0 12px;
}
.msg.error{
  background: rgba(239,68,68,.08);
  border-color: rgba(239,68,68,.18);
  color:#7f1d1d;
}

.empty{
  padding:18px;
  color: var(--muted);
}

/* Auth */
.auth-wrap{
  display:flex;
  justify-content:center;
  padding: 40px 0;
}
.auth-card{
  width:min(420px, 92vw);
  background: var(--card-2);
  border:1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.auth-card h2{ margin:0 0 6px; }
.auth-card .sub{ margin:0 0 18px; color:var(--muted); font-size:13px; }

/* Account panel */
.account-card{
  padding:16px;
  border:1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--card-2);
}
.account-meta{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
  margin-top:10px;
  font-size:13px;
}
.account-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:14px;
}

/* Period picker */
.period-picker{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-size:13px;
}
.period-lbl{
  display:inline-flex;
  align-items:center;
  gap:4px;
  white-space:nowrap;
}

/* Analytics columns */
.col-an{ font-size:12px; white-space:nowrap; }

/* Campaign schedule */
.schedule-form{ margin-top:4px; }
.schedule-inputs{
  display:flex;
  align-items:center;
  gap:4px;
  font-size:11px;
}
.schedule-lbl{
  display:flex;
  align-items:center;
  gap:2px;
  white-space:nowrap;
}
input.mini-time{
  width:72px;
  padding:1px 3px;
  font-size:11px;
  border:1px solid var(--line);
  border-radius:4px;
  background:var(--card);
  color:var(--text);
}

/* Theme toggle */
.theme-toggle{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--line);
  background: rgba(15,23,42,.04);
  color: var(--text);
  cursor:pointer;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.08em;
}
.theme-dot{
  width:10px;
  height:10px;
  border-radius:999px;
  background: linear-gradient(135deg, var(--blue), var(--green));
  display:inline-block;
}

html[data-theme="light"] .theme-toggle{
  background: #fff;
}

/* Responsive topbar */
@media (max-width: 900px){
  .topbar{ flex-direction:column; align-items:flex-start; }
  .nav{ margin-left:0; width:100%; flex-wrap:wrap; }
  .userbar{ width:100%; justify-content:flex-end; }
}

/* ======================================================
   DARK THEME OVERRIDES
   ====================================================== */

html[data-theme="dark"] .nav-link:hover{
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.10);
}
html[data-theme="dark"] .user-pill{
  border-color: rgba(255,255,255,.10);
  background: rgba(255,255,255,.05);
}

html[data-theme="dark"] .btn{
  background: rgba(255,255,255,.06);
}
html[data-theme="dark"] .btn-primary{
  background: linear-gradient(135deg, #38bdf8, #2dd4bf);
  color:#03101a;
  box-shadow: 0 10px 22px rgba(56,189,248,.25);
}
html[data-theme="dark"] .btn-ghost{
  background: transparent;
  border-color: rgba(255,255,255,.12);
}
html[data-theme="dark"] .btn-danger{
  background: rgba(249,115,22,.12);
  color: #ffd7b5;
  border-color: rgba(249,115,22,.35);
}
html[data-theme="dark"] .btn-success{
  background: rgba(45,212,191,.12);
  color: #b9fff1;
  border-color: rgba(45,212,191,.35);
}

html[data-theme="dark"] .filters-v3{
  background: var(--card-2);
  backdrop-filter: blur(8px);
}
html[data-theme="dark"] .filters-v3 .f3-search{ background: var(--card); }
html[data-theme="dark"] .f3-clear{ background: var(--card); }
html[data-theme="dark"] .f3-select{ background: var(--card); color: var(--text); }
html[data-theme="dark"] .chip{
  border-color: rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
}

html[data-theme="dark"] table.dashboard-table thead th{
  background: var(--card);
  backdrop-filter: blur(8px);
}
html[data-theme="dark"] table.dashboard-table thead th:hover{
  background: rgba(255,255,255,.04);
}
html[data-theme="dark"] table.dashboard-table thead th.is-sorted{
  background: rgba(255,255,255,.06);
}
html[data-theme="dark"] table.dashboard-table tbody tr:hover{
  background: rgba(56,189,248,.06);
}

html[data-theme="dark"] tr.row-green td  { background: rgba(45,212,191,.10) !important; }
html[data-theme="dark"] tr.row-yellow td { background: rgba(251,191,36,.12) !important; }
html[data-theme="dark"] tr.row-red td    { background: rgba(249,115,22,.12) !important; }

html[data-theme="dark"] .inline-input{ background: rgba(10,12,20,.7); color: var(--text); border-color: rgba(255,255,255,.08); }
html[data-theme="dark"] .inline-input:focus{ border-color: rgba(56,189,248,.6); box-shadow: 0 0 0 4px rgba(56,189,248,.12); }

html[data-theme="dark"] .modal-card{ background: var(--card); border-color: rgba(255,255,255,.08); }
html[data-theme="dark"] .modal-head{ border-bottom:1px solid rgba(255,255,255,.08); }
html[data-theme="dark"] .modal-actions{ border-top:1px solid rgba(255,255,255,.08); }

html[data-theme="dark"] .toggle{ background: var(--card); }
html[data-theme="dark"] .toggle:hover{ background: rgba(255,255,255,.06); }

html[data-theme="dark"] .table-head{ border-bottom-color: rgba(255,255,255,.08); }

html[data-theme="dark"] .simple-table th, html[data-theme="dark"] .simple-table td{
  border-bottom-color: rgba(255,255,255,.06);
}
html[data-theme="dark"] .simple-table tr:hover td{ background: rgba(255,255,255,.03); }

html[data-theme="dark"] .badge-green{ background: rgba(45,212,191,.12); color:#b9fff1; }
html[data-theme="dark"] .badge-blue{ background: rgba(56,189,248,.12); color:#cbefff; }
html[data-theme="dark"] .badge-red{ background: rgba(249,115,22,.14); color:#ffd7b5; }
html[data-theme="dark"] .badge.green{ background: rgba(45,212,191,.12); color:#b9fff1; border-color: rgba(45,212,191,.3); }
html[data-theme="dark"] .badge.red{ background: rgba(249,115,22,.14); color:#ffd7b5; border-color: rgba(249,115,22,.3); }

html[data-theme="dark"] .msg{
  background: rgba(56,189,248,.08);
  border-color: rgba(56,189,248,.18);
  color: #cbefff;
}
html[data-theme="dark"] .msg.error{
  background: rgba(249,115,22,.12);
  border-color: rgba(249,115,22,.22);
  color:#ffd7b5;
}

html[data-theme="light"] .msg{
  background: rgba(37,99,235,.08);
  border-color: rgba(37,99,235,.18);
  color: #0f172a;
}
html[data-theme="light"] .msg.error{
  background: rgba(239,68,68,.08);
  border-color: rgba(239,68,68,.18);
  color:#7f1d1d;
}

html[data-theme="dark"] .field input, html[data-theme="dark"] .field select, html[data-theme="dark"] .field textarea{
  border-color: rgba(255,255,255,.08);
  background: rgba(10,12,20,.7);
}
html[data-theme="dark"] .field input:focus, html[data-theme="dark"] .field select:focus, html[data-theme="dark"] .field textarea:focus{
  border-color: rgba(56,189,248,.6);
  box-shadow: 0 0 0 4px rgba(56,189,248,.12);
}

html[data-theme="dark"] .account-card{ background: rgba(255,255,255,.02); }

html[data-theme="dark"] .theme-toggle{
  background: rgba(255,255,255,.04);
}

html[data-theme="dark"] input.mini-time{
  background: rgba(10,12,20,.7);
  border-color: rgba(255,255,255,.08);
}
