:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: #181a20;
  --panel-2: #20232b;
  --line: #303440;
  --text: #eef1f4;
  --muted: #9aa3af;
  --accent: #2fbf71;
  --danger: #ef5b5b;
  --blue: #55a7ff;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.shell {
  width: min(1400px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar, .panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 20px;
}

h1 { margin: 0; font-size: 28px; line-height: 1.2; }
h2 { margin: 0 0 10px; font-size: 16px; }
p { margin: 6px 0 0; color: var(--muted); }
code { color: #d9f99d; }

.actions, .account-actions { display: flex; gap: 10px; align-items: center; }

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 14px;
  font-weight: 650;
  cursor: pointer;
}

button:hover { border-color: var(--blue); }
#refreshBtn, #loginBtn, #saveAccountsBtn { background: var(--accent); border-color: var(--accent); color: #07130c; }

.panel, .metric, .table-wrap {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
}

.panel { padding: 14px; margin: 14px 0; }

.login-grid {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

label { color: var(--muted); display: grid; gap: 6px; font-size: 13px; }

input[type="text"], input[type="password"], input[type="search"], textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0d0e11;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

textarea {
  margin-top: 12px;
  resize: vertical;
  min-height: 116px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

input:focus, textarea:focus { border-color: var(--blue); }
.msg { color: var(--muted); font-size: 13px; }
.hidden { display: none; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric { padding: 12px 14px; }
.metric .label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.metric strong { display: block; margin-top: 5px; font-size: 19px; }

.toolbar { display: flex; gap: 14px; align-items: center; margin: 14px 0; }
input[type="search"] { width: min(520px, 100%); min-height: 40px; }
.check { color: var(--muted); display: flex; align-items: center; gap: 8px; white-space: nowrap; }

.error {
  border: 1px solid rgba(239, 91, 91, 0.5);
  background: rgba(239, 91, 91, 0.12);
  color: #ffd7d7;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #1d2027;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
tbody tr:hover { background: rgba(255,255,255,0.025); }
.mailbox { font-weight: 680; }
.subject, .sender { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.badge {
  display: inline-flex;
  align-items: center;
  min-width: 74px;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 750;
}
.badge.code { background: rgba(47, 191, 113, 0.16); color: #7df0ad; }
.badge.no_code { background: rgba(240, 180, 41, 0.14); color: #ffd36e; }
.badge.error { background: rgba(239, 91, 91, 0.15); color: #ff9b9b; }
.copy { min-width: 72px; height: 32px; min-height: 32px; padding: 0 10px; }
.empty { color: var(--muted); text-align: center; padding: 28px; }

@media (max-width: 760px) {
  .shell { width: min(100vw - 20px, 1400px); padding-top: 14px; }
  .topbar, .toolbar, .panel-head, .account-actions { align-items: stretch; flex-direction: column; }
  .actions { width: 100%; }
  .actions button { flex: 1; }
  .login-grid, .metrics { grid-template-columns: 1fr; }
}
