/**
 * Aegis Intel v15.4.1 — Mobile Command Center UI
 * Replaces v15.4.0 award layer: unified surface, compact chrome, mobile-native feel.
 */

/* ——— Unified app shell ——— */
/* Semantic hidden must always win over component display rules */
.cmd-shell [hidden] {
  display: none !important;
}

.app-shell.cmd-shell {
  width: min(680px, 100%);
  padding: 8px 12px 0;
}

.cmd-shell .app-main {
  padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
}

/* ——— Compact header (same surface as page, not detached dark strip) ——— */
.cmd-shell .topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 6px 0 8px;
  margin-bottom: 4px;
  gap: 8px;
  flex-wrap: nowrap;
}

.cmd-shell .brand {
  flex-wrap: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}

.cmd-shell .brand > div {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd-shell .topbar .actions {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  width: auto;
  justify-content: flex-end;
}

.cmd-shell .topbar::before {
  background: rgba(243, 241, 236, 0.88);
  border-bottom: 1px solid var(--line-soft);
  box-shadow: none;
  inset: 0 -12px;
}

.cmd-shell .brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  font-size: 0.72rem;
  background: linear-gradient(145deg, var(--accent-soft), #fff);
  border-color: var(--line);
  color: var(--primary);
  box-shadow: none;
}

.cmd-shell .brand > div > span:first-child {
  color: var(--aegis-ink);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.cmd-shell .brand small {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 650;
  text-transform: none;
  letter-spacing: 0;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 480px) {
  .cmd-shell .beta-badge {
    display: none;
  }
}

.cmd-shell .header-trust {
  display: none;
}

.cmd-shell .beta-badge {
  font-size: 0.58rem;
  padding: 2px 6px;
  margin-left: 4px;
  vertical-align: middle;
}

.cmd-shell .admin-mode-badge {
  font-size: 0.62rem;
  padding: 3px 8px;
  margin-left: 0;
}

.cmd-shell .topbar .btn.ghost {
  background: var(--surface-soft);
  border-color: var(--line-soft);
  color: var(--text-secondary);
  min-height: 36px;
  padding: 6px 10px;
  font-size: 0.78rem;
}

.cmd-shell .topbar .actions {
  gap: 6px;
}

.cmd-shell .admin-toggle {
  display: none;
}

body.admin-mode .cmd-shell .admin-toggle {
  display: inline-flex;
}

/* ——— Home command center ——— */
.cmd-home {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cmd-mission-card {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 14px 14px 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 41, 0.03);
  backdrop-filter: blur(8px);
}

.cmd-mission-card h1 {
  margin: 0 0 6px;
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--aegis-ink);
}

.cmd-mission-body {
  margin: 0 0 4px;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.cmd-mission-disclaimer {
  margin: 0 0 10px;
  font-size: 0.68rem;
  color: var(--muted-2);
}

.cmd-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 12px;
}

.cmd-status-row .pill {
  font-size: 0.64rem;
  padding: 3px 8px;
  border-radius: 99px;
}

.cmd-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.cmd-action-row .btn {
  min-height: 44px;
  padding: 10px 12px;
  font-size: 0.84rem;
  border-radius: 11px;
}

.cmd-action-row .btn.primary {
  background: linear-gradient(180deg, #1f8f72, var(--primary));
  box-shadow: 0 2px 6px rgba(26, 122, 98, 0.2);
}

.cmd-stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.cmd-stat {
  text-align: center;
  padding: 7px 4px;
  background: var(--surface-soft);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

.cmd-stat b {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--aegis-ink);
  line-height: 1.1;
}

.cmd-stat span {
  display: block;
  font-size: 0.58rem;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.cmd-next-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cmd-next-card {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 41, 0.03);
}

.cmd-next-card h3 {
  margin: 0 0 4px;
  font-size: 0.92rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.cmd-next-card .eyebrow {
  font-size: 0.62rem;
  margin-bottom: 2px;
}

.cmd-next-card .cmd-next-copy {
  margin: 0 0 10px;
  font-size: 0.8rem;
  line-height: 1.4;
}

.cmd-next-card .btn {
  min-height: 40px;
  font-size: 0.8rem;
  border-radius: 10px;
}

.cmd-onboarding-card {
  border-left: 3px solid var(--accent);
}

/* Hide legacy hero blocks when cmd-home is active */
.cmd-home .hero-dashboard,
.cmd-home .primary-action-row {
  display: none !important;
}

/* ——— View intros: lighter ——— */
.cmd-shell .view-intro {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: none;
}

.cmd-shell .view-intro h2 {
  font-size: 1.05rem;
  margin: 2px 0 4px;
}

.cmd-shell .view-intro .eyebrow {
  font-size: 0.62rem;
}

/* ——— Unified cards ——— */
.cmd-shell .panel,
.cmd-shell .card,
.cmd-shell .hero-card {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 41, 0.03);
}

.cmd-shell .card.compact-card {
  padding: 12px;
  border-radius: 12px;
}

.cmd-shell .card.compact-card::before {
  width: 3px;
}

.cmd-shell .compact-top .ticker {
  font-size: 1.2rem;
}

.cmd-shell .card-actions.compact-card-actions .btn {
  min-height: 40px;
  font-size: 0.8rem;
  border-radius: 10px;
}

.cmd-shell .card-expand-bundle {
  margin-top: 8px;
}

.cmd-shell .card-expand-summary {
  font-size: 0.72rem;
  padding: 6px 0;
}

/* ——— Compact bottom nav ——— */
.cmd-shell .app-bottom-nav {
  grid-template-columns: repeat(4, 1fr) !important;
  max-width: min(680px, 100%);
  margin: 0 auto;
  left: 0;
  right: 0;
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
  background: rgba(243, 241, 236, 0.94);
  border-top: 1px solid var(--line-soft);
  box-shadow: 0 -4px 16px rgba(15, 23, 41, 0.04);
  backdrop-filter: blur(12px);
  min-height: 56px;
}

.cmd-shell .app-nav-btn {
  min-height: 44px;
  padding: 4px 2px;
  border-radius: 10px;
  gap: 2px;
}

.cmd-shell .app-nav-btn.is-active {
  background: rgba(26, 122, 98, 0.1);
  color: var(--primary);
}

.cmd-shell .app-nav-btn.is-active::after {
  display: none;
}

.cmd-shell .app-nav-icon {
  font-size: 0.95rem;
}

.cmd-shell .app-nav-label {
  font-size: 0.62rem;
  font-weight: 700;
}

.cmd-shell .app-nav-admin {
  display: none !important;
}

/* ——— Buttons global in cmd shell ——— */
.cmd-shell .btn {
  border-radius: 10px;
  min-height: var(--tap-min);
}

.cmd-shell .primary-action-row {
  margin: 8px 0 12px;
  padding-bottom: 0;
}

.cmd-shell .primary-action-row .btn {
  min-height: 44px;
  flex: 1 1 calc(50% - 4px);
}

/* ——— Alerts feed ——— */
.cmd-shell .brief-flat-panel,
.cmd-shell .review-queue-panel,
.cmd-shell .alert-log .event-log-item {
  border-radius: 12px;
}

.cmd-shell .brief-headline {
  font-size: 0.9rem;
  line-height: 1.4;
}

/* ——— Settings ——— */
.cmd-shell .settings-view-block {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.cmd-shell .settings-about-card {
  background: var(--surface-soft);
}

/* ——— Dossier overlay ——— */
.dossier-overlay .dossier-header {
  padding-top: max(10px, env(safe-area-inset-top, 0px));
}

/* ——— Build mismatch banner ——— */
.cmd-shell .build-mismatch-banner {
  margin: 0 0 8px;
  border-radius: 10px;
  padding: 10px 12px;
}

/* ——— Reduced motion ——— */
@media (prefers-reduced-motion: reduce) {
  .cmd-shell .btn,
  .cmd-shell .card.compact-card,
  .cmd-shell .app-nav-btn {
    transition: none;
  }
}

/* ——— Tablet / desktop ——— */
@media (min-width: 768px) {
  .app-shell.cmd-shell {
    padding: 12px 16px 0;
  }

  .cmd-mission-card h1 {
    font-size: 1.35rem;
  }
}

@media (max-width: 389px) {
  .cmd-stat-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .cmd-action-row {
    grid-template-columns: 1fr;
  }
}
