:root {
  --bg: #f9efd8;
  --bg-elevated: #fffcf4;
  --panel: #ffffff;
  --ink: #2a1710;
  --muted: #7a6350;
  --faint: #a6927c;
  --line: #e9dcc0;
  --line-soft: #f0e6d0;

  --sidebar: #241511;
  --sidebar-ink: #f3e6ce;
  --sidebar-ink-soft: #b89d82;
  --sidebar-line: #3c271e;

  --fire-1: #813921;
  --fire-2: #f9882a;
  --sienna: #813921;
  --accent: #f9882a;
  --accent-ink: #2a1105;

  --danger: #a23b2e;
  --danger-bg: #f5e0da;
  --warn: #a9762e;
  --warn-bg: #f5e8d2;
  --ok: #4c7a3d;
  --ok-bg: #e7eedf;
  --info: #4e6e7e;
  --info-bg: #e3ecee;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(42, 23, 16, 0.04), 0 8px 24px -12px rgba(42, 23, 16, 0.18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b100c;
    --bg-elevated: #221510;
    --panel: #2a1912;
    --ink: #f3e6ce;
    --muted: #c7ac8d;
    --faint: #8a7060;
    --line: #42291e;
    --line-soft: #361f16;
    --sidebar: #120a07;
    --sidebar-line: #2c1b14;
    --ok-bg: #26301f;
    --warn-bg: #332616;
    --danger-bg: #34201b;
    --info-bg: #1e2a2e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px -14px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--sidebar);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 30px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 4px;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  font-size: 22px;
}

.login-card p.sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--ink);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 11px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 13px;
}

.btn-primary { background: linear-gradient(135deg, var(--fire-1), var(--fire-2)); color: var(--accent-ink); }
.btn-primary:hover { opacity: 0.92; }
.btn-secondary { background: var(--panel); border-color: var(--line); color: var(--ink); }
.btn-danger { background: var(--panel); border-color: var(--danger); color: var(--danger); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; }

/* App shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  padding: 24px 16px 18px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sidebar-line);
}

.sidebar .brand {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: 25px;
  letter-spacing: 0.2px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.sidebar .brand::before {
  content: "";
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  border-image: linear-gradient(135deg, var(--fire-2), var(--fire-1)) 1;
}

.sidebar .role {
  font-size: 11.5px;
  color: var(--sidebar-ink-soft);
  margin-bottom: 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--sidebar-line);
}

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--sidebar-ink-soft);
  padding: 10px 12px;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 3px;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--sidebar-ink); }
.nav-item.active { background: linear-gradient(135deg, var(--fire-1), var(--fire-2)); color: var(--accent-ink); font-weight: 700; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--sidebar-line);
}

.main {
  flex: 1;
  padding: 30px 34px 60px;
  max-width: 1180px;
}

.main h2 {
  margin: 0 0 4px;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  font-size: 25px;
}

.main .page-sub {
  color: var(--muted);
  margin: 0 0 22px;
  font-size: 13.5px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.panel h3 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 700;
}

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 160px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line-soft);
}

th { color: var(--faint); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--line); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}

.badge-pending { background: var(--warn-bg); color: var(--warn); }
.badge-done { background: var(--ok-bg); color: var(--ok); }
.badge-cancel { background: var(--danger-bg); color: var(--danger); }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tab-btn {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.tab-btn.active { background: linear-gradient(135deg, var(--fire-1), var(--fire-2)); color: var(--accent-ink); border-color: transparent; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--fire-2);
}

.kpi-card .kpi-label { color: var(--muted); font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.kpi-card .kpi-value { font-family: "Fraunces", Georgia, serif; font-size: 23px; font-weight: 500; font-variant-numeric: tabular-nums; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-row .bar-label { width: 70px; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.bar-track { flex: 1; background: var(--line-soft); border-radius: 999px; height: 16px; overflow: hidden; }
.bar-fill { background: linear-gradient(90deg, var(--fire-1), var(--fire-2)); height: 100%; }
.bar-row .bar-value { width: 110px; text-align: right; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.empty-state { color: var(--muted); padding: 20px 0; text-align: center; }
