/* public/style.css — dashboard styling. Dark by default, light via [data-theme]. */

:root {
  --bg: #0e1014;
  --panel: #161a21;
  --panel2: #1c212a;
  --line: #272d38;
  --text: #e6e9ef;
  --muted: #8b95a7;
  --accent: #e8234a;
  --accent2: #ff5c7a;
  --up: #35d07f;
  --down: #ff5f56;
  --warn: #ffa500;
  --radius: 10px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel2: #f0f2f5;
  --line: #dfe3ea;
  --text: #171a1f;
  --muted: #667085;
  --up: #12864f;
  --down: #cf2d24;
  color-scheme: light;
}

* { box-sizing: border-box; }

/* Several elements below set `display`, which would otherwise beat the plain
   `hidden` attribute the JS toggles. Make `hidden` win everywhere. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 56px;
}

/* ------------------------------------------------------------------ topbar */
.topbar {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 26px; }
.topbar h1 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.sub { margin: 1px 0 0; color: var(--muted); font-size: 12px; }
.topActions { margin-left: auto; display: flex; gap: 8px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 11px; font-size: 12px; color: var(--muted);
  white-space: nowrap;
}
.chip b { color: var(--text); font-weight: 600; }
.chip.warn { border-color: var(--warn); color: var(--warn); }
.chip.warn b { color: var(--warn); }

/* ------------------------------------------------------------------ buttons */
.btn {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 13px; font-size: 13px; font-weight: 500; cursor: pointer;
  font-family: inherit;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent2); border-color: var(--accent2); }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 3px 8px; font-size: 12px; }

/* --------------------------------------------------------------------- tabs */
.tabs { display: flex; gap: 4px; padding: 14px 20px 0; flex-wrap: wrap; }
.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 8px 14px; font-size: 14px; cursor: pointer;
  font-family: inherit; border-radius: 6px 6px 0 0;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* ------------------------------------------------------------------ filters */
.filters {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
  padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.f { display: flex; flex-direction: column; gap: 4px; }
.f > span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.f input:not([type="checkbox"]), .f select {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 9px; font-size: 13px; min-width: 130px; font-family: inherit;
}
.f.narrow input { min-width: 92px; }
.f.check { flex-direction: row; align-items: center; gap: 7px; padding-bottom: 7px; }
.f.check input { width: auto; min-width: 0; margin: 0; }
.f.check span { font-size: 13px; color: var(--text); text-transform: none; letter-spacing: 0; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------------------------------------------------------------- selection */
.selbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; background: var(--accent); color: #fff;
  position: sticky; top: 63px; z-index: 15;
}
.selbar .btn { background: rgba(255,255,255,0.16); border-color: rgba(255,255,255,0.3); color: #fff; }
.selbar .btn:hover:not(:disabled) { background: rgba(255,255,255,0.28); }

.baseline { padding: 10px 20px 0; margin: 0; color: var(--muted); font-size: 12px; }
.baseline b { color: var(--text); font-weight: 600; }
.baseline .warnText { color: var(--warn); }

/* -------------------------------------------------------------------- table */
main { padding: 12px 20px 20px; }
.tableWrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th {
  position: sticky; top: 0; background: var(--panel2);
  text-align: left; padding: 9px 10px; font-size: 11px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 5;
}
tbody td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel2); }
tbody tr.selected { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }
.cbcol { width: 34px; }

