/* Cecil Layout */

/* ─── Root app container ─── */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: 1fr var(--statusbar-height);
  grid-template-areas:
    "sidebar main"
    "sidebar statusbar";
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ─── Sidebar ─── */
.sidebar {
  grid-area: sidebar;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--bg-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--transition-base);
}

/* Sidebar header / logo */
.sidebar-header {
  padding: var(--space-5) var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--bg-border);
}

.sidebar-logo {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.logo-wordmark {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--text-primary);
  background: linear-gradient(135deg, #e2ecf8 0%, #7ab3f0 60%, #3b82f6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: block;
}

.logo-backronym {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
  line-height: 1.5;
  display: block;
}

/* Nav list */
.nav-list {
  flex: 1;
  padding: var(--space-3) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition:
    color var(--transition-fast),
    background-color var(--transition-fast);
  position: relative;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text-primary);
  background-color: var(--bg-elevated);
}

.nav-link.active {
  color: var(--text-primary);
  background-color: var(--bg-elevated);
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-link.active .nav-icon {
  opacity: 1;
}

.nav-label {
  transition: opacity var(--transition-base);
}

/* Sidebar footer */
.sidebar-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--bg-border);
}

.sidebar-version {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ─── Main content ─── */
.main-content {
  grid-area: main;
  margin-left: var(--sidebar-width);
  margin-bottom: var(--statusbar-height);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--statusbar-height));
  overflow-x: hidden;
}

/* ─── Header ─── */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--bg-border);
  padding: 0 var(--space-6);
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  backdrop-filter: blur(12px);
  background: rgba(15, 21, 32, 0.9);
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.header-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.header-monitors {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ─── Time range selector ─── */
.time-range-selector {
  display: flex;
  gap: 2px;
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: 2px;
  flex-shrink: 0;
}

.time-pill {
  padding: 4px 10px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 150ms, background 150ms;
  white-space: nowrap;
  line-height: 1.4;
}

.time-pill:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.time-pill.active {
  color: var(--text-primary);
  background: var(--accent);
}

/* Smooth opacity transition when views dim during a time-range re-fetch */
.kpi-grid,
.threat-feed,
#watchlist-table-container,
#timeline-container,
.siem-list {
  transition: opacity 200ms ease;
}

/* ─── View mount ─── */
.view-mount {
  flex: 1;
  padding: var(--space-6);
  overflow-y: auto;
}

/* ─── Status bar ─── */
.status-bar {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--statusbar-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--bg-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-6);
  z-index: 50;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.status-bar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex: 1;
}

.status-bar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.status-bar-clock {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

/* ─── Cards ─── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-lg);
  transition:
    border-color var(--transition-base),
    box-shadow var(--transition-base);
}

.card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow-accent);
}

.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--bg-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.card-body {
  padding: var(--space-5);
}

/* ─── KPI Grid ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

/* KPI Card */
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
  transition:
    border-color var(--transition-base),
    box-shadow var(--transition-base),
    transform var(--transition-base);
  cursor: default;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--kpi-color, var(--accent));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kpi-card:hover {
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transform: translateY(-1px);
}

.kpi-card--clickable:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 24px rgba(59, 130, 246, 0.15);
}

.kpi-card--clickable:active {
  transform: translateY(0);
  transition-duration: 50ms;
}

.kpi-card--clickable .kpi-label::after {
  content: ' →';
  opacity: 0;
  transition: opacity 150ms;
}

.kpi-card--clickable:hover .kpi-label::after {
  opacity: 0.5;
}

.kpi-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.kpi-value {
  font-size: var(--text-3xl);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--kpi-color, var(--text-primary));
  line-height: 1;
  margin-bottom: var(--space-2);
}

