/* ==========================================================================
   MASTER.KE UNIVERSAL DESIGN SYSTEM
   Precision Architectural Monochrome (Linear / Vercel / Teenage Engineering)
   Typography: Jost with tabular-nums discipline (Hero 2.25rem / 36px, H1 1.5rem / 24px, H2 1.125rem / 18px, Body 0.875rem / 14px, UI Label 0.75rem / 12px, Micro 0.6875rem / 11px)
   Radii Scale: 3-tier system (--radius-sm 4px, --radius-md 8px, --radius-lg 14px)
   Color System: Multi-step tonal zinc/slate hierarchy + engineered functional accents (#10b981 sync, #d97706 warning, #e11d48 danger)
   Motion Policy: Snappy high-damping spring physics (160ms–220ms), 0ms on drag
   Specificity Policy: Clean selector architecture without forced overrides
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Jost:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

:root {
  color-scheme: light dark;

  &:has(> head > meta[name="color-scheme"][content="dark"]) {
    color-scheme: dark;
  }
  &:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
  }
}

/* --- 1. CORE TOKENS (LIGHT THEME DEFAULT) --- */
:root,
:root[data-theme="light"],
[data-theme="light"] {
  /* Core Surfaces - Pure White Blueprint */
  --bg-canvas: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-raised: #f8fafc;
  --bg-surface-hover: #f1f5f9;
  --bg-surface-active: #e2e8f0;
  --bg-backdrop: rgba(9, 9, 11, 0.45);

  /* Hairline Architectural Borders */
  --border-subtle: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #94a3b8;

  /* Typography Colors */
  --text-primary: #09090b;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --text-inverse: #ffffff;

  /* Brand & Engineered Functional Accents */
  --brand-accent: #09090b;
  --accent-sync: #10b981;
  --accent-warning: #d97706;
  --accent-warning-bg: rgba(217, 119, 6, 0.12);
  --accent-danger: #e11d48;
  --accent-danger-bg: rgba(225, 29, 72, 0.12);

  /* Floorplan & Digital Twin Tonal Layers - Subdued so Bays Stand Out */
  --yard-outdoor: #ffffff;
  --cabro-gray: #f8fafc;
  --cabro-walkway: #f4f5f7;
  --cabro-terracotta: #f1f3f6;
  --facility-slab: #f8fafc;
  --facility-container: #f1f5f9;
  --facility-tank: #f1f5f9;
  --facility-washroom: #f1f5f9;
  --facility-gray: #f8fafc;
  --arch-line: rgba(100, 116, 139, 0.16);
  --zone-watermark: transparent;

  /* High-Contrast Interactive Work Bays */
  --bay-fill: #e2e8f0;
  --bay-hover: #cbd5e1;
  --bay-border: #64748b;
  --snap-target: #cbd5e1;
  --snap-border: #09090b;

  /* Default Vehicle Token Neutral */
  --bus-gray-body: #52525b;
  --bus-gray-border: #3f3f46;

  /* Elevation & Diffused Ambient Shadows */
  --shadow-sm: 0 1px 2px rgba(9, 9, 11, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(9, 9, 11, 0.08), 0 1px 3px rgba(9, 9, 11, 0.04);
  --shadow-card: 0 12px 32px -4px rgba(9, 9, 11, 0.12), 0 2px 6px -1px rgba(9, 9, 11, 0.05);

  /* 3-Tier Corner Radius Scale */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Layout & Motion Constants */
  --cmd-bar-height: 48px;
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 150ms;
  --dur-med: 200ms;
}

/* --- 2. DARK THEME TOKENS --- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not(:has(> head > meta[name="color-scheme"][content="light"])) {
    --bg-canvas: #000000;
    --bg-surface: #121212;
    --bg-surface-raised: #1c1c1c;
    --bg-surface-hover: #262626;
    --bg-surface-active: #333333;
    --bg-backdrop: rgba(0, 0, 0, 0.72);

    --border-subtle: #1c1c1c;
    --border: #262626;
    --border-strong: #404040;

    --text-primary: #ffffff;
    --text-secondary: #d4d4d8;
    --text-muted: #a1a1aa;
    --text-faint: #71717a;
    --text-inverse: #000000;

    --brand-accent: #ffffff;
    --accent-sync: #10b981;
    --accent-warning: #f59e0b;
    --accent-warning-bg: rgba(245, 158, 11, 0.15);
    --accent-danger: #f43f5e;
    --accent-danger-bg: rgba(244, 63, 94, 0.15);

    --yard-outdoor: #08080a;
    --cabro-gray: #0f0f12;
    --cabro-walkway: #121215;
    --cabro-terracotta: #121215;
    --facility-slab: #0e0e11;
    --facility-container: #141417;
    --facility-tank: #141417;
    --facility-washroom: #111114;
    --facility-gray: #111114;
    --arch-line: rgba(255, 255, 255, 0.07);
    --zone-watermark: transparent;

    --bay-fill: #26262b;
    --bay-hover: #33333a;
    --bay-border: #52525b;
    --snap-target: #3f3f46;
    --snap-border: #ffffff;

    --bus-gray-body: #52525b;
    --bus-gray-border: #71717a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 6px 16px -2px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-card: 0 24px 50px -8px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08);
  }
}

:root[data-theme="dark"],
[data-theme="dark"],
:root:has(> head > meta[name="color-scheme"][content="dark"]) {
  /* Core Surfaces - Pure Black Blueprint */
  --bg-canvas: #000000;
  --bg-surface: #121212;
  --bg-surface-raised: #1c1c1c;
  --bg-surface-hover: #262626;
  --bg-surface-active: #333333;
  --bg-backdrop: rgba(0, 0, 0, 0.72);

  /* Hairline Architectural Borders */
  --border-subtle: #1c1c1c;
  --border: #262626;
  --border-strong: #404040;

  /* Typography Colors */
  --text-primary: #ffffff;
  --text-secondary: #d4d4d8;
  --text-muted: #a1a1aa;
  --text-faint: #71717a;
  --text-inverse: #000000;

  /* Brand & Engineered Functional Accents */
  --brand-accent: #ffffff;
  --accent-sync: #10b981;
  --accent-warning: #f59e0b;
  --accent-warning-bg: rgba(245, 158, 11, 0.15);
  --accent-danger: #f43f5e;
  --accent-danger-bg: rgba(244, 63, 94, 0.15);

  /* Floorplan & Digital Twin Tonal Layers */
  --yard-outdoor: #08080a;
  --cabro-gray: #0f0f12;
  --cabro-walkway: #121215;
  --cabro-terracotta: #121215;
  --facility-slab: #0e0e11;
  --facility-container: #141417;
  --facility-tank: #141417;
  --facility-washroom: #111114;
  --facility-gray: #111114;
  --arch-line: rgba(255, 255, 255, 0.07);
  --zone-watermark: transparent;

  /* High-Contrast Interactive Work Bays */
  --bay-fill: #26262b;
  --bay-hover: #33333a;
  --bay-border: #52525b;
  --snap-target: #3f3f46;
  --snap-border: #ffffff;

  /* Default Vehicle Token Neutral */
  --bus-gray-body: #52525b;
  --bus-gray-border: #71717a;

  /* Elevation & Diffused Ambient Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 6px 16px -2px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 24px 50px -8px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* --- 3. BASE RESET & TYPOGRAPHY DISCIPLINE --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body,
input,
button,
select,
textarea {
  font-family: 'Jost', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "ss01" 0;
  -webkit-font-feature-settings: "ss01" 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle 4px Precision Scrollbars for Panels & Timelines */
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

::-webkit-scrollbar {
  display: none;
}

/* Native Mobile Pull-to-Refresh Preserved */
html {
  overflow-y: auto;
  overscroll-behavior-y: auto;
}

body {
  overflow-x: clip;
  overscroll-behavior-y: auto;
}

/* Tabular Numerals Utility */
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* --- 4. SHARED UI PRIMITIVES --- */
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  text-decoration: none;
}

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