.icon { width: 34px; height: 34px; border-radius: 7px; display: block; background: var(--panel2); object-fit: cover; }
.gname { display: block; font-weight: 500; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gname:hover { color: var(--accent2); }
.gcreator { color: var(--muted); font-size: 11.5px; }
a { color: inherit; text-decoration: none; }
a.link { color: var(--accent2); text-decoration: underline; text-underline-offset: 2px; }

.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }
.badge {
  display: inline-block; padding: 2px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 600; border: 1px solid;
}
.badge.new { color: var(--accent2); border-color: var(--accent2); }
.badge.group { color: var(--warn); border-color: var(--warn); }
.badge.game { color: var(--up); border-color: var(--up); }
.badge.assigned { color: #7ddc8f; border-color: #7ddc8f; }
.badge.sent { color: var(--muted); border-color: var(--line); }
.dash { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 44px 20px; }

/* ------------------------------------------------------------------ dialogs */
dialog {
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel);
  color: var(--text); padding: 0; max-width: 720px; width: calc(100% - 40px);
}
dialog::backdrop { background: rgba(0,0,0,0.6); }
.dlg { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.dlg h2 { margin: 0; font-size: 17px; }
.hint { margin: 0; color: var(--muted); font-size: 12.5px; }
.dlg hr { border: none; border-top: 1px solid var(--line); margin: 2px 0; width: 100%; }
.dlg .row { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; cursor: pointer; }
.dlg .row input { margin-top: 3px; flex-shrink: 0; }
.dlg .row em { display: block; color: var(--muted); font-style: normal; font-size: 12px; margin-top: 1px; }
.dlg .field { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.dlg .field span { min-width: 116px; color: var(--muted); }
.dlg .field input {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 9px; width: 130px; font-family: inherit;
}
.dlgActions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.autopostOpts {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 14px; background: var(--panel2); border-radius: 9px;
}
.autopostOpts[hidden] { display: none; }

/* ------------------------------------------------------------- game dialog */
.gameDlg { max-height: 82vh; overflow-y: auto; }
.gameHead { display: flex; gap: 14px; align-items: flex-start; }
.gameHead img { width: 68px; height: 68px; border-radius: 12px; }
.gameHead h2 { margin: 0 0 3px; }
.statGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.stat { background: var(--panel2); border-radius: 9px; padding: 9px 11px; }
.stat span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat b { font-size: 16px; font-variant-numeric: tabular-nums; }
.chart { width: 100%; height: 130px; background: var(--panel2); border-radius: 9px; }
.chartLabel { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.socialList { display: flex; flex-direction: column; gap: 6px; }
.socialItem { background: var(--panel2); border-radius: 8px; padding: 8px 11px; font-size: 12.5px; }
.desc { color: var(--muted); font-size: 12.5px; max-height: 120px; overflow-y: auto; white-space: pre-wrap; }

/* -------------------------------------------------------------------- login */
.loginWrap {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg); z-index: 100; padding: 20px;
}
.loginCard {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 30px; width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 14px;
}
.loginCard h1 { margin: 0; font-size: 20px; }
.lf { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.lf input {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; font-size: 14px; font-family: inherit;
}
.loginErr { margin: 0; color: var(--down); font-size: 13px; }
.who { align-self: center; color: var(--muted); font-size: 12px; margin-right: 4px; }

/* ----------------------------------------------------------------- pipeline */
.selStatus { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.selStatus select {
  background: rgba(255,255,255,0.16); color: #fff;
  border: 1px solid rgba(255,255,255,0.3); border-radius: 7px;
  padding: 5px 8px; font-size: 13px; font-family: inherit;
}
.selStatus select option { color: var(--text); background: var(--panel); }

.pipelineRow { display: flex; gap: 9px; align-items: center; }
.pipelineRow select {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 7px 10px; font-size: 13px; font-family: inherit; flex: 1;
}

/* Pipeline stage colours: cool early, warm as a deal progresses. */
.badge.st-interested  { color: #6aa9ff; border-color: #6aa9ff; }
.badge.st-inquired    { color: #b18cff; border-color: #b18cff; }
.badge.st-responded   { color: #45c8d8; border-color: #45c8d8; }
.badge.st-negotiating { color: var(--warn); border-color: var(--warn); }
.badge.st-acquired    { color: var(--up); border-color: var(--up); }
.badge.st-passed      { color: var(--muted); border-color: var(--line); }

/* ------------------------------------------------------------ workers panel */
#workersPanel { padding: 16px 20px 20px; }
.workerCards { display: grid; grid-template-columns: repeat(auto-fill,minmax(300px,1fr)); gap: 14px; }
.workerCard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; }
.wcHead { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.wcHead em { display: block; color: var(--muted); font-style: normal; font-size: 12px; margin-top: 2px; }
.wcTotal { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.wcBar { height: 6px; background: var(--panel2); border-radius: 99px; overflow: hidden; margin: 11px 0 5px; }
.wcBar div { height: 100%; background: var(--up); border-radius: 99px; }
.wcPct { font-size: 11.5px; color: var(--muted); }
.stages { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.stage { font-size: 11px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.stage b { color: var(--text); }
.stage.st-interested { border-color:#6aa9ff; color:#6aa9ff }
.stage.st-inquired { border-color:#b18cff; color:#b18cff }
.stage.st-responded { border-color:#45c8d8; color:#45c8d8 }
.stage.st-negotiating { border-color:var(--warn); color:var(--warn) }
.stage.st-acquired { border-color:var(--up); color:var(--up) }
.wcActions { display: flex; gap: 7px; margin-top: 12px; }
.activityWrap { margin-top: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; }
.activityHead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.activityHead h3 { margin: 0; font-size: 14px; }
.activityHead select { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 5px 9px; font-family: inherit; font-size: 13px; }
.activityList { display: flex; flex-direction: column; max-height: 460px; overflow-y: auto; }
.actRow { display: grid; grid-template-columns: 110px 130px 1fr 90px; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.actRow:last-child { border-bottom: none; }
.actWho { font-weight: 600; }
.actGame { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent2); }
.actWhen { color: var(--muted); text-align: right; }

/* --------------------------------------------------------- assign dialog */
.workerList { display: flex; flex-direction: column; gap: 8px; }
.workerRow {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 12px; font-size: 13px;
}
.workerRow:hover { border-color: var(--muted); }
.workerRow input { margin: 0; flex-shrink: 0; }
.workerRow em { display: block; color: var(--muted); font-style: normal; font-size: 12px; }
#assignPreview { font-variant-numeric: tabular-nums; }
.rowActions { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
a.btn.tiny { display: inline-block; text-decoration: none; }

/* ------------------------------------------------------------------ console */
.console {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--panel); border-top: 1px solid var(--line);
}
.consoleHead {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; color: var(--text);
  padding: 10px 20px; cursor: pointer; font: inherit; font-size: 13px;
}
.consoleHead .spacer { flex: 1; }
.consoleHead #consoleHint { color: var(--muted); font-size: 12px; }
.caret { color: var(--muted); transition: transform 0.15s; }
.console[data-open="true"] .caret { transform: rotate(180deg); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.dot.busy { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

#log {
  margin: 0; padding: 0 20px 14px; max-height: 0; overflow-y: auto;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--muted); white-space: pre-wrap; transition: max-height 0.18s;
}
.console[data-open="true"] #log { max-height: 40vh; padding-bottom: 16px; }

@media (max-width: 760px) {
  .chips { order: 3; width: 100%; }
  .topActions { margin-left: 0; }
  .gname { max-width: 180px; }
}
