:root {
  --purple: #4A1968;
  --purple-light: #6B2C96;
  --gold: #8B7535;
  --gold-light: #C4A84F;
  --bg: #F8F5FF;
  --surface: #FFFFFF;
  --surface-alt: #F0EBF8;
  --text: #1A0A2B;
  --text-sec: #6B5E7B;
  --divider: #E0D6F0;
  --error: #B00020;
  --success: #2E7D32;
  --warn: #B26A00;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }

/* ── Login ── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--purple), var(--purple-light));
}
.login-card {
  background: var(--surface);
  padding: 40px; border-radius: 16px; width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { color: var(--purple); font-size: 24px; }
.login-card .sub { color: var(--text-sec); margin-bottom: 8px; }
.login-card input, .login-card button {
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--divider);
  font-size: 14px; font-family: inherit;
}
.login-card input:focus { outline: none; border-color: var(--purple); }
.login-card button {
  background: var(--purple); color: #fff; border: none; cursor: pointer;
  font-weight: 600; margin-top: 4px;
}
.login-card button:hover { background: var(--purple-light); }
.error { color: var(--error); font-size: 13px; min-height: 16px; }

/* ── Console layout ── */
.console { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--purple); color: #fff;
  display: flex; flex-direction: column; padding: 20px 0;
}
.brand { font-size: 18px; font-weight: 700; padding: 0 20px 20px; }
.sidebar nav { display: flex; flex-direction: column; flex: 1; }
.nav-item {
  background: none; border: none; color: #fff; text-align: left;
  padding: 12px 20px; font-size: 14px; cursor: pointer; opacity: .8;
  font-family: inherit;
}
.nav-item:hover { background: rgba(255,255,255,.08); opacity: 1; }
.nav-item.active { background: rgba(255,255,255,.15); opacity: 1; border-left: 3px solid var(--gold-light); }
.logout {
  margin: 20px; padding: 10px; background: rgba(255,255,255,.1);
  color: #fff; border: none; border-radius: 8px; cursor: pointer; font-family: inherit;
}
.logout:hover { background: rgba(255,255,255,.2); }

.content { flex: 1; padding: 28px 32px; overflow-y: auto; max-height: 100vh; }
.tab { display: none; }
.tab.active { display: block; }
h2 { color: var(--purple); font-size: 20px; margin-bottom: 20px; }
h3 { color: var(--text); font-size: 15px; margin: 24px 0 12px; }

/* ── Cards / grid ── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border-radius: 12px; padding: 18px;
  box-shadow: 0 2px 8px rgba(74,25,104,.08);
}
.card .value { font-size: 28px; font-weight: 700; color: var(--purple); }
.card .label { color: var(--text-sec); font-size: 12px; margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--divider); font-size: 13px; }
th { background: var(--surface-alt); color: var(--purple); font-weight: 600; }
tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; border-radius: 12px; }
td.mono, .mono { font-family: 'Consolas', monospace; font-size: 12px; }

/* ── Buttons / inputs ── */
button.btn {
  background: var(--purple); color: #fff; border: none; padding: 8px 16px;
  border-radius: 8px; cursor: pointer; font-size: 13px; font-family: inherit; font-weight: 600;
}
button.btn:hover { background: var(--purple-light); }
button.btn.ghost { background: none; color: var(--purple); border: 1px solid var(--divider); }
button.btn.ghost:hover { background: var(--surface-alt); }
button.btn.danger { background: var(--error); }
button.btn.gold { background: var(--gold); }
button.btn.small { padding: 5px 10px; font-size: 12px; }
input.in, textarea.in, select.in {
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--divider);
  font-size: 13px; font-family: inherit; width: 100%; background: var(--surface);
}
input.in:focus, textarea.in:focus { outline: none; border-color: var(--purple); }
textarea.in { resize: vertical; min-height: 60px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form-card { background: var(--surface); padding: 20px; border-radius: 12px; display: flex; flex-direction: column; gap: 12px; max-width: 520px; margin-bottom: 24px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.pill.latest { background: rgba(46,125,50,.15); color: var(--success); }
.pill.active { background: rgba(46,125,50,.15); color: var(--success); }
.pill.inactive { background: rgba(176,0,32,.12); color: var(--error); }
.muted { color: var(--text-sec); font-size: 12px; }
.warn-banner {
  background: rgba(178,106,0,.1); border: 1px solid rgba(178,106,0,.3);
  color: var(--warn); padding: 10px 14px; border-radius: 8px; font-size: 12px; margin-bottom: 16px;
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px; padding: 12px 18px;
  border-radius: 8px; color: #fff; background: var(--success);
  box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 100;
}
.toast.err { background: var(--error); }
