:root {
  --cream: #FBF8F4;
  --card: #FFFFFF;
  --sidebar: #FFFCF9;
  --orange: #F2861E;
  --orange-dark: #D96F0A;
  --orange-soft: #FDE7D3;
  --orange-ink: #A85406;
  --ink: #2B241E;
  --muted: #7D7268;
  --line: #EFE8E0;
  --good: #1F8A4C;
  --good-soft: #E0F4E8;
  --warn: #99600A;
  --warn-soft: #FDF0D5;
  --bad: #C8253A;
  --bad-soft: #FCE4E7;
  --radius: 14px;
  --font: 'Lexend', 'Segoe UI', sans-serif;
}

html, body { height: 100%; }
body { margin: 0; background: var(--cream); color: var(--ink); font-family: var(--font); font-size: 15px; font-weight: 400; line-height: 1.5; }
a { color: var(--orange-ink); text-underline-offset: 2px; }
a:hover { color: var(--orange-dark); }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

.shell { display: flex; min-height: 100vh; }
.side { width: 236px; flex-shrink: 0; display: flex; flex-direction: column; background: var(--sidebar); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand b { display: block; font-size: 1rem; font-weight: 600; line-height: 1.2; }
.brand small { display: block; font-size: .78rem; color: var(--muted); }
.side nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; flex: 1; }
.side nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: #4A4037; text-decoration: none; font-size: .9rem; }
.side nav a i { font-size: 1.02rem; }
.side nav a:hover { background: #FBF1E7; color: var(--ink); }
.side nav a.on { background: var(--orange-soft); color: var(--orange-ink); font-weight: 500; }
.logout { padding: 14px 12px 18px; }
.logout button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border: 0; border-radius: 10px; background: none; color: #4A4037; font: inherit; font-size: .9rem; text-align: left; }
.logout button:hover { background: #FBF1E7; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 26px; background: var(--sidebar); border-bottom: 1px solid var(--line); }
.menu { display: none; border: 0; background: none; font-size: 1.6rem; padding: 0 4px; color: var(--ink); }
.hello { font-weight: 600; margin-right: auto; white-space: nowrap; }
.find { position: relative; width: 290px; }
.find i { position: absolute; left: 12px; top: 8px; color: var(--muted); }
.find input { width: 100%; padding: 7px 12px 7px 34px; border: 1px solid var(--line); border-radius: 10px; background: #F8F3ED; font: inherit; font-size: .875rem; }
.bell { position: relative; display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--card); text-decoration: none; }
.bell span { position: absolute; top: -6px; right: -6px; min-width: 18px; padding: 0 4px; border-radius: 9px; background: var(--orange-dark); color: #fff; font-size: .68rem; font-weight: 600; line-height: 18px; text-align: center; }
.me { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--orange-soft); color: var(--orange-ink); font-size: .82rem; font-weight: 600; text-decoration: none; }
.page { flex: 1; padding: 24px 26px 28px; max-width: 1400px; width: 100%; }
.foot { padding: 10px 26px 16px; color: var(--muted); font-size: .82rem; }

.title { font-size: 1.45rem; font-weight: 600; line-height: 1.2; margin: 0 0 16px; }
.sub { font-size: .98rem; font-weight: 500; margin: 0; }
.lead-note { color: var(--muted); margin: -8px 0 16px; }
.hint { color: var(--muted); font-size: .875rem; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.head-acts { display: flex; gap: 8px; flex-wrap: wrap; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 12px; }
.stat { display: block; padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.stat:hover { border-color: var(--orange); color: var(--ink); }
.stat span { display: block; font-size: .875rem; }
.stat b { display: block; margin: 4px 0 6px; font-size: 1.6rem; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.stat small { display: block; font-size: .78rem; color: var(--muted); }
.stat small.up { color: var(--good); }
.stat small.down { color: var(--bad); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chips a { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px; background: #FDF1E5; color: var(--orange-ink); font-size: .84rem; text-decoration: none; }
.chips a:hover { background: var(--orange-soft); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush > .sub { padding: 16px 18px 0; margin-bottom: 10px; }
.panel:not(.flush) > .sub { margin-bottom: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.panel-head a { color: var(--orange-ink); font-size: .84rem; font-weight: 500; text-decoration: none; }
.panel-head .sub { margin: 0; }
.panel:not(.flush) > .big { margin-top: -6px; }
.big { margin: 0; font-size: 1.5rem; font-weight: 600; line-height: 1.25; }
.period { margin: 2px 0 8px; color: var(--orange-ink); font-size: .8rem; }
.chart-line, .chart-bars { position: relative; height: 240px; }
.empty { padding: 20px 18px; margin: 0; color: var(--muted); }
.panel:not(.flush) > .empty { padding: 12px 0; }
.pad-acts { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 18px 12px; }
.form-narrow { max-width: 540px; }
.form-mid { max-width: 780px; }

.items { list-style: none; margin: 0; padding: 0; }
.items li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.items li:last-child { border-bottom: 0; padding-bottom: 0; }
.items li > div { flex: 1; min-width: 0; }
.items a { color: var(--ink); font-weight: 500; text-decoration: none; }
.items a:hover { color: var(--orange-ink); }
.items small { display: block; color: var(--muted); font-size: .8rem; }
.days { display: inline-flex; align-items: center; gap: 6px; color: #4A4037; font-size: .84rem; white-space: nowrap; }
.paid { color: var(--orange-ink); font-size: .84rem; white-space: nowrap; }
.av { display: grid; place-items: center; flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; background: var(--orange-soft); color: var(--orange-ink); font-size: .82rem; font-weight: 600; }

.table-wrap { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
.grid th { padding: 10px 18px; text-align: left; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; background: #FDFAF6; }
.grid td { padding: 11px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover { background: #FEFAF5; }
.grid tfoot td { border-top: 1px solid #D8CDC1; border-bottom: 0; font-weight: 600; }
.grid small { display: block; color: var(--muted); }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid .end { text-align: right; white-space: nowrap; }
.grid .strong { font-weight: 600; }
.grid .wide { min-width: 320px; }
.voided td { color: var(--muted); text-decoration: line-through; }
.voided td.end { text-decoration: none; }
.acts > a, .acts > form { display: inline-block; margin-left: 12px; }

.tag { display: inline-block; padding: 1px 10px; border-radius: 999px; background: #F1ECE6; color: #574C42; font-size: .8rem; font-weight: 500; white-space: nowrap; }
.tag-good { background: var(--good-soft); color: #176B3A; }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-bad { background: var(--bad-soft); color: #A81C30; }

.btn { border-radius: 10px; font-weight: 500; font-size: .9rem; padding: 7px 14px; }
.btn-sm { font-size: .82rem; padding: 4px 10px; border-radius: 8px; }
.btn-main { background: var(--orange-dark); border: 1px solid var(--orange-dark); color: #fff; }
.btn-main:hover, .btn-main:focus { background: #BC5F07; border-color: #BC5F07; color: #fff; }
.btn-quiet { background: var(--card); border: 1px solid #DDD2C6; color: var(--ink); }
.btn-quiet:hover { border-color: var(--orange); color: var(--ink); }
.btn-bad { background: var(--card); border: 1px solid var(--bad); color: var(--bad); white-space: nowrap; }
.btn-bad:hover { background: var(--bad); color: #fff; }
.link-bad, .link-main { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; text-underline-offset: 2px; }
.link-bad { color: var(--bad); }
.link-main { color: var(--orange-ink); }

.form-label { font-size: .875rem; font-weight: 500; margin-bottom: 4px; }
.form-control, .form-select { border-radius: 10px; border-color: #DDD2C6; font-size: .92rem; }
.form-control:focus, .form-select:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(242,134,30,.18); }
.form-check-input:checked { background-color: var(--orange-dark); border-color: var(--orange-dark); }
.form-check-input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(242,134,30,.18); }
.field-error { color: var(--bad); font-size: .85rem; }
.field-error ul { margin: 0; padding: 0; list-style: none; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters .form-control, .filters .form-select { width: auto; flex: 0 1 220px; min-width: 150px; }
.filters input[type=search] { flex-basis: 320px; }
.inline-form { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.inline-form .form-control { min-width: 150px; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 6px 14px; border-radius: 10px; color: var(--muted); font-size: .9rem; text-decoration: none; white-space: nowrap; }
.tabs a:hover { color: var(--ink); background: #FBF1E7; }
.tabs a.on { background: var(--orange-soft); color: var(--orange-ink); font-weight: 500; }
.tabs-small a { font-size: .84rem; padding: 4px 12px; }

.flash { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .9rem; }
.flash i { margin-top: 1px; }
.flash-good { background: var(--good-soft); color: #176B3A; }
.flash-bad { background: var(--bad-soft); color: #A81C30; }

.facts-list { display: grid; grid-template-columns: 120px 1fr; gap: 6px 14px; margin: 0; font-size: .92rem; }
.facts-list dt { color: var(--muted); font-weight: 400; }
.facts-list dd { margin: 0; min-height: 1.5em; overflow-wrap: anywhere; }
.log { list-style: none; margin: 0; padding: 0 18px 14px; font-size: .9rem; }
.log li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.log li:last-child { border-bottom: 0; }
.log small { display: block; color: var(--muted); }
.msg { padding: 12px 0; border-bottom: 1px solid var(--line); }
.msg:first-child { padding-top: 0; }
.msg:last-child { border-bottom: 0; padding-bottom: 0; }
.msg small { color: var(--muted); }
.msg p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.receipt { max-width: 720px; }
.receipt-top { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.receipt-top h2 { font-size: 1.25rem; font-weight: 600; margin: 0; }
.receipt-top p { margin: 0; color: var(--muted); }
.receipt-top .end { text-align: right; }
.receipt-sum { margin-top: 18px; }
.receipt-sum td { padding-left: 0; padding-right: 0; }

.auth { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 400px; padding: 26px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; }
.auth-box .brand { padding: 0 0 18px; }
.auth-box h2 { font-size: 1.3rem; font-weight: 600; margin-bottom: 16px; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .side { position: fixed; z-index: 20; left: -250px; transition: left .18s; }
  .side.open { left: 0; }
  .menu { display: block; }
  .top, .page, .foot { padding-left: 16px; padding-right: 16px; }
  .hello { display: none; }
  .find { flex: 1; width: auto; }
}
@media (max-width: 480px) {
  .stat { padding: 14px; }
  .stat b { font-size: 1.3rem; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }
@media print {
  .side, .top, .foot, .no-print { display: none !important; }
  body { background: #fff; }
  .page { padding: 0; }
  .panel { border: 0; }
}
