@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,wght@0,300;0,400;0,600;0,700;1,300&family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

:root {
  --crimson: #c70b2b;
  --crimson-dark: #8f071e;
  --crimson-light: #f2607a;
  --crimson-pale: #fff5f6;
  --gold: #c9972a;
  --gold-light: #f0c95a;
  --gold-pale: #fdf8ec;
  --white: #ffffff;
  --bg: #f7f6f4;
  --bg-card: #ffffff;
  --surface: #fafaf9;
  --text: #1a1614;
  --text-2: #4a3f3c;
  --text-3: #8a7a78;
  --border: #e8e2df;
  --border-dark: #d4cbc8;
  --green: #1a6b3c;
  --green-bg: #f0faf5;
  --amber: #b06a00;
  --amber-bg: #fdf6e8;
  --red-bg: #fff5f6;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(26,22,20,.06), 0 1px 2px rgba(26,22,20,.04);
  --shadow: 0 4px 16px rgba(26,22,20,.08), 0 1px 4px rgba(26,22,20,.04);
  --shadow-lg: 0 12px 40px rgba(26,22,20,.12), 0 4px 12px rgba(26,22,20,.06);
  --transition: all 0.18s cubic-bezier(0.4,0,0.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-font-smoothing: antialiased; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ─── SCROLLBAR ─────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 99px; }

/* ─── TOAST SYSTEM ──────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--text); color: var(--white);
  font-size: .84rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: toastIn .24s cubic-bezier(0.4,0,0.2,1);
  max-width: 340px;
}
.toast.success { background: #163d2a; border-left: 3px solid #3ecf8e; }
.toast.error { background: #3d1016; border-left: 3px solid var(--crimson); }
.toast.info { background: #1a2a3d; border-left: 3px solid #60a5fa; }
.toast-icon { font-size: 1rem; flex-shrink: 0; }
.toast-out { animation: toastOut .2s cubic-bezier(0.4,0,0.2,1) forwards; }
@keyframes toastIn { from { opacity:0; transform:translateX(16px); } to { opacity:1; transform:translateX(0); } }
@keyframes toastOut { to { opacity:0; transform:translateX(16px); } }

/* ─── SCREENS ───────────────────────────────────── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; }

/* ─── LOGIN ─────────────────────────────────────── */
#screen-login {
  align-items: center; justify-content: center;
  background: var(--white);
  background-image:
    radial-gradient(ellipse 80% 60% at 20% 110%, rgba(199,11,43,.07) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 80% -20%, rgba(201,151,42,.06) 0%, transparent 60%);
}
.login-wrap {
  display: grid; grid-template-columns: 1fr 1fr;
  width: 100%; max-width: 960px; min-height: 560px;
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.login-left {
  background: linear-gradient(160deg, var(--crimson-dark) 0%, #5a0413 100%);
  padding: 56px 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-left::before {
  content: '';
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(0deg,transparent,transparent 39px,rgba(255,255,255,.025) 39px,rgba(255,255,255,.025) 40px),repeating-linear-gradient(90deg,transparent,transparent 39px,rgba(255,255,255,.025) 39px,rgba(255,255,255,.025) 40px);
}
.login-left-content { position: relative; z-index: 1; }
.login-logo { width: 56px; height: 56px; object-fit: contain; margin-bottom: 32px; }
.login-brand { font-family: 'Fraunces', serif; color: var(--white); font-size: 1.8rem; font-weight: 700; line-height: 1.15; margin-bottom: 12px; }
.login-tagline { color: rgba(255,255,255,.55); font-size: .84rem; line-height: 1.6; }
.login-left-footer { position: relative; z-index: 1; }
.login-left-footer p { color: rgba(255,255,255,.35); font-size: .72rem; font-family: 'DM Mono', monospace; letter-spacing: .08em; }

.login-right {
  background: var(--white);
  padding: 56px 48px;
  display: flex; flex-direction: column; justify-content: center;
}
.login-right h2 { font-family: 'Fraunces', serif; font-size: 1.5rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.login-right p { color: var(--text-3); font-size: .88rem; margin-bottom: 36px; }
.btn-discord {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 13px 20px;
  background: #5865F2; color: #fff;
  border: none; border-radius: var(--radius); cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-size: .95rem; font-weight: 600;
  transition: var(--transition);
}
.btn-discord:hover { background: #4752c4; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(88,101,242,.35); }
.login-note { margin-top: 20px; font-size: .76rem; color: var(--text-3); line-height: 1.7; text-align: center; }

/* ─── PENDING ───────────────────────────────────── */
#screen-pending { align-items: center; justify-content: center; background: var(--bg); }
.pending-card {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 48px; max-width: 440px; text-align: center;
  box-shadow: var(--shadow);
}
.pending-icon { font-size: 2.5rem; margin-bottom: 20px; }
.pending-card h2 { font-family: 'Fraunces', serif; font-size: 1.4rem; color: var(--text); margin-bottom: 10px; }
.pending-card p { font-size: .875rem; color: var(--text-2); line-height: 1.65; margin-bottom: 8px; }

/* ─── APP SHELL ─────────────────────────────────── */
#screen-app { flex-direction: column; }
.app-layout { display: flex; flex: 1; min-height: 100vh; }

/* ─── SIDEBAR ───────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 50;
  transition: transform .22s cubic-bezier(0.4,0,0.2,1);
}
.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo { width: 32px; height: 32px; object-fit: contain; }
.sidebar-brand { font-family: 'Fraunces', serif; font-size: 1rem; font-weight: 700; color: var(--text); }
.sidebar-brand span { display: block; font-family: 'DM Mono', monospace; font-size: .6rem; color: var(--text-3); font-weight: 400; letter-spacing: .08em; text-transform: uppercase; margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-section-label {
  font-family: 'DM Mono', monospace; font-size: .6rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-3);
  padding: 8px 10px 4px; margin-top: 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 6px;
  color: var(--text-2); font-size: .875rem; font-weight: 500;
  cursor: pointer; border: none; background: none;
  width: 100%; text-align: left;
  transition: var(--transition); margin-bottom: 2px;
  text-decoration: none;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--crimson-pale); color: var(--crimson); }
.nav-item.active .nav-icon { color: var(--crimson); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .7; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px;
  cursor: pointer; transition: var(--transition);
}
.user-card:hover { background: var(--bg); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--crimson); color: var(--white);
  font-size: .75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: .82rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-family: 'DM Mono', monospace; font-size: .6rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }

/* ─── TOPBAR ────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; right: 0;
  left: var(--sidebar-w);
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 28px; gap: 16px;
  z-index: 40;
}
.topbar-title { font-family: 'Fraunces', serif; font-size: 1.1rem; font-weight: 600; color: var(--text); flex: 1; }
.topbar-title small { font-family: 'DM Sans', sans-serif; font-size: .72rem; color: var(--text-3); font-weight: 400; display: block; line-height: 1; margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--white);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-2); transition: var(--transition);
}
.icon-btn:hover { background: var(--bg); border-color: var(--border-dark); color: var(--text); }

/* ─── MAIN CONTENT ──────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 32px 28px;
  min-height: calc(100vh - var(--topbar-h));
  max-width: 1200px;
}

/* ─── PAGES ─────────────────────────────────────── */
.page { display: none; animation: fadeUp .22s ease; }
.page.active { display: block; }
@keyframes fadeUp { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ─── CARDS ─────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-family: 'Fraunces', serif; font-size: 1rem; font-weight: 600; color: var(--text); }
.card-title small { font-family: 'DM Sans', sans-serif; font-size: .75rem; color: var(--text-3); font-weight: 400; display: block; margin-top: 2px; }
.card-body { padding: 22px; }

/* ─── STAT CARDS ────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px,1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 22px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; background: var(--crimson);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.stat-num { font-family: 'Fraunces', serif; font-size: 2.2rem; font-weight: 700; color: var(--text); line-height: 1; margin-bottom: 6px; }
.stat-label { font-size: .75rem; color: var(--text-3); font-weight: 500; text-transform: uppercase; letter-spacing: .06em; font-family: 'DM Mono', monospace; }
.stat-icon { position: absolute; top: 16px; right: 18px; font-size: 1.4rem; opacity: .15; }

/* ─── TABLE ─────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead tr { background: var(--surface); }
thead th {
  padding: 10px 16px; text-align: left;
  font-family: 'DM Mono', monospace; font-size: .62rem;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3); font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
td { padding: 12px 16px; color: var(--text); vertical-align: middle; }
.mono { font-family: 'DM Mono', monospace; font-size: .8rem; }

/* ─── BADGES ────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: 'DM Mono', monospace; font-size: .62rem;
  font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 4px;
}
.badge::before { content:''; width:5px; height:5px; border-radius:50%; flex-shrink:0; }
.badge-active { background: var(--green-bg); color: var(--green); }
.badge-active::before { background: var(--green); }
.badge-deregistered { background: var(--red-bg); color: var(--crimson); }
.badge-deregistered::before { background: var(--crimson); }
.badge-pending { background: var(--amber-bg); color: var(--amber); }
.badge-pending::before { background: var(--amber); }
.badge-role { background: var(--gold-pale); color: var(--gold); border: 1px solid rgba(201,151,42,.2); }
.badge-role::before { display: none; }

/* ─── TAGS ──────────────────────────────────────── */
.tag { font-family: 'DM Mono', monospace; font-size: .65rem; padding: 2px 8px; border-radius: 4px; display: inline-block; }
.tag.tm { background: #e8f8f0; color: #1a6b3c; border: 1px solid rgba(26,107,60,.15); }
.tag.pat { background: #e8f0f8; color: #1a3a6b; border: 1px solid rgba(26,58,107,.15); }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }

/* ─── BUTTONS ───────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif; font-size: .84rem; font-weight: 600;
  cursor: pointer; border: 1.5px solid transparent;
  transition: var(--transition); text-decoration: none;
  white-space: nowrap; letter-spacing: .01em;
  position: relative; overflow: hidden;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--crimson); color: var(--white); border-color: var(--crimson); }
.btn-primary:hover:not(:disabled) { background: var(--crimson-dark); border-color: var(--crimson-dark); box-shadow: 0 4px 12px rgba(199,11,43,.3); transform: translateY(-1px); }
.btn-secondary { background: var(--white); color: var(--text); border-color: var(--border-dark); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); border-color: var(--text-3); }
.btn-danger { background: var(--white); color: var(--crimson); border-color: #f0c0c5; }
.btn-danger:hover:not(:disabled) { background: var(--red-bg); border-color: var(--crimson-light); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: .78rem; border-radius: 6px; }
.btn-loading { color: transparent !important; }
.btn-loading::after {
  content: ''; position: absolute;
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin .7s linear infinite;
  color: var(--white);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── SEARCH BAR ────────────────────────────────── */
.search-bar { display: flex; gap: 10px; margin-bottom: 18px; align-items: center; }
.search-input-wrap { position: relative; flex: 1; }
.search-input-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 15px; height: 15px; pointer-events: none; }
.search-input {
  width: 100%; padding: 9px 13px 9px 34px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--white); font-family: 'DM Sans', sans-serif;
  font-size: .875rem; color: var(--text); outline: none;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--crimson); box-shadow: 0 0 0 3px rgba(199,11,43,.08); }
.filter-select {
  padding: 9px 12px; border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--white); font-family: 'DM Sans', sans-serif; font-size: .875rem;
  color: var(--text); cursor: pointer; outline: none; transition: border-color .15s;
}
.filter-select:focus { border-color: var(--crimson); }

/* ─── FORMS ─────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: .75rem; font-weight: 600;
  color: var(--text-2); margin-bottom: 6px;
  letter-spacing: .02em;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--white); font-family: 'DM Sans', sans-serif;
  font-size: .875rem; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--crimson);
  box-shadow: 0 0 0 3px rgba(199,11,43,.08);
}
.field textarea { min-height: 80px; resize: vertical; line-height: 1.5; }
.field-error { font-size: .74rem; color: var(--crimson); margin-top: 4px; display: none; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--crimson); }
.field.has-error .field-error { display: block; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-section { font-size: .7rem; font-family: 'DM Mono', monospace; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); padding-bottom: 8px; margin: 20px 0 14px; border-bottom: 1px solid var(--border); }

/* ─── MODALS ────────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(26,22,20,.5);
  backdrop-filter: blur(4px);
  z-index: 200; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; animation: backdropIn .18s ease; }
@keyframes backdropIn { from { opacity:0; } to { opacity:1; } }
.modal {
  background: var(--white); border-radius: var(--radius-lg);
  width: 100%; max-width: 560px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: modalIn .22s cubic-bezier(0.4,0,0.2,1);
}
@keyframes modalIn { from { opacity:0; transform:scale(.97) translateY(8px); } to { opacity:1; transform:scale(1) translateY(0); } }
.modal-lg { max-width: 720px; }
.modal-sm { max-width: 440px; }
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--white); z-index: 1;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-title { font-family: 'Fraunces', serif; font-size: 1.05rem; font-weight: 600; color: var(--text); }
.modal-close {
  width: 28px; height: 28px; border-radius: 6px;
  border: none; background: none; cursor: pointer;
  color: var(--text-3); font-size: 1.2rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--surface); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  position: sticky; bottom: 0;
}

/* ─── EMPTY STATE ───────────────────────────────── */
.empty-state {
  text-align: center; padding: 56px 20px;
  color: var(--text-3);
}
.empty-state svg { margin: 0 auto 16px; display: block; opacity: .3; }
.empty-state p { font-size: .875rem; }

/* ─── SKELETON ──────────────────────────────────── */
.skeleton { background: linear-gradient(90deg,var(--border) 25%,var(--bg) 50%,var(--border) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 4px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeleton-row td { padding: 14px 16px; }
.skel { display: inline-block; height: 12px; border-radius: 4px; }

/* ─── DETAIL VIEW ───────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.detail-field { background: var(--bg); border-radius: var(--radius); padding: 12px 14px; }
.df-label { font-family: 'DM Mono', monospace; font-size: .6rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); margin-bottom: 4px; }
.df-value { font-size: .875rem; color: var(--text); font-weight: 500; }

/* ─── AUDIT TIMELINE ────────────────────────────── */
.audit-list { display: flex; flex-direction: column; }
.audit-item {
  display: flex; gap: 14px; padding: 14px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.audit-item:last-child { border-bottom: none; }
.audit-dot {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: var(--white);
  background: var(--crimson); margin-top: 2px;
}
.audit-dot.green { background: var(--green); }
.audit-dot.amber { background: var(--amber); }
.audit-dot.blue { background: #1a3a6b; }
.audit-content { flex: 1; }
.audit-action { font-size: .84rem; font-weight: 600; color: var(--text); }
.audit-detail { font-size: .8rem; color: var(--text-2); margin-top: 2px; }
.audit-meta { font-family: 'DM Mono', monospace; font-size: .65rem; color: var(--text-3); margin-top: 4px; }

/* ─── PAGE HEADER ───────────────────────────────── */
.page-hdr { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-hdr h1 { font-family: 'Fraunces', serif; font-size: 1.6rem; font-weight: 700; color: var(--text); line-height: 1.15; }
.page-hdr p { font-size: .84rem; color: var(--text-3); margin-top: 4px; }

/* ─── ADMIN ─────────────────────────────────────── */
.admin-section { margin-bottom: 24px; }

/* ─── HAMBURGER ─────────────────────────────────── */
.hamburger-btn {
  display: none;
  flex-direction: column; justify-content: center; align-items: center;
  gap: 5px; width: 36px; height: 36px;
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  flex-shrink: 0; transition: var(--transition);
  margin-right: 4px;
}
.hamburger-btn:hover { background: var(--bg); }
.hamburger-btn span {
  display: block; width: 16px; height: 2px;
  background: var(--text-2); border-radius: 2px;
  transition: var(--transition);
}

/* ─── SIDEBAR OVERLAY ───────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(26,22,20,.5); backdrop-filter: blur(2px);
  z-index: 49;
}
.sidebar-overlay.open { display: block; }

/* ─── RESPONSIVE ────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); width: 240px; }
  .sidebar.open { transform: translateX(0); }
  .topbar { left: 0; padding: 0 16px; gap: 10px; }
  .main-content { margin-left: 0; padding: 20px 16px; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-left { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .hamburger-btn { display: flex; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  #dash-grid { grid-template-columns: 1fr !important; }
  .modal { max-width: 100% !important; margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .table-wrap { font-size: .8rem; }
  td, th { padding: 10px 10px !important; }
  .topbar-title { font-size: .95rem; }
}

/* ─── DIVIDER ───────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ─── DANGER ZONE ───────────────────────────────── */
.danger-zone { background: var(--red-bg); border: 1px solid #f0c0c5; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.danger-zone p { font-size: .84rem; color: var(--crimson-dark); font-weight: 500; }

/* ─── LOADING SPINNER ───────────────────────────── */
.load-spin {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border-dark);
  border-top-color: var(--crimson);
  border-radius: 50%;
  animation: spin .65s linear infinite;
  flex-shrink: 0;
}

/* ─── DARK MODE TOGGLE ──────────────────────────── */
.theme-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0;
}
.theme-toggle-label {
  font-size: .875rem; color: var(--text-2); font-weight: 500;
}
.theme-toggle-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: none; border: none; cursor: pointer; padding: 0;
}
.theme-toggle-track {
  width: 40px; height: 22px; border-radius: 99px;
  background: var(--border-dark);
  position: relative; transition: background .2s;
  display: block;
}
.theme-toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--white); box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .2s cubic-bezier(0.4,0,0.2,1);
  display: block;
}
.theme-toggle-btn.active .theme-toggle-track { background: var(--crimson); }
.theme-toggle-btn.active .theme-toggle-thumb { transform: translateX(18px); }
.theme-toggle-text {
  font-size: .78rem; color: var(--text-3); font-family: 'DM Mono', monospace;
  min-width: 20px;
}

/* ─── DARK MODE ─────────────────────────────────── */
html.dark-mode {
  --bg: #141210;
  --bg-card: #1e1b18;
  --surface: #181512;
  --white: #1e1b18;
  --text: #f0ece8;
  --text-2: #c4b8b0;
  --text-3: #7a6e68;
  --border: #2e2824;
  --border-dark: #3d3530;
  --green-bg: #0d2418;
  --green: #3ecf8e;
  --amber-bg: #241a08;
  --amber: #d4a234;
  --red-bg: #240a0e;
  --crimson-pale: #240a0e;
  --gold-pale: #1e1608;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow: 0 4px 16px rgba(0,0,0,.4), 0 1px 4px rgba(0,0,0,.2);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.5), 0 4px 12px rgba(0,0,0,.3);
}

html.dark-mode body { background: var(--bg); }

html.dark-mode .sidebar,
html.dark-mode .topbar,
html.dark-mode .modal,
html.dark-mode .modal-header,
html.dark-mode .modal-footer { background: var(--bg-card); }

html.dark-mode .login-right,
html.dark-mode .pending-card { background: var(--bg-card); }

html.dark-mode #screen-login { background: #0e0c0a; }

html.dark-mode .card { background: var(--bg-card); border-color: var(--border); }

html.dark-mode .field input,
html.dark-mode .field select,
html.dark-mode .field textarea,
html.dark-mode .search-input,
html.dark-mode .filter-select {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}
html.dark-mode .field input:focus,
html.dark-mode .field select:focus,
html.dark-mode .field textarea:focus,
html.dark-mode .search-input:focus,
html.dark-mode .filter-select:focus {
  border-color: var(--crimson-light);
  box-shadow: 0 0 0 3px rgba(199,11,43,.15);
}

html.dark-mode .btn-secondary {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border-dark);
}
html.dark-mode .btn-secondary:hover:not(:disabled) { background: var(--surface); }

html.dark-mode .btn-danger {
  background: var(--bg);
  color: var(--crimson-light);
  border-color: #4a1820;
}
html.dark-mode .btn-danger:hover:not(:disabled) { background: var(--red-bg); }

html.dark-mode .btn-ghost:hover:not(:disabled) { background: var(--surface); }

html.dark-mode thead tr { background: var(--surface); }
html.dark-mode tbody tr:hover { background: var(--surface); }

html.dark-mode .skeleton {
  background: linear-gradient(90deg,var(--border) 25%,var(--surface) 50%,var(--border) 75%);
  background-size: 200% 100%;
}

html.dark-mode .stat-card { background: var(--bg-card); border-color: var(--border); }
html.dark-mode .detail-field { background: var(--bg); }

html.dark-mode .toast { background: #f0ece8; color: #141210; }
html.dark-mode .toast.success { background: #0d2418; color: #a7f3d0; border-left-color: #3ecf8e; }
html.dark-mode .toast.error { background: #240a0e; color: #fca5a5; border-left-color: var(--crimson); }
html.dark-mode .toast.info { background: #0a1524; color: #93c5fd; border-left-color: #60a5fa; }

html.dark-mode .nav-item:hover { background: var(--surface); }
html.dark-mode .nav-item.active { background: #2a0810; color: var(--crimson-light); }
html.dark-mode .user-card:hover { background: var(--surface); }

html.dark-mode .danger-zone { background: var(--red-bg); border-color: #4a1820; }

html.dark-mode .modal-backdrop { background: rgba(0,0,0,.7); }

/* ─── IMAGE UPLOAD ──────────────────────────────── */
.img-upload-zone {
  position: relative;
  border: 2px dashed var(--border-dark);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  min-height: 110px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.img-upload-zone:hover,
.img-upload-zone.drag-over {
  border-color: var(--crimson);
  background: var(--crimson-pale);
}
.img-upload-placeholder {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 20px;
  color: var(--text-3); font-size: .8rem; text-align: center;
  pointer-events: none;
}
.img-upload-placeholder svg { opacity: .5; }
.img-upload-preview {
  max-width: 100%; max-height: 180px;
  object-fit: contain;
  border-radius: 4px;
  padding: 8px;
  display: block;
}
.img-upload-clear {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--text); color: var(--white);
  border: none; cursor: pointer; font-size: .9rem;
  display: flex; align-items: center; justify-content: center;
  opacity: .75; transition: opacity .15s;
  line-height: 1; padding: 0;
}
.img-upload-clear:hover { opacity: 1; }

/* Thumbnail in tag list */
.tm-tag-img { display: inline-flex !important; align-items: center; gap: 5px; }
.tm-tag-thumb {
  width: 16px; height: 16px;
  object-fit: contain; border-radius: 2px;
  flex-shrink: 0;
}

html.dark-mode .img-upload-zone {
  background: var(--bg);
  border-color: var(--border-dark);
}
html.dark-mode .img-upload-zone:hover,
html.dark-mode .img-upload-zone.drag-over {
  background: #240a0e;
  border-color: var(--crimson-light);
}
html.dark-mode .img-upload-clear { background: var(--text); color: #141210; }

/* ─── OFCOM SPECIFIC ────────────────────────────── */
.ofcom-lic-tags { display: flex; flex-wrap: wrap; gap: 3px; }

/* Warning badge colours */
.warn-w1 { background: #fffbe8; color: #7a5200; border: 1px solid rgba(122,82,0,.2); }
.warn-w2 { background: #fff3e8; color: #8a3a00; border: 1px solid rgba(138,58,0,.2); }
.warn-w3 { background: #fff0f0; color: #8a0000; border: 1px solid rgba(138,0,0,.2); }
