/* MK Ads Dashboard — LLG Ultraviolet brand (BRAND.md v1)
   Obsidian canvas · Slate Violet surfaces · Electric Violet accents (sparse)
   Ice text · Dusk labels · Signal Mint = positive KPIs only · flat, no gradients */
:root {
  --obsidian: #0E0B16;
  --surface: #1A1526;        /* layer 1: raised surface */
  --slate: #241E36;          /* layer 2: cards, headers  */
  --violet: #8B6CFF;
  --violet-08: rgba(139, 108, 255, .08);
  --violet-15: rgba(139, 108, 255, .15);
  --violet-35: rgba(139, 108, 255, .35);
  --ice: #F1EEFB;
  --dusk: #7A7490;
  --mint: #57D9A3;
  --line: rgba(241, 238, 251, .07);
  --amber: #E8B04B;
  --coral: #E0596E;
  --sans: "Sora", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
::selection { background: var(--violet-35); }
body {
  background: var(--obsidian);
  color: var(--ice);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  -webkit-font-smoothing: antialiased;
}

/* ---------- sidebar ---------- */
#sidebar {
  width: 232px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 26px 16px 20px;
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand-lockup { display: block; width: 158px; margin: 0 8px 6px; }
.brand-product {
  margin: 0 8px 30px;
  font-size: 10.5px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--dusk);
}
nav { display: flex; flex-direction: column; gap: 2px; }
nav button {
  position: relative;
  background: none;
  border: none;
  color: var(--dusk);
  font: inherit;
  font-weight: 500;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: color .15s, background-color .15s;
}
nav button:hover { color: var(--ice); }
nav button.active { color: var(--ice); background: var(--violet-08); }
nav button.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 22%;
  height: 56%;
  width: 2px;
  background: var(--violet);
}
.sidebar-foot {
  margin-top: auto;
  padding: 16px 8px 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--dusk);
  border-top: 1px solid var(--line);
}

/* ---------- main / page chrome ---------- */
main { flex: 1; min-width: 0; padding: 30px 36px 90px; }
.page-head { margin-bottom: 26px; }
.page-head .overline {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--violet);
  font-weight: 400;
}
.page-head h2 {
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.2;
  margin-top: 6px;
}
.page-head .sub { color: var(--dusk); font-size: 13px; margin-top: 6px; max-width: 720px; }
.page-head .sub b { color: var(--ice); font-weight: 500; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar input[type=text], .toolbar select {
  background: var(--surface);
  border: 1px solid transparent;
  color: var(--ice);
  padding: 8px 12px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  transition: border-color .15s;
}
.toolbar input[type=text]:focus, .toolbar select:focus { outline: none; border-color: var(--violet-35); }
.toolbar input[type=text] { width: 250px; }
.toolbar input::placeholder { color: var(--dusk); }
.btn {
  background: var(--violet);
  color: var(--obsidian);
  border: none;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--surface); color: var(--ice); font-weight: 500; }
.hint { color: var(--dusk); font-size: 12px; }
.hint b { color: var(--ice); font-weight: 500; }

/* ---------- tables ---------- */
.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  background: var(--surface);
}
table { border-collapse: collapse; width: max-content; min-width: 100%; }
th, td {
  padding: 9px 13px;
  text-align: left;
  vertical-align: middle;
  max-width: 280px;
  overflow-wrap: break-word;
}
th {
  background: var(--slate);
  color: var(--dusk);
  font-weight: 400;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .12em;
  white-space: pre-line;
  position: sticky;
  top: 0;
  z-index: 5;
}
td { border-top: 1px solid var(--line); }
tbody tr { transition: background-color .12s; }
tbody tr:hover td { background: var(--violet-08); }
td.center, th.center { text-align: center; }
td.right, th.right { text-align: right; }
td.mono { font-family: var(--mono); font-weight: 500; font-size: 12px; }
td.computed { color: var(--dusk); }
.status-pill { white-space: nowrap; }
.light { font-size: 14px; }

