
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 16px 20px;
  gap: 12px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-circle {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #ffffff, #22c55e, #111827);
  box-shadow: 0 0 28px rgba(34, 197, 94, 0.6);
}

h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0.03em;
}

.header-subline {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.9);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.header-badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.9);
}

/* =====================================================
   HEADER PILLS (Download + Help)
   ===================================================== */

.header-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  padding: 4px 10px;
  border-radius: 999px;

  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;

  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-muted);

  text-decoration: none;
  cursor: pointer;
}

.header-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.header-pill-secondary {
  background: rgba(15, 23, 42, 0.9);
}

.pill-icon {
  font-size: 0.85rem;
  line-height: 1;
}


.main-layout {
  flex: 1;
  min-height: 0;
  display: flex;

  /* ✅ fill the window by default */
  width: 100%;
  max-width: 100%;

  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-alt);

  /* allow scroll only when needed */
  overflow-x: auto;
  overflow-y: hidden;
}

.pane {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;

  /* vertical scrolling ONLY */
  overflow-y: auto;

  /* panes must CLIP horizontally */
  overflow-x: hidden;

  min-width: 0;
}

/* Allow wide data sections to scroll without squashing */
.pane table,
.pane .details-grid,
.pane .chart-container {
  min-width: max-content;
}

.pane-left table {
  width: max-content;
  border-collapse: collapse;
}

.pane-left th,
.pane-left td {
  white-space: nowrap;
}


/* LEFT PANE */
.pane-left {
  flex: 0 0 auto;
  width: 420px;
  min-width: 320px;

  position: relative;

  /* ❌ remove vertical scroll responsibility */
  overflow: hidden;
}


@media (min-width: 1024px) {
  .pane-left {
    width: 50%;
  }
}

/* RIGHT PANE */
.pane-right {
  flex: 1 1 auto;     /* Allow shrink on desktop */
  min-width: 520px;

  display: flex;
  flex-direction: column;
  height: 100%;

  overflow: hidden;   /* wrapper will scroll */
}

.pane-divider {
  width: 8px;
  cursor: col-resize;
  position: relative;
  flex: 0 0 auto;

  background: rgba(255,255,255,0.08);
}

body.theme-light .pane-divider {
  background: rgba(15, 23, 42, 0.18);
}

/* Visual grip */
.pane-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 36px;
  border-radius: 2px;
  transform: translate(-50%, -50%);
  background: rgba(255,255,255,0.45);
}

body.theme-light .pane-divider::after {
  background: rgba(15, 23, 42, 0.45);
}

body.theme-light .header-pill {
  background: #ffffff;
  color: #111827;
  border: 1px solid var(--border-subtle);
}

body.theme-light .header-pill:hover {
  background: #f1f5f9;
  color: var(--accent);
}

/* Touch-friendly */
@media (pointer: coarse) {
  .pane-divider {
    width: 12px;
  }
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pane-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}

.pane-meta .pill {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
}

.search-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(8, 47, 73, 0.9));
  border-radius: 16px;
  padding: 10px 14px;
  border: 1px solid rgba(51, 65, 85, 0.8);
  box-shadow: var(--shadow-soft);
}

.search-input-group {
  flex: 1 1 180px;
  display: flex;
  gap: 6px;
  align-items: center;
}

/* =====================================================
   SEVERITY SORT BUTTON — SMALL PILL
   ===================================================== */

.severity-sort {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.9);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-main);

  font-weight: 700;
  font-size: 0.75rem;
  line-height: 1;

  padding: 6px 12px;
  border-radius: 999px;

  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  transition: background 0.15s ease, border-color 0.15s ease;
}

.severity-sort:hover {
  border-color: var(--accent);
}

.severity-sort.active {
  background: rgba(239, 68, 68, 0.18);
  border-color: var(--danger);
}

/* Light mode tuning */
body.theme-light .severity-sort {
  background: #ffffff;
  color: #111827;
  border: 1px solid var(--border-subtle);
}

body.theme-light .severity-sort:hover {
  background: #f1f5f9;
}

.search-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.search-input {
  flex: 1;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid #444;
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-main);
}

.search-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.btn {
  border-radius: 999px;
  padding: 6px 10px;
  border: 1px solid rgba(148, 163, 184, 0.9);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-main);
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-icon {
  width: 30px;
  height: 30px;
  justify-content: center;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #22c55e);
  color: #f9fafb;
}

.btn-ghost {
  background: transparent;
}

.btn-small {
  padding: 4px 8px;
  font-size: 0.75rem;
}

@media (max-width: 900px) {
  .main-layout {
    flex-direction: column;
  }
  .pane-left {
    max-width: none;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }
  .pane-divider {
    height: 6px;
    width: 100%;
    cursor: row-resize;
  }
}

/* ------------------------------------------
   FLEX / RESIZE / PANEL BEHAVIOR
------------------------------------------- */

.app-shell {
    display: flex;
    height: calc(100vh - 60px);
}

