:root {
  /* Apple Dark System Surfaces */
  --bg-canvas: #07080b;
  --bg-card: rgba(22, 24, 30, 0.88);
  --bg-elevated: rgba(30, 33, 41, 0.92);
  --bg-inset: rgba(11, 12, 16, 0.78);
  --bg-hover: rgba(255, 255, 255, 0.065);

  /* Crisp Hairlines & Specular Edge */
  --hairline: rgba(255, 255, 255, 0.09);
  --hairline-strong: rgba(255, 255, 255, 0.16);
  --specular: inset 0 1px 0 rgba(255, 255, 255, 0.075);

  /* WCAG AA+ High-Readability Dark Typography */
  --text-primary: #f5f5f7;
  --text-secondary: #b4b7c2;
  --text-muted: #8a8f9e;

  /* Apple System Dark Semantic Accents */
  --green: #30d158;
  --green-soft: rgba(48, 209, 88, 0.14);
  --green-ring: rgba(48, 209, 88, 0.36);
  --amber: #ff9f0a;
  --amber-soft: rgba(255, 159, 10, 0.15);
  --amber-ring: rgba(255, 159, 10, 0.38);
  --red: #ff453a;
  --red-soft: rgba(255, 69, 58, 0.16);
  --red-ring: rgba(255, 69, 58, 0.44);
  --blue: #0a84ff;
  --blue-soft: rgba(10, 132, 255, 0.16);
  --blue-ring: rgba(10, 132, 255, 0.40);
  --teal: #64d2ff;

  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-mono: "SF Mono", ui-monospace, "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --radius-card: 16px;
  --radius-md: 11px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html, body {
  height: 100%;
  background: var(--bg-canvas);
  background-image:
    radial-gradient(ellipse 80% 42% at 50% -10%, rgba(255, 255, 255, 0.045), transparent 70%),
    radial-gradient(ellipse 40% 35% at 88% 0%, rgba(10, 132, 255, 0.045), transparent 65%);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.48;
  letter-spacing: -0.008em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* App Shell */
.shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  padding: 12px 14px 14px;
  gap: 12px;
}

/* Floating Top Bar */
.topbar {
  height: 58px;
  min-height: 58px;
  padding: 0 16px;
  border-radius: 15px;
  background: rgba(20, 22, 28, 0.84);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--hairline);
  box-shadow: var(--specular), 0 8px 28px rgba(0, 0, 0, 0.42);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(180deg, #272b34 0%, #161920 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 2px 10px rgba(0, 0, 0, 0.42);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.18;
}

.brand-name {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

.mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--hairline);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

/* Dynamic Island Live Kill Switch */
.ks-island {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  height: 38px;
  padding: 0 7px 0 14px;
  border-radius: var(--radius-pill);
  background: #0b0d11;
  border: 1px solid var(--green-ring);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 4px 18px rgba(0, 0, 0, 0.55);
  transition: all 240ms var(--ease);
  max-width: 460px;
}

.ks-island.latched {
  background: linear-gradient(180deg, rgba(70, 18, 18, 0.96) 0%, rgba(38, 10, 12, 0.98) 100%);
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(255, 69, 58, 0.18), 0 8px 26px rgba(255, 69, 58, 0.28);
  animation: islandPulse 2s ease-in-out infinite;
}

@keyframes islandPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 69, 58, 0.18), 0 8px 24px rgba(255, 69, 58, 0.24); }
  50% { box-shadow: 0 0 0 5px rgba(255, 69, 58, 0.26), 0 8px 30px rgba(255, 69, 58, 0.36); }
}

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

.dot-green { background: var(--green); box-shadow: 0 0 10px rgba(48, 209, 88, 0.75); }
.dot-red   { background: var(--red); box-shadow: 0 0 12px rgba(255, 69, 58, 0.9); }

.ks-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ks-island.latched .ks-label { color: #ffd9d6; }

.ks-btn {
  height: 26px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--hairline-strong);
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.ks-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); }

.ks-island.latched .ks-btn {
  background: var(--red);
  border-color: transparent;
  color: #fff;
}

.ks-island.latched .ks-btn:hover:not(:disabled) { background: #ff5d53; }

/* Right Toolbar */
.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* Buttons */
button, .btn-link {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--hairline);
  border-radius: 9px;
  padding: 7px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: background 150ms var(--ease), border-color 150ms var(--ease), transform 120ms var(--ease), box-shadow 150ms var(--ease);
  white-space: nowrap;
}

button:hover:not(:disabled), .btn-link:hover {
  background: rgba(255, 255, 255, 0.13);
  border-color: var(--hairline-strong);
}

button:active:not(:disabled) { transform: scale(0.985); }
button:disabled { opacity: 0.44; cursor: not-allowed; }

