:root {
  color-scheme: dark;
  --bg: #070a12;
  --panel: rgba(16, 22, 39, 0.86);
  --panel-strong: #11182a;
  --line: rgba(148, 163, 184, 0.18);
  --muted: #94a3b8;
  --text: #edf3ff;
  --accent: #6ee7f9;
  --accent-2: #818cf8;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #fb7185;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 10%, rgba(59, 130, 246, .17), transparent 28rem),
    radial-gradient(circle at 88% 14%, rgba(45, 212, 191, .12), transparent 25rem),
    var(--bg);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.shell { width: min(1440px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 56px; position: relative; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #07111f; box-shadow: 0 12px 40px rgba(103,232,249,.22);
}
.eyebrow { margin: 0 0 3px; color: var(--accent); text-transform: uppercase; letter-spacing: .15em; font-size: 11px; font-weight: 800; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(22px, 3vw, 34px); margin-bottom: 3px; letter-spacing: -.035em; }
h2 { font-size: 18px; margin-bottom: 14px; }
.muted { color: var(--muted); }
.status-pill { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 12px var(--success); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 20px; backdrop-filter: blur(20px); box-shadow: 0 18px 55px rgba(0,0,0,.22); }
.login-panel { width: min(440px, 100%); margin: 10vh auto 0; }
.stack { display: grid; gap: 12px; }
.grid { display: grid; gap: 16px; }
.grid.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card-value { font-size: 28px; font-weight: 800; letter-spacing: -.03em; }
.card-label { color: var(--muted); font-size: 13px; margin-top: 4px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
input, textarea, select {
  width: 100%; color: var(--text); background: rgba(7, 12, 24, .82); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: rgba(110,231,249,.58); box-shadow: 0 0 0 3px rgba(110,231,249,.09); }
textarea { min-height: 130px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1 1 240px; }
.btn { border: 1px solid var(--line); border-radius: 11px; padding: 10px 14px; color: var(--text); background: rgba(30,41,59,.72); transition: .16s ease; }
.btn:hover { transform: translateY(-1px); border-color: rgba(148,163,184,.4); }
.btn.primary { color: #06111d; border: 0; font-weight: 800; background: linear-gradient(135deg, var(--accent), #a5b4fc); }
.btn.danger { color: #fecdd3; border-color: rgba(251,113,133,.35); background: rgba(159,18,57,.18); }
.btn.success { color: #a7f3d0; border-color: rgba(52,211,153,.35); background: rgba(6,95,70,.18); }
.btn.small { padding: 6px 9px; font-size: 12px; }
.section { margin-top: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-size: 13px; }
th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: #11182a; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(99,102,241,.05); }
.badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.badge.on { color: #a7f3d0; background: rgba(16,185,129,.14); }
.badge.off { color: #fecdd3; background: rgba(244,63,94,.14); }
.flash { margin: 12px 0; min-height: 20px; font-size: 13px; color: var(--muted); }
.flash.error { color: var(--danger); }
.flash.success { color: var(--success); }
.mail-layout { display: grid; grid-template-columns: minmax(290px, 420px) minmax(0, 1fr); min-height: 70vh; padding: 0; overflow: hidden; }
.mail-list { border-right: 1px solid var(--line); min-height: 70vh; }
.mail-list-head, .mail-view-head { padding: 18px; border-bottom: 1px solid var(--line); }
.mail-items { max-height: calc(70vh - 76px); overflow: auto; }
.mail-item { display: block; width: 100%; padding: 14px 18px; text-align: left; border: 0; border-bottom: 1px solid var(--line); color: var(--text); background: transparent; }
.mail-item:hover, .mail-item.active { background: rgba(99,102,241,.1); }
.mail-item-title { font-weight: 700; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.mail-item-meta { margin-top: 6px; color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; gap: 8px; }
.mail-view { min-width: 0; }
.mail-content { padding: 20px; overflow: auto; max-height: calc(70vh - 76px); }
.mail-text { white-space: pre-wrap; word-break: break-word; line-height: 1.65; color: #dbe6f7; }
.mail-frame { width: 100%; min-height: 420px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.attachment { display: inline-flex; margin: 5px 6px 0 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); color: var(--accent); text-decoration: none; font-size: 12px; }
dialog { width: min(900px, calc(100% - 28px)); max-height: 90vh; color: var(--text); border: 1px solid var(--line); border-radius: 18px; background: #0b1020; padding: 0; box-shadow: 0 25px 100px rgba(0,0,0,.55); }
dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(7px); }
.dialog-body { padding: 20px; max-height: 78vh; overflow: auto; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
code { color: var(--accent); }

@media (max-width: 980px) {
  .grid.cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two { grid-template-columns: 1fr; }
  .mail-layout { grid-template-columns: 1fr; }
  .mail-list { min-height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .mail-items { max-height: 320px; }
}
@media (max-width: 580px) {
  .shell { width: min(100% - 18px, 1440px); padding-top: 16px; }
  .topbar { align-items: flex-start; }
  .grid.cards { grid-template-columns: 1fr 1fr; gap: 9px; }
  .panel { border-radius: 15px; padding: 14px; }
}
