:root {
  --ink: #2d2926;
  --muted: #756e68;
  --paper: #f6f1e8;
  --surface: #fffdf8;
  --wine: #6f1d37;
  --wine-dark: #501127;
  --vine: #53633f;
  --gold: #b58b52;
  --line: #ded5c8;
  --danger: #a23131;
  --success: #3f6c45;
  --shadow: 0 14px 36px rgba(66, 45, 33, .10);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: linear-gradient(145deg, #f7f2e9 0%, #efe7da 100%); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: inherit; }
button, input, select { font: inherit; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 74px; padding: 10px clamp(16px, 4vw, 48px); color: #fff; background: rgba(66, 15, 34, .97); border-bottom: 3px solid var(--gold); box-shadow: 0 6px 18px rgba(54, 15, 30, .18); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand-mark, .auth-emblem { display: grid; place-items: center; color: #fff; background: var(--wine); border: 1px solid rgba(255,255,255,.32); letter-spacing: .08em; font-weight: 800; }
.brand-mark { width: 44px; height: 44px; border-radius: 50%; font-size: 13px; }
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, serif; font-size: 20px; letter-spacing: .02em; }
.brand small { margin-top: 2px; color: #ddc9b3; font-size: 12px; }
.main-nav { display: flex; align-items: center; gap: 6px; }
.main-nav a { padding: 10px 13px; border-radius: 8px; color: #f3e8df; text-decoration: none; font-size: 14px; }
.main-nav a:hover, .main-nav a.is-active { background: rgba(255,255,255,.12); color: #fff; }
.nav-toggle { display: none; color: #fff; background: transparent; border: 0; font-size: 26px; }

.page-shell { width: min(1180px, calc(100% - 28px)); margin: 28px auto 60px; }
.auth-shell { display: grid; place-items: center; min-height: calc(100vh - 70px); }
.site-footer { padding: 20px; color: var(--muted); text-align: center; font-size: 12px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 6px; color: var(--wine); font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; }
h1 { margin: 0; font-size: clamp(29px, 5vw, 44px); font-weight: 500; line-height: 1.05; }
h2 { margin: 0 0 16px; font-size: 24px; font-weight: 500; }
h3 { margin: 0 0 10px; font-size: 18px; }
.intro, .muted { color: var(--muted); }
.intro { line-height: 1.55; }

.card, .auth-card { background: rgba(255,253,248,.96); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card { padding: clamp(18px, 3vw, 30px); }
.auth-card { width: min(440px, 100%); padding: 38px; }
.auth-emblem { width: 58px; height: 58px; margin-bottom: 26px; border-radius: 50%; box-shadow: 0 7px 16px rgba(111,29,55,.20); }
.auth-card h1 { font-size: 38px; }

.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; }
.field { grid-column: span 4; }
.field-wide { grid-column: span 6; }
.field-full { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: #514b46; font-size: 13px; font-weight: 700; }
input, select { width: 100%; min-height: 46px; padding: 10px 12px; color: var(--ink); background: #fff; border: 1px solid #cfc4b6; border-radius: 9px; outline: 0; }
input:focus, select:focus { border-color: var(--wine); box-shadow: 0 0 0 3px rgba(111,29,55,.10); }
input[readonly] { background: #eee8df; color: #5c5550; }
.stack-form { display: grid; gap: 17px; margin-top: 24px; }
.check-row { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; line-height: 1.4; }
.check-row input { width: 18px; min-height: 18px; margin-top: 1px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border: 1px solid transparent; border-radius: 9px; cursor: pointer; text-decoration: none; font-weight: 750; }
.button-primary { color: #fff; background: var(--wine); }
.button-primary:hover { background: var(--wine-dark); }
.button-secondary { color: var(--wine); background: #fff; border-color: #ccb8bf; }
.button-danger { color: #fff; background: var(--danger); }
.button-small { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.button-wide { width: 100%; }

.alert { margin: 0 0 18px; padding: 13px 16px; border-radius: 9px; border-left: 4px solid; }
.alert-success { color: #244c2b; background: #e5f2e6; border-color: var(--success); }
.alert-error { color: #6e2020; background: #f8e5e2; border-color: var(--danger); }
.alert-info { color: #4e422a; background: #f4ead7; border-color: var(--gold); }

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0; }
.kpi { padding: 15px; background: #f2ece2; border-radius: 10px; }
.kpi span { display: block; color: var(--muted); font-size: 12px; }
.kpi strong { display: block; margin-top: 4px; font-size: 22px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 13px; }
th, td { padding: 11px 12px; border-bottom: 1px solid #e7dfd4; text-align: left; white-space: nowrap; }
th { color: #5c5148; background: #eee6da; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 6px; }
.allocation-row { display: grid; grid-template-columns: 1fr 1fr .7fr .7fr auto; gap: 10px; align-items: center; min-width: 720px; }
.filters { display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; gap: 12px; margin-bottom: 18px; }
.tabs { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 20px; }
.tabs a { padding: 9px 13px; color: var(--wine); background: #fff; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; font-weight: 700; font-size: 13px; }
.tabs a.is-active { color: #fff; background: var(--wine); border-color: var(--wine); }
.split { display: grid; grid-template-columns: 1fr 1.4fr; gap: 22px; }
.status-pill { display: inline-flex; padding: 4px 8px; border-radius: 99px; font-size: 11px; font-weight: 800; }
.status-complete { color: #285732; background: #dfeee1; }
.status-pending { color: #75571c; background: #f4e8c9; }

@media (max-width: 820px) {
  .nav-toggle { display: block; }
  .main-nav { display: none; position: absolute; top: 72px; left: 14px; right: 14px; flex-direction: column; align-items: stretch; padding: 10px; background: var(--wine-dark); border-radius: 10px; box-shadow: var(--shadow); }
  .main-nav.is-open { display: flex; }
  .field, .field-wide { grid-column: span 6; }
  .filters { grid-template-columns: 1fr 1fr; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  .page-shell { width: min(100% - 18px, 1180px); margin-top: 18px; }
  .auth-card, .card { padding: 20px; }
  .field, .field-wide { grid-column: 1 / -1; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
  .filters { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .page-head { align-items: flex-start; flex-direction: column; }
}
