:root {
  --bg: #0a0a0a;
  --bg-2: #111111;
  --sidebar: #0d0d0d;
  --card: #161616;
  --card-2: #1a1a1a;
  --border: #2a2a2a;
  --border-strong: #3a3a3a;
  --text: #f5f5f5;
  --muted: #9a9a9a;
  --yellow: #f5c400;
  --yellow-dim: rgba(245, 196, 0, 0.12);
  --yellow-glow: rgba(245, 196, 0, 0.22);
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --sidebar-w: 240px;
  --radius: 12px;
}

* { box-sizing: border-box; }
/* Author display: rules must not override the hidden attribute */
[hidden] { display: none !important; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  font-size: 14px;
}
body.is-login { overflow: hidden; }
button, input { font: inherit; }
a { color: var(--yellow); }

/* —— Login —— */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(245, 196, 0, 0.14), transparent 40%),
    radial-gradient(600px 280px at 90% 10%, rgba(245, 196, 0, 0.08), transparent 50%),
    var(--bg);
}
.logo { width: min(220px, 70%); display: block; margin: 0 auto 6px; }
.login-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--yellow);
  border-radius: var(--radius);
  padding: 28px;
  display: grid;
  gap: 12px;
}
.login-card .sub { margin: 0 0 4px; text-align: center; color: var(--muted); }
.login-card label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.login-card input {
  background: #0f0f0f;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
}
.login-card input:focus {
  outline: none;
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px var(--yellow-dim);
}
.login-card button[type="submit"] {
  margin-top: 4px;
  border: 0;
  border-radius: 8px;
  background: var(--yellow);
  color: #111;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  font-style: italic;
  font-size: 18px;
  text-transform: uppercase;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.12s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.15s ease;
}
.login-card button[type="submit"]:hover { filter: brightness(1.05); }
.login-card button[type="submit"]:active { transform: scale(0.98); }
.login-card button[type="submit"]:disabled {
  opacity: 0.7;
  cursor: wait;
  transform: none;
}
.error { color: var(--red); margin: 0; }
.foot-note { margin: 4px 0 0; text-align: center; color: #666; font-size: 11px; }

/* —— Shell —— */
.shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  background:
    radial-gradient(900px 420px at 100% 0%, rgba(245, 196, 0, 0.05), transparent 55%),
    var(--bg);
  animation: shell-in 0.38s cubic-bezier(0.32, 0.72, 0, 1) both;
}
@keyframes shell-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand img { width: 120px; height: auto; }
.sidebar-brand span {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  font-style: italic;
  text-transform: uppercase;
  color: var(--yellow);
  font-size: 16px;
}
.sidebar-nav { display: grid; gap: 6px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 11px 12px;
  cursor: pointer;
}
.nav-item:hover { color: var(--text); background: #151515; }
.nav-item.is-active {
  color: #111;
  background: var(--yellow);
  font-weight: 600;
}
.nav-ico { opacity: 0.8; }
.nav-badge {
  margin-left: auto;
  background: #111;
  color: var(--yellow);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  padding: 2px 6px;
  text-align: center;
}
.nav-item.is-active .nav-badge {
  background: #111;
  color: var(--yellow);
}
.sidebar-foot { margin-top: auto; padding: 8px; }
.sidebar-foot .tagline { color: var(--yellow); font-size: 12px; margin: 0 0 6px; }
.sidebar-foot .powered { color: #666; font-size: 11px; margin: 0; }

.main {
  padding: 22px 28px 36px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
.eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.topbar h1 {
  margin: 0;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  font-style: italic;
  font-size: 34px;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  line-height: 1;
}
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 8px 6px 12px;
}
.pill {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.pill.on { color: #052e16; background: var(--green); border-color: transparent; }
.pill.off { color: #3f2a00; background: var(--amber); border-color: transparent; }

.ghost, .btn-secondary, .icon-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
}
.ghost, .btn-secondary { padding: 7px 12px; }
.ghost:hover, .btn-secondary:hover, .icon-btn:hover {
  border-color: var(--yellow);
  color: var(--yellow);
}
.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
}

/* —— KPIs —— */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.kpi::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: var(--border);
}
.kpi-accent {
  border-color: rgba(245, 196, 0, 0.35);
  box-shadow: 0 0 0 1px rgba(245, 196, 0, 0.05) inset;
}
.kpi-accent::after { background: var(--yellow); }
.kpi-label {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.kpi-value {
  margin: 8px 0 4px;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  font-style: italic;
  font-size: 40px;
  color: var(--yellow);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi-sub { margin: 0; color: #777; font-size: 12px; }

/* —— Panel / table —— */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.panel-head h2 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
}
.muted { color: var(--muted); margin: 0; }
.panel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.seg {
  display: inline-flex;
  background: #0f0f0f;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.seg-btn.is-active {
  background: var(--yellow);
  color: #111;
}
.search {
  width: min(260px, 100%);
  background: #0f0f0f;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 11px;
}
.search:focus {
  outline: none;
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px var(--yellow-dim);
}

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  background: #101010;
  position: sticky;
  top: 0;
}
tbody tr { cursor: pointer; transition: background 0.12s ease; }
tbody tr:hover { background: #1c1c1c; }
tbody tr.active { background: #1f1a0a; box-shadow: inset 3px 0 0 var(--yellow); }
tbody tr.unread td:nth-child(n+2) { font-weight: 600; }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: transparent;
  margin-top: 5px;
}
.dot.on { background: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-dim); }
.preview {
  color: var(--muted);
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-cell { display: grid; gap: 2px; }
.contact-cell small { color: var(--muted); font-size: 12px; }
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.status.sent { color: #86efac; background: rgba(34, 197, 94, 0.1); border-color: rgba(34, 197, 94, 0.25); }
.status.stored { color: #fcd34d; background: rgba(245, 196, 0, 0.1); border-color: rgba(245, 196, 0, 0.25); }
.empty {
  padding: 40px 18px;
  text-align: center;
  color: var(--muted);
}

.app-foot {
  margin-top: 18px;
  color: #666;
  font-size: 12px;
}

/* —— Drawer —— */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 40;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(440px, 100%);
  height: 100vh;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  z-index: 50;
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.45);
}
.drawer-inner {
  height: 100%;
  overflow: auto;
  padding: 22px;
  display: grid;
  gap: 14px;
  align-content: start;
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}
.drawer h2 {
  margin: 0;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 30px;
  font-weight: 700;
  font-style: italic;
  text-transform: uppercase;
  line-height: 1;
}
.meta { color: var(--muted); margin: 0; }
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.field-label {
  margin: 0 0 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.message-block pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-family: Inter, monospace;
  font-size: 13px;
  line-height: 1.5;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--yellow);
  color: #111 !important;
  text-decoration: none;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  font-style: italic;
  text-transform: uppercase;
  font-size: 16px;
  border-radius: 8px;
  padding: 11px 14px;
}
.drawer-actions { margin-top: 4px; }

@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .sidebar-nav { flex: 1; }
  .sidebar-foot { display: none; }
  .main { padding: 16px; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
}
