:root {
  --ink: #172521;
  --muted: #66736e;
  --line: #dfe6e2;
  --paper: #ffffff;
  --canvas: #f4f7f5;
  --green-950: #0d3025;
  --green-900: #123c2f;
  --green-800: #195540;
  --green-700: #217052;
  --green-100: #e0f1e9;
  --green-50: #eff8f4;
  --lime: #c9ee6a;
  --gold: #e8a52d;
  --gold-100: #fff1d3;
  --blue: #2878c8;
  --blue-100: #e9f3ff;
  --red: #c9443a;
  --red-100: #fff0ee;
  --shadow: 0 8px 30px rgba(20, 47, 37, .08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
button, select, input { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 242px 1fr; }
.sidebar {
  background: var(--green-950);
  color: #fff;
  padding: 24px 14px 18px;
  position: fixed;
  inset: 0 auto 0 0;
  width: 242px;
  display: flex;
  flex-direction: column;
  z-index: 30;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 10px 26px; }
.brand-mark {
  width: 39px; height: 39px; border-radius: 12px; display: grid; place-items: center;
  background: var(--lime); color: var(--green-950); font: 800 21px/1 Georgia, serif;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);
}
.brand strong { font-family: Georgia, serif; font-size: 19px; letter-spacing: -.2px; }
.brand span { display: block; color: #9bb5ab; font-size: 10px; margin-top: 4px; letter-spacing: .04em; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  width: 100%; border: 0; background: transparent; color: #b9cbc4; text-align: left;
  display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 10px;
  font-size: 13px; font-weight: 600; transition: .18s ease;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: #fff; color: var(--green-950); box-shadow: 0 4px 15px rgba(0,0,0,.12); }
.nav-icon { width: 19px; text-align: center; font-size: 17px; }
.nav-count { margin-left: auto; min-width: 20px; height: 20px; border-radius: 999px; display: grid; place-items: center; background: var(--lime); color: var(--green-950); font-size: 10px; }
.nav-divider { height: 1px; background: rgba(255,255,255,.09); margin: 13px 8px; }
.sidebar-foot { margin-top: auto; padding: 14px 12px 2px; border-top: 1px solid rgba(255,255,255,.09); }
.sidebar-foot p { color: #819b91; font-size: 10px; margin: 5px 0 0 17px; }
.environment { font-size: 11px; color: #bcd0c8; }
.environment span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; background: var(--lime); box-shadow: 0 0 0 3px rgba(201,238,106,.12); }

.main { grid-column: 2; min-width: 0; }
.topbar {
  height: 72px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 30px; position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(12px);
}
.crumbs { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.crumbs span { color: var(--muted); }
.crumbs b { color: #b9c2bd; font-weight: 400; }
.top-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.icon-btn { position: relative; border: 1px solid var(--line); background: #fff; color: var(--ink); width: 38px; height: 38px; border-radius: 11px; }
.icon-btn:hover { border-color: #a7b8b0; }
.dot { position: absolute; width: 7px; height: 7px; border-radius: 50%; right: 8px; top: 7px; background: var(--red); border: 1px solid #fff; }
.role-switch { display: flex; align-items: center; gap: 9px; border-left: 1px solid var(--line); padding-left: 14px; }
.role-switch span { font-size: 10px; color: var(--muted); }
.role-switch select { border: 0; color: var(--ink); background: transparent; font-weight: 700; font-size: 12px; outline: 0; max-width: 210px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--green-100); color: var(--green-800); font-size: 11px; font-weight: 800; }
.menu-btn { display: none; margin-right: 12px; }
.content { padding: 28px 30px 50px; max-width: 1480px; margin: 0 auto; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
.eyebrow { display: flex; align-items: center; gap: 8px; color: var(--green-700); font-weight: 800; font-size: 10px; text-transform: uppercase; letter-spacing: .11em; margin-bottom: 7px; }
.eyebrow::before { content: ""; width: 18px; height: 2px; background: var(--lime); }
h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(28px, 3vw, 40px); line-height: 1.08; letter-spacing: -.035em; margin: 0; color: var(--green-950); }
.page-head p { color: var(--muted); font-size: 13px; margin: 9px 0 0; max-width: 700px; line-height: 1.55; }
.page-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn {
  border: 0; border-radius: 10px; padding: 10px 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 800; font-size: 12px; transition: .16s ease; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--green-900); color: #fff; box-shadow: 0 6px 14px rgba(18,60,47,.18); }
.btn-primary:hover { background: var(--green-800); }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost { background: transparent; color: var(--green-700); padding-inline: 4px; }
.btn-danger { background: var(--red-100); color: var(--red); }
.btn:disabled { cursor: not-allowed; opacity: .45; transform: none; }

.demo-banner {
  background: linear-gradient(120deg, var(--green-950), #1d624a);
  color: #fff; border-radius: 18px; padding: 24px 26px; display: grid; grid-template-columns: 1.2fr 1fr auto; align-items: center; gap: 26px;
  margin-bottom: 20px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.demo-banner::after { content: ""; position: absolute; width: 210px; height: 210px; border-radius: 50%; border: 42px solid rgba(201,238,106,.08); right: -50px; top: -112px; }
.demo-banner .kicker { color: var(--lime); font-size: 10px; text-transform: uppercase; letter-spacing: .11em; font-weight: 800; }
.demo-banner h2 { font-family: Georgia, serif; font-size: 23px; margin: 6px 0 7px; letter-spacing: -.02em; }
.demo-banner p { color: #bdd0c8; font-size: 12px; margin: 0; line-height: 1.55; }
.demo-banner .btn { position: relative; z-index: 2; background: var(--lime); color: var(--green-950); }
.progress-mini { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.progress-mini span { height: 5px; border-radius: 99px; background: rgba(255,255,255,.16); }
.progress-mini span.done { background: var(--lime); }
.progress-copy { color: #c5d7d0; font-size: 10px; margin-top: 8px; display: flex; justify-content: space-between; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat, .card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 2px 10px rgba(17,43,33,.025); }
.stat { padding: 17px 18px; }
.stat-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 10px; font-weight: 700; }
.stat-icon { width: 29px; height: 29px; border-radius: 9px; display: grid; place-items: center; background: var(--green-50); color: var(--green-700); font-size: 14px; }
.stat-value { font: 700 25px/1.2 Georgia, serif; color: var(--green-950); margin: 10px 0 4px; }
.stat-foot { color: var(--muted); font-size: 10px; }
.delta-up { color: var(--green-700); font-weight: 800; }
.delta-warn { color: #a76b08; font-weight: 800; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .8fr); gap: 16px; }
.grid-even { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.card { padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 14px; color: var(--ink); }
.card-head p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.tag { border-radius: 999px; padding: 5px 8px; font-size: 9px; font-weight: 800; display: inline-flex; align-items: center; gap: 5px; }
.tag::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.tag-green { background: var(--green-100); color: var(--green-700); }
.tag-gold { background: var(--gold-100); color: #a56c0e; }
.tag-blue { background: var(--blue-100); color: var(--blue); }
.tag-red { background: var(--red-100); color: var(--red); }
.tag-gray { background: #eef1ef; color: #66736e; }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .06em; text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 13px 8px; border-bottom: 1px solid #edf1ef; vertical-align: middle; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable:hover { background: var(--green-50); cursor: pointer; }
.strong { font-weight: 800; color: var(--green-950); }
.sub { display: block; color: var(--muted); font-size: 9px; margin-top: 3px; }
.amount { font-variant-numeric: tabular-nums; font-weight: 700; }
.text-right { text-align: right; }

.activity { display: flex; gap: 11px; padding: 11px 0; border-bottom: 1px solid #edf1ef; }
.activity:last-child { border-bottom: 0; }
.activity-dot { width: 9px; height: 9px; margin-top: 3px; border-radius: 50%; background: var(--green-700); box-shadow: 0 0 0 4px var(--green-100); flex: 0 0 auto; }
.activity-dot.warn { background: var(--gold); box-shadow: 0 0 0 4px var(--gold-100); }
.activity p { margin: 0; font-size: 11px; line-height: 1.45; }
.activity time { color: var(--muted); font-size: 9px; display: block; margin-top: 3px; }

.chart { height: 150px; display: flex; align-items: flex-end; gap: 9px; padding-top: 20px; border-bottom: 1px solid var(--line); }
.bar-wrap { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 7px; }
.bar { width: min(28px, 70%); background: linear-gradient(to top, var(--green-900), #4d9877); border-radius: 5px 5px 0 0; min-height: 8px; transition: height .5s ease; }
.bar.current { background: var(--lime); outline: 1px solid #b4d85b; }
.bar-wrap label { font-size: 8px; color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filter { border: 1px solid var(--line); background: #fff; color: var(--muted); padding: 7px 11px; border-radius: 9px; font-size: 10px; font-weight: 700; }
.filter.active { background: var(--green-900); border-color: var(--green-900); color: #fff; }
.search { min-width: 220px; flex: 1; max-width: 340px; border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; background: #fff; font-size: 11px; outline: none; }
.search:focus { border-color: var(--green-700); box-shadow: 0 0 0 3px var(--green-50); }

.workflow { display: grid; grid-template-columns: repeat(7, minmax(85px,1fr)); gap: 0; margin: 6px 0 22px; overflow-x: auto; padding-bottom: 5px; }
.step { min-width: 85px; position: relative; text-align: center; padding: 0 4px; }
.step::after { content: ""; position: absolute; height: 2px; background: var(--line); top: 15px; left: 50%; width: 100%; z-index: 0; }
.step:last-child::after { display: none; }
.step-circle { position: relative; z-index: 1; margin: 0 auto 7px; width: 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; background: #fff; border: 2px solid var(--line); color: var(--muted); font-size: 10px; font-weight: 800; }
.step.done .step-circle { background: var(--green-900); border-color: var(--green-900); color: #fff; }
.step.active .step-circle { background: var(--lime); border-color: var(--lime); color: var(--green-950); box-shadow: 0 0 0 5px rgba(201,238,106,.2); }
.step.done::after { background: var(--green-900); }
.step strong { display: block; font-size: 9px; }
.step span { display: block; font-size: 8px; color: var(--muted); margin-top: 3px; }

.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 16px; }
.detail-cell { padding: 13px; border-right: 1px solid var(--line); background: #fafcfb; }
.detail-cell:last-child { border-right: 0; }
.detail-cell label { display: block; color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 5px; }
.detail-cell strong { font-size: 11px; }
.quantity-input { width: 70px; border: 1px solid var(--line); border-radius: 7px; padding: 7px; text-align: right; }
.reason-select { border: 1px solid var(--line); border-radius: 7px; padding: 7px; color: var(--ink); background: #fff; max-width: 160px; }
.callout { border-left: 3px solid var(--blue); background: var(--blue-100); border-radius: 0 10px 10px 0; padding: 12px 14px; font-size: 10px; color: #245c91; line-height: 1.5; }
.callout.warn { border-color: var(--gold); background: var(--gold-100); color: #79520f; }

.money-flow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.money-node { padding: 15px; border: 1px solid var(--line); border-radius: 12px; position: relative; background: #fff; }
.money-node::after { content: "→"; position: absolute; right: -18px; top: 50%; transform: translateY(-50%); color: #98a69f; font-weight: 800; z-index: 2; }
.money-node:last-child::after { display:none; }
.money-node span { color: var(--muted); font-size: 9px; }
.money-node strong { display: block; font-size: 12px; margin: 6px 0 4px; }
.money-node small { color: var(--muted); font-size: 8px; }

.score-ring { width: 128px; height: 128px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto; background: conic-gradient(var(--green-700) 0 94%, var(--green-100) 94%); position: relative; }
.score-ring::before { content: ""; position: absolute; inset: 12px; background: #fff; border-radius: 50%; }
.score-ring div { position: relative; text-align: center; }
.score-ring strong { display: block; font: 700 28px/1 Georgia, serif; color: var(--green-950); }
.score-ring span { font-size: 9px; color: var(--muted); }
.metric-row { display: grid; grid-template-columns: 1fr 2fr 42px; align-items: center; gap: 9px; margin: 13px 0; font-size: 10px; }
.metric-track { height: 7px; border-radius: 99px; background: #eef1ef; overflow: hidden; }
.metric-fill { height: 100%; border-radius: inherit; background: var(--green-700); }
.metric-row strong { text-align: right; }

.timeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; }
.phase { border: 1px solid var(--line); border-radius: 12px; padding: 14px; min-height: 112px; background: #fff; }
.phase.active { border-color: var(--green-700); box-shadow: inset 0 3px 0 var(--lime); }
.phase span { color: var(--green-700); font: 700 18px Georgia, serif; }
.phase strong { display: block; font-size: 10px; margin: 7px 0; }
.phase p { color: var(--muted); font-size: 9px; line-height: 1.5; margin: 0; }

.arch { display: grid; grid-template-columns: 1fr 42px 1fr 42px 1fr; gap: 8px; align-items: center; margin: 18px 0; }
.arch-node { padding: 18px 12px; border: 1px solid var(--line); border-radius: 13px; text-align: center; background: #fff; }
.arch-node.primary { background: var(--green-950); color: #fff; border-color: var(--green-950); }
.arch-node strong { display: block; font-size: 12px; }
.arch-node span { display: block; color: var(--muted); font-size: 9px; margin-top: 5px; }
.arch-node.primary span { color: #aec5bc; }
.arch-arrow { color: var(--green-700); text-align: center; font-weight: 800; font-size: 18px; }
.sync-log { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; background: var(--green-950); color: #cee3d9; padding: 14px; border-radius: 11px; line-height: 1.8; overflow-x: auto; }
.sync-ok { color: var(--lime); }

.permission-grid th:first-child, .permission-grid td:first-child { position: sticky; left: 0; background: #fff; }
.permission-cell { text-align: center; }
.check { color: var(--green-700); font-weight: 900; }
.dash { color: #b4beb9; }

.empty { padding: 45px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 13px; margin-bottom: 5px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(10,34,26,.52); display: grid; place-items: center; padding: 20px; backdrop-filter: blur(3px); }
.modal-backdrop[hidden] { display: none; }
.modal { background: #fff; width: min(650px, 100%); max-height: 88vh; overflow-y: auto; border-radius: 18px; box-shadow: 0 25px 90px rgba(0,0,0,.25); padding: 24px; }
.modal h2 { font-family: Georgia, serif; color: var(--green-950); margin: 0; font-size: 24px; }
.modal > p { color: var(--muted); font-size: 11px; line-height: 1.55; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.field label { display: block; color: var(--muted); font-size: 9px; margin-bottom: 5px; }
.field input, .field select { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 10px; color: var(--ink); background: #fff; }

.toast { position: fixed; right: 24px; bottom: 24px; background: var(--green-950); color: #fff; padding: 13px 16px; border-radius: 11px; font-size: 11px; box-shadow: var(--shadow); z-index: 80; transform: translateY(90px); opacity: 0; transition: .25s ease; max-width: 360px; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast strong { color: var(--lime); }

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .demo-banner { grid-template-columns: 1fr auto; }
  .demo-banner > div:nth-child(2) { grid-row: 2; grid-column: 1 / -1; }
  .timeline { grid-template-columns: repeat(3,1fr); }
  .money-flow { grid-template-columns: repeat(2,1fr); }
  .money-node:nth-child(2)::after { display: none; }
}
@media (max-width: 780px) {
  .app-shell { display: block; }
  .sidebar { transform: translateX(-100%); transition: .22s ease; box-shadow: 20px 0 50px rgba(0,0,0,.18); }
  .sidebar.open { transform: translateX(0); }
  .main { width: 100%; }
  .menu-btn { display: inline-grid; place-items: center; }
  .topbar { padding: 0 15px; }
  .role-switch span { display: none; }
  .role-switch select { max-width: 150px; }
  .content { padding: 22px 15px 40px; }
  .page-head { flex-direction: column; }
  .grid-2, .grid-even { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: repeat(2,1fr); }
  .detail-cell:nth-child(2) { border-right: 0; }
  .detail-cell:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .arch { grid-template-columns: 1fr; }
  .arch-arrow { transform: rotate(90deg); }
}
@media (max-width: 520px) {
  .crumbs { display: none; }
  .top-actions { width: 100%; }
  .top-actions .icon-btn { display: none; }
  .role-switch { border: 0; padding: 0; flex: 1; }
  .role-switch select { max-width: none; width: 100%; }
  .stats-grid, .money-flow, .timeline { grid-template-columns: 1fr; }
  .money-node::after { display: none; }
  .demo-banner { grid-template-columns: 1fr; padding: 22px; }
  .demo-banner > div:nth-child(2) { grid-column: auto; grid-row: auto; }
  .detail-grid, .form-grid { grid-template-columns: 1fr; }
  .detail-cell { border-right: 0; border-bottom: 1px solid var(--line); }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
}
