/* =============================================================================
   MER Helper — app shell CSS
   Palette: racing red / black / white (§16). AA contrast throughout.
   ========================================================================== */

:root {
  --red: #E0231B;
  --red-hover: #C21E17;
  --red-dark: #8B1611;
  --black: #0B0B0B;
  --charcoal: #1B1B1D;
  --graphite: #2A2A2E;
  --steel: #3E3E44;
  --line: #4A4A50;
  --muted: #B8B8BC;
  --bone: #F5F3EF;
  --white: #FFFFFF;
  --focus: #7CC4FF;
  --success: #35B37E;
  --warn:    #E0A82E;
  --danger:  #E5484D;

  --radius: 6px;
  --radius-sm: 4px;
  --rail-w: 240px;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Menlo", "Consolas", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-family: var(--sans); font-size: 15px; line-height: 1.5; color: var(--bone); background: var(--black); }
body { min-height: 100vh; }

a { color: var(--bone); text-decoration: none; }
a:hover, a:focus-visible { color: var(--white); }

img, svg { max-width: 100%; display: block; }
code { font-family: var(--mono); font-size: 13px; background: var(--graphite); padding: 1px 6px; border-radius: 3px; }

/* -----------------------------------------------------------------------------
   Focus (§18 AA)
   -------------------------------------------------------------------------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.skip-link {
  position: absolute; left: -9999px; top: 8px;
  background: var(--white); color: var(--black); padding: 8px 12px; border-radius: var(--radius-sm);
  z-index: 100;
}
.skip-link:focus { left: 8px; }

/* -----------------------------------------------------------------------------
   Guest layout
   -------------------------------------------------------------------------- */
.guest-body {
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(224,35,27,0.10), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(224,35,27,0.06), transparent 45%),
    var(--black);
}
.guest-card {
  width: 100%; max-width: 420px;
  background: var(--charcoal); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.guest-title { margin: 6px 0 4px; font-size: 22px; }
.guest-sub { margin: 0 0 20px; color: var(--muted); }

/* -----------------------------------------------------------------------------
   App shell (§18)
   -------------------------------------------------------------------------- */
.app-shell { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 100vh; }
.rail {
  background: var(--charcoal); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px 0;
  position: sticky; top: 0; height: 100vh;
}
.rail-brand {
  padding: 4px 16px 16px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  background: var(--red); color: var(--white);
  font-weight: 700; padding: 4px 8px;
  border-radius: var(--radius-sm); letter-spacing: 0.5px; font-size: 13px;
}
.brand-name { font-weight: 600; font-size: 15px; }
.brand { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; }

.rail-list { list-style: none; margin: 12px 0 0; padding: 0; flex: 1; overflow-y: auto; }
.rail-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  color: var(--muted); border-left: 3px solid transparent; cursor: pointer;
  transition: background-color .08s, color .08s, border-color .08s;
}
.rail-item:hover { background: var(--graphite); color: var(--white); }
.rail-item.is-active { color: var(--white); background: var(--graphite); border-left-color: var(--red); }
.rail-item.is-disabled { color: var(--steel); cursor: not-allowed; }
.rail-item.is-disabled:hover { background: transparent; color: var(--steel); }
.rail-icon { font-size: 10px; width: 14px; text-align: center; opacity: .7; }
.rail-footer { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.rail-user { font-size: 13px; }
.rail-user-name { color: var(--white); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-user-role { color: var(--muted); font-size: 12px; }

.stage { display: flex; flex-direction: column; min-height: 100vh; background: var(--black); }
.subtabs {
  display: flex; gap: 4px; padding: 0 24px;
  border-bottom: 1px solid var(--line); background: var(--charcoal); overflow-x: auto;
}
.subtab {
  padding: 12px 14px; color: var(--muted);
  border-bottom: 2px solid transparent; font-size: 14px; white-space: nowrap;
}
.subtab:hover { color: var(--white); background: var(--graphite); }
.subtab.is-active { color: var(--white); border-bottom-color: var(--red); }
.subtab.is-disabled { color: var(--steel); cursor: not-allowed; }

.content { padding: 24px 28px; flex: 1; max-width: 1400px; width: 100%; }
.page-head { margin-bottom: 20px; }
.page-head h1 { margin: 0 0 4px; font-size: 22px; }
.muted { color: var(--muted); }

/* -----------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.row   { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.field label { display: block; font-size: 13px; margin-bottom: 6px; color: var(--bone); font-weight: 500; }
.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=tel], .field input[type=url], .field input[type=number],
.field input:not([type]), .field textarea, .field select {
  width: 100%; padding: 10px 12px;
  background: var(--graphite); color: var(--bone);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 15px;
  transition: border-color .08s, background-color .08s;
}
.field input:hover, .field textarea:hover, .field select:hover { border-color: var(--muted); }
.field input:focus-visible, .field textarea:focus-visible, .field select:focus-visible {
  border-color: var(--focus); background: var(--charcoal);
}
.field-error {
  margin: 6px 0 0; font-size: 13px; color: var(--danger);
  display: flex; gap: 6px; align-items: center;
}
.field-error::before {
  content: "!"; display: inline-flex; width: 16px; height: 16px;
  border-radius: 50%; background: var(--danger); color: var(--white);
  font-weight: 700; font-size: 11px;
  align-items: center; justify-content: center;
}
.field-help { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.check input { accent-color: var(--red); width: 16px; height: 16px; }

/* -----------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font: 500 14px var(--sans);
  cursor: pointer; min-height: 40px;
  transition: background-color .1s, border-color .1s, color .1s;
  text-decoration: none;
}
.btn-primary { background: var(--red); color: var(--white); }
.btn-primary:hover { background: var(--red-hover); color: var(--white); }
.btn-primary:disabled { background: var(--steel); cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--bone); border-color: var(--line); }
.btn-ghost:hover { background: var(--graphite); border-color: var(--muted); color: var(--white); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: rgba(229,72,77,0.10); color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; min-height: 32px; }

/* -----------------------------------------------------------------------------
   Notices
   -------------------------------------------------------------------------- */
.notice { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); margin-bottom: 16px; }
.notice-success { border-color: var(--success); background: rgba(53,179,126,0.10); }
.notice-warn    { border-color: var(--warn);    background: rgba(224,168,46,0.10); }
.notice-danger  { border-color: var(--danger);  background: rgba(229,72,77,0.10); }

/* -----------------------------------------------------------------------------
   Tiles
   -------------------------------------------------------------------------- */
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.tile {
  background: var(--charcoal); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
}
.tile h2 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); font-weight: 600; }
.tile-value { margin: 0; font-size: 20px; font-weight: 600; }

