/* AGN Dev Control — design tokens + components. Author: Kaw.
   Dark-first (the mockup), with a light theme override. No decorative element carries function. */

:root {
  --bg: #030817;
  --bg-2: #061028;
  --panel: #081634;
  --panel-2: #0b1d44;
  --line: #16336f;
  --line-2: #1f4a9c;
  --glow: rgba(42, 120, 255, .35);
  --text: #e8efff;
  --muted: #9db0d6;
  --dim: #6c80aa;
  --brand: #2f7bff;
  --brand-2: #4fa3ff;
  --brand-ink: #ffffff;
  --ok: #34d17a;
  --warn: #ffb020;
  --bad: #ff4d5e;
  --info: #3fa9ff;
  --purple: #a77bff;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 0 0 1px var(--line), 0 8px 30px rgba(0, 0, 0, .35);
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --display: 'Orbitron', 'Inter', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #eef3fc; --bg-2: #e3ebf9; --panel: #ffffff; --panel-2: #f3f7ff; --line: #c9d7f2; --line-2: #9fb8e8;
  --glow: rgba(47, 123, 255, .15); --text: #0c1a3a; --muted: #3d5583; --dim: #6a7fa8; --brand: #1f63e6; --brand-2: #1f63e6;
  --shadow: 0 0 0 1px var(--line), 0 4px 16px rgba(20, 50, 120, .08); color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.ico { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.crumbs .ico { width: 15px; height: 15px; }
.side-card .ico { width: 18px; height: 18px; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #0d2a6b55, transparent 60%), var(--bg);
  color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
:root[data-theme="light"] body { background: var(--bg); }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: linear-gradient(180deg, #050d24, #040a1c); border-right: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
:root[data-theme="light"] .side { background: var(--panel); }
.logo { border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; box-shadow: 0 0 18px var(--glow); display: block; }
.logo img { display: block; width: 100%; height: auto; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; background: #06112b88; }
:root[data-theme="light"] .nav { background: var(--panel-2); }
.nav-group { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); padding: 10px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--text); font-weight: 600; font-size: 15px; }
.nav a:hover { background: #0f2556; text-decoration: none; }
:root[data-theme="light"] .nav a:hover { background: #e6eeff; }
.nav a.active { background: linear-gradient(90deg, #1d5ae0, #2f7bff); box-shadow: 0 0 16px var(--glow); color: #fff; }
.nav a .ico { width: 20px; height: 20px; flex: none; opacity: .95; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.side-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; align-items: center; gap: 10px; color: var(--text); background: #06112b88; }
.side-card:hover { text-decoration: none; border-color: var(--line-2); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 16px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: #040b1fcc; backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 20; }
:root[data-theme="light"] .top { background: #ffffffe6; }
.brandmark { display: flex; flex-direction: column; line-height: 1; margin-right: auto; }
.brandmark b { font-family: var(--display); font-weight: 900; font-size: 30px; letter-spacing: .04em; background: linear-gradient(180deg, #fff, #9cc3ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
:root[data-theme="light"] .brandmark b { background: none; color: var(--brand); }
.brandmark small { font-size: 10px; letter-spacing: .5em; color: var(--muted); margin-top: 6px; }
.search { position: relative; width: min(360px, 40vw); }
.search input { width: 100%; padding: 10px 38px 10px 14px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--bg-2); }
.search .ico { position: absolute; right: 12px; top: 11px; width: 16px; height: 16px; color: var(--muted); }
.search-results { position: absolute; top: 44px; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto; z-index: 30; }
.search-results a { display: block; padding: 9px 12px; color: var(--text); border-bottom: 1px solid var(--line); }
.search-results a small { color: var(--muted); margin-left: 6px; }
.iconbtn { position: relative; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--bg-2); display: grid; place-items: center; cursor: pointer; }
.iconbtn .ico { width: 20px; height: 20px; }
.iconbtn .dot { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--bad); color: #fff; font-size: 10px; display: grid; place-items: center; padding: 0 4px; }
.me { display: flex; align-items: center; gap: 10px; cursor: pointer; background: none; border: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--brand); display: inline-grid; vertical-align: middle; place-items: center; font-weight: 800; background: #0b1d44; flex: none; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; border-width: 1px; }
.me span { display: flex; flex-direction: column; text-align: left; line-height: 1.15; }
.me small { color: var(--muted); }

.content { padding: 16px 18px 24px; display: flex; flex-direction: column; gap: 16px; }
.hero { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line-2); box-shadow: 0 0 24px var(--glow); }
.hero img { display: block; width: 100%; height: auto; min-height: 90px; object-fit: cover; }
.crumbs { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-family: var(--display); font-size: 28px; letter-spacing: .02em; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.page-head .spacer { flex: 1; }
.tag-concept { border: 1px solid var(--line-2); border-radius: 6px; padding: 5px 10px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.footer { display: flex; gap: 14px; padding: 10px 18px; color: var(--dim); font-size: 12px; border-top: 1px solid var(--line); margin-top: auto; flex-wrap: wrap; }

/* ---------- components ---------- */
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.split { grid-template-columns: minmax(0, 2.1fr) minmax(300px, 1fr); }
.grid > *, .split > * { min-width: 0; }
.panel { background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
:root[data-theme="light"] .panel { background: var(--panel); }
.panel > h2, .panel-h { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: 17px; }
.panel-h h2 { margin: 0; font-size: 17px; }
.panel-h .more, .panel > h2 .more { margin-left: auto; font-size: 12.5px; font-weight: 500; }
.panel .sub { color: var(--muted); font-size: 12.5px; margin: -6px 0 10px; }
.kpi { display: flex; align-items: center; gap: 14px; }
.kpi .ico-box { width: 60px; height: 60px; border-radius: 10px; border: 1px solid var(--line-2); display: grid; place-items: center; background: #0a1d4a; flex: none; }
.kpi .ico-box .ico { width: 30px; height: 30px; color: var(--brand-2); }
.kpi.bad .ico-box { background: #3a0c16; border-color: #7a1d2c; }
.kpi.bad .ico-box .ico { color: var(--bad); }
.kpi .lbl { color: var(--muted); font-size: 13px; }
.kpi .val { font-size: 32px; font-weight: 800; line-height: 1.1; }
.kpi .delta { font-size: 12px; margin-left: 8px; }
.up { color: var(--ok); } .down { color: var(--bad); }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; font-weight: 600; color: var(--text); white-space: nowrap; }
.btn:hover { border-color: var(--brand-2); text-decoration: none; }
.btn.primary { background: linear-gradient(180deg, #2f7bff, #1d5ae0); border-color: #4f8fff; color: #fff; box-shadow: 0 0 12px var(--glow); }
.btn.danger { background: #3a0c16; border-color: #a12a3c; color: #ffd6db; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn .ico { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 6px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--line-2); background: #0d2152; color: var(--text); white-space: nowrap; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.plain::before { display: none; }
.badge.ok { color: #7ff0ae; border-color: #1f7a4a; background: #08281a; }
.badge.warn { color: #ffd27a; border-color: #8a5d0c; background: #2a1c03; }
.badge.bad { color: #ff99a4; border-color: #8a1f2d; background: #2a070d; }
.badge.info { color: #8cc8ff; border-color: #1f5aa8; background: #071c3d; }
.badge.purple { color: #cdb4ff; border-color: #5b3aa8; background: #1a0f3a; }
:root[data-theme="light"] .badge { background: #eef3ff; }
:root[data-theme="light"] .badge.ok { color: #0f7a3f; background: #e6f8ee; }
:root[data-theme="light"] .badge.warn { color: #8a5a00; background: #fff4dc; }
:root[data-theme="light"] .badge.bad { color: #b11a2c; background: #ffe9ec; }
:root[data-theme="light"] .badge.info { color: #1f5aa8; background: #e7f1ff; }
:root[data-theme="light"] .badge.purple { color: #5b3aa8; background: #f0e9ff; }

.progress { height: 8px; border-radius: 4px; background: #0d214f; overflow: hidden; flex: 1; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, #1d5ae0, #4fa3ff); box-shadow: 0 0 10px var(--glow); }
.progress.ok > i { background: linear-gradient(90deg, #1f9a59, #34d17a); }
.progress.bad > i { background: linear-gradient(90deg, #a12a3c, #ff4d5e); }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 9px 10px; border-bottom: 1px solid #0f2453; vertical-align: middle; }
:root[data-theme="light"] table.t td { border-bottom-color: var(--line); }
table.t tr:hover td { background: #0a1c45; }
:root[data-theme="light"] table.t tr:hover td { background: #f3f7ff; }
.table-wrap { overflow-x: auto; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.empty { color: var(--muted); padding: 22px; text-align: center; border: 1px dashed var(--line-2); border-radius: var(--radius); }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 10px 16px; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; display: flex; gap: 8px; align-items: center; }
.tabs a.active { color: var(--text); border-bottom-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs .ico { width: 18px; height: 18px; }

.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: #071636; display: flex; flex-direction: column; gap: 8px; }
:root[data-theme="light"] .card { background: var(--panel); }
.card.bad { border-color: #8a1f2d; box-shadow: inset 3px 0 0 var(--bad); }
.card.ok { box-shadow: inset 3px 0 0 var(--ok); }
.card h3 { margin: 0; font-size: 15px; }

/* forms */
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 600; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type=text], input[type=search], input[type=number], input[type=date], input[type=url], select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }
.check { display: flex !important; grid-auto-flow: column; align-items: center; gap: 8px; color: var(--text) !important; }
.hint { font-size: 12px; color: var(--dim); font-weight: 400; }
.err { color: var(--bad); font-size: 12.5px; }

/* modal + toast */
.modal-back { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { width: min(640px, 100%); max-height: 90vh; overflow: auto; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 0 40px var(--glow); }
.modal header { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; font-size: 17px; }
.modal header button { margin-left: auto; }
.modal .body { padding: 16px; }
.modal footer { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--panel); border: 1px solid var(--line-2); border-left: 4px solid var(--brand); border-radius: 8px; padding: 10px 14px; box-shadow: var(--shadow); max-width: 360px; }
.toast.bad { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }

/* board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.board.compact { grid-auto-columns: minmax(210px, 1fr); }
.col { background: #06122e; border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 200px; }
:root[data-theme="light"] .col { background: var(--panel-2); }
.col header { padding: 12px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.col header b { font-size: 16px; }
.col header small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; }
.col header .count { margin-left: auto; border: 1px solid var(--line-2); border-radius: 6px; padding: 0 8px; }
.col .cards { padding: 10px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.col.drop { outline: 2px dashed var(--brand-2); outline-offset: -4px; }
.tcard { border: 1px solid var(--line); border-radius: 9px; background: #0a1a3f; padding: 10px; display: flex; flex-direction: column; gap: 6px; cursor: grab; }
:root[data-theme="light"] .tcard { background: #fff; }
.tcard:hover { border-color: var(--line-2); }
.tcard.blocked { border-color: #8a1f2d; box-shadow: inset 3px 0 0 var(--bad); }
.tcard .key { font-weight: 800; font-family: var(--mono); font-size: 12.5px; }
.tcard .title { font-weight: 700; }
.tcard .desc { color: var(--muted); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tcard .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tcard .foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }

/* gates / checklists */
.gates { display: flex; flex-direction: column; gap: 2px; }
.gate { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid #0f2453; }
.gate .ico { width: 20px; height: 20px; flex: none; }
.gate.ok .ico { color: var(--ok); } .gate.bad .ico { color: var(--bad); } .gate.wait .ico { color: var(--dim); }
.gate .val { margin-left: auto; font-weight: 600; }
.gate.bad { background: #2a070d66; }
.bigver { font-family: var(--display); font-size: 30px; font-weight: 800; letter-spacing: .02em; }

.timeline { display: flex; flex-direction: column; }
.timeline .ev { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid #0f2453; }
.timeline .ev .when { margin-left: auto; color: var(--dim); font-size: 12px; white-space: nowrap; }
.timeline .ev .what { font-size: 12.5px; color: var(--muted); }

.integrations { display: flex; gap: 10px; overflow-x: auto; align-items: stretch; }
.integ { border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; display: flex; gap: 10px; align-items: center; min-width: 160px; background: #06112b; }
:root[data-theme="light"] .integ { background: var(--panel-2); }
.integ .ico { width: 24px; height: 24px; }
.integ small { display: block; font-size: 11px; }
.dotc { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; background: var(--bad); }
.dotc.ok { background: var(--ok); } .dotc.warn { background: var(--warn); }

pre.code { background: #020611; border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; font-family: var(--mono); font-size: 12.5px; white-space: pre; max-height: 60vh; }
:root[data-theme="light"] pre.code { background: #f5f8ff; }
.diff-add { color: #7ff0ae; } .diff-del { color: #ff99a4; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .panel { width: min(440px, 100%); text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; padding: 26px; }

.menu-toggle { display: none; }
@media (max-width: 1180px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px #000; }
  .menu-toggle { display: grid; }
  .brandmark b { font-size: 20px; } .brandmark small { display: none; }
  .search { display: none; }
  .me span { display: none; }
  .g3, .g2, .form .two { grid-template-columns: 1fr; }
  .content { padding: 12px 16px 20px; }
}
@media (max-width: 520px) { .g4 { grid-template-columns: 1fr; } .page-head h1 { font-size: 22px; } }
