/* AI Trading SaaS v3.0 - Obsidian Institutional Prop-Trader Terminal (Demo G0) */

:root {
  /* Neutral Obsidian Carbon Ramp (8 steps - pitch dark, zero milky blue) */
  --bg-base: #05070a;
  --bg-elevated: #0a0d12;
  --bg-card: rgba(12, 16, 23, 0.86);
  --bg-card-hover: rgba(18, 24, 34, 0.92);
  --bg-card-solid: #0c1017;
  --bg-hover: #141a24;
  --bg-input: #0c1017;

  /* Hairline Structural Borders (1px sharp, NEVER glowing) */
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-glow: rgba(41, 98, 255, 0.45);
  --border-glow-strong: rgba(56, 189, 248, 0.65);

  /* Text Hierarchy (WCAG AA high contrast) */
  --text-primary: #eaecef;
  --text-secondary: #929aa5;
  --text-muted: #5e6673;

  /* Trader Semantic Palette (Institutional - flat, high-precision) */
  --accent-cyan: #2962ff;
  --accent-ice: #38bdf8;
  --accent-emerald: #0ecb81;
  --accent-amber: #f0b90b;
  --accent-rose: #f6465d;
  --accent-violet: #8b5cf6;

  /* Crisp Dark Elevation ONLY (zero outer glow) */
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.04);

  /* Radii (Sharp Modern Terminal) */
  --radius-panel: 8px;
  --radius-control: 6px;
  --radius-tag: 4px;
  --radius-lg: 8px;
  --radius-md: 6px;
  --radius-sm: 6px;
  --radius-pill: 999px;

  --sidebar-w: 244px;
  --mobile-nav-h: 66px;
  --font-sans: "IBM Plex Sans Thai", "Noto Sans Thai", "Inter", "Leelawadee UI", "Thonburi", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background-color: var(--bg-base);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Full-viewport quantitative trader canvas */
#v2-dynamic-bg {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  z-index: 0;
  pointer-events: none;
  display: block;
}

/* Subtle Obsidian scrollbars */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: #070a0f;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-tag);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* Accessible keyboard focus */
:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

h1, h2, h3, h4, p {
  margin-top: 0;
}

h1, h2, h3, h4 {
  line-height: 1.35;
  letter-spacing: 0;
  color: var(--text-primary);
}

a {
  color: var(--accent-ice);
  text-decoration: none;
}

img,
canvas:not(#v2-dynamic-bg) {
  max-width: 100%;
}

/* Tabular numbers, Market Ticker hierarchy & semantic utilities */
.num,
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.01em;
}

.v2-ticker-price {
  font-family: var(--font-mono);
  font-size: clamp(24px, 2.4vw, 28px);
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.v2-ticker-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  background: var(--bg-card-solid);
}

.v2-ticker-cell {
  padding: 6px 12px;
  border-left: 1px solid var(--border-subtle);
  font-size: 12px;
  line-height: 1.4;
}

.v2-ticker-cell:first-child {
  border-left: 0;
}

.text-cyan { color: var(--accent-cyan); }
.text-ice { color: var(--accent-ice); }
.text-emerald, .text-pos { color: var(--accent-emerald); }
.text-amber, .text-warn { color: var(--accent-amber); }
.text-rose, .text-neg { color: var(--accent-rose); }
.text-violet { color: var(--accent-violet); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

/* ==========================================================================
   Top Non-Intrusive Demo Simulation Capsule & Offline Banner
   ========================================================================== */

.v2-demo-capsule-wrap {
  padding: 8px 12px 0;
  width: 100%;
  max-width: 1380px;
  margin: 0 auto;
}

.v2-demo-capsule {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-control);
  background: rgba(10, 13, 18, 0.90);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0;
  text-align: center;
}

.v2-demo-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--accent-amber);
}

.v2-demo-tag {
  color: var(--text-primary);
  font-weight: 500;
  letter-spacing: 0;
}