/* -----------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--charcoal); margin-top: 16px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table thead th {
  background: var(--graphite); color: var(--muted);
  font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.data-table td.cell-primary { font-weight: 600; color: var(--white); }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .row-actions, .data-table .row-actions-head { text-align: right; white-space: nowrap; }
.data-table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.data-table .row-actions form { display: inline; }
.data-table td.empty { text-align: center; color: var(--muted); padding: 32px; }

.toolbar { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.toolbar-spacer { flex: 1; }

/* -----------------------------------------------------------------------------
   Badges / pills / status
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--graphite); color: var(--bone); border: 1px solid var(--line);
}
.badge-success { color: var(--success); border-color: var(--success); background: rgba(53,179,126,0.10); }
.badge-warn    { color: var(--warn);    border-color: var(--warn);    background: rgba(224,168,46,0.10); }
.badge-danger  { color: var(--danger);  border-color: var(--danger);  background: rgba(229,72,77,0.10); }
.badge-muted   { color: var(--muted);   border-color: var(--line); }
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0;
}

/* -----------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card-narrow { max-width: 560px; }
.card {
  background: var(--charcoal); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
}
.card h2 { margin: 0 0 12px; font-size: 16px; }

/* -----------------------------------------------------------------------------
   TOTP enroll box
   -------------------------------------------------------------------------- */
.totp-box {
  display: flex; gap: 20px; align-items: center; padding: 16px;
  background: var(--white); color: var(--black); border-radius: var(--radius); margin: 16px 0;
}
.totp-secret code { font: 600 14px var(--mono); letter-spacing: 1px; display: block; margin-top: 6px; color: var(--black); background: transparent; padding: 0; }

/* -----------------------------------------------------------------------------
   DNS record blocks
   -------------------------------------------------------------------------- */
.dns-record {
  background: var(--graphite); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px;
  display: grid; grid-template-columns: 60px 1fr 100px; gap: 12px;
  align-items: start; font-size: 13px; margin-bottom: 8px;
}
.dns-record .dns-type { font-weight: 700; color: var(--white); }
.dns-record .dns-value { font-family: var(--mono); font-size: 12px; word-break: break-all; }
.dns-record .dns-status { text-align: right; }

/* -----------------------------------------------------------------------------
   Small screens
   -------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; overflow-x: auto; }
  .rail-list { display: flex; }
  .rail-footer { display: none; }
  .totp-box { flex-direction: column; }
  .data-table th, .data-table td { padding: 8px 10px; }
  .row-actions { flex-direction: column; }
}
