:root {
  --bg: #0c0b0a;
  --bg-2: #141210;
  --bg-3: #1d1a16;
  --ink: #f5f0e6;
  --muted: #a69c8e;
  --line: rgba(245, 240, 230, 0.11);
  --gold: #d6a148;
  --gold-hi: #ecc77c;
  --ok: #22c55e;
  --warn: #eab308;
  --err: #ef4444;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Manrope', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="light"] {
  --bg: #f4efe6;
  --bg-2: #fbf8f2;
  --bg-3: #ebe3d5;
  --ink: #161310;
  --muted: #5c5348;
  --line: rgba(22, 19, 16, 0.12);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
}

/* Login */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: radial-gradient(circle at 75% 20%, rgba(214, 161, 72, 0.14), transparent 55%), var(--bg);
}

.login-card {
  width: min(430px, 100%);
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 2.2rem;
}

.login-brand { display: flex; align-items: center; gap: 0.9rem; margin-bottom: 1.8rem; }
.login-brand h1 { margin: 0; font-family: var(--font-display); font-size: 1.55rem; }
.login-brand h1 span { color: var(--gold); }
.login-brand p { margin: 0.15rem 0 0; font-size: 0.84rem; color: var(--muted); }
.login-foot { margin: 1.25rem 0 0; font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted); text-align: center; }

.brand-mark {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: var(--gold); color: #12100d;
  font-family: var(--font-display); font-weight: 700; font-size: 1.35rem;
  flex-shrink: 0;
}
.brand-mark--sm { width: 32px; height: 32px; font-size: 1rem; }

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

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease;
}

.sidebar.is-collapsed { width: 68px; }
.sidebar.is-collapsed .sidebar__brand-txt,
.sidebar.is-collapsed .nav-group__label,
.sidebar.is-collapsed .nav-item { font-size: 0; }
.sidebar.is-collapsed .nav-item span { font-size: 0.78rem; }

.sidebar__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--line);
}

.sidebar__brand { display: flex; align-items: center; gap: 0.65rem; }
.sidebar__brand strong { font-family: var(--font-display); font-size: 1.05rem; display: block; line-height: 1.1; }
.sidebar__brand strong span { color: var(--gold); }
.sidebar__brand small { font-family: var(--font-mono); font-size: 0.64rem; color: var(--muted); }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 0.75rem 0.6rem 2rem; }
.nav-group { margin-bottom: 1rem; }
.nav-group__label {
  display: block; padding: 0.35rem 0.6rem;
  font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
}

.nav-item {
  width: 100%; display: flex; align-items: center; gap: 0.65rem;
  padding: 0.52rem 0.65rem; margin-bottom: 2px;
  background: transparent; border: 1px solid transparent; border-radius: 4px;
  color: var(--muted); font-size: 0.85rem; font-weight: 500; text-align: left;
  cursor: pointer; transition: all 0.15s;
}
.nav-item span { font-family: var(--font-mono); font-size: 0.72rem; color: var(--gold); min-width: 1.35rem; }
.nav-item:hover { background: var(--bg-3); color: var(--ink); }
.nav-item.is-active { background: rgba(214, 161, 72, 0.14); border-color: rgba(214, 161, 72, 0.4); color: var(--ink); font-weight: 600; }

.pill-count {
  margin-left: auto; font-style: normal; font-family: var(--font-mono); font-size: 0.68rem;
  background: var(--gold); color: #12100d; padding: 0.08rem 0.45rem; border-radius: 99px; font-weight: 700;
}

/* Workspace & Topbar */
.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 58px;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 1.35rem;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}

.topbar__left, .topbar__right { display: flex; align-items: center; gap: 0.7rem; }

.global-search input {
  width: min(320px, 42vw);
  padding: 0.48rem 0.8rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
  color: var(--ink); font-size: 0.84rem;
}

.status-chip {
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--ok);
  padding: 0.25rem 0.6rem; border: 1px solid rgba(34, 197, 94, 0.35); border-radius: 99px;
}

.user-pill { display: flex; flex-direction: column; line-height: 1.1; text-align: right; }
.user-pill strong { font-size: 0.82rem; }
.user-pill small { font-family: var(--font-mono); font-size: 0.68rem; color: var(--gold); text-transform: uppercase; }