.v2-offline-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 12px 0;
  padding: 8px 14px;
  border-radius: var(--radius-control);
  background: rgba(28, 11, 15, 0.94);
  border: 1px solid rgba(246, 70, 93, 0.45);
  color: #fecdd3;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0;
  text-align: center;
}

.v2-offline-banner.is-visible {
  display: flex;
}

/* ==========================================================================
   Dual Responsive App Shell (Mobile < 900px | Tablet & Desktop >= 900px)
   ========================================================================== */

.v2-app-layout {
  width: 100%;
  max-width: 100%;
  min-height: 100dvh;
  position: relative;
  z-index: 1;
}

/* Left Vertical Sidebar (Tablet/Desktop >= 900px) */
.v2-sidebar {
  display: none;
}

.v2-brand-mark {
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-control);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.v2-brand-mark svg {
  width: 22px;
  height: 22px;
  display: block;
}

.v2-shell {
  width: 100%;
  max-width: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px) + 12px);
}

/* Topbar */
.v2-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  margin-top: 6px;
  padding: 10px 14px;
  background: rgba(10, 13, 18, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.v2-topbar-inner {
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.v2-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.v2-topbar-titles {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.v2-topbar-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0;
  color: var(--text-primary);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 8px;
}

#v2-topbar-title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v2-topbar-sub {
  margin: 1px 0 0;
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0;
  color: var(--text-secondary);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Dynamic Background Toggle Button ([BG: LIVE] / [BG: OFF]) */
.v2-bg-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border-strong);
  background: var(--bg-card-solid);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.v2-bg-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--border-glow);
}

.v2-bg-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--accent-emerald);
}

.v2-bg-toggle.is-live {
  border-color: rgba(14, 203, 129, 0.36);
  color: var(--text-primary);
}

.v2-bg-toggle.is-off {
  border-color: var(--border-subtle);
  color: var(--text-muted);
}

.v2-bg-toggle.is-off .v2-bg-dot {
  background: var(--text-muted);
}

.v2-net-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: var(--radius-tag);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0;
  background: rgba(14, 203, 129, 0.10);
  border: 1px solid rgba(14, 203, 129, 0.34);
  color: var(--accent-emerald);
  white-space: nowrap;
}

.v2-net-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-emerald);
}

.v2-net-pill.is-offline {
  background: rgba(246, 70, 93, 0.12);
  border-color: rgba(246, 70, 93, 0.38);
  color: var(--accent-rose);
}

.v2-net-pill.is-offline .dot {
  background: var(--accent-rose);
}

.v2-net-pill.is-warn {
  background: rgba(240, 185, 11, 0.12);
  border-color: rgba(240, 185, 11, 0.38);
  color: var(--accent-amber);
}

.v2-net-pill.is-warn .dot {
  background: var(--accent-amber);
}

.v2-icon-btn {
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card-solid);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.v2-icon-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.v2-icon-btn svg {
  width: 18px;
  height: 18px;
}

.v2-desktop-only {
  display: none;
}

@media (max-width: 899.98px) {
  .v2-desktop-only {
    display: none !important;
  }
}

@media (max-width: 599.98px) {
  #v2-topbar-badge {
    display: none;
  }
}

@media (max-width: 479.98px) {
  #v2-net-label {
    display: none;
  }

  .v2-net-pill {
    padding: 8px;
  }
}

@media (max-width: 389.98px) {
  .v2-topbar {
    padding: 8px 10px;
  }

  .v2-topbar-inner,
  .v2-topbar-left,
  .v2-topbar-actions {
    gap: 6px;
  }

  .v2-topbar-title {
    font-size: 15px;
  }

  .v2-bg-toggle {
    padding: 0 8px;
    font-size: 10.5px;
  }
}

/* Main View Container */
.v2-main {
  flex: 1;
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 12px 12px 16px;
  min-width: 0;
}

.v2-main > * {
  min-width: 0;
}

