/* ==========================================================================
   MortonApps Admin Console — app.css
   Clean internal-ops styling. System font stack only (CSP: no web fonts).
   Calm neutrals, white cards, generous padding, status chips.
   ========================================================================== */

:root {
  --header-bg: #1b1f27;
  --header-bg-2: #232834;
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #e3e6ea;
  --border-strong: #cbd1d9;
  --text: #1d2330;
  --text-soft: #5a6473;
  --text-faint: #8a94a3;
  --accent: #2f6df0;
  --accent-soft: #eaf1fe;
  --accent-ink: #1a4fb8;
  --danger: #c23b3b;
  --danger-soft: #fbeaea;
  --ok: #1f8a4c;
  --ok-soft: #e7f5ec;
  --warn: #9a6a00;
  --warn-soft: #fbf2dc;
  --neutral: #5a6473;
  --neutral-soft: #eef0f3;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(18, 24, 38, 0.06), 0 4px 16px rgba(18, 24, 38, 0.06);
  --shadow-lg: 0 12px 40px rgba(18, 24, 38, 0.22);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

[hidden] { display: none !important; }

/* ---- buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: inherit;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s, opacity .12s;
}
.btn:hover { background: #f7f8fa; }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-danger {
  background: #fff;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: rgba(255,255,255,.08); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ---- form controls ------------------------------------------------------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 5px;
}
.input, select.input, textarea.input {
  width: 100%;
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.input { resize: vertical; min-height: 64px; }
.hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.errline { color: var(--danger); font-size: 13px; margin: 10px 0 0; min-height: 1em; }

/* ---- cards --------------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 22px 24px; }

/* ==========================================================================
   AUTH SCREENS (login / 2fa / enrollment)
   ========================================================================== */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background:
    radial-gradient(1200px 600px at 50% -10%, #232a38 0%, rgba(35,42,56,0) 60%),
    var(--header-bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 32px 30px 28px;
}
.auth-card.wide { max-width: 540px; }
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
}
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -0.2px; }
.brand-tag {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 5px;
}
.auth-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.auth-sub { color: var(--text-soft); margin: 0 0 22px; font-size: 13.5px; }

.code-input {
  letter-spacing: 6px;
  font-family: var(--mono);
  font-size: 22px;
  text-align: center;
}
.linklike {
  background: none; border: none; padding: 0; margin: 0;
  color: var(--accent-ink); font: inherit; font-size: 13px; cursor: pointer;
}
.linklike:hover { text-decoration: underline; }

/* enrollment steps */
.steps { margin: 0 0 18px; padding-left: 20px; color: var(--text-soft); font-size: 13px; }
.steps li { margin-bottom: 6px; }
.qr-box {
  display: flex;
  justify-content: center;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 0 auto 16px;
  width: max-content;
  max-width: 100%;
}
.qr-box svg { display: block; width: 220px; height: 220px; }
.secret-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--neutral-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 18px;
}
.secret-row code {
  font-family: var(--mono);
  font-size: 13.5px;
  word-break: break-all;
  flex: 1;
  user-select: all;
}
.recovery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  font-family: var(--mono);
  font-size: 15px;
  background: var(--neutral-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin: 4px 0 16px;
}
.recovery-grid span { user-select: all; }
.callout {
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}
.callout-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid #f0e2bc; }
.check-row { display: flex; align-items: flex-start; gap: 9px; margin: 6px 0 18px; font-size: 13.5px; }
.check-row input { margin-top: 3px; }

/* ==========================================================================
   APP SHELL
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
  padding: 0 20px;
  background: var(--header-bg);
  color: #eef1f6;
  border-bottom: 1px solid #000;
}
.app-header .brand-name { color: #fff; }
.app-header .brand-tag { color: #cfe0ff; background: rgba(47,109,240,.22); }
.header-spacer { flex: 1; }
.header-email { color: #aab4c4; font-size: 13px; }

.nav {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}
.nav button {
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  color: #aab4c4;
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 8px 13px;
  cursor: pointer;
}
.nav button:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav button.active { color: #fff; background: rgba(47,109,240,.28); }

/* account menu */
.menu-wrap { position: relative; }
.menu-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: #eef1f6;
  border-radius: 8px;
  padding: 6px 11px;
  font: inherit; font-weight: 600; font-size: 13px;
  cursor: pointer;
}
.menu-btn:hover { background: rgba(255,255,255,.14); }
.menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 40;
}
.menu-pop .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-pop .who .nm { font-weight: 700; }
.menu-pop .who .em { color: var(--text-soft); font-size: 12.5px; }
.menu-pop .who .role {
  display: inline-block; margin-top: 6px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--accent-ink); background: var(--accent-soft);
  padding: 2px 7px; border-radius: 5px;
}
.menu-item {
  display: block; width: 100%; text-align: left;
  background: none; border: none; font: inherit;
  padding: 9px 10px; border-radius: 7px; cursor: pointer; color: var(--text);
}
.menu-item:hover { background: var(--neutral-soft); }

/* main content */
.main { max-width: 1280px; margin: 0 auto; padding: 26px 22px 60px; }
.page-head { margin-bottom: 18px; }
.page-head h1 { font-size: 22px; font-weight: 750; margin: 0 0 4px; letter-spacing: -0.3px; }
.page-head p { margin: 0; color: var(--text-soft); font-size: 13.5px; }

/* filter bar */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}
.filters .field { margin-bottom: 0; min-width: 150px; }
.filters .grow { flex: 1; min-width: 220px; }
.filters .field > span { margin-bottom: 4px; }