.btn-sm {
  padding: 5px 10px;
  font-size: 11.5px;
  border-radius: 8px;
}

.btn-lg {
  padding: 9px 16px;
  font-size: 13.5px;
  border-radius: 10px;
}

.btn-white {
  background: #f5f5f7;
  color: #090a0c;
  border-color: transparent;
  font-weight: 650;
  box-shadow: 0 2px 12px rgba(255, 255, 255, 0.12);
}

.btn-white:hover:not(:disabled) {
  background: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 18px rgba(255, 255, 255, 0.2);
}

.btn-green {
  background: var(--green);
  border-color: transparent;
  color: #04160a;
  font-weight: 650;
}

.btn-green:hover:not(:disabled) {
  background: #3fe068;
  border-color: transparent;
}

.btn-red {
  background: var(--red);
  border-color: transparent;
  color: #fff;
  font-weight: 650;
}

.btn-red:hover:not(:disabled) {
  background: #ff5b52;
  border-color: transparent;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.pill-green { background: var(--green-soft); border-color: var(--green-ring); color: var(--green); }
.pill-amber { background: var(--amber-soft); border-color: var(--amber-ring); color: var(--amber); }
.pill-red   { background: var(--red-soft); border-color: var(--red-ring); color: var(--red); }
.pill-blue  { background: var(--blue-soft); border-color: var(--blue-ring); color: var(--teal); }

/* 3-Column Bento Workspace */
.grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 334px minmax(520px, 1fr) 348px;
  gap: 10px;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

/* Apple Glass Card */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--specular), 0 10px 32px rgba(0, 0, 0, 0.38);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.card-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  gap: 8px;
  flex-shrink: 0;
}

.card-title {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--text-primary);
  letter-spacing: -0.012em;
}

.card-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-body {
  padding: 11px 14px;
  min-height: 0;
  overflow-y: auto;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); }

/* Segmented Tab Switcher */
.tab-bar-wrap {
  padding: 10px 14px 4px;
  flex-shrink: 0;
}

.segmented-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-inset);
  border: 1px solid var(--hairline);
  gap: 3px;
}

.segmented-tabs button {
  border: none;
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 12.5px;
  font-weight: 600;
  background: transparent;
  color: var(--text-secondary);
}

.segmented-tabs button.active {
  background: rgba(255, 255, 255, 0.13);
  color: var(--text-primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.tab-pane {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.tab-pane.active {
  display: flex;
}

/* Left Column: Spacious, Readable Scenario Cards */
.scenario-list {
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.scenario-btn {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.032);
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: all 160ms var(--ease);
}

.scenario-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.075);
  border-color: var(--hairline-strong);
  transform: translateY(-1px);
}

.scenario-btn.active {
  background: rgba(10, 132, 255, 0.14);
  border-color: var(--blue-ring);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.scenario-num {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.scenario-btn.active .scenario-num {
  background: var(--blue);
  border-color: transparent;
  color: #fff;
}

.scenario-meta { min-width: 0; }

.scenario-name {
  display: block;
  font-size: 13.2px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scenario-sub {
  display: block;
  font-size: 11.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.scenario-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.scenario-lat {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
}

/* Custom Order Ticket Tab */
.ticket-form {
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex: 1;
}

.ticket-hint {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field label {
  font-size: 11.5px;
  font-weight: 550;
  color: var(--text-secondary);
}

.field input, .field select {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border-radius: 9px;
  background: var(--bg-inset);
  border: 1px solid var(--hairline);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.field select option {
  background: #14161b;
  color: #f5f5f7;
}

.field input:focus, .field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.26);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  height: 38px;
  border-radius: 9px;
  background: var(--bg-inset);
  border: 1px solid var(--hairline);
  gap: 3px;
}

.segmented button {
  border: none;
  border-radius: 6px;
  padding: 0;
  font-size: 12.5px;
  font-weight: 650;
  background: transparent;
  color: var(--text-secondary);
}

.segmented button.active-buy {
  background: var(--green-soft);
  color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green-ring);
}

.segmented button.active-sell {
  background: var(--red-soft);
  color: var(--red);
  box-shadow: inset 0 0 0 1px var(--red-ring);
}

.order-preview {
  padding: 11px 13px;
  border-radius: 11px;
  background: var(--bg-inset);
  border: 1px solid var(--hairline);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}

.ticket-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 9px;
  margin-top: 2px;
}

/* Middle Column: 4-Stage Pipeline */
.pipeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  padding: 9px 14px 0;
  flex-shrink: 0;
}

.pipe-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.032);
  border: 1px solid var(--hairline);
  transition: all 220ms var(--ease);
  min-width: 0;
}