/* Left column (cards) */
/* Card container must allow multiple grid columns */
.card-column {
    width: auto !important;
    min-width: 320px;
    max-width: none;
    overflow-y: auto;
    padding-right: 8px;
    display: block; /* ensure not flex */
}


/* Smooth transitions */
.details-panel.open {
    animation: slideIn 0.25s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(15px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Ensure the details wrapper stretches fully */
.details-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* CRITICAL fix */
}

/* Ensure the scrollable bubble can expand properly */
.details-bubble {
    flex: 1;
    min-height: 0; /* CRITICAL fix */
}

/* Allow status cell to expand for explanations */
.details-grid-top > div {
    overflow: visible;
}
.status-explanation {
    margin-top: 6px;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text-muted);
}

/* ------------------------------------------------
   TOP BAR ACTION ICONS
------------------------------------------------ */
.topbar-action,
.topbar-action svg {
    font-size: 1.15rem;
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

body.theme-light .topbar-action,
body.theme-light .topbar-action svg {
    color: #111827;
}

body.theme-light .topbar-action:hover {
    color: var(--accent);
}

/* =====================================================
   iPAD SAFE HORIZONTAL SCROLL WRAPPER
   ===================================================== */
.pane-scroll-x {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

/* Vertical scroll container for list view */
.pane-scroll-y {
  flex: 1;
  min-height: 0;

  overflow-y: auto;
  overflow-x: hidden;
}

/* =====================================================
   SCROLL SPACER — ensures last column is reachable
   ===================================================== */

.pane-scroll-x::after {
  content: "";
  display: inline-block;
  width: 24px;      /* scroll buffer, not visible space */
  height: 1px;
}


@media (pointer: coarse) {
  .pane-scroll-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (pointer: coarse) {
  .pane-right {
    flex: 1 0 auto;   /* keep original iPad behaviour */
    min-width: 100%;
  }
}

/* ============================================================
   HEADER ACTION ICONS — CLARITY
   ============================================================ */
.app-header svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.5;
}
/* ============================================================
   HEADER ACTION ICONS — LIGHT MODE
   ============================================================ */
body.theme-light .header-right svg {
  color: var(--text-main);
  stroke: var(--text-main);
}

body.theme-light .header-right button:hover svg {
  color: var(--accent);
}

/* ============================================================
   HEADER STATUS PILL — LIGHT MODE
   ============================================================ */
body.theme-light .header-badge {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

body.theme-light .header-badge-dot {
  box-shadow: none;
}

.btn-icon {
  font-size: 16px;
  line-height: 1;
}

body.theme-light .btn-icon {
  color: var(--icon-color);
}

/* ============================================================
   HEADER ICONS — FORCE LIGHT MODE CONTRAST
   ============================================================ */
body.theme-light .app-header svg {
  color: var(--text-main);
}

body.theme-light .app-header svg path,
body.theme-light .app-header svg circle,
body.theme-light .app-header svg line {
  fill: currentColor;
  stroke: currentColor;
}
body.theme-light .app-header button:hover svg {
  color: var(--accent);
}
body.theme-light .app-header svg path {
  fill: currentColor !important;
  stroke: currentColor !important;
}
/* ============================================================
   HEADER ICON BUTTONS — LIGHT MODE CONTRAST
   ============================================================ */
body.theme-light .app-header button {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: #111827;
}

body.theme-light .app-header button:hover {
  background: #f1f5f9;
}

body.theme-light .app-header button {
  font-weight: 600;
}
/* ============================================================
   HELP BUTTON ( ? )
   ============================================================ */
.help-btn {
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  text-decoration: none;
  color: var(--text-muted);
}

.help-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
/* ============================================================
   HELP BUTTON — LIGHT MODE CONTRAST FIX
   ============================================================ */
body.theme-light .app-header .help-btn {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: #111827;
}

body.theme-light .app-header .help-btn:hover {
  background: #f1f5f9;
  color: var(--accent);
}
/* =========================================================
   Reports bubble (Search bar) — ensure visible + above header
   ========================================================= */

#reportsBubble {
  z-index: 9999;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
}

/* Dark mode */
body.theme-dark #reportsBubble {
  background: rgba(17, 24, 39, 0.98);         /* deep slate */
  border: 1px solid rgba(255,255,255,0.12);
  color: #e5e7eb;
}

/* Light mode */
body.theme-light #reportsBubble {
  background: rgba(255, 255, 255, 0.98);      /* near-white */
  border: 1px solid rgba(0,0,0,0.12);
  color: #111827;
}
/* =====================================================
   LIST VIEW STICKY COLUMN HEADER
   ===================================================== */

.list-header {
  position: sticky;
  top: 22px; /* height of the "Systems" pane header */

  z-index: 30;
  background: var(--bg-alt);
}

/* --------------------------------------------------
   Centered Header Logo Overlay (SAFE)
-------------------------------------------------- */
.app-header {
    position: relative;
}

.header-logo-overlay {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.header-logo-overlay img {
    height: 46px;
    width: auto;
}