.kpi-trend {
  font-size: var(--text-xs);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.kpi-trend-up { color: var(--sev-critical); }
.kpi-trend-down { color: var(--status-resolved); }
.kpi-trend-neutral { color: var(--text-muted); }

/* ─── Threat filter bar ─── */
.threat-filter-bar {
  display: flex;
  gap: 2px;
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: 2px;
}

.threat-filter-pill {
  padding: 3px 10px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 150ms, background 150ms;
  white-space: nowrap;
}

.threat-filter-pill:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.threat-filter-pill.active {
  color: var(--text-primary);
  background: var(--accent);
}

/* ─── Threat feed ─── */
.threat-feed {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.threat-feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.threat-feed-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.threat-row {
  display: grid;
  grid-template-columns: 80px 1fr auto auto auto 80px;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast);
  position: relative;
}

.threat-row:hover {
  background: var(--bg-elevated);
  border-color: rgba(59, 130, 246, 0.25);
}

.threat-row.expanded {
  border-color: rgba(59, 130, 246, 0.4);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: var(--bg-elevated);
}

.threat-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.threat-actor {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.threat-source-icon {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.threat-source-cloudflare {
  background: rgba(244, 129, 32, 0.15);
  color: var(--source-cloudflare);
}

.threat-source-wiz {
  background: rgba(155, 93, 229, 0.15);
  color: var(--source-wiz);
}

.threat-source-siem {
  background: rgba(59, 130, 246, 0.15);
  color: var(--source-siem);
}

/* Threat detail panel */
.threat-detail {
  background: var(--bg-elevated);
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: var(--space-5);
  overflow: hidden;
}

.threat-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.threat-detail-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.threat-detail-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.threat-detail-value {
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.threat-raw-data {
  background: var(--bg-base);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
}

/* ─── Watchlist table ─── */
.watchlist-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 2px;
}

.watchlist-table thead th {
  padding: var(--space-2) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.watchlist-table thead th:hover {
  color: var(--text-secondary);
}

.watchlist-table thead th.sort-asc::after { content: ' ↑'; color: var(--accent); }
.watchlist-table thead th.sort-desc::after { content: ' ↓'; color: var(--accent); }

.watchlist-table tbody tr {
  background: var(--bg-surface);
  transition: background-color var(--transition-fast);
}

.watchlist-table tbody tr:hover {
  background: var(--bg-elevated);
}

.watchlist-table tbody tr.row-blocked {
  background: rgba(255, 59, 59, 0.04);
  border-left: 2px solid var(--sev-critical);
}

.watchlist-table tbody tr.row-blocked:hover {
  background: rgba(255, 59, 59, 0.08);
}

.watchlist-table tbody tr.row-watching {
  background: rgba(255, 214, 0, 0.03);
}

.watchlist-table tbody td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-primary);
  border-top: 1px solid var(--bg-border);
  border-bottom: 1px solid var(--bg-border);
}

.watchlist-table tbody td:first-child {
  border-left: 1px solid var(--bg-border);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.watchlist-table tbody td:last-child {
  border-right: 1px solid var(--bg-border);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* ─── Timeline ─── */
.timeline-day-group {
  margin-bottom: var(--space-6);
}

.timeline-day-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.timeline-day-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  white-space: nowrap;
}

.timeline-day-line {
  flex: 1;
  height: 1px;
  background: var(--bg-border);
}

.timeline-feed {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}

.timeline-feed::before {
  content: '';
  position: absolute;
  left: 19px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--bg-border);
}

.timeline-item {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast);
  position: relative;
  z-index: 1;
}

.timeline-item:hover {
  background: var(--bg-elevated);
}

.timeline-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--bg-base);
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
  z-index: 2;
}

.timeline-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.timeline-item-main {
  flex: 1;
  min-width: 0;
}

.timeline-item-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 2px;
  flex-wrap: wrap;
}

.timeline-item-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.timeline-item-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── No-action items (dimmed, dashed timeline) ─── */
.timeline-item--no-action {
  opacity: 0.55;
}

.timeline-item--no-action .timeline-dot {
  border: 1.5px dashed var(--text-muted);
  background: transparent !important;
}

.timeline-item--no-action:hover {
  opacity: 0.85;
}

/* ─── Timeline filter toggle ─── */
.timeline-filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
}

.filter-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  user-select: none;
}

.filter-toggle input[type="checkbox"] {
  appearance: none;
  width: 32px;
  height: 18px;
  background: var(--bg-border);
  border-radius: 9px;
  position: relative;
  cursor: pointer;
  transition: background var(--transition-base);
}

.filter-toggle input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition-base);
}

.filter-toggle input[type="checkbox"]:checked {
  background: var(--accent);
}

.filter-toggle input[type="checkbox"]:checked::after {
  left: 16px;
  background: var(--text-primary);
}

.filter-count {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ─── SIEM ─── */
.siem-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.siem-row {
  display: grid;
  grid-template-columns: 80px 1fr auto auto 80px;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast);
}

.siem-row:hover {
  background: var(--bg-elevated);
  border-color: rgba(59, 130, 246, 0.25);
}