.pipe-step .pipe-idx {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pipe-step .pipe-lbl {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pipe-step.pass { background: var(--green-soft); border-color: var(--green-ring); }
.pipe-step.pass .pipe-idx { background: var(--green); color: #05170b; }
.pipe-step.pass .pipe-lbl { color: #c7f9d4; }

.pipe-step.warn { background: var(--amber-soft); border-color: var(--amber-ring); }
.pipe-step.warn .pipe-idx { background: var(--amber); color: #1c1100; }
.pipe-step.warn .pipe-lbl { color: #ffe5b4; }

.pipe-step.fail { background: var(--red-soft); border-color: var(--red-ring); }
.pipe-step.fail .pipe-idx { background: var(--red); color: #fff; }
.pipe-step.fail .pipe-lbl { color: #ffd1ce; }

/* Decision Inspector */
.decision-card {
  flex: 0 1 auto;
  min-height: 224px;
  max-height: 48%;
}

.hero-welcome {
  padding: 10px 12px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.hero-welcome h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.hero-welcome p {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 500px;
  line-height: 1.45;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  margin-top: 4px;
}

.decision-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.verdict-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 13px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.015em;
  border: 1px solid var(--hairline-strong);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
}

.verdict-approved  { background: var(--green-soft); border-color: var(--green-ring); color: var(--green); }
.verdict-downsized { background: var(--amber-soft); border-color: var(--amber-ring); color: var(--amber); }
.verdict-blocked   { background: var(--red-soft); border-color: var(--red-ring); color: var(--red); }
.verdict-info      { background: var(--blue-soft); border-color: var(--blue-ring); color: var(--teal); }

.latency-chip {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
  background: var(--bg-inset);
  border: 1px solid var(--hairline);
  padding: 4px 11px;
  border-radius: var(--radius-pill);
}

.latency-chip strong { color: var(--text-primary); font-weight: 650; }

.decision-title {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.018em;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.decision-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 11px;
  line-height: 1.48;
}

.inj-box {
  background: rgba(255, 69, 58, 0.10);
  border: 1px solid var(--red-ring);
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #ffd1ce;
  word-break: break-word;
  line-height: 1.45;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.kv {
  background: var(--bg-inset);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
}

.kv-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.kv-val {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reason-box {
  background: var(--bg-inset);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--hairline-strong);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-word;
  line-height: 1.48;
}

.reason-box.border-green { border-left-color: var(--green); color: #c9fad6; }
.reason-box.border-amber { border-left-color: var(--amber); color: #ffe7b8; }
.reason-box.border-red   { border-left-color: var(--red); color: #ffd1ce; }

.tamper-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tamper-card {
  background: var(--bg-inset);
  border: 1px solid var(--hairline);
  border-radius: 11px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.48;
}

.tamper-card.ok  { border-color: var(--green-ring); background: rgba(48, 209, 88, 0.06); }
.tamper-card.bad { border-color: var(--red-ring); background: rgba(255, 69, 58, 0.08); }

/* Portfolio Telemetry KPIs */
.kpi-strip {
  display: grid;
  grid-template-columns: 1.32fr 1.32fr 0.86fr 1.04fr 0.96fr;
  gap: 7px;
  margin-bottom: 10px;
}

.kpi {
  background: var(--bg-inset);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 7px 9px;
  min-width: 0;
}

.kpi-label {
  font-size: 10.5px;
  font-weight: 550;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-val {
  font-family: var(--font-mono);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.gauges {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.gauge-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11.5px;
  margin-bottom: 5px;
}

.gauge-head .lbl { color: var(--text-secondary); font-weight: 550; }
.gauge-head .val { font-family: var(--font-mono); color: var(--text-primary); font-weight: 650; font-size: 11.5px; }

.bar-track {
  height: 7px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--green);
  transition: width 320ms var(--ease), background 240ms ease;
}

.bar-fill.amber { background: var(--amber); }
.bar-fill.red   { background: var(--red); }

/* Positions Table */
.positions-card {
  flex: 1 1 0;
  min-height: 132px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

th {
  text-align: left;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 8px 9px;
  border-bottom: 1px solid var(--hairline);
}

th.num, td.num { text-align: right; }

td {
  padding: 9px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

.pos-bar-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  width: 100%;
}

.pos-bar {
  width: 64px;
  height: 6px;
  background: rgba(255, 255, 255, 0.09);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.pos-bar > span {
  display: block;
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 280ms var(--ease);
}

.empty-state {
  padding: 20px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px dashed rgba(255, 255, 255, 0.11);
}

/* Right Column: Cryptographic Audit Ledger */
.chain-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: rgba(11, 12, 16, 0.62);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-family: var(--font-mono);
  font-size: 11.5px;
  gap: 8px;
  flex-shrink: 0;
}

.audit-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 11.5px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.filter-pills {
  display: inline-flex;
  gap: 4px;
}

.filter-pills button {
  padding: 3px 9px;
  font-size: 11px;
  border-radius: var(--radius-pill);
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.filter-pills button.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.audit-feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px 12px 26px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  position: relative;
}

.audit-feed::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 18px;
  bottom: 18px;
  width: 1px;
  background: linear-gradient(180deg, rgba(100, 210, 255, 0.4), rgba(255, 255, 255, 0.08));
}

.audit-item {
  position: relative;
  background: rgba(255, 255, 255, 0.032);
  border: 1px solid var(--hairline);
  border-radius: 11px;
  padding: 9px 11px;
  cursor: pointer;
  transition: all 150ms var(--ease);
}

.audit-item::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 15px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid #16181e;
  box-shadow: 0 0 0 1px rgba(100, 210, 255, 0.4);
}

.audit-item.ev-approved::before  { background: var(--green); box-shadow: 0 0 0 1px var(--green-ring); }
.audit-item.ev-downsized::before { background: var(--amber); box-shadow: 0 0 0 1px var(--amber-ring); }
.audit-item.ev-blocked::before   { background: var(--red); box-shadow: 0 0 0 1px var(--red-ring); }

.audit-item:hover {
  background: rgba(255, 255, 255, 0.065);
  border-color: var(--hairline-strong);
}

.audit-item.flash { animation: itemReveal 650ms var(--ease); }

@keyframes itemReveal {
  0% { background: rgba(10, 132, 255, 0.24); transform: translateY(-2px); }
  100% { background: rgba(255, 255, 255, 0.032); transform: translateY(0); }
}

.audit-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.audit-seq {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.audit-ev {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.audit-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 7px;
  word-break: break-word;
  line-height: 1.42;
}

.audit-hashes {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.audit-hashes .h-cur { color: var(--teal); }

.audit-json {
  display: none;
  margin-top: 8px;
  padding: 9px 10px;
  background: #08090c;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: #c5cedb;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
}

.audit-item.expanded .audit-json { display: block; }

/* macOS Sheet Dialogs */
dialog {
  margin: auto;
  background: rgba(24, 26, 33, 0.96);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  color: var(--text-primary);
  border: 1px solid var(--hairline-strong);
  border-radius: 16px;
  padding: 0;
  width: 470px;
  max-width: 92vw;
  box-shadow: var(--specular), 0 28px 80px rgba(0, 0, 0, 0.72);
  animation: sheetIn 180ms var(--ease);
}

.dlg-wide { width: 620px; max-width: 94vw; }

@keyframes sheetIn {
  from { opacity: 0; transform: scale(0.97) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.dlg-hdr {
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 650;
}

.dlg-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.dlg-sub {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.48;
}

.dlg-err {
  display: none;
  padding: 9px 11px;
  border: 1px solid var(--red-ring);
  background: var(--red-soft);
  color: #ffd1ce;
  font-family: var(--font-mono);
  font-size: 12px;
  border-radius: 9px;
}

.dlg-ftr {
  padding: 13px 18px;
  border-top: 1px solid var(--hairline);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 9px;
}

/* Apple Switch Toggle */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 13px;
  border-radius: 11px;
  background: var(--bg-inset);
  border: 1px solid var(--hairline);
  cursor: pointer;
}

.switch-copy strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.switch-copy span {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.apple-switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}

.apple-switch input { opacity: 0; width: 0; height: 0; position: absolute; }

.apple-slider {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.18);
  transition: background 180ms var(--ease);
}

.apple-slider::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
  transition: transform 200ms var(--ease);
}

.apple-switch input:checked + .apple-slider { background: var(--green); }
.apple-switch input:checked + .apple-slider::after { transform: translateX(18px); }

.code-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.code-hdr span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.code-block {
  background: #08090c;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 11px 13px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #d7dfe9;
  white-space: pre;
  overflow-x: auto;
  max-height: 185px;
  overflow-y: auto;
  line-height: 1.45;
}

/* Apple HUD Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  background: rgba(30, 33, 41, 0.96);
  backdrop-filter: blur(20px);
  border: 1px solid var(--hairline-strong);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.6);
  font-size: 13px;
  font-weight: 550;
  color: var(--text-primary);
  transition: opacity 200ms var(--ease), transform 220ms var(--ease);
  z-index: 999;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1220px) {
  .shell { height: auto; overflow: auto; }
  .grid { grid-template-columns: 1fr; }
  .topbar { grid-template-columns: 1fr; height: auto; padding: 12px 14px; }
  .topbar-right { justify-content: flex-start; flex-wrap: wrap; }
}