.ui-btn-primary {
  background: var(--text-primary);
  color: var(--text-inverse);
  border-color: var(--text-primary);
  font-weight: 600;
}

.ui-btn-primary:hover {
  background: var(--text-secondary);
  border-color: var(--text-secondary);
  color: var(--text-inverse);
}

.ui-btn-icon {
  width: 30px;
  height: 30px;
  padding: 0;
}

/* --- 5. SITEWIDE 48-PIXEL TOP COMMAND BAR & MASTER LOGO PRIMITIVE --- */
#topCommandBar,
.cmd-bar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: var(--cmd-bar-height);
  min-height: var(--cmd-bar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  padding: 0 14px;
  gap: 10px;
  z-index: 200;
  -webkit-user-select: none;
  user-select: none;
}

.cmd-left {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  min-width: 0;
  flex-shrink: 0;
}

.cmd-brand-mark {
  height: 20px;
  width: auto;
  aspect-ratio: 1000 / 560;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
  margin: 2px 0;
}

.cmd-brand-title {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.2px;
  color: var(--text-primary);
  white-space: nowrap;
}

.cmd-brand-divider {
  width: 1px;
  height: 14px;
  background: var(--border);
  flex-shrink: 0;
}

.cmd-brand-sub {
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd-center {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  justify-content: center;
}

.cmd-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

@media (max-width: 960px) {
  .cmd-brand-divider,
  .cmd-brand-sub {
    display: none;
  }
}

@media (max-width: 640px) {
  #topCommandBar,
  .cmd-bar {
    padding: 0 12px;
    gap: 8px;
  }
}

/* --- 6. UNIFIED SITEWIDE NAVIGATION (.cmd-brand-link & SAHIBVIRDEE.COM PORTAL CHROME) --- */
.cmd-brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
  flex-shrink: 0;
}

