:root {
  --bg: #0b0d12; --panel: #141821; --panel2: #1b2130;
  --border: #242b3a; --text: #e6edf3; --muted: #8b95a7;
  --accent: #4f8bff; --accent2: #7b5bff;
  --ok: #3fd27f; --warn: #ffb547; --err: #ff5b70;
  --input-bg: #1b2130; --console-bg: #05070b; --console-text: #c3d4ea;
  --radius: 10px;
}
body.theme-light {
  --bg: #f4f6fb; --panel: #ffffff; --panel2: #eef2f8;
  --border: #d9dfeb; --text: #1a2233; --muted: #5a6b85;
  --accent: #3366ff; --accent2: #7b5bff;
  --ok: #1aaf5d; --warn: #c6830d; --err: #d93250;
  --input-bg: #f7f9fc; --console-bg: #0f1420; --console-text: #e4ecf7;
}
* { box-sizing: border-box }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif;
  font-size: 14px; direction: ltr; transition: background .18s, color .18s; }
a { color: var(--accent); text-decoration: none }
button, input, select, textarea { font: inherit; color: inherit; color-scheme: dark }
body.theme-light button, body.theme-light input, body.theme-light select, body.theme-light textarea { color-scheme: light }

/* unify ALL form inputs (fixes the white default inputs) */
input[type="text"], input[type="number"], input[type="email"], input[type="password"], select, textarea {
  background: var(--input-bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 8px 10px; outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent) }

/* LOGIN */
.login-body { display: grid; place-items: center; min-height: 100vh;
  background: radial-gradient(1200px 500px at 50% -10%, #1a2240 0%, var(--bg) 60%); }
.login-card { background: var(--panel); padding: 32px 28px; border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 360px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.login-logo { font-size: 42px; margin-bottom: 4px }
.login-card h1 { margin: 0 0 4px; font-size: 20px }
.login-card .muted { color: var(--muted); margin-bottom: 20px }
.login-card label { display: block; text-align: left; margin: 10px 0; font-size: 13px; color: var(--muted) }
.login-card input { width: 100%; margin-top: 4px; padding: 10px 12px; background: var(--panel2);
  border: 1px solid var(--border); border-radius: 8px; outline: none }
.login-card input:focus { border-color: var(--accent) }
.login-card button { margin-top: 16px; width: 100%; padding: 10px; background: var(--accent);
  color: #fff; border: 0; border-radius: 8px; font-weight: 600; cursor: pointer }
.alert { background: rgba(255,91,112,.12); color: var(--err); border: 1px solid rgba(255,91,112,.3);
  padding: 8px 12px; border-radius: 8px; margin-bottom: 8px; font-size: 13px }

/* TOPBAR */
.topbar { display: flex; align-items: center; gap: 24px; padding: 14px 24px;
  background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10 }
.brand { font-weight: 700; font-size: 16px }
.topbar nav { display: flex; gap: 6px; flex: 1 }
.tab { background: transparent; border: 0; color: var(--muted); padding: 8px 14px;
  border-radius: 8px; cursor: pointer; font-weight: 500 }
.tab:hover { background: var(--panel2); color: var(--text) }
.tab.active { background: var(--accent); color: #fff }
.user { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--err); transition: background .2s }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok) }

/* LAYOUT */
main { max-width: 1400px; margin: 0 auto; padding: 24px; }
.tab-pane { display: none }
.tab-pane.active { display: block; animation: fade .18s ease-out }
@keyframes fade { from { opacity:0; transform: translateY(4px) } to { opacity:1; transform: none } }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 16px; margin-bottom: 20px }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px }
.card-head { display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap }
.card-head h3 { margin: 0; font-size: 15px; font-weight: 600 }

.pill { font-size: 11px; padding: 3px 10px; border-radius: 999px; background: var(--panel2);
  border: 1px solid var(--border); color: var(--muted); text-transform: uppercase; letter-spacing: .5px }