.siem-query {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Monitor pill ─── */
.monitor-pill {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
}

.monitor-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.monitor-dot.healthy {
  background: var(--monitor-healthy);
}

.monitor-dot.stale {
  background: var(--monitor-stale);
}

.monitor-dot.error {
  background: var(--monitor-error);
}

.monitor-name {
  font-weight: 600;
  color: var(--text-primary);
}

.monitor-freq {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0.7;
}

.monitor-last-run {
  color: var(--text-muted);
}

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-critical {
  background: var(--sev-critical-bg);
  color: var(--sev-critical);
  border: 1px solid var(--sev-critical-border);
}

.badge-high {
  background: var(--sev-high-bg);
  color: var(--sev-high);
  border: 1px solid var(--sev-high-border);
}

.badge-medium {
  background: var(--sev-medium-bg);
  color: var(--sev-medium);
  border: 1px solid var(--sev-medium-border);
}

.badge-low {
  background: var(--sev-low-bg);
  color: var(--sev-low);
  border: 1px solid var(--sev-low-border);
}

.badge-info {
  background: var(--sev-info-bg);
  color: var(--sev-info);
  border: 1px solid var(--sev-info-border);
}

.badge-open {
  background: var(--sev-high-bg);
  color: var(--sev-high);
  border: 1px solid var(--sev-high-border);
}

.badge-investigating {
  background: var(--status-investigating-bg);
  color: var(--status-investigating);
  border: 1px solid rgba(185, 127, 255, 0.3);
}

.badge-resolved {
  background: var(--status-resolved-bg);
  color: var(--status-resolved);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-blocked {
  background: var(--status-blocked-bg);
  color: var(--status-blocked);
  border: 1px solid var(--sev-critical-border);
}

.badge-watching {
  background: var(--status-watching-bg);
  color: var(--status-watching);
  border: 1px solid var(--sev-medium-border);
}

.badge-actor {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--bg-border);
  font-family: var(--font-mono);
  font-size: 10px;
}

.badge-action {
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

/* ─── Section headers ─── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.section-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-primary);
}

.section-count {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding: 2px 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  border: 1px solid var(--bg-border);
}

/* ─── Page header ─── */
.page-header {
  margin-bottom: var(--space-6);
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ─── Sidebar collapsed state (JS-toggled) ─── */
.sidebar.collapsed .logo-backronym,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-version {
  opacity: 0;
  pointer-events: none;
  width: 0;
  overflow: hidden;
}

.sidebar.collapsed .nav-link {
  justify-content: center;
}

.sidebar.collapsed .sidebar-header {
  text-align: center;
  padding-left: var(--space-2);
  padding-right: var(--space-2);
}

.sidebar.collapsed .logo-wordmark {
  font-size: 12px;
  letter-spacing: 0.1em;
}

/* ─── Bottom tab bar (mobile only — hidden by default) ─── */
.bottom-tab-bar {
  display: none;
}

/* ─── Watchlist mobile cards (hidden by default, shown on mobile) ─── */
.watchlist-cards {
  display: none;
}

/* ─── Responsive ─── */
@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .threat-row {
    grid-template-columns: 70px 1fr auto auto 70px;
  }
}

@media (max-width: 900px) {
  :root {
    --sidebar-width: var(--sidebar-width-collapsed);
  }

  .logo-backronym,
  .nav-label,
  .sidebar-version {
    display: none;
  }

  .logo-wordmark {
    font-size: 14px;
    letter-spacing: 0.12em;
  }

  .sidebar-header {
    padding: var(--space-4) var(--space-2);
    text-align: center;
  }

  .nav-link {
    justify-content: center;
    padding: var(--space-3);
  }

  .nav-icon {
    width: auto;
    font-size: 18px;
  }

  .threat-row {
    grid-template-columns: 60px 1fr auto 60px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .time-range-selector {
    gap: 1px;
  }
  .time-pill {
    padding: 3px 7px;
    font-size: 10px;
  }
}

/* ─── Tablet / mobile breakpoint ─── */
@media (max-width: 768px) {
  /* Hide desktop sidebar and status bar */
  .sidebar {
    display: none;
  }

  .status-bar {
    display: none;
  }

  /* Remove sidebar margin — full width layout */
  .main-content {
    margin-left: 0;
    margin-bottom: 56px; /* height of bottom tab bar */
    min-height: calc(100vh - 56px);
  }

  /* App grid: single column, main + tab bar row */
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    grid-template-areas: "main";
  }

  /* Bottom tab bar */
  .bottom-tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-surface);
    border-top: 1px solid var(--bg-border);
    z-index: 100;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
    /* Lift above any content */
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4);
  }

  .tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 16px;
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: color var(--transition-fast), background-color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .tab-item:hover {
    color: var(--text-secondary);
    background-color: var(--bg-elevated);
  }

  .tab-item.active {
    color: var(--accent);
  }

  .tab-icon {
    font-size: 20px;
    line-height: 1;
  }

  .tab-label {
    line-height: 1;
    letter-spacing: 0.04em;
  }

  /* View mount: pad bottom so content isn't under tab bar */
  .view-mount {
    padding: var(--space-4);
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  /* Header: stack vertically on mobile */
  .header {
    flex-wrap: wrap;
    height: auto;
    padding: var(--space-3) var(--space-4);
    gap: var(--space-2);
  }

  .header-left {
    flex: 1 1 auto;
  }

  .header-title {
    font-size: var(--text-base);
  }

  .header-subtitle {
    font-size: 10px;
  }

  /* Monitor pills: hide on mobile (status bar is also hidden) */
  .header-monitors {
    display: none;
  }

  /* Time range selector: horizontal scroll strip */
  .time-range-selector {
    order: 3;
    flex: 0 0 100%;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-radius: var(--radius-md);
    gap: 1px;
  }

  .time-range-selector::-webkit-scrollbar {
    display: none;
  }

  .time-pill {
    padding: 4px 10px;
    font-size: 11px;
    flex-shrink: 0;
  }

  /* KPI grid: 2x2 on mobile */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-4);
  }

  .kpi-value {
    font-size: var(--text-2xl);
  }

  .kpi-card {
    padding: var(--space-4);
  }

  /* Threat feed: full width cards */
  .threat-row {
    grid-template-columns: 28px 1fr auto;
    gap: var(--space-2);
    padding: var(--space-3);
  }

  /* Hide actor and time columns on small screens — keep icon, title, badge */
  .threat-row .threat-actor,
  .threat-row .threat-item-time {
    display: none;
  }

  .threat-detail-grid {
    grid-template-columns: 1fr;
  }

  /* SIEM rows: simplify columns */
  .siem-row {
    grid-template-columns: 1fr auto;
    gap: var(--space-2);
    padding: var(--space-3);
  }

  .siem-query {
    display: none;
  }

  /* Watchlist: hide table, show cards */
  .watchlist-table {
    display: none;
  }

  .watchlist-cards {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
  }

  .watchlist-card {
    background: var(--bg-surface);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    transition: border-color var(--transition-fast);
  }

  .watchlist-card.card-blocked {
    border-left: 3px solid var(--sev-critical);
    background: rgba(255, 59, 59, 0.04);
  }

  .watchlist-card.card-watching {
    border-left: 3px solid var(--sev-medium);
  }

  .watchlist-card:hover {
    border-color: rgba(59, 130, 246, 0.35);
  }

  .watchlist-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
    gap: var(--space-2);
  }

  .watchlist-card-ip {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
  }

  .watchlist-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px var(--space-3);
  }

  .watchlist-card-field {
    display: flex;
    flex-direction: column;
    gap: 1px;
  }

  .watchlist-card-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
  }

  .watchlist-card-value {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .watchlist-card-value.font-mono {
    font-family: var(--font-mono);
  }

  /* Timeline: tighter spacing */
  .timeline-item {
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3) var(--space-2) var(--space-2);
  }

  .timeline-item-content {
    flex-direction: column;
    gap: var(--space-1);
  }

  .timeline-item-time {
    font-size: 10px;
  }

  /* Page headers: reduce on mobile */
  .page-header {
    margin-bottom: var(--space-4);
  }

  .page-title {
    font-size: var(--text-xl);
  }
}

/* ─── Phone breakpoint ─── */
@media (max-width: 480px) {
  .view-mount {
    padding: var(--space-3);
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .header {
    padding: var(--space-2) var(--space-3);
  }

  .kpi-grid {
    gap: var(--space-2);
  }

  .kpi-card {
    padding: var(--space-3);
  }

  .kpi-value {
    font-size: var(--text-xl);
  }

  .kpi-label {
    font-size: 9px;
  }

  .threat-row {
    padding: var(--space-2) var(--space-3);
  }

  .tab-item {
    padding: 6px 10px;
  }

  .page-title {
    font-size: var(--text-lg);
  }
}
