:root {
  --bg: #F5F2EB; --surface: #FFFFFF; --elevated: #FAF8F4; --border: #DDD7CA;
  --text: #171614; --muted: #666158; --accent: #B83A1B; --accent-ink: #FFFFFF;
  --ok: #1D6B42; --err: #B91C1C;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100dvh; overflow: hidden; font-family: 'Plus Jakarta Sans', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.mono { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: 13px; }
.err-msg { color: var(--err); font-size: 13px; margin: 0; }

.auth-gate { display: flex; align-items: center; justify-content: center; height: 100dvh; padding: 1rem; }
.auth-gate[hidden] { display: none; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem; display: flex; flex-direction: column; gap: 0.75rem; }
.brand-row { display: flex; align-items: center; gap: 0.5rem; font-size: 1.1rem; }
.seal-dot { width: 12px; height: 12px; background: var(--accent); border-radius: 2px; }
.auth-card label { display: flex; flex-direction: column; gap: 0.25rem; font-weight: 600; font-size: 12px; }
.auth-card input, .drawer-form input, .drawer-form select, .drawer-form textarea, #global-search {
  padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 4px; background: var(--elevated);
}

.admin-shell { display: flex; height: 100dvh; width: 100%; overflow: hidden; }
.admin-shell[hidden] { display: none; }
.sidebar { width: 220px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 1rem; gap: 1rem; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; }
.side-nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.side-nav button { text-align: left; padding: 0.5rem 0.75rem; min-height: 40px; border: none; background: transparent; border-radius: 4px; font-weight: 600; color: var(--muted); }
.side-nav button.is-active, .side-nav button:hover { background: var(--elevated); color: var(--text); }
.side-nav button.is-active { border-left: 3px solid var(--accent); color: var(--accent); }
.sidebar-foot { display: flex; flex-direction: column; gap: 0.5rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.top-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 0.75rem; }
.top-toolbar h1 { margin: 0; font-size: 1.15rem; }
.workspace-pane { flex: 1; min-height: 0; overflow-y: auto; padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: 1rem; }

.btn { padding: 0.45rem 0.9rem; min-height: 36px; border: 1px solid var(--border); background: var(--surface); border-radius: 4px; font-weight: 600; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.icon-btn { width: 36px; height: 36px; border: 1px solid var(--border); background: var(--elevated); border-radius: 4px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem; }
.kpi-box { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1rem; text-align: left; transition: border-color 0.15s ease; }
.kpi-box:hover { border-color: var(--accent); }
.kpi-box strong { display: block; font-size: 1.5rem; margin: 0.25rem 0; }
.trend-up { color: var(--ok); font-size: 12px; font-weight: 700; }

.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; overflow-x: auto; }
.dense-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dense-table th, .dense-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; }
.dense-table th { background: var(--elevated); font-weight: 700; cursor: pointer; user-select: none; }

.edit-drawer { width: 340px; flex-shrink: 0; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; padding: 1rem; gap: 1rem; overflow-y: auto; }
.edit-drawer[hidden] { display: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-form { display: flex; flex-direction: column; gap: 0.75rem; }
.drawer-form label { display: flex; flex-direction: column; gap: 0.25rem; font-weight: 600; font-size: 12px; }
.skeleton-row { height: 38px; margin: 0.5rem; border-radius: 4px; background: linear-gradient(90deg, #e5e0d5 25%, #f5f2eb 50%, #e5e0d5 75%); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.toast-stack { position: fixed; right: 1rem; bottom: 1rem; z-index: 90; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { padding: 0.65rem 1rem; background: var(--surface); border: 1px solid var(--text); border-radius: 6px; font-weight: 600; box-shadow: 0 6px 18px rgba(0,0,0,0.12); }

.mobile-only { display: none; }
@media (max-width: 768px) {
  .mobile-only { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar { position: fixed; left: -240px; top: 0; bottom: 0; z-index: 50; transition: left 0.2s ease; }
  .sidebar.is-open { left: 0; }
  .edit-drawer { position: fixed; inset: auto 0 0 0; width: 100%; max-height: 82dvh; border-left: none; border-top: 1px solid var(--border); z-index: 60; }
  .btn, .icon-btn, .side-nav button { min-height: 44px; }
}
