:root {
  --brand: #0EAF4B;
  --brand-dark: #0A8A3B;
  --brand-tint: #EAF6EF;
  --brand-line: #BEE9CE;
  --ink: #12221A;
  --ink-2: #49604F;
  --line: #DDE7DF;
  --bg: #F5F8F6;
  --card: #FFFFFF;
  --danger: #C0392B;
  --warn: #B7791F;
  --blue: #1D6FB8;
  --violet: #6B46C1;
  --mono: "SF Mono", "Cascadia Mono", Consolas, monospace;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(18,34,26,.06), 0 4px 14px rgba(18,34,26,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #0A8A3B 0%, #0EAF4B 45%, #EAF6EF 45.2%, #F5F8F6 100%); }
.login-card { width: 380px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 32px; }
.login-card .brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.login-card .brand-row img { height: 34px; }
.login-card h1 { font-size: 20px; margin: 0 0 2px; }
.login-card .sub { color: var(--ink-2); font-size: 12.5px; margin-bottom: 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #fff; }
.field input:focus, .field select:focus { outline: 2px solid var(--brand-line); border-color: var(--brand); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border: 1px solid transparent; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; background: var(--brand); color: #fff; }
.btn:hover { background: var(--brand-dark); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand-dark); }
.btn.danger { background: #fff; color: var(--danger); border-color: #E8C4BE; }
.btn.danger:hover { background: #FDF3F1; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.err { color: var(--danger); font-size: 13px; margin: 8px 0; }
.demo-box { margin-top: 20px; border-top: 1px dashed var(--line); padding-top: 14px; font-size: 12px; color: var(--ink-2); }
.demo-box table { width: 100%; border-collapse: collapse; }
.demo-box td { padding: 3px 2px; }
.demo-box .mono { font-family: var(--mono); font-size: 11.5px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: #0D1F16; color: #CFE3D4; flex-shrink: 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { display: flex; align-items: center; gap: 9px; padding: 18px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand img { height: 26px; }
.sidebar .brand .name { color: #fff; font-weight: 700; font-size: 15px; letter-spacing: .02em; }
.sidebar .brand .sub { font-size: 10.5px; color: #7FA98C; text-transform: uppercase; letter-spacing: .08em; }
.nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.nav .group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #5F8A6C; padding: 14px 18px 5px; }
.nav a { display: flex; align-items: center; gap: 9px; padding: 8px 18px; color: #B9D1C0; text-decoration: none; font-size: 13.5px; border-left: 3px solid transparent; }
.nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav a.active { background: rgba(14,175,75,.15); border-left-color: var(--brand); color: #fff; }
.nav .dot { width: 7px; height: 7px; border-radius: 50%; background: #5F8A6C; flex-shrink: 0; }
.nav a.active .dot { background: var(--brand); }
.sidebar .user { border-top: 1px solid rgba(255,255,255,.08); padding: 12px 16px; font-size: 12px; }
.sidebar .user .who { color: #fff; font-weight: 600; }
.sidebar .user .role { color: #7FA98C; }
.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.topbar h2 { margin: 0; font-size: 19px; }
.topbar .crumb { font-size: 12px; color: var(--ink-2); }
.topbar .right { display: flex; gap: 8px; align-items: center; }

/* ---------- components ---------- */
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card h3 { margin: 0 0 12px; font-size: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h3 .hint { font-weight: 400; font-size: 11.5px; color: var(--ink-2); }
.kpi { padding: 14px 16px; }
.kpi .label { font-size: 11.5px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 3px; }
.kpi .value.small { font-size: 17px; }
.kpi .note { font-size: 11.5px; color: var(--ink-2); margin-top: 2px; }
.kpi .warn { color: var(--warn); }
.kpi .danger { color: var(--danger); }
.chip { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.chip.A { background: #E1F5E6; color: #0A7A34; }
.chip.B { background: #E8F4E9; color: #2E7D46; }
.chip.C { background: #FDF3D7; color: #8A6D1A; }
.chip.D { background: #FCE8D8; color: #B35E1D; }
.chip.E { background: #FBE3E0; color: #B03224; }
.chip.F { background: #F6D6D2; color: #9C2B1F; }
.chip.UNSCORED, .chip.none { background: #EDF1EE; color: #6B7A70; }
.chip.ok { background: #E1F5E6; color: #0A7A34; }
.chip.no { background: #FBE3E0; color: #B03224; }
.chip.small { font-size: 10px; padding: 1px 6px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); padding: 7px 9px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px 9px; border-bottom: 1px solid #EDF2EE; vertical-align: top; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover { background: var(--brand-tint); }
.tbl .num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }
.bar-row { display: flex; align-items: center; gap: 8px; margin: 5px 0; font-size: 12.5px; }
.bar-row .lbl { width: 130px; color: var(--ink-2); flex-shrink: 0; }
.bar-row .track { flex: 1; background: #EDF2EE; border-radius: 5px; height: 14px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--brand); border-radius: 5px; }
.bar-row .fill.warn { background: var(--warn); }
.bar-row .fill.danger { background: var(--danger); }
.bar-row .val { width: 52px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.rail { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.rail .lbl { width: 140px; font-size: 12.5px; color: var(--ink-2); flex-shrink: 0; }
.rail .track { position: relative; flex: 1; height: 16px; background: #EDF2EE; border-radius: 8px; }
.rail .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 8px; background: var(--brand); }
.rail .fill.over { background: var(--danger); }
.rail .tick { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .5; }
.rail .val { width: 56px; text-align: right; font-size: 12px; font-weight: 600; }
.notice { border: 1px solid var(--brand-line); background: var(--brand-tint); border-radius: 8px; padding: 10px 13px; font-size: 12.5px; color: #0F5E2E; margin: 10px 0; }
.notice.warn { border-color: #F0DCA8; background: #FDF7E7; color: #7A5D10; }
.notice.danger { border-color: #E8C4BE; background: #FDF3F1; color: #9C2B1F; }
.notice.mono-text { font-family: var(--mono); font-size: 12px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.status-pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; background: #EDF1EE; color: #55685C; }
.status-pill.application { background: #E8F0FA; color: #1D6FB8; }
.status-pill.conditions_pending { background: #FDF3D7; color: #8A6D1A; }
.status-pill.approved { background: #E1F5E6; color: #0A7A34; }
.status-pill.disbursed { background: #EDE9FB; color: #6B46C1; }
.status-pill.repaying { background: #E1F5E6; color: #0A7A34; }
.status-pill.settled { background: #E1F5E6; color: #0A7A34; }
.status-pill.defaulted { background: #FBE3E0; color: #B03224; }
.status-pill.submitted { background: #E8F0FA; color: #1D6FB8; }
.status-pill.paid { background: #E1F5E6; color: #0A7A34; }
.status-pill.committed, .status-pill.active { background: #E1F5E6; color: #0A7A34; }
.status-pill.draft { background: #EDF1EE; color: #55685C; }
.status-pill.deployed { background: #E1F5E6; color: #0A7A34; }
.status-pill.rejected, .status-pill.retired { background: #FBE3E0; color: #B03224; }
.status-pill.in_review, .status-pill.approved-model { background: #FDF3D7; color: #8A6D1A; }
.steps { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.step { border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; font-size: 12.5px; display: flex; gap: 7px; align-items: center; }
.step.done { background: var(--brand-tint); border-color: var(--brand-line); }
.step .tick { color: var(--brand); font-weight: 800; }
.hero { display: flex; gap: 14px; align-items: center; padding: 18px 20px; }
.hero .ring { width: 74px; height: 74px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 800; color: #fff; flex-shrink: 0; }
.hero .title { font-size: 17px; font-weight: 700; }
.hero .meta { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }
.hero .meta .mono { margin-right: 10px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters input, .filters select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.filters input[type=search] { min-width: 260px; }
.empty { text-align: center; color: var(--ink-2); padding: 30px 10px; font-size: 13px; }
.tag { display: inline-block; background: #EDF1EE; border-radius: 4px; padding: 1px 6px; font-size: 11px; color: #55685C; font-family: var(--mono); margin-right: 4px; }
.progress { height: 8px; background: #EDF2EE; border-radius: 5px; overflow: hidden; min-width: 90px; }
.progress .fill { height: 100%; background: var(--brand); border-radius: 5px; }
.switch-role { font-size: 12px; }
.gsearch { position: relative; }
.gsearch input { width: 240px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 20px; font-size: 13px; background: #fff; }
.gsearch input:focus { outline: 2px solid var(--brand-line); }
.gresults { position: absolute; top: 40px; right: 0; width: 360px; max-height: 420px; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 30px rgba(18,34,26,.14); z-index: 50; padding: 6px; }
.gs-item { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); font-size: 13px; }
.gs-item:hover { background: var(--brand-tint); }
.gs-icon { width: 28px; height: 28px; border-radius: 50%; background: #EDF2EE; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.gs-empty { padding: 14px; text-align: center; color: var(--ink-2); font-size: 12.5px; }
.bellwrap { position: relative; }
.bell { position: relative; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 15px; }
.bellcount { display: none; position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; min-width: 17px; height: 17px; border-radius: 9px; align-items: center; justify-content: center; padding: 0 4px; }
.bellcount.show { display: flex; }
.notifdrawer { position: absolute; top: 46px; right: 0; width: 340px; max-height: 440px; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 30px rgba(18,34,26,.14); z-index: 50; }
.nd-head { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); padding: 10px 14px; border-bottom: 1px solid var(--line); }
.nd-item { display: block; padding: 10px 14px; text-decoration: none; color: var(--ink); font-size: 12.5px; border-bottom: 1px solid #F0F4F1; }
.nd-item.unread { background: var(--brand-tint); }
.nd-item:hover { background: #F0F6F2; }
.rolemenu { position: relative; }
.userchip { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--brand-line); background: var(--brand); color: #fff; font-weight: 800; font-size: 13px; cursor: pointer; }
.rmenu { position: absolute; top: 46px; right: 0; width: 230px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 30px rgba(18,34,26,.14); z-index: 50; padding: 6px; }
.rmenu-head { padding: 8px 12px; font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.rmenu-item { display: block; padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); font-size: 13px; }
.rmenu-item:hover { background: var(--brand-tint); }
.loading { text-align: center; color: var(--ink-2); padding: 60px 0; font-size: 13.5px; }
@media (max-width: 900px) { .sidebar { width: 60px; } .sidebar .brand .name, .sidebar .nav a span, .sidebar .user { display: none; } .main { padding: 14px; } }
/* ---------- configuration studio ---------- */
.config-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.config-nav-item { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-size: 13px; color: var(--ink); }
.config-nav-item:hover { border-color: var(--brand-line); background: var(--brand-tint); }
.config-nav-item.on { border-color: var(--brand); background: var(--brand-tint); box-shadow: inset 3px 0 0 var(--brand); }
.config-nav-label { font-weight: 600; }
.json-view { background: #F7FAF8; border: 1px solid var(--line); border-radius: 10px; padding: 14px; font-family: var(--mono); font-size: 12px; line-height: 1.6; overflow: auto; max-height: 560px; white-space: pre-wrap; word-break: break-word; }
.json-editor { width: 100%; background: #F7FAF8; border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-family: var(--mono); font-size: 12px; line-height: 1.6; min-height: 380px; resize: vertical; color: var(--ink); }
.json-editor:focus { outline: none; border-color: var(--brand); }
