:root {
  --ink: #29283d;
  --muted: #747486;
  --brand: #2d285f;
  --brand-soft: #eeecf8;
  --line: #e8e6ef;
  --canvas: #f6f5f9;
  --panel: #fff;
  --green: #16865a;
  --green-soft: #e9f6ef;
  --red: #b54545;
  --red-soft: #fbecec;
  --amber: #a66c12;
  --amber-soft: #fff3dd;
  --peach: #f4be88;
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: Arial, Helvetica, sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 25px 18px; color: #f6f4ff; background: var(--brand); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 7px 28px; }
.brand-mark, .login-brand > span { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; color: var(--brand); background: #fff; font-size: 21px; font-weight: 900; }
.brand b, .brand small, .login-brand b, .login-brand small { display: block; }
.brand b { letter-spacing: .1em; font-size: 14px; }
.brand small, .login-brand small { margin-top: 3px; letter-spacing: .19em; font-size: 8px; }
.sidebar nav { display: grid; gap: 3px; }
.sidebar nav a { min-height: 42px; display: flex; align-items: center; padding: 0 12px; border-radius: 9px; color: #cecae7; font-size: 12px; }
.sidebar nav a:hover { color: #fff; background: rgba(255,255,255,.1); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding: 16px 8px 0; border-top: 1px solid rgba(255,255,255,.12); font-size: 11px; }
.sidebar-foot button { border: 0; color: #c8c4e3; background: none; cursor: pointer; font-size: 10px; }
.main { min-width: 0; padding: 0 32px 46px; }
.topbar { min-height: 100px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.topbar small, .panel small, .form-intro small, .upload-panel > small { color: var(--muted); letter-spacing: .1em; font-size: 9px; font-weight: 700; }
.topbar h1 { margin: 7px 0 0; letter-spacing: -.025em; font-size: 24px; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; padding: 0 14px; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-size: 11px; font-weight: 700; }
.button.primary { color: #fff; background: var(--brand); border-color: var(--brand); }
.button.secondary { color: var(--brand); background: #fff; border-color: var(--line); }
.button.wide { width: 100%; }
.messages { display: grid; gap: 8px; margin-top: 16px; }
.message { padding: 11px 13px; border: 1px solid #d6eade; border-radius: 9px; color: #176640; background: var(--green-soft); font-size: 11px; }
.message.warning { color: var(--amber); border-color: #f0dab2; background: var(--amber-soft); }
.message.error { color: var(--red); border-color: #efc7c7; background: var(--red-soft); }
.balance { min-height: 168px; display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 25px; padding: 28px 30px; overflow: hidden; border-radius: 18px; color: #fff; background: var(--brand); background-image: radial-gradient(circle at 70% -40%, rgba(255,255,255,.16), transparent 45%); }
.balance small, .balance strong, .balance span { display: block; }
.balance small { color: #cbc7e6; font-size: 10px; }
.balance strong { margin-top: 10px; letter-spacing: -.05em; font-size: clamp(36px,4.5vw,50px); }
.balance span { margin-top: 9px; color: #d2cfea; font-size: 11px; }
.balance a { padding: 11px 13px; border: 1px solid rgba(255,255,255,.25); border-radius: 8px; font-size: 10px; font-weight: 700; }
.metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-top: 13px; }
.metrics article, .project-summary article, .reconcile-head > article:first-child { padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.metrics span, .metrics small, .project-summary span, .reconcile-head article span, .reconcile-head article small { display: block; color: var(--muted); font-size: 10px; }
.metrics strong { display: block; margin-top: 10px; font-size: 20px; }
.metrics small { margin-top: 8px; font-size: 9px; }
.split { display: grid; grid-template-columns: minmax(0,1.6fr) minmax(300px,.75fr); gap: 13px; margin-top: 13px; }
.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 9px 24px rgba(37,32,79,.03); }
.panel > header { min-height: 70px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 19px 12px; }
.panel h2, .form-intro h2 { margin: 6px 0 0; letter-spacing: -.02em; font-size: 17px; }
.panel > header > a { color: var(--brand); font-size: 10px; font-weight: 700; }
.list { padding: 0 19px 8px; }
.movement { min-height: 64px; display: grid; grid-template-columns: 34px minmax(160px,1fr) auto auto; align-items: center; gap: 10px; border-top: 1px solid #efedf3; font-size: 10px; }
.direction { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 8px; font-weight: 900; }
.direction.inflow { color: var(--green); background: var(--green-soft); }
.direction.outflow { color: var(--red); background: var(--red-soft); }
.movement b, .movement small { display: block; }
.movement b { font-size: 11px; }
.movement small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.movement > strong { min-width: 102px; text-align: right; }
.status { display: inline-flex; padding: 6px 8px; border-radius: 7px; color: #686779; background: #efedf3; white-space: nowrap; font-size: 8px; font-weight: 700; }
.status.reconciled, .status.confirmed, .status.paid { color: var(--green); background: var(--green-soft); }
.status.parsed, .status.realized { color: var(--amber); background: var(--amber-soft); }
.empty { padding: 22px 4px; color: var(--muted); font-size: 11px; }
.action-panel, .upload-panel, .review-file { padding: 20px; background: #fbfaff; }
.action-panel h2, .upload-panel h2, .review-file h2 { margin: 7px 0; font-size: 19px; }
.action-panel p, .upload-panel p, .review-file p, .form-intro p { color: var(--muted); line-height: 1.55; font-size: 11px; }
.action-panel ol { display: grid; gap: 8px; padding: 0; list-style: none; }
.action-panel li { display: flex; align-items: center; gap: 9px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 10px; }
.action-panel li span { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; color: var(--brand); background: var(--brand-soft); font-weight: 800; }
.projects-card, .page-panel { margin-top: 13px; }
.table { padding: 0 19px 12px; }
.table-row { min-height: 47px; display: grid; grid-template-columns: minmax(190px,1.35fr) .6fr .7fr .85fr .85fr; align-items: center; gap: 12px; border-top: 1px solid #efedf3; color: #5f5e70; font-size: 10px; }
.table-row b, .table-row strong { color: var(--ink); }
.table-head { min-height: 31px; border-top: 0; color: #8b8999; letter-spacing: .05em; text-transform: uppercase; font-size: 8px; font-weight: 800; }
.project-grid { grid-template-columns: minmax(190px,1.3fr) .7fr .7fr .7fr .8fr; }
.cost-grid { grid-template-columns: minmax(180px,1.3fr) .7fr .8fr .65fr; }
.invoice-grid { grid-template-columns: minmax(150px,1.1fr) .8fr .6fr .85fr .65fr; }
.project-summary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-top: 25px; }
.project-summary strong { display: block; margin-top: 10px; font-size: 19px; }
.project-summary .result { color: #fff; border-color: var(--brand); background: var(--brand); }
.project-summary .result span { color: #cbc7e6; }
.budget-split { grid-template-columns: minmax(0,1.5fr) minmax(290px,.65fr); }
.form-panel { margin-top: 25px; padding: 22px; }
.form-panel.compact { margin-top: 0; }
.form-intro { margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.form-stack { display: grid; gap: 13px; }
.form-grid label, .form-stack label { display: grid; gap: 6px; color: #555467; font-size: 10px; font-weight: 700; }
.form-grid .full { grid-column: 1/-1; }
input, select, textarea { width: 100%; min-height: 40px; padding: 9px 10px; border: 1px solid #dcd9e7; border-radius: 8px; color: var(--ink); background: #fff; font-size: 11px; }
textarea { min-height: 74px; resize: vertical; }
.errorlist { margin: 0; padding-left: 16px; color: var(--red); font-size: 9px; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 5px; }
.tax-preview { padding: 16px; border-radius: 11px; color: #fff; background: var(--brand); }
.tax-preview span, .tax-preview small, .tax-preview strong { display: block; }
.tax-preview span, .tax-preview small { color: #cec9e7; font-size: 9px; }
.tax-preview strong { margin: 7px 0 4px; font-size: 23px; }
.document-split { grid-template-columns: minmax(280px,.65fr) minmax(0,1.35fr); margin-top: 25px; }
.upload-box { display: grid; gap: 12px; margin-top: 18px; padding: 18px; border: 1px dashed #c9c4dc; border-radius: 11px; background: #fff; }
.support-note { display: block; margin-top: 12px; line-height: 1.45; }
.document-row { min-height: 63px; display: grid; grid-template-columns: 98px minmax(150px,1fr) auto 42px; align-items: center; gap: 10px; border-top: 1px solid #efedf3; font-size: 10px; }
.document-row b, .document-row small { display: block; }
.document-row small { margin-top: 4px; color: var(--muted); font-size: 8px; }
.review-split { grid-template-columns: minmax(280px,.65fr) minmax(0,1.35fr); margin-top: 25px; }
.safety-note { display: grid; gap: 4px; margin-top: 22px; padding: 12px; border-left: 3px solid var(--amber); color: #6b531e; background: var(--amber-soft); font-size: 10px; }
.data-list { margin: 0; padding: 0 19px 14px; }
.data-list > div { min-height: 44px; display: grid; grid-template-columns: .8fr 1.2fr; align-items: center; gap: 15px; border-top: 1px solid #efedf3; font-size: 10px; }
.data-list dt { color: var(--muted); }
.data-list dd { margin: 0; font-weight: 700; word-break: break-word; }
.confirm-bar { display: flex; align-items: center; gap: 9px; padding: 15px 19px; border-top: 1px solid var(--line); }
.reconcile-head { display: grid; grid-template-columns: .65fr 1.35fr; gap: 13px; margin-top: 25px; }
.reconcile-head > article:first-child { display: flex; flex-direction: column; justify-content: center; color: #fff; border-color: var(--brand); background: var(--brand); }
.reconcile-head article:first-child span, .reconcile-head article:first-child small { color: #cec9e7; }
.reconcile-head article strong { display: block; margin: 11px 0; font-size: 29px; }
.reconcile-split { grid-template-columns: 1.2fr .8fr; }
.snapshot-list { padding: 0 19px 12px; }
.snapshot-list > div { display: grid; grid-template-columns: 70px 1fr; gap: 6px 10px; padding: 12px 0; border-top: 1px solid #efedf3; font-size: 10px; }
.snapshot-list small { grid-column: 2; color: var(--muted); }
.advance-list { padding: 0 19px 12px; }
.advance-list > div { min-height: 71px; display: grid; grid-template-columns: 35px minmax(130px,1fr) auto auto auto; align-items: center; gap: 12px; border-top: 1px solid #efedf3; font-size: 10px; }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: var(--brand); background: var(--brand-soft); font-size: 9px; font-weight: 800; }
.advance-list b, .advance-list small { display: block; }
.advance-list small { margin-bottom: 4px; color: var(--muted); font-size: 8px; }
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--brand); background-image: radial-gradient(circle at 80% 0, rgba(255,255,255,.15), transparent 40%); }
.login-card { width: min(430px,100%); padding: 34px; border-radius: 18px; background: #fff; box-shadow: 0 30px 70px rgba(15,11,49,.28); }
.login-brand { display: flex; align-items: center; gap: 11px; color: var(--brand); }
.login-card h1 { margin: 28px 0 10px; font-size: 26px; }
.login-card > p { margin: 0 0 22px; color: var(--muted); line-height: 1.5; font-size: 12px; }

@media (max-width: 1050px) {
  .metrics, .project-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .split, .document-split, .review-split, .reconcile-head, .reconcile-split { grid-template-columns: 1fr; }
  .table { overflow-x: auto; }
  .table-row { min-width: 710px; }
}

@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; padding: 16px; }
  .brand { padding-bottom: 13px; }
  .sidebar nav { display: flex; overflow-x: auto; padding-bottom: 4px; }
  .sidebar nav a { min-width: max-content; }
  .sidebar-foot { display: none; }
  .main { padding: 0 16px 32px; }
  .topbar { min-height: 86px; }
  .top-actions .secondary { display: none; }
  .movement { grid-template-columns: 32px 1fr auto; padding: 9px 0; }
  .movement .status { display: none; }
  .advance-list { overflow-x: auto; }
  .advance-list > div { min-width: 650px; }
}

@media (max-width: 520px) {
  .metrics, .project-summary, .form-grid { grid-template-columns: 1fr; }
  .balance { align-items: flex-start; flex-direction: column; }
  .balance strong { font-size: 36px; }
  .movement { grid-template-columns: 32px 1fr; }
  .movement > strong { grid-column: 2; text-align: left; }
  .data-list > div { grid-template-columns: 1fr; padding: 10px 0; gap: 5px; }
  .confirm-bar { align-items: stretch; flex-direction: column; }
  .confirm-bar form, .confirm-bar .button { width: 100%; }
}
