:root {
  --ink: #17332b;
  --ink-soft: #5f716b;
  --forest: #16372d;
  --green: #296b55;
  --mint: #cfe9dd;
  --cream: #f6f2e8;
  --cream-deep: #eee8d9;
  --paper: #fffdf7;
  --orange: #e2783f;
  --gold: #dfb45b;
  --line: rgba(23, 51, 43, .13);
  --shadow: 0 24px 70px rgba(28, 55, 45, .10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 0%, rgba(223,180,91,.17), transparent 28rem),
    linear-gradient(180deg, #fbf8ef 0, #f4f1e8 42rem, #f8f6ef 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
a { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 2rem;
  min-height: 76px;
  padding: .75rem clamp(1rem, 4vw, 4rem);
  background: rgba(251,248,239,.9);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; margin-right: auto; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: #fff;
  background: var(--forest);
  font: 700 1rem Georgia, serif;
  letter-spacing: .05em;
}
.brand strong, .brand small { display: block; }
.brand strong { font: 700 1.08rem Georgia, serif; }
.brand small { margin-top: .1rem; color: var(--ink-soft); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; }
.topbar nav { display: flex; gap: 1.7rem; }
.topbar nav a { color: var(--ink-soft); font-size: .88rem; text-decoration: none; }
.topbar nav a:hover { color: var(--green); }
.quiet-button { border: 0; background: transparent; color: var(--ink-soft); cursor: pointer; }

.shell { width: min(1220px, calc(100% - 2rem)); margin: 0 auto; padding: 4.5rem 0 5rem; }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 3rem; margin-bottom: 3rem; }
.eyebrow { margin: 0 0 .65rem; color: var(--orange); font-size: .7rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-weight: 500; }
h1 { max-width: 760px; font-size: clamp(2.8rem, 7vw, 5.8rem); line-height: .94; letter-spacing: -.045em; }
h1 em { color: var(--green); font-weight: inherit; }
.hero-copy { max-width: 600px; margin: 1.4rem 0 0; color: var(--ink-soft); font-size: 1.04rem; line-height: 1.7; }
.month-control { min-width: 225px; padding: 1.1rem; background: rgba(255,255,255,.55); border: 1px solid var(--line); border-radius: 20px; }
.month-control label { display: block; margin-bottom: .4rem; color: var(--ink-soft); font-size: .72rem; }
.month-control select { width: 100%; padding: .65rem .4rem; color: var(--ink); background: transparent; border: 0; border-bottom: 1px solid var(--line); font-weight: 700; outline: none; }
.status-pill { display: inline-block; margin-top: .75rem; padding: .35rem .6rem; border-radius: 999px; font-size: .67rem; font-weight: 750; }
.status-pill.ready { color: #1e664f; background: #d9eee5; }
.status-pill.pending { color: #84621c; background: #f3e6bf; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.metric, .panel { background: rgba(255,253,247,.88); border: 1px solid var(--line); box-shadow: var(--shadow); }
.metric { position: relative; min-height: 205px; padding: 1.35rem; border-radius: 24px; overflow: hidden; }
.metric-primary { color: #fff; background: var(--forest); }
.metric-icon { display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 2.3rem; border-radius: 50%; color: var(--green); background: var(--mint); font-weight: 800; }
.metric-primary .metric-icon { color: var(--forest); background: var(--gold); }
.metric p { margin: 0 0 .55rem; color: var(--ink-soft); font-size: .76rem; }
.metric-primary p, .metric-primary small { color: rgba(255,255,255,.65); }
.metric strong { display: block; font: 500 clamp(1.65rem, 3vw, 2.35rem) Georgia, serif; white-space: nowrap; }
.metric small { position: absolute; left: 1.35rem; bottom: 1.35rem; color: var(--ink-soft); font-size: .67rem; }

.content-grid { display: grid; grid-template-columns: 1.4fr .8fr; gap: 1rem; margin-top: 1rem; }
.panel { padding: clamp(1.3rem, 3vw, 2rem); border-radius: 28px; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: 1.8rem; }
.panel-heading h2 { font-size: clamp(1.45rem, 3vw, 2rem); }
.rate-badge { display: grid; place-items: center; min-width: 62px; height: 62px; border-radius: 50%; color: #fff; background: var(--orange); font: 700 1.05rem Georgia, serif; }
.potential-breakdown > div { display: flex; justify-content: space-between; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--line); }
.potential-breakdown span { color: var(--ink-soft); }
.potential-breakdown .total-line { border-bottom: 0; color: var(--ink); }
.potential-breakdown .total-line span { color: var(--ink); font-weight: 700; }
.formula { display: flex; align-items: center; justify-content: center; gap: clamp(.45rem, 2vw, 1.1rem); margin-top: 1.5rem; padding: 1.2rem; border-radius: 18px; background: var(--cream); }
.formula span { font-weight: 700; }
.formula b { color: var(--orange); }
.formula strong { color: var(--green); font: 700 1.4rem Georgia, serif; }
.performance-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; margin-top: .8rem; }
.performance-strip > div { min-height: 84px; padding: .85rem; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.44); }
.performance-strip span, .performance-strip strong { display: block; }
.performance-strip span { min-height: 2.2em; color: var(--ink-soft); font-size: .67rem; line-height: 1.35; }
.performance-strip strong { margin-top: .45rem; font: 600 1.05rem Georgia, serif; }
.performance-strip .loss { color: #9a3d2e; background: #fff4ed; }

.donut-wrap { display: grid; place-items: center; }
.donut { --share: 0deg; display: grid; place-items: center; width: 185px; aspect-ratio: 1; border-radius: 50%; background: conic-gradient(var(--green) var(--share), #e8e4d9 0); position: relative; }
.donut::after { content: ""; position: absolute; width: 125px; aspect-ratio: 1; border-radius: 50%; background: var(--paper); }
.donut span { z-index: 1; font: 700 1.65rem Georgia, serif; }
.legend { width: 100%; margin-top: 1.6rem; }
.legend > div { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .6rem; padding: .5rem 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; }
.dot.seller { background: var(--green); }
.dot.central { background: #d8d3c5; }

.trend-panel { margin-top: 1rem; min-height: 330px; }
.settlement-panel { margin-top: 1rem; }
.settlement-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem; }
.settlement-row { display: flex; min-height: 82px; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 16px; flex-direction: column; justify-content: space-between; background: rgba(255,255,255,.42); }
.settlement-row span { color: var(--ink-soft); font-size: .72rem; line-height: 1.35; }
.settlement-row strong { font: 500 1.25rem Georgia, serif; }
.settlement-row.subtotal, .settlement-row.invoice-total { background: var(--cream-deep); }
.settlement-row.transfer-total { color: #fff; border-color: var(--forest); background: var(--forest); }
.settlement-row.transfer-total span { color: rgba(255,255,255,.7); }
.settlement-row.detail { min-height: 66px; }
.soft-label { padding: .4rem .7rem; border-radius: 999px; color: var(--ink-soft); background: var(--cream); font-size: .65rem; }
.trend-chart { display: flex; align-items: end; gap: 1.2rem; width: 100%; max-width: 100%; height: 200px; padding: .8rem .5rem 0; overflow-x: auto; overflow-y: hidden; border-bottom: 1px solid var(--line); }
.bar-item { display: grid; grid-template-rows: auto 1fr auto; height: 100%; min-width: 75px; text-align: center; }
.bar-item strong { font-size: .75rem; }
.bar-item span { padding-top: .5rem; color: var(--ink-soft); font-size: .7rem; }
.bar-track { display: flex; align-items: end; justify-content: center; height: 145px; }
.bar { width: 34px; min-height: 10px; border-radius: 12px 12px 3px 3px; background: linear-gradient(180deg, var(--orange), var(--gold)); }

.documents-grid { grid-template-columns: 1fr 1fr; }
.document-row { display: flex; align-items: center; gap: .8rem; padding: .9rem 0; border-bottom: 1px solid var(--line); }
.document-row:last-child { border-bottom: 0; }
.doc-check { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font-weight: 800; }
.available .doc-check { color: #1f6a51; background: #d9eee5; }
.missing .doc-check { color: #8a6a28; background: #f4e9ca; }
.document-row strong, .document-row small { display: block; }
.document-row small { margin-top: .2rem; color: var(--ink-soft); }
.notes-panel ul { margin: 0; padding: 0; list-style: none; }
.notes-panel li { position: relative; padding: .75rem 0 .75rem 1.3rem; color: var(--ink-soft); line-height: 1.5; border-bottom: 1px solid var(--line); }
.notes-panel li::before { content: ""; position: absolute; top: 1.25rem; left: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--orange); }

footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1.5rem clamp(1rem, 4vw, 4rem); color: var(--ink-soft); background: var(--forest); font-size: .7rem; }
.fatal { max-width: 640px; margin: 20vh auto; padding: 2rem; text-align: center; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(circle at 50% 0, #2c6653, var(--forest) 55%); }
.login-card { width: min(430px, 100%); padding: 2.3rem; border-radius: 30px; background: var(--paper); box-shadow: 0 30px 100px rgba(0,0,0,.3); }
.login-card .brand-mark { margin-bottom: 2.2rem; }
.login-card h1 { font-size: 2.45rem; }
.login-card > p:not(.eyebrow) { color: var(--ink-soft); line-height: 1.6; }
.login-card label { display: block; margin: 1.7rem 0 .45rem; font-size: .75rem; font-weight: 700; }
.login-card input { width: 100%; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 12px; outline: none; }
.login-card input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(41,107,85,.12); }
.login-card button { width: 100%; margin-top: 1rem; padding: .9rem; border: 0; border-radius: 12px; color: #fff; background: var(--green); font-weight: 800; cursor: pointer; }
.login-error { color: #a34032 !important; font-size: .8rem; }

@media (max-width: 900px) {
  .topbar nav { display: none; }
  .shell { padding-top: 3rem; }
  .hero { align-items: stretch; flex-direction: column; }
  .month-control { width: 100%; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .documents-grid { grid-template-columns: 1fr 1fr; }
  .settlement-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 580px) {
  .topbar { min-height: 66px; gap: .8rem; }
  .brand small { display: none; }
  .shell { width: min(100% - 1rem, 1220px); padding-top: 2rem; }
  h1 { font-size: 3.15rem; }
  .hero-copy { font-size: .92rem; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: .55rem; }
  .metric { min-height: 215px; padding: 1rem; border-radius: 19px; }
  .metric-icon { margin-bottom: 1.4rem; }
  .metric strong { font-size: 1.45rem; }
  .metric small { left: 1rem; bottom: 1rem; max-width: calc(100% - 2rem); }
  .panel { border-radius: 20px; }
  .formula { flex-wrap: wrap; }
  .performance-strip { grid-template-columns: 1fr; }
  .performance-strip > div { min-height: auto; }
  .performance-strip span { min-height: 0; }
  .documents-grid { grid-template-columns: 1fr; }
  .settlement-list { grid-template-columns: 1fr 1fr; gap: .5rem; }
  .settlement-row { min-height: 92px; padding: .85rem; }
  .settlement-row strong { font-size: 1.08rem; }
  footer { flex-direction: column; }
}