/* Desktop/Tablet System Status Bar (hidden on mobile < 900px) */
.v2-system-bar {
  display: none;
}

/* ==========================================================================
   Mobile Fixed 5-Item Bottom Tab Bar (< 900px)
   ========================================================================== */

.v2-mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: stretch;
  height: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px));
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
  background: rgba(10, 13, 18, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-subtle);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.65);
}

.v2-mobile-link {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  padding: 4px 2px;
  border-radius: var(--radius-control);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.v2-mobile-icon {
  width: 34px;
  height: 26px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.v2-mobile-icon svg {
  width: 19px;
  height: 19px;
  display: block;
}

.v2-mobile-link.is-active {
  color: var(--text-primary);
  font-weight: 700;
}

.v2-mobile-link.is-active .v2-mobile-icon {
  background: rgba(41, 98, 255, 0.16);
  border-color: var(--border-glow);
  color: var(--accent-ice);
}

.v2-mobile-link.is-active::after {
  content: "";
  position: absolute;
  bottom: 2px;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent-cyan);
}

/* ==========================================================================
   Tablet & Desktop Layout (>= 900px)
   ========================================================================== */

@media (min-width: 900px) {
  .v2-mobile-nav {
    display: none !important;
  }

  .v2-mobile-only {
    display: none !important;
  }

  .v2-desktop-only {
    display: inline-flex;
  }

  .v2-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    z-index: 40;
    display: flex;
    flex-direction: column;
    padding: 18px 14px 16px;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border-subtle);
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.50);
  }

  .v2-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 4px 6px 16px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    text-decoration: none;
  }

  .v2-sidebar-brand-title {
    font-size: 15.5px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .v2-sidebar-brand-ver {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-ice);
    padding: 1px 6px;
    border-radius: var(--radius-tag);
    background: rgba(41, 98, 255, 0.15);
    border: 1px solid var(--border-glow);
  }

  .v2-sidebar-brand-sub {
    font-size: 11.5px;
    line-height: 1.45;
    letter-spacing: 0;
    color: var(--text-secondary);
    margin-top: 2px;
  }

  .v2-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
  }

  .v2-sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: var(--radius-control);
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  }

  .v2-sidebar-link svg {
    width: 19px;
    height: 19px;
    flex-shrink: 0;
    transition: color 0.15s ease;
  }

  .v2-sidebar-link:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    border-color: var(--border-subtle);
  }

  .v2-sidebar-link.is-active {
    color: var(--text-primary);
    font-weight: 700;
    background: rgba(41, 98, 255, 0.14);
    border-color: var(--border-glow);
  }

  .v2-sidebar-link.is-active svg {
    color: var(--accent-ice);
  }

  .v2-sidebar-link.is-active::before {
    content: "";
    position: absolute;
    left: -1px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 2px;
    background: var(--accent-cyan);
  }

  .v2-sidebar-footer {
    margin-top: auto;
    padding: 12px;
    border-radius: var(--radius-panel);
    background: var(--bg-card-solid);
    border: 1px solid var(--border-subtle);
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary);
  }

  .v2-sidebar-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 5px;
  }

  .v2-sidebar-footer-row:last-child {
    margin-bottom: 0;
  }

  .v2-sidebar-footer strong {
    color: var(--text-primary);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .v2-shell {
    padding-left: var(--sidebar-w);
    padding-bottom: 0;
  }

  .v2-demo-capsule-wrap {
    padding: 10px 22px 0;
  }

  .v2-topbar {
    padding: 10px 22px;
  }

  .v2-topbar-title {
    font-size: 17.5px;
  }

  .v2-main {
    padding: 16px 22px 18px;
  }

  /* Bottom 4 System-Status Bar */
  .v2-system-bar {
    display: block;
    width: 100%;
    max-width: 1360px;
    margin: 0 auto;
    padding: 4px 22px 22px;
  }

  .v2-system-bar-card {
    padding: 12px 16px;
    border-radius: var(--radius-panel);
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-card);
  }

  .v2-system-bar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
    color: var(--text-primary);
  }

  .v2-system-bar-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
  }

  .v2-sys-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-control);
    background: var(--bg-card-solid);
    border: 1px solid var(--border-subtle);
    min-width: 0;
  }

  .v2-sys-icon {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-control);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(14, 203, 129, 0.12);
    border: 1px solid rgba(14, 203, 129, 0.36);
    color: var(--accent-emerald);
  }

  .v2-sys-icon svg {
    width: 15px;
    height: 15px;
  }

  .v2-sys-item.is-warn .v2-sys-icon {
    background: rgba(240, 185, 11, 0.12);
    border-color: rgba(240, 185, 11, 0.38);
    color: var(--accent-amber);
  }

  .v2-sys-item.is-err .v2-sys-icon {
    background: rgba(246, 70, 93, 0.12);
    border-color: rgba(246, 70, 93, 0.38);
    color: var(--accent-rose);
  }

  .v2-sys-meta {
    min-width: 0;
  }

  .v2-sys-label {
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.45;
    letter-spacing: 0;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .v2-sys-val {
    font-size: 11.5px;
    line-height: 1.45;
    letter-spacing: 0;
    color: var(--accent-emerald);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .v2-sys-item.is-warn .v2-sys-val {
    color: var(--accent-amber);
  }

  .v2-sys-item.is-err .v2-sys-val {
    color: var(--accent-rose);
  }
}

/* ==========================================================================
   Shared Contract Cards & Responsive Grids
   ========================================================================== */

.v2-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-panel);
  padding: 16px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
  min-width: 0;
}

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