.content { padding: 1.5rem; flex: 1; }

/* Common UI */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.page-head h2 { margin: 0; font-family: var(--font-display); font-size: 1.65rem; letter-spacing: -0.02em; }
.page-head p { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.88rem; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(195px, 1fr)); gap: 0.9rem; margin-bottom: 1.35rem; }
.kpi-card {
  background: var(--bg-2); border: 1px solid var(--line); padding: 1.1rem 1.2rem;
}
.kpi-card__label { font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); display: flex; justify-content: space-between; }
.kpi-card__val { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; margin: 0.35rem 0 0.2rem; color: var(--ink); }
.kpi-card__sub { font-size: 0.78rem; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.panel { background: var(--bg-2); border: 1px solid var(--line); padding: 1.2rem; margin-bottom: 1rem; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-bottom: 0.9rem; }
.panel__head h3 { margin: 0; font-family: var(--font-display); font-size: 1.06rem; }

.chart-box { width: 100%; height: 280px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--line); text-align: left; }
th { font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

/* Kanban */
.kanban { display: flex; gap: 0.85rem; overflow-x: auto; padding-bottom: 1rem; }
.kanban-col { min-width: 240px; max-width: 260px; flex-shrink: 0; background: var(--bg-2); border: 1px solid var(--line); padding: 0.8rem; }
.kanban-col__head { display: flex; justify-content: space-between; align-items: center; font-family: var(--font-mono); font-size: 0.72rem; color: var(--gold); margin-bottom: 0.7rem; text-transform: uppercase; }
.kanban-card { background: var(--bg-3); border: 1px solid var(--line); padding: 0.75rem; margin-bottom: 0.6rem; }
.kanban-card strong { display: block; font-size: 0.88rem; }
.kanban-card small { display: block; color: var(--muted); font-size: 0.76rem; margin: 0.2rem 0 0.5rem; }

/* Forms & Buttons */
.stack-form { display: grid; gap: 0.85rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem; }
.field { display: grid; gap: 0.3rem; }
.field label { font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gold); }
.field input, .field select, .field textarea {
  width: 100%; padding: 0.58rem 0.75rem; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; color: var(--ink); font-size: 0.86rem;
}
.form-error { color: #f87171; font-size: 0.82rem; margin: 0; min-height: 1.1em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.62rem 1.05rem; border-radius: 4px; border: 1px solid transparent;
  font-weight: 600; font-size: 0.84rem; cursor: pointer; white-space: nowrap;
}
.btn--sm { padding: 0.4rem 0.72rem; font-size: 0.78rem; }
.btn--block { width: 100%; }
.btn--gold { background: var(--gold); color: #12100d; }
.btn--gold:hover { background: var(--gold-hi); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn--danger { background: rgba(239, 68, 68, 0.16); color: #f87171; border-color: rgba(239, 68, 68, 0.4); }

.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: transparent; border: 1px solid var(--line); border-radius: 4px;
  color: var(--ink); cursor: pointer;
}
.icon-btn:hover { border-color: var(--gold); color: var(--gold); }

.badge { display: inline-block; padding: 0.16rem 0.5rem; font-family: var(--font-mono); font-size: 0.68rem; border-radius: 3px; text-transform: uppercase; }
.badge--ok { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.badge--warn { background: rgba(234, 179, 8, 0.16); color: #facc15; }
.badge--err { background: rgba(239, 68, 68, 0.16); color: #f87171; }
.badge--gold { background: rgba(214, 161, 72, 0.16); color: var(--gold-hi); }

.empty-state {
  padding: 2rem 1rem; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); font-size: 0.88rem;
}

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.85rem; }
.media-card { background: var(--bg-3); border: 1px solid var(--line); overflow: hidden; }
.media-card img { width: 100%; height: 140px; object-fit: cover; display: block; }
.media-card__body { padding: 0.7rem; }

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 900;
  background: var(--bg-3); border: 1px solid var(--gold); color: var(--ink);
  padding: 0.75rem 1.1rem; font-size: 0.85rem; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.mobile-only { display: none; }

@media (max-width: 960px) {
  .grid-2 { grid-template-columns: 1fr; }
  .mobile-only { display: grid; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 120; transform: translateX(-100%); transition: transform 0.25s; }
  .sidebar.is-mobile-open { transform: translateX(0); }
}
