:root {
  --bg: #070707;
  --surface: #121212;
  --surface-2: #1a1a1a;
  --line: rgba(201, 162, 39, 0.22);
  --text: #f4efe4;
  --muted: #a89f8d;
  --accent: #c9a227;
  --font-display: "Outfit", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --ink: #070707;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: var(--bg); color: var(--text); font-family: var(--font-display); }
.accent { color: var(--accent); }
button { cursor: pointer; font-family: inherit; }

/* ---------- LOGIN ---------- */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
body.cms-on .login-screen {
  display: none !important;
  pointer-events: none;
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 44px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-mark { color: var(--accent); font-size: 28px; }
.login-box h1 { font-size: 22px; margin-bottom: 4px; }
.login-box p { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.login-box input {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
}
.login-box .btn-primary {
  background: var(--accent);
  color: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 13px;
  font-weight: 700;
  margin-top: 6px;
}
.login-error { display: none; color: #ff6b6b; font-size: 12px; font-family: var(--font-mono); }
.login-error.show { display: block; }
.login-hint { color: var(--muted); font-size: 11px; font-family: var(--font-mono); }

/* ---------- DASHBOARD LAYOUT ---------- */
.dashboard { display: none; min-height: 100vh; position: relative; z-index: 1; }
.dashboard.active { display: grid; grid-template-columns: 240px 1fr; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 2;
  min-height: 100vh;
}
.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 28px;
}
.sidebar-logo { font-weight: 700; font-size: 14px; }
.cms-burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.cms-burger span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}
.cms-burger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.cms-burger.active span:nth-child(2) { opacity: 0; }
.cms-burger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.sidebar-drawer {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-height: 0;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex-grow: 1; overflow-y: auto; }
.nav-group {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 14px 8px 4px;
}
.nav-badge {
  display: inline-flex;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
}
.side-link {
  text-align: left;
  background: none;
  border: none;
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  display: flex;
  align-items: center;
  width: 100%;
  position: relative;
  z-index: 2;
}
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.active { background: var(--accent); color: var(--ink); font-weight: 600; }
.sidebar-bottom { display: flex; flex-direction: column; gap: 12px; }
.sidebar-bottom a { color: var(--muted); font-size: 13px; }
.sidebar-bottom a:hover { color: var(--accent); }
.logout-btn {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
}
.logout-btn:hover { border-color: var(--accent); color: var(--accent); }

.main-panel { padding: 40px 44px; position: relative; z-index: 1; min-width: 0; }
.view { display: none; }
.view.active { display: block; }
.view h2 { font-size: 24px; margin-bottom: 28px; }

.view-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; flex-wrap: wrap; gap: 14px; }
.view-header h2 { margin-bottom: 0; }
.view-actions { display: flex; gap: 10px; }
.view-actions input {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; color: var(--text); font-size: 13px; min-width: 220px;
}

.btn-primary {
  background: var(--accent); color: var(--ink); border: none;
  padding: 11px 20px; border-radius: 999px; font-weight: 600; font-size: 13px;
}
.btn-ghost {
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  padding: 11px 20px; border-radius: 999px; font-size: 13px;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 26px; text-align: left;
}
.stat-card span { font-size: 30px; font-weight: 700; color: var(--accent); display: block; margin-bottom: 6px; }
.stat-card p { color: var(--muted); font-size: 13px; }

/* posts table */
.posts-table { width: 100%; border-collapse: collapse; }
.posts-table th {
  text-align: left; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em;
  color: var(--muted); padding: 12px; border-bottom: 1px solid var(--line);
}
.posts-table td { padding: 14px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.status-pill { padding: 4px 12px; border-radius: 999px; font-size: 11px; font-family: var(--font-mono); }
.status-pill.published { background: rgba(215,255,62,0.15); color: var(--accent); }
.status-pill.draft { background: rgba(255,255,255,0.08); color: var(--muted); }
.row-actions { display: flex; gap: 10px; }
.row-actions button { background: none; border: none; color: var(--muted); font-size: 13px; }
.row-actions button:hover { color: var(--accent); }
.row-actions .delete:hover { color: #ff6b6b; }
.row-actions .btn-ghost,
.row-actions .btn-danger {
  padding: 8px 14px;
  font-size: 12px;
  border-radius: 999px;
}
.row-actions .btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}
.row-actions .btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.row-actions .btn-danger {
  background: transparent;
  color: #ff6b6b;
  border: 1px solid rgba(255,107,107,0.4);
}
.row-actions .btn-danger:hover { background: rgba(255,107,107,0.12); color: #ff6b6b; }

/* gallery admin */
.gallery-admin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.gallery-admin-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 0; overflow: hidden; display: flex; flex-direction: column;
}
.gallery-admin-item img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
}
.gallery-admin-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px;
}
.gallery-admin-item span { font-size: 11px; font-family: var(--font-mono); color: var(--muted); word-break: break-all; }
.gallery-admin-item button { background: none; border: none; color: var(--muted); font-size: 16px; }
.gallery-admin-item button:hover { color: #ff6b6b; }

/* modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(6,7,4,0.85); backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center; z-index: 999; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 32px; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
}
.modal-box h3 { margin-bottom: 20px; font-size: 19px; }
.modal-box form { display: flex; flex-direction: column; gap: 6px; }
.modal-box label { font-size: 12px; color: var(--muted); font-family: var(--font-mono); margin-top: 10px; }
.modal-box input[type="text"], .modal-box input[type="email"], .modal-box input[type="tel"], .modal-box select, .modal-box textarea {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; color: var(--text); font-size: 14px; font-family: inherit; resize: vertical;
}
.modal-box select { appearance: none; }
.checkbox-row { display: flex; align-items: center; gap: 8px; flex-direction: row !important; margin-top: 14px; }
.checkbox-row input { width: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; color: var(--accent); margin-bottom: 6px; }
.muted { color: var(--muted); font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; margin: -12px 0 22px; }
.btn-danger {
  background: transparent; color: #ff6b6b; border: 1px solid rgba(255,107,107,0.4);
  padding: 11px 20px; border-radius: 999px; font-size: 13px;
}
.btn-danger:hover { background: rgba(255,107,107,0.12); }
.panel-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px;
}
.panel-card h3 { font-size: 15px; margin-bottom: 16px; }
.dash-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 22px;
}
.span-2 { grid-column: span 2; }
.chart-box { min-height: 160px; }
.dash-list { display: flex; flex-direction: column; gap: 10px; }
.dash-list.tall { max-width: 860px; }
.list-row {
  display: flex; justify-content: space-between; gap: 16px; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.list-row p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.list-row span { color: var(--muted); font-size: 12px; font-family: var(--font-mono); white-space: nowrap; }
.list-row .row-actions {
  flex-shrink: 0;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.subhead { font-size: 15px; margin: 8px 0 14px; }
.section-split {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 36px 0 14px; max-width: 860px;
}
.section-split .subhead { margin: 0; }
.mail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.mail-actions a { text-decoration: none; display: inline-flex; align-items: center; }
.toast-ok { color: var(--accent); font-size: 13px; }
.mail-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 18px; align-items: start; }
.mail-list { display: flex; flex-direction: column; gap: 8px; max-height: 70vh; overflow-y: auto; }
.mail-item {
  text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; color: inherit; display: flex; flex-direction: column; gap: 4px;
  cursor: pointer; width: 100%;
}
.mail-item span, .mail-item em { color: var(--muted); font-size: 12px; font-style: normal; }
.mail-item p { font-size: 13px; color: var(--muted); }
.mail-item.unread { border-color: var(--accent); }
.mail-item.active { background: var(--surface-2); border-color: var(--accent); }
.mail-detail {
  min-height: 280px;
  position: sticky;
  top: 20px;
}
.mail-detail h3 { font-size: 18px; line-height: 1.35; margin-bottom: 16px; }
.mail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 18px;
  margin: 0 0 18px;
}
.mail-meta div { display: flex; flex-direction: column; gap: 4px; }
.mail-meta dt {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}
.mail-meta dd { font-size: 14px; color: var(--text); }
.mail-meta a { color: var(--accent); }
.mail-body-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.mail-body { white-space: pre-wrap; line-height: 1.6; margin: 0 0 16px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-grid fieldset { border: none; display: flex; flex-direction: column; gap: 8px; }
.settings-grid label { font-size: 12px; color: var(--muted); font-family: var(--font-mono); margin-top: 8px; }
.settings-grid input, .settings-grid textarea, .client-note {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; color: var(--text); font-size: 14px; font-family: inherit;
}
.settings-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.settings-actions { grid-column: span 2; display: flex; align-items: center; gap: 14px; }
.form-ok { display: none; color: var(--accent); font-size: 13px; }
.form-ok.show { display: inline; }
.client-note { width: 100%; min-width: 180px; }

.sidebar-backdrop { display: none; }

@media (max-width: 800px) {
  .dashboard.active { grid-template-columns: 1fr; }
  .cms-burger { display: flex; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 40;
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    padding: 0;
    border-right: none;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }
  .sidebar-top {
    margin-bottom: 0;
    padding: 12px 16px;
    background: var(--surface);
    position: relative;
    z-index: 42;
  }
  .sidebar-drawer {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 41;
    flex-grow: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 8px 16px 20px;
    max-height: min(78vh, calc(100dvh - 64px));
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.25s, visibility 0.25s, transform 0.25s;
  }
  .sidebar.is-open .sidebar-drawer {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
  }
  .sidebar-nav { flex-direction: column; flex-wrap: nowrap; overflow: visible; }
  .sidebar-bottom {
    flex-direction: column;
    margin: 16px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(7, 7, 7, 0.62);
  }
  .sidebar-backdrop[hidden] { display: none; }
  body.cms-nav-lock { overflow: hidden; }
  .main-panel { padding: 24px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .gallery-admin-grid { grid-template-columns: 1fr 1fr; }
  .posts-table { display: block; overflow-x: auto; }
  .dash-grid, .mail-layout, .settings-grid { grid-template-columns: 1fr; }
  .mail-meta { grid-template-columns: 1fr; }
  .mail-detail { position: static; }
  .span-2, .settings-actions { grid-column: auto; }
  .settings-row { grid-template-columns: 1fr; }
}
