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

:root {
  --bg:      #08101f;
  --surface: #101828;
  --surface2: #151f30;
  --border:  rgba(255,255,255,0.07);
  --text:    #eef2ff;
  --muted:   rgba(238,242,255,0.45);
  --blue:    #2360B8;
  --blue-soft: rgba(35,96,184,0.18);
  --orange:  #E8622A;
  --orange-soft: rgba(232,98,42,0.15);
  --red-soft: rgba(220,53,69,0.12);
  --red: #ff6b7a;
}

body.admin-body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Login ──────────────────────────────────────────── */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 40px;
}

.login-logo {
  font-family: 'Unbounded', sans-serif;
  font-size: 30px;
  font-weight: 700;
  margin-bottom: 6px;
}
.login-logo .amp, .admin-brand .amp { color: var(--orange); }

.login-sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 36px;
}

.login-error {
  background: var(--red-soft);
  border: 1px solid rgba(220,53,69,0.25);
  color: var(--red);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}
.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.form-group input {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 16px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--blue); }

.login-btn {
  width: 100%;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s;
}
.login-btn:hover { opacity: 0.85; }
.login-btn:active { opacity: 0.7; }

/* ── Dashboard layout ──────────────────────────────── */
.admin-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px 80px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
}

.admin-brand {
  font-family: 'Unbounded', sans-serif;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.admin-badge {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--blue-soft);
  color: #7BAEF0;
  border-radius: 6px;
  padding: 4px 9px;
}

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-site-link {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  transition: color 0.2s;
}
.admin-site-link:hover { color: var(--text); }

.logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}
.logout-btn:hover { border-color: rgba(255,255,255,0.18); color: var(--text); }

/* ── Main ───────────────────────────────────────────── */
.admin-main { padding-bottom: 40px; }

.admin-title {
  font-family: 'Unbounded', sans-serif;
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 36px;
}

/* ── Stat cards ─────────────────────────────────────── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 52px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px;
}
.stat-card-orange {
  border-color: rgba(232,98,42,0.25);
  background: linear-gradient(135deg, var(--surface), rgba(232,98,42,0.06));
}

.stat-card-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}
.stat-card-val {
  font-family: 'Unbounded', sans-serif;
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
}
.stat-card-val.orange { color: var(--orange); }

/* ── Table section ──────────────────────────────────── */
.admin-section { }
.admin-section-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 18px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
}
.admin-table th {
  text-align: left;
  padding: 13px 20px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.admin-table td {
  padding: 14px 20px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover td { background: rgba(255,255,255,0.02); }

.page-path { display: flex; flex-direction: column; gap: 2px; }
.page-label { font-weight: 500; font-size: 14px; }
.page-route {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--muted);
}

.view-bar-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.view-bar {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}
.view-bar-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 3px;
}
.view-count {
  font-family: 'Unbounded', sans-serif;
  font-size: 13px;
  font-weight: 700;
  min-width: 36px;
  text-align: right;
}

.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ── Admin nav ──────────────────────────────────────────────── */
.admin-nav {
  display: flex;
  gap: 4px;
}
.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.2s;
}
.admin-nav-link:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.admin-nav-link.active { background: var(--blue-soft); color: #7BAEF0; }

.nav-badge {
  background: var(--orange);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 6px;
  min-width: 18px;
  text-align: center;
}

/* ── Stat card — link variant ───────────────────────────────── */
.stat-card-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s;
}
.stat-card-link:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(0,0,0,0.2); }
.stat-card-sub { font-size: 12px; color: var(--muted); margin-top: 8px; }

.badge-new-inline {
  display: inline-block;
  background: var(--orange);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  padding: 2px 10px;
}

