/* tmail admin — tema yang sama dengan situs publik (gelap ala aplikasi email). */
:root {
  --ink: #e8eaed;
  --ink-2: #aecbfa;
  --blue: #8ab4f8;
  --blue-deep: #aecbfa;
  --blue-soft: #394457;
  --paper: #2d2e30;
  --bg: #202124;
  --line: #3c4043;
  --line-soft: #2f3033;
  --muted: #9aa0a6;
  --green: #81c995;
  --red: #f28b82;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --font-ui: "Roboto", -apple-system, "Segoe UI", sans-serif;
  --font-display: "Roboto", -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Roboto Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14.5px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -.01em; }
h2 { font: 500 20px var(--font-ui); margin-bottom: 10px; }
h3 { font-size: 15px; margin: 20px 0 6px; }
p { margin: 0; }
button { font: inherit; cursor: pointer; }
code { font: 500 13px var(--font-mono); background: var(--bg); border: 1px solid var(--line-soft); border-radius: 6px; padding: 1px 6px; }
::selection { background: var(--blue-soft); }

.wrap { max-width: 860px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.ic { width: 20px; height: 20px; flex: none; }
.ic-sm { width: 16px; height: 16px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
/* display:flex di atas menimpa atribut hidden bawaan — tanpa baris ini layar
   login tidak bisa hilang walau hidden=true, dashboard ketutup terus
   (bug 2026-11-07, sama seperti kartu iklan). */
.login-wrap[hidden] { display: none; }
.login-card {
  width: 100%; max-width: 400px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow); padding: 28px;
}
.brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--blue);
  color: #202124; display: flex; align-items: center; justify-content: center;
}
.brand-mark .ic { width: 19px; height: 19px; }
.brand-name { font: 500 20px/1 var(--font-ui); letter-spacing: -.02em; }
.admin-tag {
  font: 600 11px var(--font-ui); letter-spacing: .08em; text-transform: uppercase;
  background: var(--blue-soft); color: var(--blue-deep); border-radius: 999px; padding: 3px 8px;
  vertical-align: middle;
}
.login-card h1 { font: 500 22px var(--font-ui); margin-bottom: 4px; }
.login-card .muted { font-size: 14px; margin-bottom: 18px; }

/* ---------- form ---------- */
.field-label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
.field-label:first-of-type { margin-top: 0; }
input[type="text"], input[type="password"], input[type="number"] {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  font: 500 14.5px var(--font-ui); color: var(--ink); background: var(--paper); outline: none;
}
select {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  font: 500 14.5px var(--font-ui); color: var(--ink); background: var(--paper); outline: none; cursor: pointer;
}
select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(138, 180, 248, .25); }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(138, 180, 248, .25); }
textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  font: 500 14.5px/1.5 var(--font-ui); color: var(--ink); background: var(--paper); outline: none; resize: vertical;
}
textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(138, 180, 248, .25); }
.switch-row { display: flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 600; cursor: pointer; margin-bottom: 6px; }
.switch-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--blue); cursor: pointer; }

/* ---------- toast notifikasi ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 100;
  transform: translateX(-50%) translateY(8px);
  background: #e8eaed; color: #202124; border-radius: 10px; padding: 12px 18px;
  font: 500 14px var(--font-ui); box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #b91c1c; }
.err { color: var(--red); font-size: 13.5px; margin: 10px 0 0; }
.ok-msg { color: var(--green); font-size: 13.5px; margin: 10px 0 0; }

/* ---------- tombol ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  font-weight: 600; font-size: 14px; transition: background .15s, border-color .15s;
}
.btn:hover { background: rgba(232, 234, 237, .08); border-color: var(--line); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-deep); border-color: var(--blue-deep); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 8px 10px; }
.btn.ghost:hover { background: rgba(232, 234, 237, .08); color: var(--ink); }
.btn.big { width: 100%; justify-content: center; padding: 12px 16px; margin-top: 16px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--paper); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line); }
.icon-btn .ic { width: 17px; height: 17px; }

/* ---------- dashboard ---------- */
.topbar { background: var(--paper); border-bottom: 1px solid var(--line-soft); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }

