:root {
  --bg: #f4ede4;
  --bg-elev: #faf9f6;
  --bg-soft: #efe6da;
  --gold: #b79d71;
  --gold-2: #c9b07a;
  --rose: #c9ada7;
  --copper: #d4a373;
  --ink: #4a3d30;
  --muted: #8d7b68;
  --line: #e4d8c8;
  --danger: #9b4a3c;
  --ok: #6b7f5a;
  --shadow: 0 10px 30px rgba(74, 61, 48, 0.08);
  --radius: 14px;
  --nav: 72px;
  --safe-b: env(safe-area-inset-bottom);
  --font: "Outfit", system-ui, sans-serif;
  --serif: "Cormorant Garamond", Georgia, serif;
}

[data-theme="dark"] {
  --bg: #1a1612;
  --bg-elev: #241f19;
  --bg-soft: #2c261f;
  --gold: #c9b07a;
  --gold-2: #ddc49a;
  --rose: #c9ada7;
  --copper: #d4a373;
  --ink: #f4ede4;
  --muted: #b5a48f;
  --line: #3a3228;
  --danger: #e08a7a;
  --ok: #a3c48a;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); }
button, input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(183, 157, 113, 0.18), transparent 60%),
    var(--bg);
}
.login-card {
  width: min(420px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px 24px 22px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card img { width: 180px; border-radius: 16px; margin-bottom: 8px; }
.brand-name { font-family: var(--serif); letter-spacing: 0.42em; font-size: 22px; margin: 8px 0 0; }
.brand-tag { color: var(--muted); font-size: 13px; margin: 8px 0 22px; }
.login-card form { text-align: left; display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field span { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
}
.btn {
  appearance: none;
  border: 0;
  background: linear-gradient(135deg, var(--gold), var(--copper));
  color: #241f19;
  font-weight: 600;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  min-height: 44px;
}
.btn.secondary { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.ghost { background: var(--bg-soft); color: var(--ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.full { width: 100%; }
.btn:disabled { opacity: 0.55; }

.app-shell { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar img.logo { width: 36px; height: 36px; object-fit: cover; border-radius: 10px; }
.topbar .titles { flex: 1; min-width: 0; }
.topbar h1 { font-family: var(--serif); font-size: 20px; margin: 0; letter-spacing: 0.18em; font-weight: 600; }
.topbar p { margin: 0; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 44px; height: 44px; border: 1px solid var(--line); background: var(--bg-elev);
  border-radius: 12px; display: grid; place-items: center; cursor: pointer; position: relative; color: var(--ink);
}
.badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--copper); color: #241f19; border-radius: 99px;
  font-size: 10px; font-weight: 700; display: grid; place-items: center;
}
.layout { display: grid; grid-template-columns: 1fr; }
.sidebar { display: none; }
.content { padding: 16px 16px calc(var(--nav) + var(--safe-b) + 16px); max-width: 1200px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { font-family: var(--serif); font-size: 32px; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.grid { display: grid; gap: 12px; }
.grid.stats { grid-template-columns: repeat(2, 1fr); }
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 500; }
.metric { font-family: var(--serif); font-size: 28px; margin: 0; }
.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; letter-spacing: 0.04em; }
.row-link { cursor: pointer; }
.row-link:hover { background: var(--bg-soft); }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 99px; padding: 4px 10px; font-size: 12px;
  background: var(--bg-soft); color: var(--ink); border: 1px solid var(--line);
}
.pill.warn { background: color-mix(in srgb, var(--copper) 22%, var(--bg-elev)); }
.pill.ok { background: color-mix(in srgb, var(--ok) 18%, var(--bg-elev)); }
.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.searchbar input { flex: 1; }
.form-grid { display: grid; gap: 12px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--bg);
}
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--bg-elev); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.bottom-nav a, .bottom-nav button {
  display: grid; place-items: center; gap: 2px; min-height: 58px;
  background: none; border: 0; color: var(--muted); font-size: 11px; cursor: pointer;
}
.bottom-nav .on { color: var(--ink); }
.drawer-bg {
  position: fixed; inset: 0; background: rgba(26, 22, 18, 0.35); z-index: 40;
  opacity: 0; pointer-events: none; transition: 0.2s;
}
.drawer-bg.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%);
  background: var(--bg-elev); z-index: 41; transform: translateX(100%);
  transition: transform 0.22s ease; border-left: 1px solid var(--line);
  display: grid; grid-template-rows: auto 1fr auto;
}
.drawer.open { transform: none; }
.drawer header, .drawer footer { padding: 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.drawer footer { border-bottom: 0; border-top: 1px solid var(--line); }
.note { padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.note.unread { background: color-mix(in srgb, var(--gold) 12%, var(--bg-elev)); }
.note time { color: var(--muted); font-size: 12px; }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav) + 16px); z-index: 50;
  background: var(--ink); color: var(--bg); padding: 12px 14px; border-radius: 12px; display: none;
}
.toast.show { display: block; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.more-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--bg-elev); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0; padding: 12px 12px calc(12px + var(--safe-b));
  display: none; max-height: 70dvh; overflow: auto;
}
.more-sheet.open { display: block; }
.more-sheet a { display: block; padding: 12px; border-radius: 10px; }
.more-sheet a:hover { background: var(--bg-soft); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
.kpi { font-size: 12px; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.split { display: grid; gap: 12px; }
@media (min-width: 960px) {
  .layout { grid-template-columns: 240px 1fr; min-height: calc(100dvh - 64px); }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    padding: 16px 12px; border-right: 1px solid var(--line); background: var(--bg-elev);
    position: sticky; top: 64px; height: calc(100dvh - 64px); overflow: auto;
  }
  .sidebar a { padding: 10px 12px; border-radius: 10px; color: var(--muted); }
  .sidebar a.on, .sidebar a:hover { background: var(--bg-soft); color: var(--ink); }
  .bottom-nav, .more-sheet { display: none !important; }
  .content { padding: 24px; }
  .grid.stats { grid-template-columns: repeat(4, 1fr); }
  .split { grid-template-columns: 1.2fr 0.8fr; }
  .toast { left: auto; right: 24px; width: 320px; bottom: 24px; }
}
.err { color: var(--danger); font-size: 13px; min-height: 18px; }
.mono { font-variant-numeric: tabular-nums; }
.switch { display: flex; align-items: center; gap: 8px; }
.comp-row { display: grid; grid-template-columns: 1fr 1fr 90px auto; gap: 8px; align-items: end; }
@media (max-width: 700px) { .comp-row { grid-template-columns: 1fr 1fr; } }