.cmd-crumb-trail {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.cmd-crumb-trail[hidden] {
  display: none;
}

.cmd-crumb-sep {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-muted);
  user-select: none;
}

.cmd-crumb-current {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* SahibVirdee.com Portal Shell (Content & Standalone Pages) */
body.sv-portal {
  --sv-bg: #ffffff;
  --sv-text: #000000;
  --sv-support-mid: #555555;
  --sv-support-low: #e2e2e2;
  --sv-spacing: 1rem;
  --sv-btn-size: 2.75rem;
  --sv-icon-size: 1.5rem;
  --sv-icon-stroke: 2.5;
  --sv-br-ui: 12px;
  --sv-header-height: calc(var(--sv-btn-size) + (2 * var(--sv-spacing)));
  --sv-safe-top: env(safe-area-inset-top, 0px);
  --sv-safe-left: env(safe-area-inset-left, 0px);
  --sv-safe-right: env(safe-area-inset-right, 0px);
  --sv-safe-bottom: env(safe-area-inset-bottom, 0px);
  --sv-floating-right: calc(var(--sv-spacing) + var(--sv-safe-right));
  --sv-floating-top: calc(var(--sv-spacing) + var(--sv-safe-top));
  --sv-floating-bottom: calc(var(--sv-spacing) + var(--sv-safe-bottom));

  --bg-canvas: var(--sv-bg);
  --bg-surface: var(--sv-bg);
  --bg-surface-raised: var(--sv-support-low);
  --bg-surface-hover: var(--sv-support-low);
  --bg-surface-active: var(--sv-support-low);
  --border: var(--sv-support-low);
  --border-subtle: var(--sv-support-low);
  --border-strong: var(--sv-support-mid);
  --text-primary: var(--sv-text);
  --text-secondary: var(--sv-support-mid);
  --text-muted: var(--sv-support-mid);
  --text-faint: var(--sv-support-mid);
  --text-inverse: var(--sv-bg);
  --brand-accent: var(--sv-text);

  background: var(--sv-bg);
  color: var(--sv-text);
  font-feature-settings: "ss01" 0;
  -webkit-font-feature-settings: "ss01" 0;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not(:has(> head > meta[name="color-scheme"][content="light"])) body.sv-portal {
    --sv-bg: #000000;
    --sv-text: #ffffff;
    --sv-support-mid: #8a8a8a;
    --sv-support-low: #111111;
  }
}

:root[data-theme="dark"] body.sv-portal,
[data-theme="dark"] body.sv-portal,
:root:has(> head > meta[name="color-scheme"][content="dark"]) body.sv-portal {
  --sv-bg: #000000;
  --sv-text: #ffffff;
  --sv-support-mid: #8a8a8a;
  --sv-support-low: #111111;
}

.sv-title-row {
  position: relative;
  z-index: 30;
  width: 100%;
  min-height: var(--sv-header-height);
  padding-top: var(--sv-floating-top);
  padding-bottom: var(--sv-spacing);
  padding-left: calc(var(--sv-spacing) + var(--sv-safe-left));
  padding-right: calc(var(--sv-floating-right) + var(--sv-controls-clearance, 7rem));
  display: flex;
  align-items: center;
  background: transparent;
}

.sv-breadcrumb {
  min-width: 0;
  max-width: 100%;
}

.sv-breadcrumb > ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  line-height: 1.1;
}