.tabs { display: flex; gap: 4px; margin: 22px 0; overflow-x: auto; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.tab {
  border: 0; background: none; color: var(--muted); font: 600 14px var(--font-ui);
  padding: 10px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--blue-deep); border-bottom-color: var(--blue); }

.panel { padding-bottom: 40px; }
.panel > .muted { font-size: 14px; margin-bottom: 16px; max-width: 640px; }
.note { font-size: 13.5px; margin-top: 16px; }

/* statistik */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.stat-n { display: block; font: 500 28px var(--font-ui); color: var(--ink); }
.stat-l { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }

/* domain */
.domain-list { display: grid; gap: 8px; margin-bottom: 16px; }
.domain-row {
  display: flex; align-items: center; gap: 10px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.domain-row code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: none; border: 0; padding: 0; font-size: 14.5px; }
.add-row { display: flex; gap: 10px; }
.add-row input { flex: 1; }

/* pesan */
.search-row { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.search-row .ic { color: var(--muted); }
.search-row input { flex: 1; }
.admin-msg-list { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow-y: auto; overflow-x: hidden; box-shadow: var(--shadow); max-height: 520px; }
.admin-msg-list:empty { display: none; }
.admin-msg-row {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left;
  padding: 13px 16px; background: none; border: 0; border-bottom: 1px solid var(--line-soft);
  color: var(--ink); font: inherit;
}
.admin-msg-row:last-child { border-bottom: 0; }
.admin-msg-row:hover { background: rgba(232, 234, 237, .06); }
.admin-msg-main { flex: 1; min-width: 0; }
.admin-msg-addr { display: block; font: 500 12.5px var(--font-mono); color: var(--blue-deep); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-msg-subject { display: block; font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-msg-meta { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-msg-time { flex: none; font: 400 12px var(--font-mono); color: var(--muted); }

/* Aturan display bawaan author menimpa [hidden] bawaan browser. */
#msgSearchRow[hidden], #msgMore[hidden] { display: none; }
#msgMore { display: block; margin: 12px auto 0; }

/* pembaca pesan admin — ganti tampilan di tempat (seperti kotak masuk utama),
   bukan di bawah daftar. */
.reader { margin-top: 0; }
.reader-bar { display: flex; align-items: center; gap: 4px; padding: 4px 0 12px; }
.reader-spacer { flex: 1; }
.mail { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.mail-head { display: flex; align-items: flex-start; gap: 12px; }
.mail-who { flex: 1; min-width: 0; }
.mail-who strong { display: block; font-size: 15px; }
.mail-who span { display: block; font-size: 12.5px; }
.mail-subject { font: 500 20px/1.35 var(--font-ui); margin: 16px 0 6px; }
.mail-body { border-top: 1px solid var(--line-soft); margin-top: 12px; padding-top: 16px; font-size: 14.5px; }
.mail-body pre { white-space: pre-wrap; word-break: break-word; font: inherit; margin: 0; }
.mail-body iframe { width: 100%; min-height: 420px; border: 0; display: block; }

/* api key */
.key-field {
  display: flex; align-items: center; gap: 8px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 12px; padding: 8px 8px 8px 14px; margin-bottom: 12px;
}
.key-field code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: none; border: 0; padding: 0; font-size: 14px; }
.code-block {
  background: #17181a; color: #aecbfa; border-radius: 12px; padding: 14px 16px;
  font: 400 12.5px/1.7 var(--font-mono); overflow-x: auto; white-space: pre; margin: 6px 0 14px;
}

/* pengaturan */
.settings-form { max-width: 420px; }
.settings-form .btn { margin-top: 18px; }

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .add-row { flex-direction: column; }
  .search-row { flex-wrap: wrap; }
  .admin-msg-time { display: none; }
  .mail { padding: 16px; }
}
