/* Backoffice. Dark, same tokens as the portal and the client. */
:root {
  color-scheme: dark;
  --bg: #0f1013;
  --side: #14161a;
  --panel: #1b1d22;
  --panel-2: #23262d;
  --line: #2f333b;
  --grid: #2a2d34;
  --text: #ecebe7;
  --dim: #b4b7bf;
  --muted: #8a8e97;
  --gold: #d4a63a;
  --gold-hi: #e9be55;
  --gold-ink: #17181b;
  /* Chart mark: the brand gold stepped into the dark-mode lightness band
     (validated: OKLCH L 0.48-0.67, contrast >= 3:1 on --panel). */
  --mark: #b88a2c;
  --mark-hover: #d4a63a;
  --ok: #5fbf6a;
  --warn: #e0b040;
  --danger: #e0605a;
  --info: #6ea8fe;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Noto Sans", Roboto, Ubuntu, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
[hidden] { display: none !important; }
a { color: var(--gold-hi); }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 17px; }
.brand b { color: var(--gold); }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 8px; padding: 9px 16px; font: 600 14px/1.2 var(--font); cursor: pointer;
  border: 1px solid transparent; text-decoration: none; white-space: nowrap;
}
.btn-gold { background: var(--gold); color: var(--gold-ink); }
.btn-gold:hover { background: var(--gold-hi); }
.btn-ghost { background: rgba(255, 255, 255, .04); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: rgba(255, 255, 255, .08); border-color: #454a55; }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(224, 96, 90, .5); }
.btn-danger:hover { background: rgba(224, 96, 90, .1); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: default; }
label { display: block; color: var(--dim); font-size: 13.5px; font-weight: 600; margin: 14px 0 6px; }
input[type="text"], input[type="password"], input[type="url"], input[type="number"], input:not([type]), select, textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; font: 14.5px var(--font);
}
textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212, 166, 58, .18); }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; margin: 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--gold); }
.hint { color: var(--muted); font-size: 13px; margin-top: 5px; }
.error { color: var(--danger); font-size: 14px; margin: 10px 0 0; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(600px 400px at 20% 20%, rgba(95, 191, 106, .08), transparent 70%),
              radial-gradient(600px 400px at 80% 80%, rgba(217, 87, 79, .08), transparent 70%); }
.login-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 30px; }
.login-card h1 { font-size: 26px; margin: 22px 0 8px; }
.login-card p.muted { font-size: 14px; }
.login-card .btn { width: 100%; margin-top: 20px; padding: 11px; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 26px; position: sticky; top: 0; height: 100vh; }
.side nav { display: grid; gap: 4px; }
.side nav a { display: flex; align-items: center; gap: 11px; color: var(--dim); text-decoration: none; padding: 10px 12px; border-radius: 9px; font-weight: 600; font-size: 14.5px; }
.side nav a svg { width: 18px; height: 18px; flex: none; }
.side nav a:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.side nav a[aria-current="page"] { color: var(--gold-hi); background: rgba(212, 166, 58, .1); }
.me { margin-top: auto; display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; padding-top: 16px; border-top: 1px solid var(--line); }
.me .btn { grid-column: 1 / -1; }
.me small { display: block; color: var(--muted); font-size: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: var(--gold-ink); display: grid; place-items: center; font-weight: 800; }
.main { padding: 28px 32px 60px; min-width: 0; outline: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.page-head h1 { font-size: 26px; }
.page-head p { color: var(--muted); margin: 6px 0 0; }
.filters { display: flex; gap: 10px; align-items: center; }
.filters select { width: auto; padding: 7px 10px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.panel + .panel, .grid-2 + .panel, .panel + .grid-2 { margin-top: 16px; }
.panel h2 { font-size: 16.5px; }
.panel .sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-top: 16px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi b { display: block; font-size: 30px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi small { color: var(--muted); font-size: 12.5px; }

/* ---------- Charts ---------- */
.chart { position: relative; margin-top: 14px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11.5px; font-family: var(--font); }
/* Bars and labels let the pointer through to the (larger) transparent hit areas. */
.chart .bar { fill: var(--mark); pointer-events: none; }
.chart text { pointer-events: none; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .hit:focus + .bar, .chart .bar.active { fill: var(--mark-hover); }
.chart .hit:focus { outline: none; }
.chart .value { fill: var(--text); font-size: 11.5px; font-weight: 600; font-family: var(--font); }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; font-size: 12.5px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
}
.tooltip b { display: block; font-size: 15px; }
.tooltip span { color: var(--muted); }
.hbars { display: grid; gap: 10px; margin-top: 16px; }
.hbar { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: center; font-size: 13.5px; }
.hbar .name { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hbar .fill { height: 14px; background: var(--mark); border-radius: 0 4px 4px 0; min-width: 2px; flex: none; }
.hbar .num { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
details.table-view { margin-top: 12px; }
details.table-view summary { cursor: pointer; color: var(--dim); font-size: 13px; }
.empty { color: var(--muted); padding: 26px 0; text-align: center; font-size: 14px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.meter { display: inline-block; height: 8px; background: var(--mark); border-radius: 0 3px 3px 0; vertical-align: middle; margin-right: 8px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--line); color: var(--dim); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.published { color: var(--ok); border-color: rgba(95, 191, 106, .45); }
.pill.draft { color: var(--warn); border-color: rgba(224, 176, 64, .45); }
.pill.archived { color: var(--muted); }
.pill.required { color: var(--danger); border-color: rgba(224, 96, 90, .45); }
.pill.required::before { display: none; }

/* ---------- Releases ---------- */
.release-group { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; margin-top: 16px; overflow: hidden; }
.release-group > header { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.release-group > header h2 { font-size: 18px; }
.release-group table { font-size: 13.5px; }
.release-group td:first-child, .release-group th:first-child { padding-left: 18px; }
.release-group td:last-child, .release-group th:last-child { padding-right: 18px; }
.src { display: grid; gap: 2px; min-width: 200px; }
.src small { color: var(--muted); }
.sha { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.progress { height: 6px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-top: 6px; border: 1px solid var(--line); }
.progress i { display: block; height: 100%; width: 0; background: var(--gold); }
tr.editor td { background: rgba(255, 255, 255, .02); }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.edit-actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.platform-checks { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 6px; }
.form-row { display: grid; grid-template-columns: 180px 1fr 1fr; gap: 0 16px; }
.notice { border: 1px solid rgba(224, 176, 64, .45); background: rgba(224, 176, 64, .08); color: #f1dca4; border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-bottom: 16px; }

/* ---------- Platforms ---------- */
.platform-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 16px; }
.platform-card header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.platform-card header h2 { font-size: 16.5px; }
.platform-card .id { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.small-row { display: grid; grid-template-columns: 1fr 90px; gap: 0 12px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 100; max-width: min(420px, calc(100vw - 40px)); }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--ok); border-radius: 10px; padding: 10px 14px; font-size: 14px; box-shadow: 0 12px 30px rgba(0, 0, 0, .5); }
.toast.bad { border-left-color: var(--danger); }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; }
  .side nav { grid-auto-flow: column; overflow-x: auto; }
  .side nav a { padding: 8px 10px; font-size: 13.5px; }
  .me { margin: 0 0 0 auto; border: 0; padding: 0; grid-template-columns: auto auto; }
  .me > span:nth-child(2) { display: none; }
  .me .btn { grid-column: auto; }
  .main { padding: 20px 16px 48px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .form-row, .edit-grid { grid-template-columns: 1fr; }
  .platform-cards { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 110px 1fr; }
}
