:root {
  --bg: #f4f5f2;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #66727f;
  --line: #e3e6e1;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --accent-soft: #e4f0ec;
  --warm: #d08a3c;
  --neg: #b3402e;
  --pos: #1f6f5c;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 14px; font-weight: 650; }
h3 { font-size: 13px; margin: 18px 0 8px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
small, .muted { color: var(--muted); }
small { font-size: 12px; }
.nowrap { white-space: nowrap; }

/* Layout */
.shell { display: grid; grid-template-columns: 208px 1fr; min-height: 100vh; }
.nav { background: var(--ink); color: #cfd6dc; padding: 20px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.nav a, .nav .linklike { color: #cfd6dc; padding: 9px 12px; border-radius: 8px; font-size: 14.5px; display: block; }
.nav a:hover, .nav .linklike:hover { background: rgba(255,255,255,0.08); text-decoration: none; color: #fff; }
.nav a.on { background: rgba(255,255,255,0.14); color: #fff; font-weight: 600; }
.nav .brand, .login .brand { font-size: 18px; font-weight: 700; color: #fff; padding: 4px 12px 18px; letter-spacing: -0.01em; }
.brand span { font-weight: 400; opacity: 0.6; }
.nav-end { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.linklike { background: none; border: 0; font: inherit; cursor: pointer; text-align: left; width: 100%; }
main { padding: 28px 32px 60px; min-width: 0; max-width: 1280px; width: 100%; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline { display: inline-flex; gap: 8px; align-items: center; margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid2 .card { margin-bottom: 18px; }

/* Controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: 14px; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c5cbc4; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #195c4c; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger { color: var(--neg); border-color: #e7c8c2; background: transparent; }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid #cdd3cc; border-radius: 8px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="search"] { width: 260px; max-width: 100%; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.kpi-label { font-size: 12.5px; color: var(--muted); }
.kpi-value { font-size: 23px; font-weight: 650; letter-spacing: -0.02em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi.neg .kpi-value { color: var(--neg); }
.kpi.pos .kpi-value { color: var(--pos); }
.kpi.debt { background: var(--ink); border-color: var(--ink); color: #fff; }
.kpi.debt .kpi-label, .kpi.debt .kpi-sub { color: #aeb8c1; }

.chart { position: relative; height: 280px; }

/* Tables */
.table-wrap { overflow-x: auto; padding: 4px 0; }
table { border-collapse: collapse; width: 100%; }
.data th, .data td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.data thead th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.data tbody tr:last-child td { border-bottom: 0; }
.data tfoot th { border-top: 2px solid var(--line); border-bottom: 0; }
.data .row-link { cursor: pointer; }
.data .row-link:hover { background: #f8f9f6; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.neg { color: var(--neg); }
td.pos { color: var(--pos); }
.empty { color: var(--muted); padding: 28px 14px !important; text-align: center !important; }

.bars td { padding: 6px 0; vertical-align: middle; }
.bars .name { width: 34%; padding-right: 12px; }
.bars .bar { width: 36%; }
.bars .bar span { display: block; height: 10px; border-radius: 5px; background: var(--accent); min-width: 2px; }
.bars .bar span.credit { background: var(--ink); }
.bars .bar span.owner { background: var(--warm); }
.bars .share { width: 46px; text-align: right; color: var(--muted); font-size: 13px; padding-left: 10px; }
.bars.compact .name { width: auto; }

/* List toolbars */
.toolbar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.pager { display: inline-flex; gap: 6px; align-items: center; }
.toolbar .total { margin-left: auto; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 13px; color: var(--muted); }
.chip strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* Forms */
.form { max-width: 720px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field[hidden] { display: none; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .field select { width: 100%; }
.f-description, .f-note, .f-title { grid-column: 1 / -1; }
.help { font-size: 12px; color: var(--muted); }
.err { font-size: 12.5px; color: var(--neg); }
.has-error input, .has-error select { border-color: var(--neg); }
.req { color: var(--neg); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.danger-zone { max-width: 720px; margin: -6px 0 18px; }

.messages { margin-bottom: 16px; }
.msg { padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); color: #164f41; margin-bottom: 8px; font-size: 14px; }
.msg.error { background: #f8e7e3; color: #7d2c1f; }

/* Login */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 14px; padding: 26px; }
.login .brand { color: var(--ink); padding: 0 0 6px; }
.login label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.login input { width: 100%; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 2px; }
  .nav .brand { padding: 4px 10px 4px 6px; }
  .nav a, .nav .linklike { padding: 7px 10px; }
  .nav-end { margin: 0 0 0 auto; flex-direction: row; }
  main { padding: 18px 14px 40px; }
  .grid2 { grid-template-columns: 1fr; gap: 0; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 20px; }
  .fields { grid-template-columns: 1fr; }
  .toolbar .total { margin-left: 0; width: 100%; }
  input[type="search"] { width: 100%; }
  .bars .bar { display: none; }
  .bars .name { width: auto; }
  input, select, .btn { font-size: 16px; }
}
