:root {
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-2: #f0eee7;
  --ink: #151617;
  --muted: #69706d;
  --line: #ddd9cf;
  --line-dark: rgba(255,255,255,.12);
  --gold: #b8873e;
  --gold-2: #d8b66c;
  --green: #196b4c;
  --blue: #315f8f;
  --red: #9a3b38;
  --purple: #76518b;
  --sidebar: #10100f;
  --shadow: 0 18px 50px rgba(22, 20, 17, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

.auth-locked {
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(16, 16, 15, .96), rgba(16, 16, 15, .72)),
    url("./assets/gallery-hero.png") center/cover;
}
.auth-locked .app-shell { display: none; }
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  padding: 30px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid rgba(184,135,62,.36);
  box-shadow: 0 30px 90px rgba(0,0,0,.32);
}
.login-card img {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: cover;
}
.login-card h1 {
  font-size: clamp(44px, 10vw, 68px);
  line-height: .92;
}
.login-copy {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.55;
}
.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
}
.is-authenticated .login-screen { display: none; }
.is-authenticated .app-shell { display: grid; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 28px;
  padding: 22px 16px;
  background: var(--sidebar);
  color: #fffdf8;
  border-right: 1px solid rgba(184,135,62,.28);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 6px;
  font-family: Georgia, serif;
  font-size: 14px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.brand img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
}
.side-nav {
  display: grid;
  align-content: start;
  gap: 6px;
}
.side-nav button {
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255,255,255,.68);
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-size: 12px;
  font-weight: 800;
}
.side-nav button.active,
.side-nav button:hover {
  background: rgba(184,135,62,.18);
  border-color: rgba(184,135,62,.52);
  color: #fffdf8;
}
.store-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line-dark);
  background: rgba(255,255,255,.05);
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #62d391;
  box-shadow: 0 0 0 6px rgba(98,211,145,.12);
}
.store-status strong,
.store-status small { display: block; }
.store-status small { color: rgba(255,255,255,.58); margin-top: 3px; }

.main {
  min-width: 0;
  padding: 22px clamp(18px, 3vw, 34px) 44px;
}
.topbar,
.section-head,
.panel-head,
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  margin: -22px calc(clamp(18px, 3vw, 34px) * -1) 22px;
  padding: 18px clamp(18px, 3vw, 34px);
  background: rgba(245,246,243,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.kicker {
  margin: 0 0 7px;
  color: #8a6126;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .18em;
  text-transform: uppercase;
}
h1, h2, h3 { margin: 0; letter-spacing: 0; }
h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 4vw, 54px);
  font-weight: 500;
}
h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 3vw, 40px);
  font-weight: 500;
}
h3 {
  font-size: 18px;
  font-weight: 800;
}
.top-actions,
.toolbar,
.dialog-actions,
.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.search {
  position: relative;
  width: min(320px, 32vw);
}
.search span {
  position: absolute;
  left: 12px;
  top: 9px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.search input {
  width: 100%;
  min-height: 48px;
  padding: 21px 12px 7px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.btn,
.icon-btn,
.row-actions button,
.campaign-grid button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 16px;
}
.btn.primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #16110a;
}
.btn.ghost {
  background: var(--surface);
}
.icon-btn {
  width: 42px;
}
.section {
  display: none;
  animation: fadeIn .18s ease-out;
}
.section.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.metric {
  min-height: 138px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  padding: 20px;
}
.metric span,
.metric small {
  color: var(--muted);
}
.metric strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 3vw, 39px);
  font-weight: 500;
}
.metric .up { color: var(--green); }
.metric.alert strong { color: var(--red); }
.finance .metric strong { font-size: clamp(25px, 2.5vw, 34px); }

.dashboard-grid,
.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, .85fr);
  gap: 14px;
}
.panel {
  min-width: 0;
  padding: 20px;
}
.compact-panel {
  align-self: start;
}
.section-head {
  margin: 2px 0 14px;
}
select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fbfaf6;
  color: var(--ink);
  padding: 11px 12px;
}
select { min-height: 42px; }

.bar-chart {
  height: 255px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
  gap: 14px;
  padding-top: 18px;
}
.bar-chart div {
  min-height: 48px;
  height: var(--h);
  display: flex;
  align-items: end;
  justify-content: center;
  background: linear-gradient(180deg, #d8b66c, #6f4d1b);
}
.bar-chart span {
  display: block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  padding: 10px 0;
  color: #fffdf8;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.task-list,
.stack-form,
.role-list,
.campaign-grid,
.funnel {
  display: grid;
  gap: 12px;
}
.task-list label,
.check-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  color: var(--ink);
}
.task-list input,
.check-line input,
.data-table input[type="checkbox"] {
  width: auto;
  accent-color: var(--gold);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}
.data-table th,
.data-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
.data-table th {
  color: #765018;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
}
.data-table td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}
.data-table tr.is-muted {
  opacity: .48;
}
.row-actions {
  min-width: 225px;
}
.row-actions button,
.campaign-grid button {
  padding: 0 10px;
  color: #2b2520;
}
.row-actions button:hover,
.campaign-grid button:hover {
  border-color: var(--gold);
  color: #6c4a19;
}
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  min-height: 28px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.pill.live { background: #dbeee6; color: var(--green); }
.pill.review { background: #f4e3bc; color: #775018; }
.pill.sold { background: #eadde6; color: var(--purple); }
.pill.inactive { background: #e6e2d9; color: #5b5a54; }

.funnel div,
.campaign-grid div,
.role-list div {
  display: grid;
  gap: 5px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.funnel strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 500;
}
.funnel span,
.campaign-grid span,
.role-list span {
  color: var(--muted);
}
.stack-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.artwork-dialog {
  width: min(820px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  background: transparent;
}
.artwork-dialog::backdrop {
  background: rgba(11, 10, 9, .62);
}
.dialog-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 28px 80px rgba(0,0,0,.28);
  padding: 22px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.wide { grid-column: 1 / -1; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: 360px;
  padding: 14px 16px;
  background: #151617;
  color: #fff;
  box-shadow: 0 18px 44px rgba(0,0,0,.24);
  transform: translateY(140%);
  transition: transform .18s ease-out;
}
.toast.show { transform: translateY(0); }

@media (max-width: 1180px) {
  .metric-grid,
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid,
  .split-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    grid-template-rows: auto auto auto;
  }
  .side-nav {
    grid-template-columns: repeat(7, minmax(130px, 1fr));
    overflow-x: auto;
  }
  .topbar { display: grid; }
  .top-actions { align-items: stretch; }
  .search { width: 100%; }
  .btn { width: 100%; }
}
@media (max-width: 620px) {
  .main { padding-inline: 14px; }
  .topbar { margin-inline: -14px; padding-inline: 14px; }
  .metric-grid,
  .settings-grid,
  .form-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .section-head,
  .panel-head,
  .dialog-head { align-items: stretch; display: grid; }
}