/* entry columns — the three manual fields */
th.manual {
  color: var(--violet);
  background: var(--slate);
  box-shadow: inset 0 2px 0 var(--violet);
}
td.manual { background: rgba(139, 108, 255, .05); }
.entry-control {
  width: 100%;
  min-width: 116px;
  background: var(--obsidian);
  border: 1px solid var(--violet-35);
  color: var(--ice);
  font: inherit;
  font-size: 12.5px;
  padding: 7px 10px;
  border-radius: 7px;
  transition: border-color .15s, box-shadow .15s;
}
.entry-control.mono { font-family: var(--mono); font-weight: 500; font-size: 12px; }
select.entry-control { min-width: 215px; }
.entry-control:hover { border-color: var(--violet); }
.entry-control:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--violet-15);
}
.entry-control.saved { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(87, 217, 163, .18); }
.entry-control::placeholder { color: var(--dusk); opacity: .7; }

/* editable cells (inventory / logins / legend) */
td.editable { cursor: text; }
td.editable:hover { box-shadow: inset 0 0 0 1px var(--violet-35); border-radius: 4px; }
td .cell-input, td select.cell-input {
  width: 100%;
  min-width: 90px;
  background: var(--obsidian);
  border: 1px solid var(--violet);
  color: var(--ice);
  font: inherit;
  font-size: 12.5px;
  padding: 4px 7px;
  border-radius: 6px;
}
.del-btn { background: none; border: none; color: var(--dusk); cursor: pointer; font-size: 13px; }
.del-btn:hover { color: var(--coral); }

/* ---------- summary ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 34px;
  max-width: 1120px;
}
.card {
  background: var(--surface);
  border-radius: 12px;
  padding: 18px 20px 16px;
}
.card .label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--dusk);
  margin-bottom: 10px;
  font-weight: 400;
}
.card .value {
  font-size: 30px;
  line-height: 1.1;
  font-weight: 500;
  font-family: var(--mono);
  color: var(--ice);
}
.card.accent { box-shadow: inset 0 2px 0 var(--violet); }
.card.mint .value { color: var(--mint); }
h2.section {
  font-size: 11px;
  color: var(--dusk);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .18em;
  margin: 32px 0 12px;
}
.summary-table { min-width: 720px; }
.summary-table td, .summary-table th { white-space: nowrap; }
.summary-table td.num { font-family: var(--mono); font-weight: 500; font-size: 12.5px; text-align: right; }
.summary-table td:first-child { font-weight: 500; }

/* ---------- logins ---------- */
.secret {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .1em;
  color: var(--dusk);
  cursor: pointer;
  white-space: nowrap;
}
.secret.shown { letter-spacing: 0; color: var(--ice); }
.copy-btn { background: none; border: none; cursor: pointer; color: var(--dusk); font-size: 11px; margin-left: 6px; }
.copy-btn:hover { color: var(--violet); }

/* ---------- legend ---------- */
.legend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.legend-card { background: var(--surface); border-radius: 12px; padding: 18px 20px; }
.legend-card h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--violet);
  font-weight: 400;
  margin-bottom: 14px;
}
.legend-card h3 .hint { text-transform: none; letter-spacing: 0; }
.legend-card dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 12.5px; }
.legend-card dt { white-space: nowrap; font-weight: 500; }
.legend-card dd { color: var(--dusk); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  background: var(--slate);
  border-radius: 6px;
  padding: 5px 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
}
.chip button { background: none; border: none; color: var(--dusk); cursor: pointer; }
.chip button:hover { color: var(--coral); }
.chip-add { display: flex; gap: 6px; }
.chip-add input {
  background: var(--obsidian);
  border: 1px solid var(--line);
  color: var(--ice);
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  font-size: 12.5px;
  flex: 1;
}
.chip-add input:focus { outline: none; border-color: var(--violet-35); }
.model-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 12.5px; }
.model-row .track {
  color: var(--dusk);
  font-family: var(--mono);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* ---------- login ---------- */
.hidden { display: none !important; }
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--obsidian);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.login-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 36px 34px 30px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.login-mark { width: 44px; margin: 0 auto 6px; }
.login-title { font-weight: 600; font-size: 16px; letter-spacing: -.01em; }
.login-sub { color: var(--dusk); font-size: 12.5px; margin-bottom: 10px; }
.login-card input {
  background: var(--obsidian);
  border: 1px solid var(--line);
  color: var(--ice);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
}
.login-card input:focus { outline: none; border-color: var(--violet-35); }
.login-card .btn { margin-top: 4px; padding: 11px; }
.login-error { color: var(--coral); font-size: 12px; min-height: 16px; }
.signout {
  display: block;
  margin-top: 10px;
  color: var(--dusk);
  font-size: 11px;
  text-decoration: none;
}
.signout:hover { color: var(--violet); }

