/* ZoneSampo EOS — application styles (no framework) */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f0f2f5; --border: #e1e5ea; --text: #1a1f29; --muted: #66707f;
  --brand: #0f3d5e; --brand-2: #1c6ea4; --accent: #e8a33d; --ok: #1f8a4c; --warn: #c58a12; --bad: #c62f2f; --info: #1c6ea4;
  --ok-bg: #e3f4ea; --warn-bg: #fdf1d9; --bad-bg: #fbe3e3; --muted-bg: #eef0f3;
  --side: #0f1c2b; --side-text: #cfd8e3; --side-active: #1c6ea4;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f141b; --surface: #171e27; --surface-2: #1d2631; --border: #2a3542; --text: #e6ebf1; --muted: #93a0b0;
    --ok-bg: #123726; --warn-bg: #3b2c0c; --bad-bg: #3d1616; --muted-bg: #222c37; --side: #0b1118; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--brand-2); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; } h2 { font-size: 1.05rem; margin: 0 0 .75rem; } h3 { font-size: .95rem; margin: 0 0 .5rem; }
p { margin: 0 0 .6rem; } code, .mono { font-family: var(--mono); font-size: .85em; }
small, .small { font-size: .8rem; } .muted { color: var(--muted); }
.boot { padding: 3rem; color: var(--muted); text-align: center; }