.pill.ok   { color: var(--ok);   border-color: rgba(63,210,127,.3); background: rgba(63,210,127,.1) }
.pill.err  { color: var(--err);  border-color: rgba(255,91,112,.3); background: rgba(255,91,112,.1) }
.pill.warn { color: var(--warn); border-color: rgba(255,181,71,.3); background: rgba(255,181,71,.1) }

.stat .stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: .5px; margin-bottom: 6px }
.stat .stat-value { font-size: 26px; font-weight: 700 }
.stat .stat-sub { color: var(--muted); font-size: 12px; margin-top: 4px }
.stat .stat-value.ok { color: var(--ok) }
.stat .stat-value.err { color: var(--err) }
.stat .stat-value.warn { color: var(--warn) }

.bar { height: 6px; background: var(--panel2); border-radius: 3px; margin-top: 10px; overflow: hidden }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2));
  width: 0%; transition: width .4s }

.controls { display: flex; gap: 8px; flex-wrap: wrap }
.btn { background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; transition: all .15s }
.btn:hover { background: #2b3348 }
.btn:disabled { opacity: .5; cursor: not-allowed }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff }
.btn.primary:hover { background: #3b74e6 }
.btn.danger { background: transparent; border-color: rgba(255,91,112,.4); color: var(--err) }
.btn.danger:hover { background: rgba(255,91,112,.1) }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap }
.row.end { justify-content: flex-end }
.hint { color: var(--muted); font-size: 12px; margin-top: 8px; min-height: 16px }
.hint.ok { color: var(--ok) } .hint.err { color: var(--err) } .hint.warn { color: var(--warn) }

.search { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 12px; color: var(--text); width: 240px }

.ip-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr));
  gap: 6px; max-height: 500px; overflow: auto; padding: 4px }
.ip-item { background: var(--panel2); padding: 8px 10px; border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }

.kv > div { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border) }
.kv > div:last-child { border-bottom: 0 }
.kv span { color: var(--muted) }

/* SESSION */
.session-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 12px }
.session-grid > div { background: var(--panel2); padding: 12px 14px; border-radius: 8px;
  display: flex; flex-direction: column; gap: 4px }
.session-grid .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px }
.session-grid b { font-size: 14px; word-break: break-all }
h4.sub { font-size: 13px; color: var(--muted); margin: 20px 0 8px; text-transform: uppercase; letter-spacing: .5px }

.format-tabs { display: flex; gap: 6px; margin-bottom: 14px }
.ftab { background: var(--panel2); border: 1px solid var(--border); color: var(--muted);
  padding: 7px 14px; border-radius: 8px; cursor: pointer }
.ftab.active { background: var(--accent); color: #fff; border-color: var(--accent) }

.format-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 12px }
.fitem { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 14px }
.fitem h4 { margin: 0 0 6px; font-size: 14px }
.fitem .fmeta { color: var(--muted); font-size: 12px; margin-bottom: 10px }
.fitem .fsubject { color: var(--text); font-size: 13px; margin-bottom: 10px }
.fitem .frow { display: flex; gap: 6px }
.fitem .frow button { font-size: 12px; padding: 5px 10px }

dialog { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); padding: 24px; max-width: 540px; width: 90%; }
dialog::backdrop { background: rgba(0,0,0,.5); backdrop-filter: blur(3px) }
dialog h3 { margin: 0 0 14px }
dialog label { display: block; margin: 10px 0; color: var(--muted); font-size: 13px }
dialog input, dialog textarea { width: 100%; margin-top: 4px; padding: 8px 10px; background: var(--panel2);
  border: 1px solid var(--border); border-radius: 6px; color: var(--text) }
dialog textarea { font-family: ui-monospace, monospace; resize: vertical }

.log { background: #05070b; color: #9ccfff; padding: 14px; border-radius: 8px;
  max-height: 400px; overflow: auto; font-family: ui-monospace, monospace; font-size: 12px;
  white-space: pre-wrap; word-break: break-all; margin: 0 }