/* ---------- add-campaign modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 11, 22, .82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  padding: 24px;
}
.modal {
  background: var(--surface);
  border-radius: 14px;
  padding: 26px 28px 22px;
  width: 680px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head { margin-bottom: 18px; }
.modal-head .overline {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--violet);
}
.modal-head h3 { font-size: 18px; font-weight: 600; letter-spacing: -.01em; margin-top: 4px; }
.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
  margin-bottom: 20px;
}
.m-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.m-field.wide { grid-column: 1 / -1; }
.m-field span {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--dusk);
}
.m-field input, .m-field select {
  background: var(--obsidian);
  border: 1px solid var(--line);
  color: var(--ice);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
  font-size: 13px;
  width: 100%;
}
.m-field input:focus, .m-field select:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-15); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--slate);
  color: var(--ice);
  font-weight: 500;
  font-size: 13px;
  padding: 11px 18px;
  border-radius: 10px;
  border-left: 2px solid var(--violet);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .2s, transform .2s;
  z-index: 99;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }

/* ---------- status tabs (campaign overview) ---------- */
.status-tabs {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 0 0 14px;
}
.status-tab {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  color: var(--dusk); padding: 6px 14px; font: 500 12px var(--sans); cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.status-tab:hover { color: var(--ice); }
.status-tab.active { background: var(--violet); border-color: var(--violet); color: #fff; }
.status-tab .count {
  font: 500 11px var(--mono); color: var(--dusk);
  background: rgba(14, 11, 22, .45); border-radius: 999px; padding: 1px 8px;
}
.status-tab.active .count { color: #fff; background: rgba(255, 255, 255, .18); }

/* ---------- two-tier campaign rows ---------- */
td.ellipsis, th.ellipsis { max-width: 300px; }
td.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ctable tbody tr:not(.detail-row) { cursor: pointer; }
.row-toggle {
  background: none; border: 1px solid var(--line); border-radius: 7px;
  color: var(--dusk); width: 26px; height: 24px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s ease, border-color .15s ease, transform .15s ease;
}
tr:hover .row-toggle { color: var(--ice); border-color: var(--violet-35); }
tr.open .row-toggle svg { transform: rotate(180deg); }
.row-toggle svg { transition: transform .15s ease; }
tr.detail-row td {
  background: rgba(139, 108, 255, .04);
  border-top: none;
  padding: 0 14px 4px;
}
tr.detail-row:hover td { background: rgba(139, 108, 255, .04); }
.detail-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px 30px; padding: 12px 6px 16px;
  border-top: 1px dashed var(--line);
}
.d-field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.d-field.wide { grid-column: 1 / -1; }
.d-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .16em; color: var(--dusk);
}
.d-val { font-size: 12.5px; color: var(--ice); overflow-wrap: anywhere; }
.d-val.mono { font-family: var(--mono); }

/* ---------- campaign table density (fit without side-scroll) ---------- */
#ctable th, #ctable td { padding: 8px 9px; }
#ctable td.light, #ctable th.light { padding-left: 5px; padding-right: 5px; }
#ctable td.ellipsis { max-width: 190px; }
#ctable td[data-key="client"], #ctable td[data-key="model"] {
  max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#ctable .entry-control { min-width: 0; }
#ctable td[data-key="status"] .entry-control { width: 138px; }
#ctable td[data-key="yesterday_spend"] .entry-control,
#ctable td[data-key="balance"] .entry-control { width: 90px; }
