:root {
  color-scheme: light;
  --bg: #f2f6f5;
  --surface: #ffffff;
  --surface-2: #f7faf9;
  --surface-3: #edf4f2;
  --text: #17212b;
  --muted: #64727d;
  --line: #d9e3e0;
  --line-strong: #c5d4d0;
  --brand: #087f78;
  --brand-dark: #05635e;
  --brand-soft: #e1f2ef;
  --blue: #2878b5;
  --blue-soft: #e8f2fa;
  --twofa: #176f91;
  --twofa-dark: #115670;
  --twofa-soft: #e6f2f6;
  --twofa-line: #bfd8e2;
  --cyan: #168fa3;
  --cyan-soft: #e5f6f8;
  --accent: #b7791f;
  --accent-soft: #fff4da;
  --danger: #be4650;
  --danger-soft: #fae9eb;
  --shadow: 0 18px 48px rgba(34, 56, 52, 0.10);
  --shadow-soft: 0 8px 24px rgba(34, 56, 52, 0.07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, input, select { min-height: 42px; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-width: 1px !important;
  min-height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0 !important;
}
.muted { color: var(--muted); }
.danger-text { color: var(--danger); }
.icon { width: 18px; height: 18px; stroke-width: 1.9; flex: 0 0 auto; }

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { cursor: wait; opacity: .6; transform: none; }
.btn-primary { background: var(--brand); color: white; box-shadow: 0 8px 18px rgba(8, 127, 120, .18); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: #9fb8b2; background: var(--surface-2); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: #e8bfc3; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-icon { width: 40px; padding: 0; }
.btn-block { width: 100%; }
.btn-large { min-height: 50px; font-size: 15px; }
.icon-link { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; }

.field { display: grid; gap: 8px; }
.field label { font-weight: 700; color: #33434c; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 10px; background: white;
  color: var(--text); padding: 0 13px; outline: none; transition: border-color .16s ease, box-shadow .16s ease;
}
.field textarea { min-height: 110px; padding-block: 11px; resize: vertical; line-height: 1.55; }
.field-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.field-tools small { color: var(--muted); }
.field input::placeholder, .field textarea::placeholder { color: #98a5ad; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(8,127,120,.12); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.message { min-height: 20px; margin: 12px 0 0; color: var(--danger); }
.eyebrow, .card-kicker { display: block; color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: 1.2px; }

/* Public workspace */
.public-shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; background: var(--bg); }
.public-head, .public-foot { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.public-head { min-height: 76px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(197, 212, 208, .7); }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 800; font-size: 17px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--brand); color: white; box-shadow: 0 8px 18px rgba(8,127,120,.2); }
.brand-mark svg { width: 20px; height: 20px; }
.secure-status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.secure-status > span { width: 8px; height: 8px; border-radius: 50%; background: #24a36b; box-shadow: 0 0 0 4px rgba(36,163,107,.12); }
.public-main { padding: 50px 20px 70px; }
.query-tool { width: min(1180px, 100%); margin: 0 auto; }
.query-heading { text-align: center; margin-bottom: 28px; }
.query-heading h1 { font-size: 34px; line-height: 1.18; margin: 8px 0 9px; }
.query-heading p { margin: 0; color: var(--muted); font-size: 15px; }
.query-tabs {
  width: min(650px, 100%); margin: 0 auto 28px; padding: 5px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  border: 1px solid var(--line); border-radius: 15px; background: #e8efed; box-shadow: inset 0 1px 2px rgba(34,56,52,.05);
}
.query-tab {
  min-height: 64px; border: 1px solid transparent; border-radius: 11px; padding: 8px 15px;
  background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: flex-start;
  gap: 12px; text-align: left; transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, color .16s ease;
}
.query-tab:hover { background: rgba(255,255,255,.48); color: var(--text); }
.query-tab .tab-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #65767c; flex: 0 0 auto; }
.query-tab .tab-icon .icon { width: 20px; height: 20px; }
.query-tab > span:last-child { display: grid; gap: 3px; min-width: 0; }
.query-tab strong { color: var(--text); font-size: 15px; }
.query-tab small { font-size: 12px; color: var(--muted); }
.query-tab.active { background: white; border-color: rgba(197,212,208,.78); color: var(--text); box-shadow: 0 4px 13px rgba(34,56,52,.09); }
.query-tab.active .tab-icon { background: var(--brand-soft); color: var(--brand-dark); }
.query-panel { display: none; }
.query-panel.active { display: block; }
.query-workspace { display: grid; grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr); gap: 20px; align-items: stretch; }
.workspace-card {
  position: relative;
  background: var(--surface);
  border: 1px solid rgba(197,212,208,.72);
  border-radius: 16px;
  padding: 27px;
  box-shadow: 0 16px 42px rgba(34,56,52,.075), 0 2px 8px rgba(34,56,52,.035);
  min-width: 0;
  overflow: hidden;
}
.workspace-card::before { content: ''; position: absolute; inset: 0 0 auto; height: 3px; background: var(--brand); }
#mail-panel .output-card::before { background: var(--accent); }
#totp-panel .input-card::before { background: var(--twofa); }
#totp-panel .output-card::before { background: var(--cyan); }
.workspace-card-head { display: flex; align-items: center; gap: 13px; margin-bottom: 20px; }
.workspace-card-head h2 { margin: 4px 0 0; font-size: 20px; }
.workspace-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; flex: 0 0 auto; }
.workspace-icon.mail { background: var(--brand-soft); color: var(--brand); }
.workspace-icon.totp { background: var(--twofa-soft); color: var(--twofa-dark); }
.workspace-icon.output { background: var(--accent-soft); color: var(--accent); }
#totp-panel .workspace-icon.output { background: var(--cyan-soft); color: var(--cyan); }
.card-copy { color: var(--muted); line-height: 1.7; margin: -4px 0 22px; }
.input-card form { display: grid; }
.mail-mode-switch {
  margin: 0 0 18px; padding: 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface-3);
}
.mail-mode-button {
  min-width: 0; min-height: 42px; padding: 0 12px; border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700;
}
.mail-mode-button:hover { color: var(--text); background: rgba(255,255,255,.55); }
.mail-mode-button.active { color: var(--brand-dark); border-color: var(--line); background: white; box-shadow: 0 3px 9px rgba(34,56,52,.08); }
.batch-field-tools { justify-content: space-between; }
.totp-meta-fields { margin-top: 15px; }
.output-card { display: flex; flex-direction: column; }
.output-surface { min-height: 330px; flex: 1; display: grid; align-items: center; border: 1px solid rgba(217,227,224,.72); background: #f8fbfa; border-radius: 14px; padding: 24px; }
.mail-output-surface { background: #f6fbfa; }
.totp-output-surface { background: #f5fafb; border-color: #cfe2e8; }
.result-placeholder { text-align: center; color: var(--muted); max-width: 310px; margin: auto; }
.result-placeholder strong { display: block; color: var(--text); font-size: 17px; margin-top: 15px; }
.result-placeholder p { line-height: 1.65; margin: 8px 0 0; }
.placeholder-icon { width: 66px; height: 66px; margin: 0 auto; border-radius: 18px; display: grid; place-items: center; background: white; border: 1px solid rgba(217,227,224,.76); color: var(--brand); box-shadow: 0 10px 28px rgba(34,56,52,.08); }
.placeholder-icon svg { width: 28px; height: 28px; }
.totp-placeholder { max-width: 350px; }
.totp-placeholder-icon { width: 66px; height: 66px; border-radius: 18px; border-color: #cfe2e8; background: white; color: var(--twofa); box-shadow: 0 10px 28px rgba(34,56,52,.08); }
.placeholder-code { display: flex; justify-content: center; gap: 8px; margin-top: 19px; }
.placeholder-code span { width: 10px; height: 10px; border-radius: 50%; background: #72afbf; }
.placeholder-code span:nth-child(2), .placeholder-code span:nth-child(5) { background: #91cbd4; }
.placeholder-code span:nth-child(3), .placeholder-code span:nth-child(6) { background: #e4bc68; }
.output-surface:has(.result:not(.hidden)) .result-placeholder { display: none; }
.result { width: 100%; }
.result-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; color: var(--muted); padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.result-meta strong { color: var(--text); }
.result-meta > * { min-width: 0; overflow-wrap: anywhere; }
.code-section { padding: 22px 0; border-bottom: 1px solid var(--line); }
.code-section-head h2 { margin: 0; font-size: 15px; }
.code-section > .muted { margin: 14px 0 0; }
.code-line { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 22px 0; }
.code-value { font: 800 42px/1 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--brand-dark); overflow-wrap: anywhere; }
.result-detail { display: grid; gap: 8px; color: var(--muted); line-height: 1.5; }
.result-empty { margin: 22px 0 0; text-align: center; }
.mail-list { display: grid; gap: 12px; padding-top: 16px; }
.mail-item { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.mail-item-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.mail-item-title { min-width: 0; display: grid; gap: 5px; }
.mail-item-title strong, .mail-item-title span { overflow-wrap: anywhere; }
.mail-item-title span, .mail-item-head time { color: var(--muted); font-size: 12px; }
.mail-item-head time { flex: 0 0 auto; white-space: nowrap; }
.mail-preview { margin: 13px 0; color: var(--muted); font-size: 13px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.mail-item-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mail-code { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.mail-code > span { font: 800 20px/1 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--brand-dark); overflow-wrap: anywhere; }
.mail-code-state { color: var(--muted); font-size: 12px; }
.mail-body-panel { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); }
.mail-body { margin: 0; max-height: 420px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: 400 13px/1.7 system-ui, sans-serif; color: var(--text); }
.mail-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 16px; color: var(--muted); font-size: 12px; }
.batch-result-meta { padding-bottom: 14px; }
.batch-result-list { display: grid; padding-top: 8px; }
.batch-result-row {
  min-width: 0; min-height: 76px; display: grid; grid-template-columns: minmax(150px, 1.2fr) 92px minmax(140px, .9fr) 40px;
  align-items: center; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line);
}
.batch-result-row:last-child { border-bottom: 0; }
.batch-result-identity { min-width: 0; display: flex; align-items: center; gap: 10px; }
.batch-result-identity > div, .batch-result-code { min-width: 0; display: grid; gap: 4px; }
.batch-result-identity strong, .batch-result-identity small, .batch-result-code small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-result-identity small, .batch-result-code small { color: var(--muted); font-size: 11px; }
.batch-row-index { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: 0 0 auto; background: var(--surface-3); color: var(--muted); font-size: 11px; font-weight: 800; }
.batch-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.batch-status > span { width: 7px; height: 7px; border-radius: 50%; background: #98a5ad; flex: 0 0 auto; }
.batch-status.received { color: #22764f; }
.batch-status.received > span { background: #2eae73; box-shadow: 0 0 0 3px rgba(46,174,115,.12); }
.batch-status.waiting > span { background: var(--accent); box-shadow: 0 0 0 3px rgba(183,121,31,.12); }
.batch-status.invalid { color: var(--danger); }
.batch-status.invalid > span { background: var(--danger); }
.batch-result-code strong { font: 800 23px/1 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--brand-dark); letter-spacing: 0; }
.batch-waiting .batch-result-code strong, .batch-invalid .batch-result-code strong { color: #aab5ba; }
.batch-result-action { display: grid; place-items: center; }
.batch-refresh-note { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.batch-refresh-note > span { min-width: 0; }
.batch-refresh-note .btn { margin-left: auto; flex: 0 0 auto; min-height: 38px; padding-inline: 12px; }
.totp-result-meta { border-bottom-color: #cfe2e8; }
.totp-entry-list { display: grid; gap: 13px; padding-top: 18px; }
.totp-entry { padding: 17px; border: 1px solid #cfe2e8; border-radius: 14px; background: white; box-shadow: 0 9px 22px rgba(20,86,108,.07); min-width: 0; }
.totp-entry-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.totp-entry-head h2 { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.totp-entry-head p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.totp-identity, .admin-totp-platform { display: flex; align-items: center; gap: 11px; min-width: 0; }
.totp-identity > div { min-width: 0; }
.totp-platform-avatar { width: 38px; height: 38px; border-radius: 12px; display: inline-grid; place-items: center; flex: 0 0 auto; background: var(--twofa-soft); color: var(--twofa-dark); font-size: 12px; font-weight: 850; }
.tone-google { background: #fcebe8; color: #bc3f32; }
.tone-microsoft { background: #e5f3fb; color: #176b9b; }
.tone-github { background: #e9ebee; color: #24292f; }
.tone-apple { background: #e9eef1; color: #35434b; }
.tone-discord { background: #ececfd; color: #5865d8; }
.tone-telegram { background: #e3f4fb; color: #1684b7; }
.totp-code-line { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 21px 0 16px; }
.totp-code-value { color: var(--twofa-dark); }
.totp-entry-foot { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; min-width: 0; }
.totp-live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 3px rgba(22,143,163,.12); flex: 0 0 auto; }
.totp-secret-hint { margin-left: auto; }
.totp-convert-button { background: var(--twofa); box-shadow: 0 8px 18px rgba(23,111,145,.2); }
.totp-convert-button:hover { background: var(--twofa-dark); }
.compact-note { margin: 10px 0 0; font-size: 12px; line-height: 1.6; }
.public-foot { padding: 22px 0; color: var(--muted); font-size: 12px; border-top: 1px solid rgba(197,212,208,.7); }

/* Login */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #eef4f2; }
.login-box { width: min(430px, 100%); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-brand > div { display: grid; gap: 2px; }
.login-brand strong { font-size: 17px; }
.login-brand span:last-child { color: var(--muted); font-size: 12px; }
.login-panel { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 31px; box-shadow: var(--shadow); }
.login-panel h1 { margin: 8px 0 7px; font-size: 25px; }
.login-copy { color: var(--muted); margin: 0 0 24px; }
.login-panel form { display: grid; gap: 16px; }
.login-panel form > .btn { min-height: 48px; }

/* Admin workspace */
.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar { background: #f8fbfa; color: var(--text); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 4px 8px 24px; }
.nav { display: grid; gap: 5px; }
.nav button { position: relative; border: 0; background: transparent; color: #586872; border-radius: 11px; padding: 0 12px; display: flex; align-items: center; gap: 11px; text-align: left; font-weight: 700; }
.nav button > .icon { width: 20px; height: 20px; }
.nav button::before { content: ''; position: absolute; left: 0; width: 3px; height: 22px; border-radius: 3px; background: transparent; }
.nav button:hover { background: #edf4f2; color: var(--text); }
.nav button.active { background: var(--brand-soft); color: var(--brand-dark); }
.nav button.active::before { background: var(--brand); }
.sidebar-bottom { position: absolute; left: 14px; right: 14px; bottom: 18px; }
.sidebar-bottom .btn { width: 100%; }
.admin-main { min-width: 0; }
.topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-title { display: grid; gap: 3px; }
.topbar-title > span { color: var(--brand); font-size: 10px; font-weight: 800; letter-spacing: 1.1px; }
.topbar h1 { font-size: 20px; margin: 0; }
.admin-user { display: flex; align-items: center; gap: 11px; min-width: 0; }
.admin-avatar {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; overflow: visible;
  background: #dce8e5; border: 2px solid white; position: relative; box-shadow: 0 0 0 1px var(--line), 0 5px 13px rgba(34,56,52,.13); flex: 0 0 auto;
}
.admin-avatar-person { position: relative; width: 38px; height: 38px; border-radius: 50%; overflow: hidden; background: #d9e7e4; }
.admin-avatar-face { position: absolute; left: 12px; top: 8px; width: 15px; height: 17px; border-radius: 48% 48% 46% 46%; background: #e7b18e; z-index: 2; }
.admin-avatar-face::before {
  content: ''; position: absolute; left: 4px; top: 7px; width: 2px; height: 2px; border-radius: 50%;
  background: #35464a; box-shadow: 6px 0 0 #35464a;
}
.admin-avatar-face::after {
  content: ''; position: absolute; left: 5px; top: 12px; width: 5px; height: 2px;
  border-bottom: 1px solid rgba(126,71,55,.72); border-radius: 0 0 5px 5px;
}
.admin-avatar-hair { position: absolute; left: 10px; top: 5px; width: 19px; height: 13px; border-radius: 55% 55% 40% 38%; background: #35464a; z-index: 3; transform: rotate(-4deg); }
.admin-avatar-hair::after { content: ''; position: absolute; right: 1px; top: 8px; width: 4px; height: 8px; border-radius: 0 0 4px 4px; background: #35464a; }
.admin-avatar-body { position: absolute; left: 6px; bottom: -7px; width: 27px; height: 20px; border-radius: 50% 50% 0 0; background: #4b686b; }
.admin-avatar-body::before {
  content: ''; position: absolute; left: 10px; top: 1px; width: 7px; height: 5px;
  border-radius: 0 0 5px 5px; background: #f4f8f7;
}
.admin-presence { position: absolute; right: -1px; bottom: 1px; width: 11px; height: 11px; border-radius: 50%; background: #2eae73; border: 2px solid white; }
.admin-user-copy { display: grid; gap: 2px; min-width: 0; }
.admin-user-copy strong { font-size: 13px; }
.admin-user-copy small { color: var(--muted); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { padding: 28px; max-width: 1540px; }
.section { display: none; }
.section.active { display: block; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 20px; }
.section-head h2 { margin: 0 0 5px; font-size: 24px; }
.section-head p { margin: 0; color: var(--muted); line-height: 1.6; }
.head-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: -4px 0 14px; }
.search-field { position: relative; width: min(390px, 100%); }
.search-field .icon { position: absolute; left: 13px; top: 12px; color: var(--muted); pointer-events: none; }
.search-field input { padding-left: 40px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat { background: white; border: 1px solid var(--line); border-radius: 14px; padding: 20px; min-height: 112px; box-shadow: var(--shadow-soft); }
.stat:nth-child(2) .stat-label { color: var(--blue); }
.stat:nth-child(3) .stat-label { color: var(--accent); }
.stat:nth-child(4) .stat-label { color: var(--danger); }
.stat-label { color: var(--brand); display: flex; align-items: center; gap: 8px; font-weight: 700; }
.stat-value { font-size: 29px; font-weight: 800; margin-top: 14px; }
.panel { background: white; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 22px; box-shadow: var(--shadow-soft); overflow: hidden; }
.panel-head { padding: 17px 19px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-head h3 { margin: 0; font-size: 16px; }
.panel-body { padding: 20px; }
.setting-toggle { display: flex; align-items: center; justify-content: space-between; gap: 18px; cursor: pointer; }
.setting-toggle > span:first-child { min-width: 0; display: grid; gap: 5px; }
.setting-toggle strong, .setting-toggle small { overflow-wrap: anywhere; }
.setting-toggle small { color: var(--muted); }
.setting-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { width: 48px; height: 28px; flex: 0 0 auto; position: relative; border-radius: 999px; background: #cbd6d3; transition: background .16s ease; }
.toggle-track::after { content: ''; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: white; box-shadow: 0 2px 6px rgba(34,56,52,.18); transition: transform .16s ease; }
.setting-toggle input:checked + .toggle-track { background: var(--brand); }
.setting-toggle input:checked + .toggle-track::after { transform: translateX(20px); }
.setting-toggle input:focus-visible + .toggle-track { outline: 3px solid rgba(40,128,113,.22); outline-offset: 3px; }
.status-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
.status-item { padding: 18px 20px; border-right: 1px solid var(--line); }
.status-item:last-child { border-right: 0; }
.status-item strong { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #2eae73; box-shadow: 0 0 0 4px rgba(46,174,115,.12); }
.status-dot.warn { background: var(--accent); box-shadow: 0 0 0 4px rgba(183,121,31,.12); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 13px 15px; border-bottom: 1px solid #e6ecea; vertical-align: middle; }
th { color: #697780; font-size: 12px; font-weight: 800; background: #f5f8f7; }
tbody tr { transition: background .14s ease; }
tbody tr:hover { background: #f8fbfa; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 750; background: var(--brand-soft); color: var(--brand-dark); }
.badge.off { background: #edf0f2; color: var(--muted); }
.badge.error { background: var(--danger-soft); color: var(--danger); }
.actions { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.actions .btn { min-height: 35px; padding: 0 10px; font-size: 12px; }
.empty { padding: 38px 18px; text-align: center; color: var(--muted); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(23,33,43,.42); z-index: 20; display: grid; place-items: center; padding: 20px; }
.modal { width: min(570px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: white; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.modal-head { padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 18px; margin: 0; }
.modal-body { padding: 21px; }
.secret-box { background: var(--brand-soft); border: 1px solid #b8dcd5; padding: 14px; border-radius: 11px; font: 700 15px/1.5 ui-monospace, monospace; overflow-wrap: anywhere; margin: 14px 0; }
.secret-section + .secret-section { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 20px; }
.secret-section h3 { margin: 0 0 10px; font-size: 14px; }
.secret-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: stretch; }
.secret-row .secret-box { margin: 0; }
.secret-row .btn { height: auto; }
.code-secret { font-size: 24px; letter-spacing: 0; }
.import-results { white-space: pre-wrap; max-height: 330px; overflow: auto; }
.qr { display: block; width: 220px; max-width: 100%; margin: 0 auto 15px; }
.toast { position: fixed; right: 22px; bottom: 22px; background: #20313a; color: white; padding: 12px 16px; border-radius: 11px; box-shadow: var(--shadow); z-index: 40; max-width: 380px; }

@media (max-width: 980px) {
  .query-workspace { grid-template-columns: 1fr; }
  .output-surface { min-height: 290px; }
  .admin-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .sidebar .brand span:last-child, .nav button > span, .sidebar-bottom span { display: none; }
  .sidebar .brand { justify-content: center; padding-inline: 0; }
  .nav button, .sidebar-bottom button { justify-content: center; width: 100%; padding: 0; }
  .nav button::before { left: 1px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 660px) {
  .public-head, .public-foot { width: calc(100% - 28px); }
  .public-main { padding: 34px 14px 54px; }
  .query-heading h1 { font-size: 28px; }
  .query-tabs { gap: 3px; padding: 4px; }
  .query-tab { min-height: 60px; padding: 7px 9px; gap: 8px; }
  .query-tab .tab-icon { width: 34px; height: 34px; }
  .query-tab small { display: none; }
  .workspace-card { padding: 21px 18px; }
  .output-surface { padding: 18px; min-height: 260px; }
  .totp-entry { padding: 15px; }
  .batch-result-row { grid-template-columns: minmax(0, 1fr) auto; gap: 9px 12px; padding: 14px 0; }
  .batch-result-state { justify-self: end; }
  .batch-result-code { grid-column: 1; padding-left: 38px; }
  .batch-result-action { grid-column: 2; grid-row: 2; }
  .batch-refresh-note { align-items: flex-start; flex-wrap: wrap; }
  .batch-refresh-note .btn { width: 100%; margin-left: 0; }
  .mail-item-head { display: grid; gap: 7px; }
  .mail-item-head time { white-space: normal; }
  .mail-item-foot { align-items: stretch; flex-direction: column; }
  .mail-item-foot > .btn { width: 100%; }
  .mail-pagination { flex-wrap: wrap; }
  .mail-pagination > span { width: 100%; order: -1; text-align: center; }
  .totp-code-value { font-size: 32px; }
  .code-value { font-size: 34px; }
  .admin-shell { display: block; padding-bottom: 70px; }
  .sidebar { position: fixed; z-index: 10; inset: auto 0 0 0; width: auto; height: 70px; padding: 7px; border-right: 0; border-top: 1px solid var(--line); }
  .sidebar .brand, .sidebar-bottom { display: none; }
  .nav { display: flex; justify-content: space-between; height: 100%; }
  .nav button { width: min(50px, calc((100vw - 14px) / 6)); min-height: 52px; }
  .nav button::before { inset: auto 12px 0; width: auto; height: 3px; }
  .topbar { padding: 0 15px; }
  .admin-user-copy { display: none; }
  .content { padding: 20px 14px; }
  .section-head { align-items: stretch; flex-direction: column; }
  .section-head .btn { width: 100%; }
  .head-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .head-actions .btn:last-child { grid-column: 1 / -1; }
  .list-toolbar { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .status-grid { grid-template-columns: 1fr; }
  .status-item { border-right: 0; border-bottom: 1px solid var(--line); }
  .status-item:last-child { border-bottom: 0; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { min-height: 100px; padding: 15px; }
  .stat-value { font-size: 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .login-panel { padding: 26px 21px; }
}

@media (max-width: 420px) {
  .secure-status { display: none; }
  .query-tab strong { font-size: 14px; }
  .stats { grid-template-columns: 1fr; }
  .code-value { font-size: 30px; }
  .totp-entry-foot { flex-wrap: wrap; }
  .totp-secret-hint { width: 100%; margin-left: 14px; }
}

@media (max-width: 350px) {
  .sidebar { padding-inline: 4px; }
  .nav button { width: calc((100vw - 8px) / 6); }
}