.sv-breadcrumb > ol > li {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  margin: 0;
  padding: 0;
}

.sv-breadcrumb > ol > li + li::before {
  content: "/" / "";
  margin: 0 0.22em;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--sv-support-mid);
  user-select: none;
}

.sv-brand-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--sv-btn-size);
  min-width: 44px;
  padding: 0;
  text-decoration: none;
  border-radius: 6px;
}

.sv-brand-mark {
  height: 1.75rem;
  width: auto;
  aspect-ratio: 1000 / 560;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
}

.sv-crumb-heading {
  margin: 0;
  padding: 0;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0;
  text-wrap: balance;
}

.sv-crumb-link,
.sv-crumb-heading > a {
  display: inline-flex;
  align-items: center;
  min-height: var(--sv-btn-size);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0;
  text-decoration: none;
  color: var(--sv-text);
  border-radius: 6px;
}

.sv-crumb-link.is-dimmed {
  color: var(--sv-support-mid);
}

.sv-crumb-link:hover {
  color: var(--sv-text);
}

.sv-brand-home:focus-visible,
.sv-crumb-link:focus-visible,
.sv-crumb-heading > a:focus-visible,
.sv-corner-btn:focus-visible,
.sv-jump-top-btn:focus-visible {
  outline: 2px solid var(--sv-text);
  outline-offset: 3px;
}

@media (forced-colors: active) {
  .sv-breadcrumb a[aria-current="page"] {
    text-decoration: underline;
  }
}

@media (max-width: 640px) {
  .sv-breadcrumb > ol > li + li::before,
  .sv-crumb-heading,
  .sv-crumb-link,
  .sv-crumb-heading > a {
    font-size: 1.5rem;
  }

  .sv-brand-mark {
    height: 1.375rem;
  }
}

/* Floating 2.75rem Feather Corner Controls */
.sv-corner-controls {
  position: fixed;
  top: var(--sv-floating-top);
  right: var(--sv-floating-right);
  z-index: 2000;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border-radius: var(--sv-br-ui);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

.sv-corner-controls[hidden] {
  display: none;
}

.sv-corner-btn,
.sv-jump-top-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--sv-btn-size);
  height: var(--sv-btn-size);
  min-width: var(--sv-btn-size);
  min-height: var(--sv-btn-size);
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: var(--sv-text);
  color: var(--sv-bg);
  cursor: pointer;
  text-decoration: none;
  flex: 0 0 var(--sv-btn-size);
}

.sv-corner-controls > :first-child {
  border-top-left-radius: var(--sv-br-ui);
  border-bottom-left-radius: var(--sv-br-ui);
}

.sv-corner-controls > :last-child {
  border-top-right-radius: var(--sv-br-ui);
  border-bottom-right-radius: var(--sv-br-ui);
}

.sv-jump-top-btn {
  position: fixed;
  right: var(--sv-floating-right);
  bottom: var(--sv-floating-bottom);
  z-index: 2000;
  border-radius: var(--sv-br-ui);
}

.sv-jump-top-btn[hidden] {
  display: none;
}

.sv-corner-btn svg,
.sv-jump-top-btn svg,
.sv-back-cursor svg {
  width: var(--sv-icon-size);
  height: var(--sv-icon-size);
  stroke: currentColor;
  stroke-width: var(--sv-icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  display: block;
}

/* Click-Outside Back Zone & Floating Arrow Cursor */
.sv-back-cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2001;
  width: var(--sv-btn-size);
  height: var(--sv-btn-size);
  border-radius: var(--sv-br-ui);
  background: var(--sv-text);
  color: var(--sv-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translate3d(-100px, -100px, 0);
  will-change: transform;
}

.sv-back-cursor.is-visible {
  opacity: 1;
}

body.sv-back-cursor-active,
body.sv-back-cursor-active * {
  cursor: none;
}

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute;
  clip-path: inset(50%);
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  white-space: nowrap;
}