/* layout */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidenav { flex: 1; padding: .75rem .5rem; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 700; padding: .6rem .75rem 1rem; font-size: 1.05rem; }
.logo { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--brand-2), var(--accent)); color: #fff; font-weight: 800; letter-spacing: .5px; }
.nav-group { margin: .5rem 0 .9rem; }
.nav-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #7f8ea0; padding: .25rem .75rem; }
.sidenav a:not(.brand) { display: block; padding: .45rem .75rem; border-radius: 7px; color: var(--side-text); margin: 1px 0; }
.sidenav a:not(.brand):hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidenav a.active { background: var(--side-active); color: #fff; }
.userbox { padding: .75rem; border-top: 1px solid rgba(255,255,255,.08); }
.userbox .user { color: #fff; }
.content { min-width: 0; }
.topbar { display: flex; align-items: center; gap: .75rem; padding: .5rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.menu-toggle { display: none; }
.outlet { padding: 1.25rem; }
.page { max-width: 1400px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: -260px; width: 240px; transition: left .2s; z-index: 50; }
  body.nav-open .side { left: 0; }
  .menu-toggle { display: inline-block; }
  .outlet { padding: .75rem; }
}

/* cards & kpis */
.card { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
.stack > .card { margin-bottom: 1rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .8rem; border-left: 4px solid var(--border); }
.kpi.ok { border-left-color: var(--ok); } .kpi.warn { border-left-color: var(--warn); } .kpi.bad { border-left-color: var(--bad); }
.kpi-value { font-size: 1.35rem; font-weight: 700; line-height: 1.1; } .kpi-label { color: var(--muted); font-size: .78rem; margin-top: .2rem; }
.countdown { text-align: right; } .countdown .kpi-value { font-size: 2.2rem; color: var(--brand-2); }
.bar { height: 8px; background: var(--muted-bg); border-radius: 4px; overflow: hidden; min-width: 60px; } .bar-fill { height: 100%; background: var(--brand-2); }
.notice { background: var(--warn-bg); border: 1px solid var(--warn); border-radius: 8px; padding: .5rem .75rem; }
.notice.warn { color: var(--text); }
.ok-text { color: var(--ok); } .bad-text { color: var(--bad); }

/* pills */
.pill { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .74rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.pill.muted { background: var(--muted-bg); color: var(--muted); border-color: transparent; }

/* tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table.grid { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.grid th, table.grid td { padding: .5rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.grid thead th { background: var(--surface-2); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); position: sticky; top: 0; z-index: 1; }
table.grid tbody tr:hover { background: var(--surface-2); }
table.grid tbody tr { cursor: pointer; } table.grid.compact tbody tr, .sheet-table tbody tr { cursor: default; }
table.grid.compact th, table.grid.compact td { padding: .35rem .5rem; }
table.grid tr.overdue td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
table.grid tr.total td, table.grid tr.total th { font-weight: 700; border-top: 2px solid var(--border); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.neg { color: var(--bad); }
td.wrap { white-space: normal; min-width: 240px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 420px; }
th.row-head { text-align: left; font-weight: 600; white-space: nowrap; }
td.actions, th.actions { width: 1%; white-space: nowrap; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .75rem; }
.toolbar .input[type=search] { min-width: 220px; }
.facets { display: flex; gap: .4rem; flex-wrap: wrap; }
.facets select { max-width: 200px; }

/* scorecard */
.sticky-first table th.row-head { position: sticky; left: 0; background: var(--surface); z-index: 2; }
table.scorecard td.num { cursor: pointer; min-width: 3.4rem; }
table.scorecard th.current { background: var(--brand-2); color: #fff; }
.st-green { background: var(--ok-bg) !important; } .st-yellow { background: var(--warn-bg) !important; } .st-red { background: var(--bad-bg) !important; }
td.computed, .sw.computed { background: var(--muted-bg); color: var(--muted); font-style: italic; }
.legend { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--muted); margin: .5rem 0; flex-wrap: wrap; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: .5rem; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: .5rem .9rem; cursor: pointer; color: var(--muted); font: inherit; }
.tab.active { color: var(--brand-2); border-bottom-color: var(--brand-2); font-weight: 600; }

/* forms */
.input { width: 100%; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); font: inherit; }
.input:focus { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: var(--brand-2); }
.input.small { padding: .25rem .4rem; font-size: .82rem; width: auto; }
.input.cell { width: 7.5rem; text-align: right; }
.input.code { font-size: 1.4rem; letter-spacing: .3em; text-align: center; font-family: var(--mono); }
textarea.input { resize: vertical; }
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .6rem; }
.field > span { font-size: .78rem; font-weight: 600; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .span2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.btn { display: inline-flex; align-items: center; gap: .3rem; padding: .45rem .8rem; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; } .btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: var(--bad); } .btn.danger:not(.ghost) { background: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: .25rem .55rem; font-size: .8rem; }
.btn.block { width: 100%; justify-content: center; margin-top: .5rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; align-items: center; } .row.gap { gap: .5rem; } .row.end { justify-content: flex-end; } .row.between { justify-content: space-between; } .row.wrap { flex-wrap: wrap; }

/* modal & toast */
.modal-overlay { position: fixed; inset: 0; background: rgba(10, 15, 25, .5); display: grid; place-items: center; z-index: 100; padding: 1rem; }
.modal { background: var(--surface); border-radius: 12px; width: min(560px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(880px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-body { padding: 1rem; }
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .4rem; z-index: 200; }
.toast { background: var(--text); color: var(--bg); padding: .6rem .9rem; border-radius: 8px; opacity: 0; transform: translateY(8px); transition: all .25s; max-width: 380px; }
.toast.show { opacity: 1; transform: none; } .toast.ok { background: var(--ok); color: #fff; } .toast.err { background: var(--bad); color: #fff; }

/* auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(1200px 600px at 20% -10%, rgba(28,110,164,.25), transparent), var(--bg); }
.auth-brand { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.2rem; justify-content: center; } .auth-brand h1 { margin: 0; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.5rem; width: min(420px, 100%); box-shadow: var(--shadow); }
.auth-wrap > div { width: min(420px, 100%); }
.qr { display: grid; place-items: center; margin: .5rem 0 1rem; } .qr svg { max-width: 220px; height: auto; border: 8px solid #fff; border-radius: 8px; }
.secret { display: block; word-break: break-all; margin: .5rem 0; padding: .4rem; background: var(--surface-2); border-radius: 6px; }

/* dashboard / l10 */
.list { padding-left: 1.1rem; margin: 0; } .list li { margin-bottom: .4rem; } .list.compact li { margin-bottom: .2rem; font-size: .86rem; }
.gates { list-style: none; padding: 0; margin: 0; } .gates li { display: grid; grid-template-columns: 1.6rem 1fr auto auto; gap: .5rem; align-items: center; padding: .3rem 0; border-bottom: 1px solid var(--border); }
.gate-seq { display: inline-grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--surface-2); font-size: .72rem; font-weight: 700; }
.l10-cols { grid-template-columns: 300px 1fr; } @media (max-width: 900px) { .l10-cols { grid-template-columns: 1fr; } }
.agenda { list-style: none; padding: 0; margin: 0; } .agenda li { display: flex; gap: .6rem; padding: .5rem; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.agenda li.active { background: var(--surface-2); border-color: var(--brand-2); } .agenda li.done { opacity: .55; }
.agenda-min { min-width: 2.2rem; font-weight: 700; color: var(--brand-2); }
.clock { font-family: var(--mono); font-size: 1.4rem; font-weight: 700; min-width: 5rem; text-align: right; } .clock.over { color: var(--bad); }

/* workbook */
.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .6rem; }
.sheet-card { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .8rem; color: var(--text); }
.sheet-card:hover { border-color: var(--brand-2); text-decoration: none; }
.sheet-code { font-family: var(--mono); font-weight: 700; color: var(--brand-2); }
.sheet { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; }
.sheet-heading { margin: 1.2rem 0 .5rem; padding-bottom: .25rem; border-bottom: 2px solid var(--brand-2); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-2); }
.sheet-text { white-space: pre-wrap; }
.kv { display: grid; grid-template-columns: minmax(160px, 220px) 1fr; gap: .3rem .8rem; padding: .3rem 0; border-bottom: 1px dashed var(--border); }
.kv-key { font-weight: 600; } .kv-val { white-space: pre-wrap; }
.kv:has(> .kv-val:nth-child(3)) { grid-template-columns: minmax(160px, 220px) repeat(auto-fit, minmax(160px, 1fr)); }
.cell[contenteditable="true"] { display: block; min-width: 2rem; min-height: 1.2em; border-radius: 4px; padding: 0 2px; }
.cell[contenteditable="true"]:focus { outline: 2px solid var(--brand-2); background: var(--surface-2); }
.sheet-table td { white-space: pre-wrap; min-width: 8rem; }
pre.json { font-size: .75rem; background: var(--surface-2); padding: .5rem; border-radius: 6px; max-height: 50vh; overflow: auto; }