/* ── Status badges ──────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  padding: 4px 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.badge-new     { background: rgba(232,98,42,0.18); color: #F4915A; border: 1px solid rgba(232,98,42,0.3); }
.badge-read    { background: var(--blue-soft);     color: #7BAEF0; border: 1px solid rgba(35,96,184,0.3); }
.badge-replied { background: rgba(34,197,94,0.12); color: #4ade80; border: 1px solid rgba(34,197,94,0.25); }

/* ── Contacts table ─────────────────────────────────────────── */
.contacts-table .contact-row { cursor: pointer; }
.contacts-table .contact-row:hover td { background: rgba(255,255,255,0.03); }

.contact-date  { font-size: 12px; color: var(--muted); white-space: nowrap; }
.contact-time  { font-size: 11px; }
.contact-name  { font-weight: 500; }
.contact-email { font-family: 'Space Mono', monospace; font-size: 12px; color: var(--muted); }
.contact-service { font-size: 13px; }
.contact-preview { font-size: 13px; color: var(--muted); max-width: 280px; }

/* ── Contact detail ─────────────────────────────────────────── */
.detail-breadcrumb { margin-bottom: 28px; }
.breadcrumb-link {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}
.breadcrumb-link:hover { color: var(--text); }

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.detail-name { font-family: 'Unbounded', sans-serif; font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.detail-email { font-family: 'Space Mono', monospace; font-size: 13px; color: #7BAEF0; text-decoration: none; }
.detail-email:hover { text-decoration: underline; }

.detail-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 32px;
}
.detail-meta-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.detail-meta-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; }
.detail-meta-val   { font-size: 14px; font-weight: 500; }

/* ── Thread ─────────────────────────────────────────────────── */
.thread { display: flex; flex-direction: column; gap: 16px; margin-bottom: 28px; }

.thread-msg {
  border-radius: 14px;
  padding: 20px 22px;
  max-width: 85%;
}
.thread-msg-visitor {
  background: var(--surface);
  border: 1px solid var(--border);
  align-self: flex-start;
}
.thread-msg-admin {
  background: var(--blue-soft);
  border: 1px solid rgba(35,96,184,0.25);
  align-self: flex-end;
}

.thread-msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}
.thread-msg-who  { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.thread-msg-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.thread-msg-body { font-size: 14px; line-height: 1.7; white-space: pre-wrap; }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 13px;
  margin-bottom: 20px;
}
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.25); color: #4ade80; }
.alert-error   { background: var(--red-soft); border: 1px solid rgba(220,53,69,0.25); color: var(--red); }

/* ── Reply form ─────────────────────────────────────────────── */
.reply-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
}
.reply-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.reply-to    { font-size: 13px; color: var(--muted); margin-bottom: 20px; }

.reply-textarea {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}
.reply-textarea:focus { border-color: var(--blue); }

.reply-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.reply-note { font-size: 12px; color: var(--muted); }
.reply-btn {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.reply-btn:hover { opacity: 0.85; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .admin-wrap { padding: 0 16px 60px; }

  .admin-header {
    flex-wrap: wrap; gap: 12px;
    padding: 20px 0 16px; margin-bottom: 28px;
  }
  .admin-header-right { gap: 8px; }
  .admin-site-link    { display: none; }
  .admin-brand        { font-size: 16px; }
  .admin-badge        { display: none; }

  .admin-nav {
    order: 3; width: 100%;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }

  .admin-title    { font-size: 20px; margin-bottom: 24px; }
  .stat-card-val  { font-size: 32px; }

  .admin-section  { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .contact-preview { max-width: 140px; }

  .detail-header  { flex-direction: column; align-items: flex-start; }
  .detail-name    { font-size: 18px; }

  .thread-msg     { max-width: 95%; }

  .reply-actions  { flex-direction: column; align-items: stretch; }
  .reply-btn      { text-align: center; }

  .login-card     { padding: 32px 20px; }
  .login-logo     { font-size: 24px; }
}

@media (max-width: 480px) {
  .stat-cards       { grid-template-columns: 1fr; }
  .detail-meta-row  { flex-direction: column; }
  .detail-meta-item { width: 100%; }
}