/* errors banner */
.banner {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--warn-soft);
  border: 1px solid #f0e2bc;
  color: var(--warn);
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---- tables -------------------------------------------------------------- */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data thead th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-faint);
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
  white-space: nowrap;
}
table.data tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: #f7f9fc; }
.cell-strong { font-weight: 650; color: var(--text); }
.cell-sub { color: var(--text-faint); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.muted { color: var(--text-faint); }
.empty-state { padding: 44px 20px; text-align: center; color: var(--text-faint); }
.id-pill {
  font-family: var(--mono); font-size: 12px;
  color: var(--text-soft);
}

/* ---- chips --------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center;
  font-size: 11.5px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
  text-transform: capitalize; white-space: nowrap;
  line-height: 1.4;
}
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-neutral { background: var(--neutral-soft); color: var(--neutral); }
.chip-accent { background: var(--accent-soft); color: var(--accent-ink); }
.chip-type {
  background: var(--neutral-soft); color: var(--text-soft);
  text-transform: none; font-weight: 700;
}
.chip-type.bug { background: #fdecea; color: #b23a2c; }
.chip-type.feature { background: #eaf1fe; color: var(--accent-ink); }
.sev-dot { display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:6px; vertical-align: middle; }

/* ==========================================================================
   DRAWER (detail panel) + MODAL (confirm / forms)
   ========================================================================== */
.scrim {
  position: fixed; inset: 0;
  background: rgba(18, 24, 38, .42);
  backdrop-filter: blur(1.5px);
  z-index: 50;
  display: flex;
}
.scrim.right { justify-content: flex-end; }
.scrim.center { justify-content: center; align-items: center; padding: 24px; }

.drawer {
  width: min(560px, 100%);
  height: 100%;
  background: var(--card);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slidein .16s ease-out;
}
@keyframes slidein { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.drawer-head .x {
  margin-left: auto;
  background: none; border: none; font-size: 22px; line-height: 1;
  color: var(--text-faint); cursor: pointer; padding: 0 4px;
}
.drawer-head .x:hover { color: var(--text); }
.drawer-title { font-size: 17px; font-weight: 700; margin: 0; }
.drawer-sub { color: var(--text-soft); font-size: 13px; margin: 3px 0 0; }
.drawer-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.drawer-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}

.modal {
  width: min(460px, 100%);
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 24px 24px 20px;
  animation: pop .14s ease-out;
}
.modal.wide { width: min(560px, 100%); }
@keyframes pop { from { transform: scale(.97); opacity: .5; } to { transform: none; opacity: 1; } }
.modal h3 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 0 0 16px; color: var(--text-soft); font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.confirm-summary {
  background: var(--neutral-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13.5px;
  margin: 4px 0 4px;
}
.confirm-summary b { color: var(--text); }

/* definition lists in detail panels */
.dl { display: grid; grid-template-columns: 132px 1fr; gap: 9px 14px; margin: 0 0 18px; font-size: 13.5px; }
.dl dt { color: var(--text-faint); font-weight: 600; }
.dl dd { margin: 0; word-break: break-word; }
.section-label {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-faint);
  margin: 22px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.desc-block {
  white-space: pre-wrap;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.55;
}
.shot { max-width: 100%; border: 1px solid var(--border); border-radius: 8px; display: block; }

/* mini user/history list */
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.mini-list li:last-child { border-bottom: none; }
.mini-list .grow { flex: 1; min-width: 0; }
.mini-list .nm { font-weight: 600; }
.mini-list .sub { color: var(--text-faint); font-size: 12px; }

/* timeline (status history) */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 20px; border-left: 2px solid var(--border); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 3px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
}
.timeline .tl-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.timeline .tl-time { color: var(--text-faint); font-size: 12px; }
.timeline .tl-note { color: var(--text-soft); font-size: 12.5px; margin-top: 3px; white-space: pre-wrap; }

/* expandable json in audit log */
.json-toggle {
  background: none; border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 2px 8px; font: inherit; font-size: 12px;
  cursor: pointer; color: var(--text-soft);
}
.json-toggle:hover { background: var(--neutral-soft); }
pre.json {
  margin: 8px 0 0; padding: 12px 14px;
  background: #1b1f27; color: #d6e0ef;
  border-radius: 8px; font-family: var(--mono); font-size: 12px;
  overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}

/* action group inside detail */
.action-group { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

/* ==========================================================================
   TOASTS
   ========================================================================== */
.toast-host {
  position: fixed; bottom: 22px; right: 22px; z-index: 100;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
}
.toast {
  min-width: 260px; max-width: 380px;
  background: #1b1f27; color: #fff;
  border-radius: 10px; padding: 12px 15px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  display: flex; gap: 10px; align-items: flex-start;
  animation: toastin .18s ease-out;
}
@keyframes toastin { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.ok { border-left: 4px solid #43c277; }
.toast.err { border-left: 4px solid #e36a6a; }
.toast .tx { flex: 1; }

/* spinner / loading */
.loading { padding: 40px; text-align: center; color: var(--text-faint); }
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2.5px solid var(--border-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* utility */
.row-gap { display: flex; gap: 10px; flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.right { text-align: right; }
.flex { display: flex; } .between { justify-content: space-between; } .center-y { align-items: center; }

@media (max-width: 640px) {
  .nav { display: none; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dt { margin-top: 8px; }
  .recovery-grid { grid-template-columns: 1fr; }
}