.v2-card-emerald {
  background: rgba(11, 18, 16, 0.90);
  border-color: rgba(14, 203, 129, 0.34);
}

.v2-card-violet {
  background: rgba(15, 13, 24, 0.90);
  border-color: rgba(139, 92, 246, 0.36);
}

.v2-grid-kpi {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.v2-grid-kpi > * {
  min-width: 0;
}

.v2-split-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  width: 100%;
  min-width: 0;
}

.v2-split-main > * {
  min-width: 0;
}

.v2-grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  width: 100%;
  min-width: 0;
}

.v2-grid-2 > * {
  min-width: 0;
}

@media (min-width: 768px) {
  .v2-demo-capsule-wrap {
    padding: 10px 18px 0;
  }

  .v2-topbar {
    padding: 10px 18px;
  }

  .v2-main {
    padding: 16px 18px 20px;
  }

  .v2-grid-kpi {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
  }

  .v2-split-main,
  .v2-main .v2-split-main {
    grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
  }

  .v2-grid-2,
  .v2-main .vi-overview-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
  }

  .v2-main .vh-donut-layout {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (min-width: 900px) {
  .v2-demo-capsule-wrap {
    padding: 10px 22px 0;
  }

  .v2-topbar {
    padding: 10px 22px;
  }

  .v2-main {
    padding: 16px 22px 18px;
  }

  .v2-grid-kpi {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
  }
}

@media (min-width: 1024px) {
  .v2-split-main,
  .v2-main .v2-split-main {
    grid-template-columns: minmax(0, 1.95fr) minmax(0, 1fr);
    gap: 16px;
  }
}

@media (max-width: 340px) {
  .v2-grid-kpi {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ==========================================================================
   Badges (.v2-badge, .v2-badge-pass/review/block/unknown/gold/cyan)
   Sharp 4px technical badge corners, zero neon blur
   ========================================================================== */

.v2-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-tag);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0;
  white-space: nowrap;
  border: 1px solid var(--border-strong);
  background: var(--bg-card-solid);
  color: var(--text-primary);
}

.v2-badge-pass {
  background: rgba(14, 203, 129, 0.12);
  border-color: rgba(14, 203, 129, 0.40);
  color: var(--accent-emerald);
}

.v2-badge-review {
  background: rgba(240, 185, 11, 0.12);
  border-color: rgba(240, 185, 11, 0.42);
  color: var(--accent-amber);
}

.v2-badge-block {
  background: rgba(246, 70, 93, 0.12);
  border-color: rgba(246, 70, 93, 0.42);
  color: var(--accent-rose);
}

.v2-badge-unknown {
  background: rgba(94, 102, 115, 0.20);
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.v2-badge-gold {
  background: rgba(240, 185, 11, 0.14);
  border-color: rgba(240, 185, 11, 0.48);
  color: var(--accent-amber);
}

.v2-badge-cyan {
  background: rgba(41, 98, 255, 0.15);
  border-color: var(--border-glow);
  color: var(--accent-ice);
}

/* ==========================================================================
   Buttons (.v2-btn, .v2-btn-primary, .v2-btn-danger, .v2-btn-ghost)
   Tight 6px control corners, >= 44px touch target, flat institutional fills
   ========================================================================== */

.v2-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 9px 16px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border-strong);
  background: var(--bg-card-solid);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

.v2-btn:hover:not(:disabled) {
  border-color: var(--border-glow);
  background: var(--bg-hover);
}

.v2-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.v2-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.v2-btn-primary {
  background: var(--accent-cyan);
  border-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.v2-btn-primary:hover:not(:disabled) {
  background: #1e53e5;
  border-color: rgba(255, 255, 255, 0.28);
  color: #ffffff;
}

.v2-btn-danger {
  background: var(--accent-rose);
  border-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.v2-btn-danger:hover:not(:disabled) {
  background: #e0384f;
  border-color: rgba(255, 255, 255, 0.28);
  color: #ffffff;
}

.v2-btn-ghost {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.v2-btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: #ffffff;
}

.v2-btn-sm {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 12.5px;
  border-radius: var(--radius-control);
}

.v2-btn-block {
  width: 100%;
}

/* ==========================================================================
   Segmented Sub-Tab Bar (.v2-tabs & .v2-tab)
   ========================================================================== */

.v2-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-control);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
}

.v2-tabs::-webkit-scrollbar {
  display: none;
}

.v2-tab {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.v2-tab:hover:not(.is-active) {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.v2-tab.is-active,
.v2-tab[aria-selected="true"] {
  background: rgba(41, 98, 255, 0.16);
  border-color: var(--border-glow);
  color: var(--text-primary);
  font-weight: 700;
}

/* ==========================================================================
   Institutional Toggle Switch (.v2-switch) - sole permitted pill control
   ========================================================================== */

input[type="checkbox"].v2-switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 50px;
  height: 28px;
  margin: 0;
  border-radius: var(--radius-pill);
  background: #181f2c;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.18s ease, border-color 0.18s ease;
}

input[type="checkbox"].v2-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #eaecef;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  transition: transform 0.18s ease;
}

input[type="checkbox"].v2-switch:checked {
  background: var(--accent-emerald);
  border-color: rgba(255, 255, 255, 0.22);
}

input[type="checkbox"].v2-switch:checked::after {
  transform: translateX(22px);
  background: #ffffff;
}

label.v2-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 50px;
  height: 28px;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
}

