/* Apple macOS 27 UI Kit / Liquid Glass Bright Theme (SF Pro, System Colors, Translucent Glass) */
:root {
  color-scheme: light;
  --window: #f5f5f7;
  --surface-0: #f5f5f7;
  --surface-1: #ffffff;
  --surface-2: #f4f5f7;
  --hover: rgba(0, 0, 0, 0.045);
  --border: rgba(0, 0, 0, 0.09);
  --grid: rgba(0, 0, 0, 0.065);
  --text-primary: rgba(0, 0, 0, 0.88);
  --text-secondary: rgba(0, 0, 0, 0.56);
  --text-muted: rgba(0, 0, 0, 0.38);

  --accent: #007aff;
  --pos: #007aff;
  --neg: #ff3b30;
  --neg-text: #d70015;
  --pos-tint: rgba(0, 122, 255, 0.12);
  --neg-tint: rgba(255, 59, 48, 0.12);
  --warn-tint: rgba(255, 149, 0, 0.14);
  --good-tint: rgba(40, 205, 65, 0.14);

  --critical: #ff3b30;
  --warning: #ff9500;
  --warning-text: #b25000;
  --good: #28cd41;
  --good-text: #147d28;

  --glass: rgba(255, 255, 255, 0.68);
  --glass-edge: rgba(255, 255, 255, 0.82);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.05);
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  --bg-image: radial-gradient(1200px 600px at 85% -10%, rgba(0, 122, 255, 0.06), transparent 60%),
              radial-gradient(900px 500px at -10% 110%, rgba(48, 176, 199, 0.05), transparent 60%);
  --card-bg: #ffffff;
  --th-bg: #ffffff;
  --nav-on: rgba(0, 122, 255, 0.11);
  --seg-bg: rgba(118, 118, 128, 0.12);
  --seg-on: #ffffff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  margin: 0;
}

body {
  background: var(--window);
  color: var(--text-primary);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.003em;
  background-image: var(--bg-image);
  background-attachment: fixed;
}

button, select, input {
  font: inherit;
  color: inherit;
}

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  border: 0.5px solid var(--glass-edge);
  box-shadow: var(--glass-shadow);
}

/* Window Layout: Floating Glass Sidebar + Content */
.app {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  min-height: 100vh;
}

@media (max-width: 920px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static !important;
    height: auto !important;
    margin: 10px !important;
  }
}

.sidebar {
  position: sticky;
  top: 10px;
  height: calc(100vh - 20px);
  margin: 10px 0 10px 10px;
  border-radius: 20px;
  padding: 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Brand Header: No logo mark, no TM, Floshield by Nera */
.brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 10px 14px;
  border-bottom: 0.5px solid var(--border);
  margin-bottom: 4px;
}

.brand b {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.brand .by-nera {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
}

.brand .by-nera a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.brand .by-nera a:hover {
  text-decoration: underline;
}

.nav-h {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 10px 4px;
}

nav.tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

nav.tabs button,
.stem-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  background: none;
  border: 0;
  border-radius: 9px;
  padding: 7px 10px;
  cursor: pointer;
  color: var(--text-primary);
  text-align: left;
  font-size: 13px;
  transition: background-color 0.14s ease;
}

nav.tabs button svg {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--accent);
}

nav.tabs button:hover,
.stem-row:hover {
  background: var(--hover);
}

nav.tabs button.on {
  background: var(--nav-on);
  color: var(--accent);
  font-weight: 600;
}

.badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--pos-tint);
  color: var(--accent);
}

.badge.warn {
  background: var(--warn-tint);
  color: var(--warning-text);
}

.stem-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stem-row {
  padding: 6px 10px;
  font-size: 12.5px;
}

.stem-row.on {
  background: rgba(0, 0, 0, 0.06);
  font-weight: 600;
}

.stem-row .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}

.stem-row .nm {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stem-row .amt {
  color: var(--text-secondary);
  font-size: 11.5px;
}

.side-foot {
  margin-top: auto;
  padding: 12px 10px 4px;
  border-top: 0.5px solid var(--border);
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.side-foot a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

/* Main Content Area & Floating Toolbar */
.content {
  min-width: 0;
  padding: 10px 16px 0 16px;
}

.toolbar {
  position: sticky;
  top: 10px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 18px;
  border-radius: 18px;
  flex-wrap: wrap;
}

.toolbar h1 {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  font-size: 17px;
  font-weight: 650;
  margin: 0;
  letter-spacing: -0.015em;
}

.status {
  color: var(--text-secondary);
  font-size: 12px;
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.stchip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.55);
  border: 0.5px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font: inherit;
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 500;
}

.stchip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  flex: none;
}

.stchip[data-lv="warn"] .dot {
  background: var(--warning);
}

.stchip[data-lv="bad"] .dot {
  background: var(--critical);
}

