:root {
  --ink: #241e1a;
  --muted: #6d625c;
  --background: #f8f6f3;
  --surface: #ffffff;
  --surface-alt: #f2ede8;
  --border: #ded4cc;
  --primary: #70462e;
  --primary-hover: #5d3824;
  --sage: #527057;
  --sage-soft: #e7f0e5;
  --warning: #935b1e;
  --warning-soft: #fff0d8;
  --danger: #a33024;
  --danger-soft: #fde7e3;
  --shadow: 0 8px 28px rgba(75, 50, 34, .08);
  font-family: "Prompt", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: var(--background); }
body.auth-pending { overflow: hidden; background: #312923; }
body.auth-pending::before { position: fixed; inset: -28px; z-index: 0; background: rgba(38, 31, 27, .72) url("../../screen.png") center / cover no-repeat; background-blend-mode: multiply; content: ""; filter: blur(14px); pointer-events: none; transform: scale(1.06); }
body.auth-pending .app-shell { visibility: hidden; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
svg { width: 19px; height: 19px; stroke-width: 1.8; }

.app-shell { min-height: 100vh; padding-left: 260px; }
.sidebar { position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; width: 260px; padding: 24px 14px 16px; background: #2f2925; color: #f9f4f0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 58px; height: 58px; flex: 0 0 58px; object-fit: contain; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; color: #fff4ec; background: var(--primary); border-radius: 7px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 15px; font-weight: 600; }
.brand span { color: #cbbdb4; font-size: 11px; }
.sidebar-user { display: flex; gap: 10px; align-items: center; margin: 34px 8px 22px; padding: 12px 0; border-top: 1px solid rgba(255,255,255,.12); border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar-user strong { display: block; font-size: 13px; font-weight: 500; }
.sidebar-user span:not(.avatar) { display: block; color: #cbbdb4; font-size: 12px; }
.avatar { display: inline-grid; width: 32px; height: 32px; flex: 0 0 32px; place-items: center; border-radius: 50%; background: #d9e9d5; color: #325537; font-size: 13px; font-weight: 600; }
.nav-list { display: grid; gap: 3px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border: 0; border-radius: 5px; background: transparent; color: #d7cbc4; text-align: left; font-size: 13px; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(219, 174, 145, .16); color: #fff0e8; box-shadow: inset 3px 0 var(--primary); }
.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.12); }

.main-content { width: min(1440px, 100%); margin: auto; padding: 0 42px 44px; }
.topbar { display: flex; height: 72px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.topbar-date, .topbar-actions, .profile-button { display: flex; align-items: center; gap: 9px; }
.topbar-date { color: var(--muted); font-size: 13px; }
.topbar-date svg { color: var(--primary); }
.topbar-actions { gap: 14px; }
.profile-button { padding: 4px; border: 0; background: transparent; color: var(--ink); font-size: 13px; }
.profile-button svg { width: 15px; height: 15px; color: var(--muted); }
.icon-button { display: inline-grid; width: 36px; height: 36px; place-items: center; border: 0; border-radius: 5px; background: transparent; color: var(--ink); }
.icon-button:hover { background: var(--surface-alt); }
.mobile-menu { display: none; }
.notification-button { position: relative; }
.notification-button b { position: absolute; right: 2px; top: 1px; display: grid; width: 16px; height: 16px; place-items: center; border-radius: 50%; background: var(--danger); color: white; font-size: 10px; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 34px 0 22px; }
.eyebrow, .section-label { margin: 0 0 5px; color: var(--primary); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 30px; letter-spacing: 0; line-height: 1.25; }
h2 { margin-bottom: 0; font-size: 18px; line-height: 1.4; }
.page-header p:not(.eyebrow) { margin-bottom: 0; color: var(--muted); font-size: 14px; }
.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.date-control { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--muted); }
.date-control svg { width: 17px; }
.date-control input { width: 128px; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 13px; }
.button { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; gap: 7px; padding: 0 14px; border: 1px solid transparent; border-radius: 5px; font-size: 13px; font-weight: 500; }
.button svg { width: 16px; height: 16px; }
.button.primary { background: var(--primary); color: white; }
.button.primary:hover { background: var(--primary-hover); }
.button.secondary { border-color: var(--primary); background: var(--surface); color: var(--primary); }
.button.secondary:hover { background: #fcf5ef; }
.button.text { padding-inline: 5px; background: transparent; color: var(--primary); }
.button.text:hover { text-decoration: underline; }
.full-width { width: 100%; }

.alert-panel { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; padding: 12px 16px; border: 1px solid #edc78b; border-radius: 6px; background: var(--warning-soft); color: #694312; }
.alert-panel > div { display: flex; align-items: center; gap: 12px; }
.alert-panel svg { color: var(--warning); }
.alert-panel strong, .alert-panel span { display: block; }
.alert-panel strong { font-size: 13px; }
.alert-panel span { color: #7d684c; font-size: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-card, .panel, .report-status, .quick-actions { border: 1px solid var(--border); border-radius: 6px; background: var(--surface); box-shadow: 0 1px 1px rgba(75, 50, 34, .02); }
.stat-card { position: relative; min-height: 130px; padding: 16px; overflow: hidden; }
.stat-card > span { display: block; color: var(--muted); font-size: 12px; }
.stat-card strong { display: inline-block; margin: 18px 5px 0 0; font-size: 30px; line-height: 1; }
.stat-card small { color: var(--muted); font-size: 12px; }
.stat-card.emphasis { border-color: #d7b9a6; background: #fdf9f6; }
.stat-card.emphasis strong { color: var(--primary); }
.status-row { display: flex; gap: 14px; margin-top: 14px; }
.report-status { flex: 1; padding: 15px 17px; }
.status-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.status-heading h2 { font-size: 17px; }
.badge { display: inline-flex; align-items: center; width: max-content; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.badge.waiting { background: var(--warning-soft); color: #87541e; }
.badge.complete { background: var(--sage-soft); color: #3c653f; }
.badge.error { background: var(--danger-soft); color: var(--danger); }
.badge.revised { background: #eee7fa; color: #624991; }
.status-meta { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; color: var(--muted); font-size: 12px; }
.status-meta span { display: inline-flex; align-items: center; gap: 5px; }
.status-meta svg { width: 15px; color: var(--primary); }
.status-meta b { color: var(--ink); font-weight: 500; }
.report-note { margin: 14px 0 0; padding: 10px 12px; border-left: 3px solid var(--primary); background: #faf7f4; color: var(--muted); font-size: 12px; line-height: 1.6; white-space: pre-wrap; }
.quick-actions { display: flex; padding: 4px; }
.quick-action { display: grid; width: 66px; min-height: 80px; place-items: center; align-content: center; gap: 5px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 11px; }
.quick-action:hover { background: var(--surface-alt); color: var(--primary); }
.quick-action svg { width: 21px; height: 21px; color: var(--primary); }

.record-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(330px, .85fr); gap: 14px; margin-top: 14px; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin-top: 14px; }
.panel { overflow: hidden; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 18px 14px; border-bottom: 1px solid var(--border); }
.panel-header h2 { font-size: 17px; }
.muted { color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 650px; border-spacing: 0; border-collapse: collapse; font-size: 12px; }
th { padding: 10px 16px; border-bottom: 1px solid var(--border); background: #fbfaf8; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
td { padding: 11px 16px; border-bottom: 1px solid #eee9e5; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfaf8; }
.number { text-align: right; }
td.number { font-weight: 500; text-align: right; }
.entry-name { color: var(--ink); font-weight: 500; }
.entry-source, .entry-time { color: var(--muted); }
.table-totals { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 25px; padding: 14px 16px; border-top: 2px solid var(--border); background: #faf7f4; }
.table-totals div { display: grid; gap: 2px; }
.table-totals span { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.table-totals strong { font-size: 15px; }
.table-totals .grand-total { padding-left: 22px; border-left: 1px solid var(--border); }
.table-totals .grand-total strong { color: var(--primary); font-size: 18px; }
.resort-panel .table-totals { min-height: 67px; align-items: center; }
.resort-panel .table-totals .grand-total { padding-left: 0; border-left: 0; }
.trend-panel { display: flex; flex-direction: column; }
.bar-chart { display: flex; height: 256px; align-items: end; justify-content: space-around; gap: 9px; padding: 22px 18px 12px; border-bottom: 1px solid var(--border); }
.bar-group { display: grid; height: 100%; flex: 1; align-items: end; justify-items: center; grid-template-columns: 1fr 1fr; gap: 3px; }
.bar { width: min(18px, 80%); align-self: end; border-radius: 3px 3px 0 0; background: var(--primary); }
.bar.resort { background: var(--sage); }
.bar-group small { grid-column: 1 / -1; margin-top: 6px; color: var(--muted); font-size: 9px; }
.chart-legend { display: flex; gap: 14px; padding: 14px 18px; color: var(--muted); font-size: 11px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--primary); }
.chart-legend span:last-child i { background: var(--sage); }
.history-panel { margin-top: 14px; }
.history-list { display: grid; }
.history-item { display: flex; align-items: center; gap: 11px; padding: 12px 18px; border-bottom: 1px solid #eee9e5; }
.history-item:last-child { border-bottom: 0; }
.history-icon { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 50%; background: var(--sage-soft); color: var(--sage); }
.history-icon svg { width: 16px; }
.history-item div:nth-child(2) { flex: 1; }
.history-item strong, .history-item span:not(.badge) { display: block; }
.history-item strong { font-size: 12px; font-weight: 500; }
.history-item span:not(.badge) { color: var(--muted); font-size: 11px; }

.comparison-panel { margin-top: 14px; }
.period-summary { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--border); }
.period-summary > div { min-height: 108px; padding: 16px 18px; border-right: 1px solid var(--border); }
.period-summary > div:last-child { border-right: 0; background: #faf7f4; }
.period-summary span, .period-summary small { display: block; color: var(--muted); font-size: 11px; }
.period-summary strong { display: inline-block; margin: 15px 5px 0 0; color: var(--primary); font-size: 25px; line-height: 1; }
.comparison-note { margin: 0; padding: 12px 18px; color: var(--muted); font-size: 11px; }

.modal { width: min(590px, calc(100% - 30px)); max-height: min(760px, calc(100vh - 30px)); padding: 0; border: 0; border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
#login-modal { overflow: hidden; }
.modal::backdrop { background: rgba(26, 21, 18, .46); }
.modal-content { display: flex; max-height: inherit; flex-direction: column; padding: 20px; overflow: auto; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.modal-header h2 { font-size: 20px; }
.modal-note { margin: 0 0 14px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.entry-form-list { display: grid; gap: 8px; margin-bottom: 14px; }
.entry-form-group { display: grid; gap: 4px; }
.entry-group-heading { display: grid; gap: 1px; padding: 10px 0 7px; border-bottom: 2px solid var(--border); }
.entry-group-heading strong { color: var(--primary); font-size: 13px; }
.entry-group-heading span { color: var(--muted); font-size: 11px; }
.entry-field { display: grid; grid-template-columns: 1fr 124px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid #eee9e5; }
.entry-field label { font-size: 13px; font-weight: 500; }
.entry-field small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.field { display: grid; gap: 5px; margin-bottom: 13px; }
.field span { color: var(--muted); font-size: 12px; }
.field input, .field textarea, .entry-field input { width: 100%; padding: 8px 9px; border: 1px solid var(--border); border-radius: 5px; outline: none; background: white; color: var(--ink); }
.field input:focus, .field textarea:focus, .entry-field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(112,70,46,.1); }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 16px; }
.line-card { margin: 4px 0 14px; padding: 16px; border: 1px solid var(--border); border-radius: 6px; background: #fbfaf8; }
.line-card-header { padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.line-card-header strong, .line-card-header span { display: block; }
.line-card-header strong { font-size: 15px; }
.line-card-header span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.line-card-totals { display: grid; gap: 8px; margin-top: 13px; }
.line-card-totals div { display: flex; justify-content: space-between; font-size: 12px; }
.line-card-totals div:last-child { padding-top: 8px; border-top: 1px solid var(--border); font-size: 14px; font-weight: 600; }
.line-card-totals strong { color: var(--primary); }
.login-content { padding: 28px; }
.login-content { min-width: min(420px, calc(100vw - 30px)); border: 1px solid rgba(255, 255, 255, .5); background: rgba(255, 255, 255, .96); }
.login-brand { margin-bottom: 24px; color: var(--ink); }
.login-logo { width: 124px; height: 96px; flex-basis: 124px; }
.login-brand span { color: var(--muted); }
.login-content h2 { margin-bottom: 6px; font-size: 22px; }
.form-message { min-height: 18px; margin: -4px 0 8px; color: var(--danger); font-size: 12px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 100; max-width: min(380px, calc(100% - 40px)); padding: 12px 15px; border-radius: 6px; box-shadow: var(--shadow); color: white; font-size: 13px; }
.toast.success { background: #3f6845; }
.toast.error { background: #9a3228; }

@media (max-width: 1100px) { .stats-grid, .period-summary { grid-template-columns: repeat(2, 1fr); } .record-grid, .content-grid { grid-template-columns: 1fr; } .trend-panel { min-height: 330px; } .period-summary > div:nth-child(2) { border-right: 0; } .period-summary > div:nth-child(-n+2) { border-bottom: 1px solid var(--border); } }
@media (max-width: 820px) {
  .app-shell { padding-left: 0; padding-bottom: 70px; }
  .sidebar { display: none; }
  .sidebar.open { display: flex; width: 280px; box-shadow: var(--shadow); }
  .main-content { padding: 0 16px 28px; }
  .topbar { height: 60px; }
  .mobile-menu { display: inline-grid; }
  .topbar-date { display: none; }
  .page-header { align-items: flex-start; flex-direction: column; padding-top: 25px; }
  .header-actions { justify-content: flex-start; }
  .status-row { flex-direction: column; }
  .record-grid { grid-template-columns: 1fr; }
  .quick-actions { justify-content: stretch; }
  .quick-action { flex: 1; min-height: 58px; grid-template-columns: auto auto; }
}
@media (max-width: 540px) {
  h1 { font-size: 25px; }
  .topbar-user-name, #topbar-user-name { display: none; }
  .profile-button { padding-right: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { min-height: 105px; padding: 13px; }
  .stat-card strong { margin-top: 14px; font-size: 24px; }
  .alert-panel { align-items: flex-start; flex-direction: column; }
  .date-control { width: 100%; }
  .date-control input { flex: 1; width: auto; }
  .header-actions { width: 100%; }
  .header-actions .button { flex: 1; padding-inline: 8px; }
  .table-totals { justify-content: space-between; gap: 12px; }
  .table-totals .grand-total { width: 100%; padding: 10px 0 0; border-top: 1px solid var(--border); border-left: 0; }
  .period-summary { grid-template-columns: 1fr 1fr; }
  .period-summary > div { min-height: 96px; padding: 13px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .button { width: 100%; }
  .toast { right: 16px; bottom: 16px; }
}