label.v2-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

label.v2-switch > span,
label.v2-switch .v2-switch-track,
label.v2-switch .v2-switch-slider {
  position: relative;
  display: block;
  width: 50px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: #181f2c;
  border: 1px solid var(--border-strong);
  transition: background 0.18s ease, border-color 0.18s ease;
}

label.v2-switch > span::after,
label.v2-switch .v2-switch-track::after,
label.v2-switch .v2-switch-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #eaecef;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  transition: transform 0.18s ease;
}

label.v2-switch input[type="checkbox"]:checked + span,
label.v2-switch input[type="checkbox"]:checked + .v2-switch-track,
label.v2-switch input[type="checkbox"]:checked + .v2-switch-slider {
  background: var(--accent-emerald);
  border-color: rgba(255, 255, 255, 0.22);
}

label.v2-switch input[type="checkbox"]:checked + span::after,
label.v2-switch input[type="checkbox"]:checked + .v2-switch-track::after,
label.v2-switch input[type="checkbox"]:checked + .v2-switch-slider::after {
  transform: translateX(22px);
  background: #ffffff;
}

button.v2-switch,
div.v2-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 50px;
  height: 28px;
  padding: 0;
  border-radius: var(--radius-pill);
  background: #181f2c;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.18s ease, border-color 0.18s ease;
}