.form label { display: block; margin: 10px 0; color: var(--muted); font-size: 13px }
.form input { width: 100%; margin-top: 4px; padding: 8px 10px; background: var(--panel2);
  border: 1px solid var(--border); border-radius: 6px; color: var(--text) }
.form h3.sep { margin: 18px 0 4px; font-size: 14px; color: var(--text) }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 12px }

/* table */
.tbl { width: 100%; border-collapse: collapse; margin-top: 8px }
.tbl th, .tbl td { padding: 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px }
.tbl th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .5px }
.tbl .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; color: var(--muted) }
.tbl .err-text { color: var(--err); font-size: 11px; margin-top: 3px; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.tbl .trunc { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.chip { background: var(--panel2); padding: 2px 8px; border-radius: 12px; font-size: 11px;
  color: var(--muted); display: inline-block; margin: 1px }
.badge { background: var(--accent); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 10px; margin-left: 6px }
.fresh-pill { background: var(--panel2); padding: 8px 12px; border-radius: 8px; margin-bottom: 6px;
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; margin-right: 6px }
.fresh-list { display: flex; flex-wrap: wrap; gap: 6px }
code { background: var(--panel2); padding: 1px 6px; border-radius: 4px; font-size: 12px }
.muted { color: var(--muted) }

/* Froms Checker tab */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr } }
.chips-box { display: flex; flex-wrap: wrap; gap: 6px; max-height: 260px; overflow: auto; padding: 4px }
.chips-box .chip { background: var(--panel2); border: 1px solid var(--border); padding: 5px 10px;
  border-radius: 16px; font-size: 12px; font-family: ui-monospace, monospace; color: var(--text) }
.drop-zone { border: 2px dashed var(--border); border-radius: 8px; padding: 14px; margin-bottom: 10px;
  text-align: center; color: var(--muted); font-size: 13px; transition: all .15s }
.drop-zone.over { border-color: var(--accent); background: rgba(79,139,255,.08); color: var(--accent) }
.drop-zone p { margin: 0 }
.console-view { background: var(--console-bg); color: var(--console-text); padding: 14px; border-radius: 8px;
  max-height: 480px; overflow: auto; font-family: ui-monospace, monospace; font-size: 12px;
  white-space: pre-wrap; word-break: break-all; margin: 0; line-height: 1.5 }
.console-view .ok  { color: #3fd27f }
.console-view .err { color: #ff5b70 }
.console-view .warn{ color: #ffb547 }
.console-view .dim { color: var(--muted) }
.switch { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px }

/* theme toggle button in topbar */
.theme-btn { background: transparent; border: 1px solid var(--border); color: var(--muted);
  padding: 6px 10px; border-radius: 8px; cursor: pointer; font-size: 14px }
.theme-btn:hover { color: var(--text); border-color: var(--accent) }

/* Inbox Monitor */
.monitor-list { max-height: 360px; overflow: auto; padding: 4px }
.mon-item { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; margin-bottom: 8px; display: grid;
  grid-template-columns: 90px 1fr 1fr 1fr; gap: 10px; align-items: center; font-size: 13px;
  animation: flash .8s ease-out; }
.mon-item .t { color: var(--muted); font-family: ui-monospace, monospace; font-size: 11px }
.mon-item .from { font-weight: 600; word-break: break-all }
.mon-item .to   { color: var(--muted); word-break: break-all }
.mon-item .subj { color: var(--text); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
@keyframes flash { 0% { background: rgba(63,210,127,.3); } 100% { background: var(--panel2); } }

/* make FROM textarea nicely sized */
#ck-from-text, #ck-to-text { width: 100%; font-family: ui-monospace, monospace; font-size: 12px;
  background: var(--input-bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px; box-sizing: border-box; resize: vertical }
.ro-badge { background: var(--panel2); color: var(--muted); padding: 2px 8px; border-radius: 10px;
  font-size: 11px; margin-left: 6px }
