:root {
  --navy-950: #061022;
  --navy-900: #08152b;
  --navy-800: #0e2347;
  --gold-300: #fae396;
  --gold-400: #f2c94c;
  --gold-500: #d4af37;
  --bg: #f1f5f9;
  --white: #ffffff;
  --border: #dbe3ee;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #dc2626;
  --success: #16a34a;
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }

/* Auth Screen */
.auth-screen {
  min-height: 100vh;
  background: linear-gradient(155deg, var(--navy-950), var(--navy-800));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 430px;
  background: #fff;
  border-radius: 18px;
  padding: 28px;
  border: 2px solid var(--gold-500);
  box-shadow: 0 24px 54px rgba(0, 0, 0, 0.35);
}
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-logo-circle {
  width: 60px; height: 60px; margin: 0 auto 10px;
  border-radius: 50%; background: var(--navy-900);
  border: 2px solid var(--gold-400);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
}
.auth-brand h1 { margin: 0; color: var(--navy-900); font-size: 1.45rem; }
.auth-brand p { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }

/* App Shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 265px;
  flex: 0 0 265px;
  background: var(--navy-950);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  border-left: 2px solid rgba(212, 175, 55, 0.35);
}
.sidebar-head {
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex; align-items: center; justify-content: space-between;
}
.sb-brand { display: flex; align-items: center; gap: 10px; }
.sb-icon { font-size: 1.6rem; }
.sb-brand strong { display: block; color: var(--gold-400); font-size: 1rem; }
.sb-brand small { color: #94a3b8; font-size: 0.78rem; }
.close-sb-btn { display: none; background: transparent; border: none; color: #fff; font-size: 1.2rem; cursor: pointer; }
.sb-nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  width: 100%;
  text-align: right;
  background: transparent;
  border: none;
  color: #cbd5e1;
  padding: 11px 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); }
.nav-item.active { background: linear-gradient(135deg, var(--gold-400), var(--gold-500)); color: var(--navy-950); }
.count-pill {
  background: #dc2626; color: #fff;
  padding: 1px 7px; border-radius: 999px; font-size: 0.75rem;
}
.nav-item.active .count-pill { background: var(--navy-950); color: var(--gold-300); }
.sb-footer { padding: 14px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.sb-user-email { font-size: 0.78rem; color: #94a3b8; margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { margin: 0; font-size: 1.15rem; color: var(--navy-900); }
.menu-btn { display: none; background: var(--navy-900); color: var(--gold-300); border: none; padding: 7px 11px; border-radius: 8px; font-size: 1.1rem; cursor: pointer; }
.content-wrap { padding: 20px; max-width: 1200px; width: 100%; }
.container-pad { padding: 0 20px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.stat-card {
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-right: 4px solid var(--gold-500);
}
.stat-card small { color: var(--muted); font-weight: 700; display: block; }
.stat-card strong { font-size: 1.7rem; color: var(--navy-900); }

.panel-card {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  border: 1px solid var(--border);
}
.panel-card h3 { margin: 0 0 12px; color: var(--navy-900); font-size: 1.05rem; }
.panel-head-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.panel-head-row h3 { margin: 0; }
.muted-sm { font-size: 0.85rem; color: var(--muted); margin: 4px 0 0; }

.two-col-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Tables */
.table-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid #eef2f7;
  text-align: right;
  vertical-align: middle;
}
.data-table th { background: #f8fafc; color: var(--navy-900); font-weight: 800; white-space: nowrap; }
.mini-thumb { width: 48px; height: 40px; border-radius: 8px; object-fit: cover; background: #0e2347; }

/* Forms & Buttons */
.field label { display: block; font-size: 0.85rem; font-weight: 700; margin-bottom: 4px; color: var(--navy-900); }
.field input, .field select, .field textarea, .input-inline {
  width: 100%;
  padding: 9px 11px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  background: #fff;
}
.input-inline { max-width: 300px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-full { grid-column: 1 / -1; }
.stack-form { display: flex; flex-direction: column; gap: 11px; }
.checks-row { display: flex; gap: 14px; padding-top: 6px; font-size: 0.9rem; font-weight: 600; }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: none;
  font-weight: 700; font-size: 0.9rem; cursor: pointer;
}
.btn-gold { background: linear-gradient(135deg, var(--gold-400), var(--gold-500)); color: var(--navy-950); }
.btn-outline { background: #fff; color: var(--navy-900); border: 1.5px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: #e2e8f0; color: #334155; }
.btn-sm { padding: 6px 11px; font-size: 0.82rem; }
.btn-block { width: 100%; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.76rem; font-weight: 700; }
.pill-green { background: #dcfce7; color: #166534; }
.pill-red { background: #fee2e2; color: #991b1b; }
.pill-amber { background: #fef3c7; color: #92400e; }
.pill-navy { background: #e0ecff; color: #1e3a8a; }

.alert { padding: 11px 14px; border-radius: 10px; font-size: 0.88rem; margin-top: 10px; }
.alert-info { background: #e0ecff; color: #1e3a8a; border: 1px solid #93c5fd; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warn { background: #fef3c7; color: #78350f; border: 1px solid #fcd34d; }

.inline-upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline-upload-row input[type="text"] { flex: 1; min-width: 180px; }
.thumbs-edit-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.thumb-edit-item { position: relative; width: 78px; height: 64px; border-radius: 8px; overflow: hidden; border: 1.5px solid var(--border); }
.thumb-edit-item img { width: 100%; height: 100%; object-fit: cover; }
.thumb-edit-item button {
  position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; border: none; background: rgba(220, 38, 38, 0.92); color: #fff; font-size: 0.72rem; cursor: pointer;
}

.qr-box { display: flex; justify-content: center; padding: 12px; background: #fff; border: 1px solid var(--border); border-radius: 12px; }
.secret-copy-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; background: #f8fafc; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); }
.secret-copy-row code { flex: 1; font-size: 0.86rem; word-break: break-all; }

/* Modals */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(6, 16, 34, 0.65);
  display: flex; align-items: center; justify-content: center;
  padding: 14px; overflow-y: auto;
}
.modal-box {
  background: #fff; width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto;
  border-radius: 16px; padding: 20px;
}
.modal-sm { max-width: 460px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { margin: 0; color: var(--navy-900); }
.close-modal { background: #f1f5f9; border: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; }
.modal-foot { display: flex; gap: 8px; margin-top: 10px; }

.toast {
  position: fixed; bottom: 20px; left: 20px; z-index: 90;
  background: var(--navy-900); color: var(--gold-300);
  border: 1px solid var(--gold-500);
  padding: 11px 18px; border-radius: 12px; font-weight: 700;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

@media (max-width: 960px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col-cards { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; right: -280px; z-index: 70;
    transition: right 0.2s ease;
  }
  .sidebar.open { right: 0; }
  .menu-btn, .close-sb-btn { display: inline-flex; }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .content-wrap { padding: 14px; }
}
