:root {
  --ink: #0B2B26; --ink-2: #3E5652; --muted: #6B7D7A; --line: #DCE5E3; --line-2: #EEF3F2;
  --bg: #F5F8F7; --card: #FFFFFF; --teal: #018A7C; --teal-d: #016E63; --mint: #14E0BD; --mint-l: #E3FBF6;
  --red: #C2412D; --red-l: #FBEAE7; --amber: #A86A00; --amber-l: #FDF3DF; --blue: #2C62B8; --blue-l: #E8F0FB;
  --r: 8px; --shadow: 0 1px 2px rgba(11,43,38,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #CFE0DD; padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.side .brand { display: block; padding: 4px 8px 18px; }
.side .brand img { width: 150px; filter: brightness(0) invert(1); opacity: .95; }
.side nav a { display: flex; align-items: center; gap: 10px; color: #CFE0DD; padding: 8px 10px; border-radius: 6px; font-weight: 500; }
.side nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.side nav a.on { background: rgba(20,224,189,.14); color: var(--mint); }
.side nav .sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 4px; }
.side .me { margin-top: auto; font-size: 12px; padding: 8px 10px; color: #9DB5B1; }
.side .me form { display: inline; }
.side .me button { background: none; border: 0; color: #9DB5B1; padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }
.main { padding: 22px 28px 60px; min-width: 0; }
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.top .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* cards & grid */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card > h2:first-child { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 24px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--muted); }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #FAFCFB; }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 650; border-top: 2px solid var(--line); }
.table-wrap { overflow-x: auto; }
td.actions { white-space: nowrap; text-align: right; }

/* forms */
label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid #C9D6D3; border-radius: 6px; font: inherit; color: var(--ink); background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--mint); outline-offset: -1px; border-color: var(--teal); }
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 12px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline .field { margin-bottom: 0; }
form.inline-form { display: inline; }
.check { display: flex; gap: 6px; align-items: center; font-weight: 500; font-size: 13px; }
.check input { width: auto; }
.help { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 6px; border: 1px solid var(--teal); background: var(--teal); color: #fff; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--teal-d); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--teal); }
.btn.ghost:hover { background: var(--mint-l); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--ink-2); padding: 4px 8px; font-weight: 500; }
.btn.quiet:hover { background: var(--line-2); }
.btn.danger { background: #fff; color: var(--red); border-color: #E6B8AF; }
.btn.danger:hover { background: var(--red-l); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* pills */
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--mint-l); color: var(--teal-d); }
.pill.warn { background: var(--amber-l); color: var(--amber); }
.pill.bad { background: var(--red-l); color: var(--red); }
.pill.info { background: var(--blue-l); color: var(--blue); }

/* flash */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; border: 1px solid; }
.flash.ok { background: var(--mint-l); border-color: #A6EEDF; color: var(--teal-d); }
.flash.error { background: var(--red-l); border-color: #EDC2BA; color: var(--red); }
.flash.warn { background: var(--amber-l); border-color: #EFD39C; color: var(--amber); }

/* stage bar */
.stagebar { display: flex; gap: 3px; margin: 10px 0 2px; flex-wrap: wrap; }
.stagebar form, .stagebar a { flex: 1 1 0; min-width: 80px; display: flex; }
.stagebar button { width: 100%; height: 100%; border: 0; padding: 7px 4px; font: inherit; font-size: 11.5px; font-weight: 600; background: var(--line-2); color: var(--muted); cursor: pointer; border-radius: 4px; }
.stagebar button.done { background: #BFF3E8; color: var(--teal-d); }
.stagebar button.cur { background: var(--teal); color: #fff; }
.stagebar button:hover { outline: 2px solid var(--mint); }

/* pipeline board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: 230px; gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.col { background: #EAF0EF; border-radius: var(--r); padding: 10px; min-height: 200px; }
.col h3 { display: flex; justify-content: space-between; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); margin-bottom: 10px; }
.tile { display: block; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; margin-bottom: 8px; color: var(--ink); }
.tile:hover { border-color: var(--teal); text-decoration: none; }
.tile .n { font-weight: 600; }
.tile .m { font-size: 12px; color: var(--muted); margin-top: 3px; }
.tile .due { color: var(--red); font-weight: 600; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.list li:last-child { border-bottom: 0; }
.opp li { display: flex; gap: 8px; align-items: flex-start; }
.opp .lvl { flex: none; margin-top: 2px; }
.activity li { font-size: 13px; }
.activity .when { color: var(--muted); font-size: 11.5px; }
.activity .note { background: #FFFBEA; border-left: 3px solid #F1C84B; padding: 6px 8px; border-radius: 3px; }

/* policy block */
.policy { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 14px; background: #fff; }
.policy > header { padding: 12px 14px; border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; background: #FAFCFB; border-radius: var(--r) var(--r) 0 0; }
.policy .body { padding: 12px 14px; }
.docs td { padding: 6px 8px; font-size: 13px; }
details > summary { cursor: pointer; color: var(--teal); font-weight: 600; font-size: 13px; padding: 4px 0; }
details[open] > summary { margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.big-savings { font-size: 28px; font-weight: 700; color: var(--teal); font-variant-numeric: tabular-nums; }
pre.json { background: #F7FAF9; border: 1px solid var(--line); padding: 10px; border-radius: 6px; max-height: 300px; overflow: auto; font-size: 12px; }

.login { max-width: 360px; margin: 12vh auto; }
.login img { width: 200px; display: block; margin: 0 auto 24px; }

@media (max-width: 1100px) { .cols-main { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side nav { display: flex; flex-wrap: wrap; } .side .me { margin: 0; }
  .main { padding: 16px; } .g2, .g3, .g4 { grid-template-columns: 1fr; }
}

.side nav .badge { margin-left: auto; background: var(--mint); color: var(--ink); border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.task { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.task:last-child { border-bottom: 0; }
.task .tick button { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #9FB4B0; background: #fff; cursor: pointer; padding: 0; margin-top: 1px; }
.task .tick button:hover { border-color: var(--teal); background: var(--mint-l); }
.task.done .tick button { background: var(--teal); border-color: var(--teal); }
.task.done .t { text-decoration: line-through; color: var(--muted); }
.task .body { flex: 1; min-width: 0; }
.task .meta { font-size: 12px; color: var(--muted); }
.task .edit { display: flex; gap: 6px; align-items: center; }
.task .edit select, .task .edit input { padding: 3px 6px; font-size: 12px; width: auto; }
.grp-h { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; margin: 4px 0 2px; }
.path { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; background: var(--line-2); padding: 3px 6px; border-radius: 4px; word-break: break-all; user-select: all; }