.btn {
  height: 30px;
  padding: 0 13px;
  border-radius: 999px;
  border: 0.5px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.14s ease;
}

.btn:hover {
  background: var(--surface-2);
}

.btn.primary {
  background: var(--accent);
  color: #ffffff;
  border-color: transparent;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 122, 255, 0.25);
}

.btn.primary:hover {
  filter: brightness(1.06);
}

main {
  padding: 16px 2px 60px;
  max-width: 1480px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Executive Finding Sentence Strip (Replaces KPI Tile Grids) */
.finding-banner {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 15px 18px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-left: 3.5px solid var(--good);
}

.finding-banner.warn {
  border-left-color: var(--warning);
}

.finding-banner.bad {
  border-left-color: var(--critical);
}

.finding-sentence {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
}

.finding-sentence b {
  font-weight: 650;
}

.inline-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding-top: 8px;
  border-top: 0.5px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

.inline-facts span b {
  color: var(--text-primary);
  font-weight: 600;
}

/* Segmented Control (.seg) */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  background: var(--seg-bg);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 7px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-secondary);
  background: transparent;
  user-select: none;
  transition: all 0.14s ease;
}

.chip:hover {
  color: var(--text-primary);
}

.chip.on {
  background: var(--seg-on);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  font-weight: 600;
}

/* Cards & Grids */
.grid {
  display: grid;
  gap: 14px;
}

.two {
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
}

.three-way {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1080px) {
  .two,
  .three-way {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: var(--card-shadow);
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.card h2 {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  font-size: 15px;
  margin: 0 0 2px;
  font-weight: 650;
  letter-spacing: -0.012em;
}

.card .sub {
  color: var(--text-secondary);
  font-size: 12px;
}

/* Apple Tables */
.tablewrap {
  overflow-x: auto;
  margin: 0 -6px;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 12.5px;
}

th, td {
  padding: 7px 10px;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child,
th.l,
td.l {
  text-align: left;
}

tbody tr:nth-child(even) td {
  background: var(--surface-2);
}

tbody tr td:first-child {
  border-radius: 6px 0 0 6px;
}

tbody tr td:last-child {
  border-radius: 0 6px 6px 0;
}

th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--th-bg);
  border-bottom: 0.5px solid var(--border);
  padding-top: 6px;
  padding-bottom: 6px;
}

tr.click {
  cursor: pointer;
}

tr.click:hover td {
  background: var(--hover) !important;
}

/* Status Tags */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: 999px;
  padding: 2px 9px;
  background: var(--seg-bg);
  color: var(--text-primary);
  white-space: nowrap;
}

.tag .dot {
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  display: inline-block;
}

.tag.ok {
  background: var(--good-tint);
  color: var(--good-text);
}

.tag.ok .dot {
  background: var(--good);
}

.tag.watch {
  background: var(--warn-tint);
  color: var(--warning-text);
}

.tag.watch .dot {
  background: var(--warning);
}

.tag.high {
  background: var(--neg-tint);
  color: var(--neg-text);
}

.tag.high .dot {
  background: var(--critical);
}

.mono {
  font-family: "SF Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
}

/* Charts & Scrubbers */
.chart-stage {
  background: var(--surface-2);
  border: 0.5px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  position: relative;
}

.telemetry-svg {
  width: 100%;
  height: 265px;
  display: block;
  cursor: crosshair;
}

.scrubber-strip {
  margin-top: 10px;
  padding: 9px 14px;
  background: var(--surface-2);
  border-radius: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

/* Controls & Sliders */
.ctrls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.ctrl {
  background: var(--surface-2);
  padding: 10px 12px;
  border-radius: 10px;
  border: 0.5px solid var(--border);
}

.ctrl label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.ctrl label b {
  color: var(--text-primary);
  font-weight: 600;
}

.ctrl input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.lbar {
  display: inline-block;
  width: 90px;
  height: 6px;
  border-radius: 3px;
  background: var(--grid);
  vertical-align: middle;
  overflow: hidden;
  margin-right: 6px;
}

.lbar i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--good);
}

.lbar i.warn {
  background: var(--warning);
}

.lbar i.over {
  background: var(--critical);
}

/* Modal Sheet (<dialog closedby="any">) */
dialog.apple-sheet {
  margin: auto;
  width: min(840px, 94vw);
  max-height: 88vh;
  background: var(--surface-1);
  color: var(--text-primary);
  border: 0.5px solid var(--border);
  border-radius: 20px;
  padding: 0;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18), 0 4px 16px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

dialog.apple-sheet::backdrop {
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.sheet-inner {
  padding: 24px 26px;
  overflow-y: auto;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media print {
  .sidebar,
  .toolbar,
  main,
  .sheet-actions {
    display: none !important;
  }
  dialog.apple-sheet {
    position: static;
    width: 100%;
    max-height: none;
    border: none;
    box-shadow: none;
  }
}
