:root {
  color-scheme: light dark;
  --page: light-dark(#f8f6f2, #181613);
  --panel: light-dark(#fffdfa, #211e1b);
  --nav: light-dark(#f0ebe4, #1d1a17);
  --soft: light-dark(#f6f1eb, #27231f);
  --ink: light-dark(#2a211d, #f5ebe1);
  --muted: light-dark(#6d6058, #c2b4aa);
  --rule: light-dark(#e6ddd3, #40362f);
  --control: light-dark(#b8a99c, #746457);
  --accent: light-dark(#873d29, #f4a586);
  --accent-fill: light-dark(#943f29, #df8f70);
  --accent-text: light-dark(#fffdfa, #23160f);
  --accent-soft: light-dark(#f3e2d7, #3d2a22);
  --green: light-dark(#335e43, #c2e0ca);
  --green-soft: light-dark(#e7f0e6, #293b2d);
  --red: light-dark(#8a372f, #f1b1a6);
  --red-soft: light-dark(#f9e9e4, #482a25);
  --mark: light-dark(#ba735c, #ca8b71);
  --shadow: 0 1px 2px light-dark(#3d29100a, #0003);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
  font-size: 15px;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; color: var(--ink); background: var(--page); }
[hidden] { display: none !important; }
h1, h2, p, dl, dd { margin: 0; }
h1 { font-size: clamp(1.7rem, 3vw, 2.3rem); line-height: 1.15; letter-spacing: -.035em; font-weight: 740; }
h2 { font-size: 1.05rem; line-height: 1.32; font-weight: 690; }
p { overflow-wrap: anywhere; }
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, summary:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
summary { cursor: pointer; }
button, input, select { color: inherit; font: inherit; }
button { cursor: pointer; }
input, select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: .52em .7em;
  border: 1px solid var(--control);
  border-radius: 8px;
  background: var(--panel);
}
input::placeholder { color: var(--muted); opacity: 1; }
form { margin: 0; }
label { display: grid; gap: 5px; min-width: 0; color: var(--muted); font-size: .83rem; font-weight: 580; }
input, select { font-weight: 400; color: var(--ink); font-size: .93rem; }
.sr-only, .skip:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  margin: -1px;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip:focus { position: fixed; z-index: 2; top: 9px; left: 9px; padding: 10px 14px; color: var(--accent); background: var(--panel); }
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: .53em .92em;
  color: inherit;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  font-weight: 620;
  font-size: .88rem;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}
.button.primary { color: var(--accent-text); background: var(--accent-fill); }
.button.primary:hover { filter: brightness(.94); }
.button.secondary { color: var(--accent); background: var(--panel); border-color: var(--control); }
.button.quiet { color: var(--muted); }
.button.secondary:hover, .button.quiet:hover { color: var(--accent); background: var(--accent-soft); border-color: var(--rule); }
.text-link { color: var(--accent); font-weight: 650; text-decoration: none; }
.text-link:hover { text-decoration: underline; }

.layout { display: grid; grid-template-columns: 223px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 29px;
  min-width: 0;
  background: var(--nav);
  border-right: 1px solid var(--rule);
  padding: 25px 16px 19px;
}
.brand { display: inline-flex; align-items: center; align-self: flex-start; gap: 10px; color: var(--accent); text-decoration: none; }
.brand-symbol {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 10px;
  background: var(--accent-fill);
  color: var(--accent-text);
  font: 700 1.5rem/1 Georgia, serif;
}
.brand-text { min-width: 0; }
.brand strong { display: block; font: 700 1.36rem/1.07 Georgia, "Times New Roman", serif; letter-spacing: .09em; }
.brand small { display: block; color: var(--muted); font-size: .74rem; margin-top: 3px; }
.sidebar nav { display: grid; gap: 3px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 8px 11px;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink);
  font-size: .91rem;
  text-decoration: none;
}
.sidebar nav a::before { content: ""; width: 4px; height: 17px; flex: 0 0 4px; border-radius: 3px; }
.sidebar nav a:hover { background: var(--soft); }
.sidebar nav a[aria-current] { color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.sidebar nav a[aria-current]::before { background: var(--accent); }
.account { display: flex; gap: 9px; align-items: center; margin-top: auto; padding: 13px 5px 0; border-top: 1px solid var(--rule); }
.account strong, .account small { display: block; overflow-wrap: anywhere; font-size: .79rem; }
.account small { color: var(--muted); font-weight: 400; }
.avatar {
  display: grid;
  flex: 0 0 31px;
  height: 31px;
  place-items: center;
  border-radius: 50%;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: .78rem;
  font-weight: 700;
}
.workspace { min-width: 0; }
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 7px 12px;
  min-height: 67px;
  padding: 11px clamp(18px, 3.2vw, 45px);
  background: var(--panel);
  border-bottom: 1px solid var(--rule);
}
.branch { color: var(--muted); font-size: .88rem; font-weight: 590; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.top-actions .button { min-height: 34px; }
.workspace-main {
  display: grid;
  gap: 17px;
  padding: clamp(18px, 3vw, 37px) clamp(17px, 3.2vw, 45px) 42px;
  max-width: 1480px;
  min-width: 0;
  margin-inline: auto;
}
.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 18px; }
.page-header p, .panel-header p { margin-top: 5px; color: var(--muted); }
.page-header p { font-size: .88rem; }
.page-tools { min-width: 0; max-width: 100%; }
.breadcrumb a { font-size: .88rem; }

.periods {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 9px;
  max-width: 100%;
}
.period-picks { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: 9px; background: var(--soft); border: 1px solid var(--rule); }
.period-picks a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 31px;
  padding: 3px 9px;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: .79rem;
  font-weight: 620;
  text-decoration: none;
  white-space: nowrap;
}
.period-picks a:hover { color: var(--accent); }
.period-picks a[aria-current] { color: var(--accent); border-color: var(--rule); background: var(--panel); }
.custom-period { max-width: 100%; }
.custom-period summary { min-height: 39px; padding: 9px 10px; border-radius: 8px; color: var(--accent); font-size: .82rem; font-weight: 620; }
.custom-period summary:hover, .custom-period[open] summary { background: var(--soft); }
.custom-period[open] { flex-basis: 100%; }
.period-dates { align-self: center; color: var(--muted); font-size: .79rem; }
.date-form { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-top: 9px; }
.date-form label { flex: 0 1 142px; }
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--soft);
}
.filters label { flex: 1 1 137px; }
.filters .search-field { flex-basis: 232px; }
.filter-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.filter-actions .button { min-height: 40px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric, .panel { min-width: 0; background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; box-shadow: var(--shadow); }
.metric { padding: 13px 15px; }
.metric p, .metric small { color: var(--muted); font-size: .78rem; line-height: 1.35; }
.metric p { font-weight: 570; }
.metric strong { display: block; margin: 6px 0 3px; font-size: clamp(1.36rem, 2.35vw, 1.9rem); line-height: 1.14; font-variant-numeric: tabular-nums; letter-spacing: -.03em; overflow-wrap: anywhere; }
.metric small { display: block; }
.panel { padding: 15px 17px; }
.panel-header { margin-bottom: 12px; }
.panel-header p, .panel-footer, .empty, .note { color: var(--muted); font-size: .84rem; }
.empty { padding-block: 7px 10px; }
.note { margin-top: 9px; }
.panel-footer { border-top: 1px solid var(--rule); margin-top: 7px; padding-top: 11px; }
.columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.columns.overview { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
.stack { display: grid; gap: 14px; min-width: 0; }
.notice {
  margin: 0;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--soft);
  padding: 10px 12px;
  color: var(--muted);
  font-size: .87rem;
}
.notice.danger { color: var(--red); background: var(--red-soft); }
.facts { display: grid; }
.facts > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  border-bottom: 1px solid var(--rule);
  padding-block: 8px;
}
.facts > div:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); font-size: .86rem; }
.facts dd { font-weight: 620; font-size: .88rem; text-align: right; overflow-wrap: anywhere; }
.facts + .table-wrap { border-top: 1px solid var(--rule); margin-top: 8px; }
.address-list { margin: 0; padding-inline-start: 1.3em; color: var(--ink); overflow-wrap: anywhere; }
.address-list li + li { margin-top: 7px; }
.bars { display: grid; gap: 9px; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(48px, max-content) minmax(50px, 1fr) 35px;
  align-items: center;
  gap: 9px;
  font-size: .78rem;
}
.bar-label { color: var(--muted); }
.bar-row strong { text-align: right; font-variant-numeric: tabular-nums; }
.bar-row meter { width: 100%; height: 12px; accent-color: var(--mark); }
.bar-row meter::-webkit-meter-bar { background: var(--soft); border-radius: 4px; border: 0; box-shadow: none; }
.bar-row meter::-webkit-meter-optimum-value { background: var(--mark); border-radius: 4px; }
.bar-row meter::-moz-meter-bar { background: var(--mark); border-radius: 4px; }

.table-wrap { min-width: 0; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--rule); vertical-align: top; overflow-wrap: anywhere; }
.data-table th { color: var(--muted); font-size: .78rem; font-weight: 635; background: var(--soft); }
.data-table th:first-child { border-top-left-radius: 6px; }
.data-table th:last-child { border-top-right-radius: 6px; }
.data-table td:last-child, .data-table th:last-child { text-align: right; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--page); }
.cell-label { display: none; }
.cell-note { display: block; color: var(--muted); margin-top: 2px; font-size: .78rem; }
.badge {
  display: inline-block;
  padding: 2px 7px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 540;
}
.badge.positive { color: var(--green); background: var(--green-soft); }
.badge.negative { color: var(--red); background: var(--red-soft); }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding-top: 8px; margin-top: 8px; border-top: 1px solid var(--rule); color: var(--muted); font-size: .82rem; }
.pagination div { display: flex; gap: 5px; }

.auth-shell { min-height: 100dvh; padding: 22px clamp(16px, 4vw, 48px) 40px; }
.auth-top { display: flex; justify-content: space-between; align-items: center; }
.auth-card {
  display: grid;
  gap: 17px;
  margin: clamp(33px, 11vh, 100px) auto 0;
  padding: clamp(19px, 4vw, 35px);
  max-width: 440px;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.auth-form { display: grid; gap: 13px; }
.auth-form > .button { margin-top: 4px; min-height: 43px; }
.password-field { display: grid; gap: 5px; }
.password-row { display: flex; gap: 7px; }
.password-row .button { flex: 0 0 auto; min-width: 6rem; }
.error-panel { max-width: 680px; }
.error-panel > * + * { margin-top: 14px; }

@media (max-width: 1060px) {
  .layout { grid-template-columns: 177px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .brand-symbol { width: 34px; height: 34px; flex-basis: 34px; }
  .brand { gap: 7px; }
}
@media (max-width: 850px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { min-height: 55px; }
}
@media (max-width: 700px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { padding: 11px 12px; gap: 9px; border-right: 0; border-bottom: 1px solid var(--rule); }
  .sidebar nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sidebar nav a { padding-inline: 6px; gap: 4px; min-height: 39px; font-size: .82rem; }
  .sidebar nav a::before { flex-basis: 3px; }
  .account { display: none; }
  .workspace-main { gap: 12px; }
  .columns, .columns.overview { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 510px) {
  .sidebar nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .workspace-main { padding-inline: 12px; }
  .topbar { padding-inline: 12px; }
  .top-actions .button { padding-inline: 6px; font-size: .81rem; }
  .metric, .panel { padding: 11px 12px; }
  .metrics { gap: 8px; }
  .filters { padding: 9px; }
  input, select { font-size: 16px; }
  .data-table thead { position: absolute; width: 1px; height: 1px; margin: -1px; clip-path: inset(50%); overflow: hidden; }
  .data-table tbody, .data-table tr, .data-table td { display: block; }
  .data-table tr { padding-block: 7px; }
  .data-table tr + tr { border-top: 1px solid var(--rule); }
  .data-table td, .data-table td:last-child { display: grid; grid-template-columns: minmax(95px, 1fr) minmax(0, 1.2fr); align-items: baseline; gap: 7px; text-align: left; border: 0; padding: 4px 2px; }
  .data-table td .badge { justify-self: start; }
  .data-table td .cell-note { grid-column: 2; }
  .cell-label { display: inline; color: var(--muted); font-size: .78rem; }
}
@media (pointer: coarse) {
  .button, .top-actions .button, .sidebar nav a, input, select, .custom-period summary { min-height: 44px; }
  .period-picks a { min-height: 41px; }
  .data-table .text-link { display: inline-flex; min-height: 34px; align-items: center; }
}
@media print {
  :root { color-scheme: light; }
  .layout { display: block; }
  .sidebar, .topbar, .page-tools, .periods, .filters, .pagination, .skip { display: none; }
  .workspace-main { padding: 0; }
  .panel, .metric { break-inside: avoid; box-shadow: none; }
}
