/**
 * Aegis Intel v15.4.3 — Final Premium UI Tightening Pass
 * Layer on premium-visual-v1542.css — visual polish only, no structure changes.
 */

/* ——— Tokens ——— */
:root {
  --premium-btn-height: 52px;
  --premium-nav-height: 52px;
  --guard-nav-clearance: calc(var(--premium-nav-height) + 12px + env(safe-area-inset-bottom, 0px));
  --guard-action-inset: calc(12px + env(safe-area-inset-bottom, 0px));
}

/* ——— 1. Background — unified light premium, no dark lower mismatch ——— */
html {
  background-color: var(--premium-ivory);
  background-image:
    radial-gradient(ellipse 100% 70% at 10% -5%, rgba(26, 122, 98, 0.08), transparent 42%),
    radial-gradient(ellipse 80% 50% at 90% 0%, rgba(13, 142, 168, 0.05), transparent 38%),
    linear-gradient(180deg, var(--premium-ivory) 0%, #f0ede6 55%, #ebe8e1 100%);
  min-height: 100%;
}

html::before {
  opacity: 0.22;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 20%, black 10%, transparent 78%);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

/* ——— 2. Header — compact light glass, readable version, polished More ——— */
.cmd-shell .topbar {
  padding: 5px 0 6px;
  margin-bottom: 2px;
}

.cmd-shell .topbar::before {
  background: rgba(248, 246, 242, 0.92);
  border-bottom: 1px solid rgba(221, 214, 203, 0.5);
  box-shadow: 0 1px 8px rgba(15, 23, 41, 0.04);
  backdrop-filter: blur(12px) saturate(1.05);
  -webkit-backdrop-filter: blur(12px) saturate(1.05);
}

.cmd-shell .brand small {
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
  opacity: 0.92;
}

.cmd-shell .brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  font-size: 0.72rem;
  box-shadow: 0 1px 4px rgba(26, 122, 98, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.cmd-shell .topbar .btn.ghost {
  min-height: 34px;
  padding: 5px 10px;
  font-size: 0.76rem;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.62);
  border-color: rgba(221, 214, 203, 0.55);
}

.cmd-shell .more-menu summary.btn.ghost {
  font-weight: 650;
  letter-spacing: -0.01em;
}

.cmd-shell .more-menu-body {
  border: 1px solid var(--premium-border);
  border-radius: 12px;
  background: var(--premium-glass-strong);
  box-shadow: var(--premium-shadow-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 4px;
  min-width: 148px;
}

.cmd-shell .more-menu-body .btn.ghost {
  width: 100%;
  justify-content: flex-start;
  border: 0;
  background: transparent;
  min-height: 36px;
  border-radius: 8px;
}

.cmd-shell .more-menu-body .btn.ghost:hover:not(:disabled) {
  background: rgba(26, 122, 98, 0.08);
}

/* Admin badge — only visible when body.admin-mode (JS sets hidden) */
body:not(.admin-mode) .cmd-shell .admin-mode-badge {
  display: none !important;
}

body.admin-mode .cmd-shell .admin-mode-badge {
  font-size: 0.58rem;
  padding: 2px 7px;
  margin-left: 6px;
  border-radius: 99px;
  flex-shrink: 0;
}

/* ——— 3. Mission card — compact, badges wrap, less height ——— */
.cmd-mission-card {
  padding: 13px 14px 11px;
  border-radius: 14px;
}

.cmd-mission-card h1 {
  font-size: 1.18rem;
  line-height: 1.16;
  margin-bottom: 4px;
}

.cmd-mission-body {
  font-size: 0.82rem;
  line-height: 1.42;
  margin-bottom: 2px;
}

.cmd-mission-disclaimer {
  margin-bottom: 8px;
  font-size: 0.66rem;
}

.cmd-status-row {
  gap: 4px;
  margin-bottom: 10px;
}

.cmd-status-row .pill {
  font-size: 0.6rem;
  padding: 3px 8px;
  white-space: normal;
  text-align: center;
  line-height: 1.25;
  max-width: 100%;
}

.cmd-shell .app-main {
  padding-bottom: var(--guard-nav-clearance);
}

.cmd-shell .cmd-action-row {
  scroll-margin-bottom: var(--guard-nav-clearance);
}

.cmd-shell .primary-action-row {
  padding-bottom: var(--guard-action-inset);
  scroll-margin-bottom: var(--guard-nav-clearance);
}

/* ——— 4. Home CTAs — ~52px buttons, safe padding above bottom nav ——— */

.cmd-action-row.dashboard-actions {
  margin-top: 4px;
  margin-bottom: 10px;
  gap: 8px;
}

.cmd-action-row .btn {
  min-height: var(--premium-btn-height);
  max-height: 64px;
  padding: 10px 12px;
  font-size: 0.83rem;
}

/* ——— 5. Stats — instrument-style, strong nums, small labels ——— */
.cmd-stat {
  padding: 8px 3px 7px;
  border-radius: 10px;
}

.cmd-stat::before {
  left: 10%;
  right: 10%;
  height: 2px;
  opacity: 0.65;
}

.cmd-stat b {
  font-size: 1.18rem;
  font-weight: 850;
  line-height: 1.05;
}

.cmd-stat span {
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-top: 1px;
  opacity: 0.88;
}

/* ——— 6. Bottom nav — compact, safe-area, refined active indicator ——— */
.cmd-shell .app-bottom-nav {
  min-height: var(--premium-nav-height);
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
  background: rgba(248, 246, 242, 0.96);
  box-shadow: 0 -4px 16px rgba(15, 23, 41, 0.04);
  grid-template-columns: repeat(4, 1fr) !important;
}

.cmd-shell .app-nav-admin {
  display: none !important;
}

.cmd-shell .app-nav-btn {
  min-height: 42px;
  padding: 3px 2px;
  border-radius: 10px;
}

.cmd-shell .app-nav-btn.is-active::after {
  width: 14px;
  height: 2px;
  bottom: 4px;
  box-shadow: 0 0 4px rgba(26, 122, 98, 0.28);
}

.cmd-shell .app-nav-label {
  font-size: 0.58rem;
  font-weight: 720;
}

.cmd-shell .app-nav-icon {
  font-size: 0.9rem;
}

/* ——— 7. Ticker drawer — safe padding, visible above browser chrome ——— */
.ticker-drawer-panel {
  border: 1px solid var(--premium-border);
  box-shadow: 0 -8px 32px rgba(15, 23, 41, 0.12);
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  max-height: min(calc(100dvh - env(safe-area-inset-top, 0px)), 900px);
}

@media (max-width: 767px) {
  .ticker-drawer {
    align-items: flex-end;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .ticker-drawer-panel {
    max-height: min(88vh, 720px);
    border-radius: 16px 16px 0 0;
  }
}

/* ——— 8. Dossier — border/shadow alignment ——— */
.aegis-dossier-panel {
  border-radius: 15px;
  box-shadow: 0 14px 44px rgba(15, 23, 41, 0.12), 0 0 0 1px rgba(255, 255, 255, 0.45) inset;
}

#aegis-dossier-root .aegis-dossier-section {
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* ——— Tablet / desktop refinements ——— */
@media (min-width: 768px) {
  .cmd-mission-card h1 {
    font-size: 1.32rem;
  }

  .cmd-mission-card {
    padding: 15px 18px 13px;
    border-radius: 16px;
  }

  .cmd-stat b {
    font-size: 1.24rem;
  }
}

@media (max-width: 389px) {
  .cmd-stat b {
    font-size: 1.05rem;
  }

  .cmd-action-row .btn {
    min-height: 48px;
    font-size: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cmd-shell .app-nav-btn.is-active::after {
    box-shadow: none;
  }
}