button.v2-switch::after,
div.v2-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #eaecef;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  transition: transform 0.18s ease;
}

button.v2-switch.is-on,
button.v2-switch.is-active,
button.v2-switch.on,
button.v2-switch[aria-checked="true"],
div.v2-switch.is-on,
div.v2-switch.is-active,
div.v2-switch[aria-checked="true"] {
  background: var(--accent-emerald);
  border-color: rgba(255, 255, 255, 0.22);
}

button.v2-switch.is-on::after,
button.v2-switch.is-active::after,
button.v2-switch.on::after,
button.v2-switch[aria-checked="true"]::after,
div.v2-switch.is-on::after,
div.v2-switch.is-active::after,
div.v2-switch[aria-checked="true"]::after {
  transform: translateX(22px);
  background: #ffffff;
}

/* ==========================================================================
   Cohesive Form Controls & Tables inside Views
   ========================================================================== */

.v2-main input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
.v2-main select,
.v2-main textarea,
.v2-input,
.v2-select {
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.v2-main input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus,
.v2-main select:focus,
.v2-main textarea:focus,
.v2-input:focus,
.v2-select:focus {
  outline: 1px solid var(--border-glow);
  outline-offset: 0;
  border-color: var(--accent-cyan);
  background: #0e131c;
}

.v2-main input[type="range"] {
  width: 100%;
  min-height: 44px;
  accent-color: var(--accent-cyan);
}

.v2-main table,
.v2-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.v2-main th,
.v2-main td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: middle;
}

.v2-main th {
  background: var(--bg-card-solid);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0;
}

/* ==========================================================================
   Loading Skeleton & Toast Stack
   ========================================================================== */

.v2-loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 220px;
  text-align: center;
  color: var(--text-secondary);
}

.v2-spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.10);
  border-top-color: var(--accent-cyan);
  animation: v2-spin 0.8s linear infinite;
}

@keyframes v2-spin {
  to { transform: rotate(360deg); }
}

.v2-toast-root {
  position: fixed;
  right: 12px;
  left: 12px;
  bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.v2-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-panel);
  background: rgba(12, 16, 23, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-glow);
  box-shadow: var(--shadow-card);
  color: var(--text-primary);
  font-size: 13.5px;
  line-height: 1.5;
  letter-spacing: 0;
  animation: v2-toast-in 0.18s ease-out;
}

.v2-toast-ok {
  border-color: rgba(14, 203, 129, 0.45);
}

.v2-toast-warn {
  border-color: rgba(240, 185, 11, 0.48);
}

.v2-toast-err {
  border-color: rgba(246, 70, 93, 0.50);
}

.v2-toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.v2-toast-ok .v2-toast-icon { color: var(--accent-emerald); }
.v2-toast-warn .v2-toast-icon { color: var(--accent-amber); }
.v2-toast-err .v2-toast-icon { color: var(--accent-rose); }
.v2-toast-info .v2-toast-icon { color: var(--accent-ice); }

.v2-toast-msg {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.v2-toast-close {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
}

@keyframes v2-toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 900px) {
  .v2-toast-root {
    left: auto;
    right: 22px;
    bottom: 22px;
    width: 380px;
  }
}

@media (max-width: 480px) {
  .v2-demo-capsule {
    font-size: 11px;
    padding: 6px 10px;
    border-radius: var(--radius-control);
    flex-wrap: wrap;
    gap: 4px 6px;
  }

  .v2-card {
    padding: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
