:root {
  --ink: #132a3a;
  --ink-2: #284254;
  --muted: #6c7a86;
  --paper: #ffffff;
  --canvas: #f4f6f8;
  --line: #dfe5e9;
  --gold: #c49a58;
  --gold-soft: #f4eadb;
  --good: #1f7a5a;
  --warn: #a26515;
  --bad: #b74646;
  --shadow: 0 12px 30px rgba(19, 42, 58, .08);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--canvas); }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar {
  background: var(--ink); color: white; padding: 28px 18px; position: sticky; top: 0;
  height: 100vh; display: flex; flex-direction: column; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px; }
.brand img { width: 42px; height: 42px; }
.brand strong { font-size: 1.05rem; display: block; }
.brand span { display: block; color: #b8c5cd; font-size: .78rem; margin-top: 2px; }
.nav-list { display: grid; gap: 8px; }
.nav-button {
  border: 0; background: transparent; color: #d5dee4; text-align: left; padding: 12px 14px;
  border-radius: 12px; display: flex; align-items: center; gap: 10px;
}
.nav-button:hover, .nav-button.active { background: rgba(255,255,255,.11); color: white; }
.sidebar-footer { margin-top: auto; padding: 14px; background: rgba(255,255,255,.08); border-radius: 14px; }
.sidebar-footer small { color: #b8c5cd; display: block; margin-top: 4px; }

.main { min-width: 0; padding: 28px 34px 110px; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 26px; }
.title-block h1 { margin: 0; font-size: clamp(1.55rem, 2.4vw, 2.25rem); letter-spacing: -.03em; }
.title-block p { margin: 6px 0 0; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 10px; }

.chip, .status-chip { border-radius: 999px; padding: 8px 11px; font-size: .79rem; border: 1px solid var(--line); background: var(--paper); }
.status-chip.good { color: var(--good); background: #edf8f3; border-color: #cae9dc; }
.status-chip.warn { color: var(--warn); background: #fff7e8; border-color: #f0d8a9; }
.status-chip.bad { color: var(--bad); background: #fff0f0; border-color: #efcaca; }

.grid { display: grid; gap: 18px; }
.kpi-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
.two-col { grid-template-columns: minmax(0,1.25fr) minmax(320px,.75fr); }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card h2, .card h3 { margin: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.card-header p { margin: 5px 0 0; color: var(--muted); font-size: .88rem; }
.kpi-label { color: var(--muted); font-size: .82rem; }
.kpi-value { font-size: clamp(1.35rem, 2vw, 2rem); margin-top: 10px; font-weight: 720; letter-spacing: -.03em; }
.kpi-note { margin-top: 8px; font-size: .78rem; color: var(--muted); }

.progress { background: #edf0f2; height: 9px; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--gold); border-radius: inherit; }
.list { display: grid; gap: 10px; }
.list-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid #edf0f2; }
.list-row:last-child { border-bottom: 0; }
.list-row strong { display: block; }
.list-row small { color: var(--muted); display: block; margin-top: 3px; }
.amount.negative { color: var(--bad); }
.amount.positive { color: var(--good); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
td { padding: 13px 12px; border-bottom: 1px solid #edf0f2; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }

.btn { border: 1px solid var(--line); background: var(--paper); color: var(--ink); padding: 10px 14px; border-radius: 11px; font-weight: 650; }
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--ink); color: white; border-color: var(--ink); }
.btn.gold { background: var(--gold); color: #17130c; border-color: var(--gold); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 7px 10px; font-size: .82rem; }

.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
label { font-size: .82rem; color: var(--ink-2); font-weight: 650; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); background: white; color: var(--ink); border-radius: 11px;
  padding: 11px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
textarea { min-height: 94px; resize: vertical; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

.notice { padding: 13px 15px; border-radius: 12px; background: #eef5f8; border: 1px solid #d8e6ed; color: var(--ink-2); margin-bottom: 16px; }
.notice strong { color: var(--ink); }
.empty { color: var(--muted); text-align: center; padding: 34px 10px; }

.goal-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
.goal-card .goal-line { display: flex; justify-content: space-between; margin: 15px 0 9px; font-size: .85rem; }
.goal-card .goal-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .78rem; margin-top: 10px; }

.mobile-nav { display: none; }
.role-select { min-width: 165px; }
.screen-reader { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.toast { position: fixed; right: 24px; bottom: 24px; background: var(--ink); color: white; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); z-index: 50; animation: toast-in .2s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top left, #e8eef1, var(--canvas) 42%); }
.login-card { width: min(460px,100%); background: white; border: 1px solid var(--line); border-radius: 24px; padding: 32px; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.login-brand img { width: 54px; }
.login-card h1 { margin: 0; }
.login-card p { color: var(--muted); }
.login-card .stack { display: grid; gap: 13px; }

@media (max-width: 1060px) {
  .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .goal-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .main { padding: 20px 16px 96px; }
  .topbar { align-items: flex-start; }
  .top-actions .chip { display: none; }
  .kpi-grid, .goal-grid, .form-grid { grid-template-columns: 1fr; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(5,1fr); position: fixed; bottom: 0; left: 0; right: 0;
    padding: 7px 7px calc(7px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96);
    border-top: 1px solid var(--line); z-index: 40; backdrop-filter: blur(14px);
  }
  .mobile-nav button { border: 0; background: transparent; color: var(--muted); padding: 8px 3px; border-radius: 10px; font-size: .69rem; }
  .mobile-nav button.active { color: var(--ink); background: var(--gold-soft); }
  .mobile-nav .icon { display: block; font-size: 1rem; margin-bottom: 3px; }
  .toast { right: 14px; left: 14px; bottom: 86px; text-align: center; }
  .role-select { min-width: 130px; }
}
