/* =====================================================
   DESIGN TOKENS — light (default)
   ===================================================== */

:root {
  color-scheme: light;
  /* Brand */
  --teal:        #00b4a6;
  --teal-dark:   #009688;
  --amber:       #f59e0b;
  --red:         #ef4444;
  --green:       #16A34A;

  /* Sidebar (always dark) */
  --sidebar-bg:     #0d1b2a;
  --sidebar-border: #243447;
  --sidebar-text:   #8da4be;
  --sidebar-muted:  #3d5570;
  --sidebar-dim:    #5a7390;

  /* Fonts */
  --mono:    'DM Mono', monospace;
  --display: 'Outfit', system-ui, sans-serif;
  --body:    'Outfit', system-ui, sans-serif;

  /* Elevation — tinted to sidebar navy */
  --shadow-sm: 0 2px 8px rgba(13, 27, 42, 0.08);
  --shadow-md: 0 8px 24px rgba(13, 27, 42, 0.12);
  --shadow-lg: 0 16px 40px rgba(13, 27, 42, 0.16);

  /* Light surface tokens */
  --bg-app:            #F0F2F5;
  --bg-surface:        #FFFFFF;
  --bg-surface-raised: #F8FAFC;
  --bg-surface-hover:  #F1F5F9;
  --bg-input:          #F8FAFC;
  --border:            #E2E8F0;
  --border-subtle:     #F1F5F9;
  --border-warm:       #ddd6c8;
  --text-primary:      #0F172A;
  --text-secondary:    #475569;
  --text-muted:        #94A3B8;
  --text-dim:          #CBD5E1;
  --topbar-bg:         #FFFFFF;
  --topbar-border:     #E2E8F0;
  --flash-bg-notice:   rgba(0,180,166,0.10);
  --flash-bg-alert:    rgba(239,68,68,0.08);
}

/* =====================================================
   DARK THEME — manual toggle
   ===================================================== */

[data-theme="dark"] {
  color-scheme: dark;
  --bg-app:            #0B1220;
  --bg-surface:        #131E2E;
  --bg-surface-raised: #1a2740;
  --bg-surface-hover:  #22345a;
  --bg-input:          #0d1824;
  --border:            #1e3050;
  --border-subtle:     #182840;
  --border-warm:       #1e3050;
  --text-primary:      #E8F0F8;
  --text-secondary:    #8da4be;
  --text-muted:        #6b8aaa;
  --text-dim:          #4a6a8a;
  --topbar-bg:         #0f1c2e;
  --topbar-border:     #1e3050;
  --flash-bg-notice:   rgba(0,180,166,0.15);
  --flash-bg-alert:    rgba(239,68,68,0.12);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg-app:            #0B1220;
    --bg-surface:        #131E2E;
    --bg-surface-raised: #1a2740;
    --bg-surface-hover:  #22345a;
    --bg-input:          #0d1824;
    --border:            #1e3050;
    --border-subtle:     #182840;
    --border-warm:       #1e3050;
    --text-primary:      #E8F0F8;
    --text-secondary:    #8da4be;
    --text-muted:        #6b8aaa;
    --text-dim:          #4a6a8a;
    --topbar-bg:         #0f1c2e;
    --topbar-border:     #1e3050;
    --flash-bg-notice:   rgba(0,180,166,0.15);
    --flash-bg-alert:    rgba(239,68,68,0.12);
  }
}

/* =====================================================
   RESET & BASE
   ===================================================== */

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--body);
  background: var(--bg-app);
  color: var(--text-primary);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0.5rem;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: var(--teal);
  color: #0d1b2a;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 4px;
}

.skip-link:focus {
  left: 0.5rem;
  outline: 2px solid var(--text-primary);
  outline-offset: 2px;
}

/* =====================================================
   LEGACY HEADER (non-shell pages — kept for fallback)
   ===================================================== */

.site-header {
  background: var(--sidebar-bg);
  border-bottom: 3px solid var(--teal);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.site-header .wordmark {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 800;
  color: #F8FAFC;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.site-header .wordmark span { color: var(--teal); }

.site-header nav a {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--sidebar-text);
  text-decoration: none;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 0.15s;
}

.site-header nav a:hover { color: #F8FAFC; }

/* =====================================================
   LAYOUT PRIMITIVES
   ===================================================== */

.page-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 2rem;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 2.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-warm);
}

.page-header h1 {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}

/* =====================================================
   BUTTONS
   ===================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--display);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.btn:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.btn:active { transform: translateY(1px) scale(0.99); }
.btn-primary { background: var(--teal); color: #0d1b2a; }
.btn-primary:hover { background: var(--teal-dark); box-shadow: var(--shadow-sm); }
.btn-ghost { background: transparent; color: var(--teal); border: 1.5px solid var(--teal); }
.btn-ghost:hover { background: rgba(0,180,166,0.08); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; box-shadow: var(--shadow-sm); }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.75rem; }

/* =====================================================
   CARDS — FACILITY
   ===================================================== */

.facility-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.facility-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  position: relative;
}

.facility-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--teal);
  border-radius: 4px 0 0 4px;
}

.facility-card:hover {
  border-color: var(--teal);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.facility-card .card-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.facility-card h2 {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.facility-card .card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  max-width: 28rem;
  margin: 0 auto;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-raised);
  border-radius: 8px;
  color: var(--text-dim);
}

.empty-state h2 {
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  text-wrap: balance;
}

.empty-state p {
  font-size: 0.875rem;
  line-height: 1.55;
  margin-bottom: 1.5rem;
}

/* =====================================================
   DETAIL / FORMS
   ===================================================== */

.detail-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2rem;
}

.detail-card + .detail-card { margin-top: 1.5rem; }

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.section-header h2 {
  font-family: var(--display);
  font-size: 1.2rem;
  color: var(--text-primary);
  margin-top: 0.35rem;
}

.card-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.meta-item .meta-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.meta-item .meta-value {
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 500;
}

.form-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2rem;
  max-width: 560px;
}

.field { margin-bottom: 1.5rem; }

.field label {
  display: block;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="file"],
.field textarea,
.field select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: var(--body);
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: 3px;
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus,
.field textarea:focus,
.field select:focus { border-color: var(--teal); }

.field .field-error {
  font-size: 0.75rem;
  color: var(--red);
  margin-top: 0.3rem;
  font-family: var(--mono);
}

.form-actions { display: flex; gap: 1rem; margin-top: 2rem; }

.resource-list {
  display: grid;
  gap: 0.75rem;
}

.resource-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.status-pill {
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  padding: 0.25rem 0.6rem;
  text-transform: uppercase;
}

.status-pill-pending { background: rgba(245,158,11,0.12); color: var(--amber); }
.status-pill-processing { background: rgba(0,180,166,0.12); color: var(--teal); }
.status-pill-complete { background: rgba(22,163,74,0.12); color: var(--green); }
.status-pill-failed { background: rgba(220,38,38,0.12); color: var(--red); }

.inventory-floor-group + .inventory-floor-group { margin-top: 1.5rem; }

.inventory-floor-title {
  font-family: var(--display);
  font-size: 1rem;
  color: var(--text-primary);
  margin: 1.25rem 0 0.75rem;
}

.inventory-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.inventory-table th,
.inventory-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.inventory-table th {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.inventory-row--edited { background: rgba(245,158,11,0.05); }

.provenance-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.45rem;
  border-radius: 3px;
  margin-right: 0.35rem;
  background: rgba(0,180,166,0.1);
  color: var(--teal-dark);
}

.provenance-badge--manual,
.provenance-badge--edited {
  background: rgba(245,158,11,0.12);
  color: var(--amber);
}

/* =====================================================
   FLASH
   ===================================================== */

.flash {
  padding: 0.75rem 2rem;
  font-size: 0.85rem;
}

.flash-notice { background: var(--flash-bg-notice); color: var(--teal-dark); border-bottom: 1px solid rgba(0,180,166,0.2); }
.flash-alert  { background: var(--flash-bg-alert);  color: var(--red);       border-bottom: 1px solid rgba(239,68,68,0.15); }

/* =====================================================
   APP SHELL — sidebar layout
   ===================================================== */

body.app-shell {
  display: flex;
  flex-direction: row;
  min-height: 100dvh;
  background: var(--bg-app);
}

/* Sidebar — always dark, ignores theme tokens */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sidebar-border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-wordmark {
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 800;
  color: #F8FAFC;
  text-decoration: none;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-wordmark .logo-icon {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--teal);
  flex-shrink: 0;
  --logo-bg: var(--sidebar-bg);
}

.sidebar-wordmark span { color: var(--teal); }

.sidebar-org {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--sidebar-text);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
}

.nav-section-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  padding: 0 0.5rem;
  margin-bottom: 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-family: var(--display);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--sidebar-text);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  margin-bottom: 1px;
}

.nav-item:hover { background: rgba(255,255,255,0.06); color: #d0dce9; }

.nav-item:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}

.nav-item--active {
  background: rgba(0,180,166,0.12);
  color: var(--teal);
}

.nav-item--active svg { stroke: var(--teal); }

.nav-item--disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.nav-badge {
  margin-left: auto;
  font-size: 0.6rem;
  font-family: var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.07);
  color: var(--sidebar-dim);
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.sidebar-user-email {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--sidebar-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.sidebar-signout {
  font-family: var(--display);
  font-size: 0.7rem;
  color: var(--sidebar-muted);
  background: none;
  border: 1px solid var(--sidebar-border);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}

.sidebar-signout:hover { color: #F8FAFC; border-color: var(--sidebar-dim); }

.sidebar-build { display: flex; gap: 0.5rem; align-items: center; }

.build-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sidebar-muted);
}

.build-value {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--sidebar-dim);
}

/* Main area */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  padding: 0 2rem;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.topbar-breadcrumb {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}

.breadcrumb-root { color: var(--text-primary); font-weight: 500; }

.topbar-actions { display: flex; gap: 0.75rem; align-items: center; }

.main-content {
  padding: 2rem;
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin-inline: auto;
}

/* =====================================================
   THEME TOGGLE BUTTON
   ===================================================== */

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-surface-raised);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.theme-toggle svg { display: block; }

/* show/hide sun vs moon icons based on theme */
.icon-sun  { display: none !important; }
.icon-moon { display: block !important; }

[data-theme="dark"] .icon-sun  { display: block !important; }
[data-theme="dark"] .icon-moon { display: none !important; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun  { display: block !important; }
  :root:not([data-theme="light"]) .icon-moon { display: none !important; }
}

/* =====================================================
   DASHBOARD
   ===================================================== */

.dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.75rem;
}

.dashboard-title {
  font-family: var(--display);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.035em;
  line-height: 1.15;
  text-wrap: balance;
}

.dashboard-subtitle {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.dashboard-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.85rem;
  margin-top: 0.2rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-dot--ok { background: var(--green); }

.status-text {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}

/* Stat row */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  border-top: 3px solid var(--teal);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.stat-card:not(.stat-card--muted):hover {
  box-shadow: var(--shadow-sm);
  border-color: rgba(0, 180, 166, 0.35);
}

.stat-card--muted { border-top-color: var(--border); }

.stat-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.stat-value {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-card--muted .stat-value { color: var(--text-dim); }

.stat-sub {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.stat-sub a { color: var(--teal); text-decoration: none; }
.stat-sub a:hover { text-decoration: underline; }

/* Dashboard two-panel grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.dashboard-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.panel-header {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface-raised);
}

.panel-title {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* Action list */
.action-list { padding: 0.5rem 0; }

.action-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.1s;
  cursor: pointer;
}

.action-item:last-child { border-bottom: none; }
.action-item:hover:not(.action-item--disabled) { background: var(--bg-surface-hover); }
.action-item--disabled { opacity: 0.45; cursor: default; pointer-events: none; }

.action-icon {
  width: 32px;
  height: 32px;
  background: var(--bg-surface-raised);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.action-item:hover:not(.action-item--disabled) .action-icon {
  background: rgba(0,180,166,0.1);
  color: var(--teal);
}

.action-body { flex: 1; min-width: 0; }

.action-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.15rem;
}

.action-desc {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.action-arrow { color: var(--text-dim); flex-shrink: 0; }
.action-item:hover:not(.action-item--disabled) .action-arrow { color: var(--teal); }

.action-soon {
  font-family: var(--mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: var(--bg-surface-raised);
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Workflow steps */
.workflow-steps { padding: 0.5rem 0; }

.workflow-step {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.workflow-step:last-child { border-bottom: none; }

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  flex-shrink: 0;
}

.workflow-step--done .step-num {
  background: rgba(0,180,166,0.12);
  color: var(--teal);
  border: 1.5px solid var(--teal);
}

.workflow-step--pending .step-num {
  background: var(--bg-surface-raised);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}

.step-body { flex: 1; }

.step-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.15rem;
}

.workflow-step--pending .step-name { color: var(--text-muted); }

.step-desc {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-dim);
}

.step-badge {
  font-family: var(--mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  flex-shrink: 0;
}

.step-badge--active {
  background: rgba(22,163,74,0.1);
  color: var(--green);
  border: 1px solid rgba(22,163,74,0.25);
}

.step-badge--soon {
  background: var(--bg-surface-raised);
  color: var(--text-muted);
}

/* =====================================================
   PAGE-LEVEL: adjust existing page-container for new shell
   ===================================================== */

.app-shell .page-container {
  max-width: none;
  margin: 0;
  padding: 2rem;
}

.app-shell .page-header { margin-bottom: 1.75rem; }

/* =====================================================
   HAMBURGER BUTTON (mobile only)
   ===================================================== */

.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-surface-raised);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.hamburger:hover { background: var(--bg-surface-hover); color: var(--text-primary); }

.hamburger-icon  { display: block; }
.hamburger-close { display: none; }

.hamburger[aria-expanded="true"] .hamburger-icon  { display: none; }
.hamburger[aria-expanded="true"] .hamburger-close { display: block; }

/* =====================================================
   SIDEBAR OVERLAY (mobile)
   ===================================================== */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.sidebar-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* =====================================================
   RESPONSIVE — tablet (< 1024px)
   ===================================================== */

@media (max-width: 1024px) {
  .stat-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* =====================================================
   RESPONSIVE — mobile (< 768px)
   ===================================================== */

@media (max-width: 767px) {
  /* Off-canvas sidebar */
  .hamburger { display: flex !important; }

  .sidebar-overlay { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 260px;
    min-width: 260px;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  body.app-shell {
    flex-direction: column;
  }

  /* Stats: 1-col on mobile */
  .stat-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* Dashboard panels: stack */
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  /* Main content: tighter padding */
  .main-content {
    padding: 1rem;
  }

  .app-shell .page-container {
    padding: 1rem;
  }

  /* Dashboard header: stack on very small */
  .dashboard-header {
    flex-direction: column;
    gap: 0.75rem;
  }

  /* Form card: full-width */
  .form-card {
    max-width: 100%;
  }

  /* Topbar: tighten */
  .topbar {
    padding: 0 1rem;
  }

  .topbar-breadcrumb {
    font-size: 0.7rem;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Touch targets: 44px min height */
  .nav-item {
    min-height: 44px;
  }

  .action-item {
    min-height: 44px;
  }

  .btn {
    min-height: 44px;
    padding: 0.6rem 1.2rem;
  }

  .btn-sm {
    min-height: 36px;
  }

  /* Facility grid: single column on narrow */
  .facility-grid {
    grid-template-columns: 1fr;
  }

  /* Meta grid: 1-col */
  .meta-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Workflow step padding */
  .workflow-step {
    padding: 0.85rem 1rem;
  }

  .action-item {
    padding: 0.85rem 1rem;
  }
}

/* =====================================================
   AUTH PAGES (login, password reset)
   ===================================================== */

.auth-body {
  background: var(--sidebar-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}

.auth-page {
  width: 100%;
  max-width: 420px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.auth-brand {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.auth-brand .logo-icon {
  width: 2.5rem;
  height: 2.5rem;
  color: var(--teal);
  --logo-bg: var(--bg-base, #0d1b2a);
}

.auth-wordmark {
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 800;
  color: #F8FAFC;
  letter-spacing: -0.03em;
}

.auth-wordmark span { color: var(--teal); }

.auth-tagline {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--sidebar-text);
  letter-spacing: 0.06em;
  margin-top: 0.4rem;
  text-transform: uppercase;
}

.auth-card .field { margin-bottom: 0; }

.auth-card .field label {
  display: block;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.auth-card .field input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-family: var(--body);
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: 4px;
  outline: none;
  transition: border-color 0.15s;
}

.auth-card .field input:focus { border-color: var(--teal); }
.auth-card .field input::placeholder { color: var(--text-dim); }

.auth-remember {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.auth-remember input[type="checkbox"] { accent-color: var(--teal); }

.auth-submit {
  width: 100%;
  justify-content: center;
  font-size: 0.875rem;
  padding: 0.75rem;
}

.auth-links {
  text-align: center;
  font-size: 0.8rem;
}

.auth-links a {
  color: var(--teal);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.auth-links a:hover { text-decoration: underline; }

.auth-footer {
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.auth-footer-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--sidebar-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.auth-footer-sep { color: var(--sidebar-muted); font-size: 0.7rem; }

/* =====================================================
   LANDING PAGE
   ===================================================== */

.landing-body {
  background: var(--sidebar-bg);
  min-height: 100dvh;
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  color: #e2eaf4;
  position: relative;
}

.landing-body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.landing-body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse 80% 60% at 20% 0%, rgba(0, 180, 166, 0.12), transparent 55%),
              radial-gradient(ellipse 60% 50% at 100% 100%, rgba(0, 100, 120, 0.15), transparent 50%);
}

.lp-wrap {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* Nav */
.lp-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.lp-wordmark {
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 800;
  color: #F8FAFC;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lp-wordmark .logo-icon {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--teal);
  --logo-bg: var(--lp-bg, #0a1628);
}

.lp-wordmark span { color: var(--teal); }

/* Hero */
.lp-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 5rem 0 4rem;
  max-width: 720px;
}

.lp-eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 1.5rem;
}

.lp-headline {
  font-family: var(--display);
  font-size: clamp(2.5rem, 6vw, 3.75rem);
  font-weight: 700;
  color: #F8FAFC;
  letter-spacing: -0.045em;
  line-height: 1.08;
  margin-bottom: 1.75rem;
  text-wrap: balance;
}

.lp-sub {
  font-size: 1.05rem;
  color: #8da4be;
  line-height: 1.7;
  max-width: 38ch;
  margin-bottom: 2.5rem;
  text-wrap: pretty;
}

.lp-cta { display: flex; gap: 1rem; flex-wrap: wrap; }

.lp-cta .btn-primary {
  background: var(--teal);
  color: #0d1b2a;
  font-weight: 700;
  padding: 0.85rem 2rem;
  font-size: 0.9rem;
}

.lp-cta .btn-primary:hover {
  background: var(--teal-dark);
  box-shadow: 0 8px 28px rgba(0, 180, 166, 0.25);
}

/* Features — lead + two-column (not three equal towers) */
.lp-features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem 1.5rem;
  padding: 3rem 0 4rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.lp-feature {
  padding: 1.5rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.lp-feature:hover {
  border-color: rgba(0, 180, 166, 0.35);
  background: rgba(255,255,255,0.05);
}

.lp-feature--lead {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.25rem 1.75rem;
  align-items: start;
  padding: 2rem;
}

.lp-feature-icon {
  width: 40px;
  height: 40px;
  background: rgba(0,180,166,0.1);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
  margin-bottom: 1rem;
}

.lp-feature-title {
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 700;
  color: #F8FAFC;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

.lp-feature-desc {
  font-size: 0.82rem;
  color: #6b8aaa;
  line-height: 1.6;
}

/* Footer */
.lp-footer {
  padding: 1.5rem 0;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lp-footer-copy {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: #3d5570;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lp-footer-sep { color: #3d5570; font-size: 0.7rem; }

/* Responsive */
@media (max-width: 767px) {
  .lp-features { grid-template-columns: 1fr; }
  .lp-feature--lead { grid-template-columns: 1fr; }
  .lp-hero { padding: 3rem 0 2rem; }
}

/* Sheet Viewer */
.sheet-viewer {
  position: relative;
  display: inline-block;
  max-width: 100%;
  overflow: auto;
}

.sheet-image {
  display: block;
  max-width: 100%;
  height: auto;
}

.ocr-box {
  position: absolute;
  border: 1px solid rgba(59, 130, 246, 0.7);
  background: rgba(59, 130, 246, 0.08);
  cursor: default;
  pointer-events: all;
}

.ocr-box:hover {
  border-color: rgba(245, 158, 11, 0.9);
  background: rgba(245, 158, 11, 0.15);
  z-index: 10;
}

/* ── Calibration / utility ─────────────────────────────────── */
.hidden { display: none !important; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: .125rem .5rem;
  border-radius: 9999px;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.4;
}
.badge-success { background: rgba(22,163,74,.15); color: var(--green); }
.badge-info { background: rgba(0,180,166,.15); color: var(--teal-dark); }
.badge-warning { background: rgba(245,158,11,.15); color: var(--amber); }
.badge-danger { background: rgba(239,68,68,.15); color: var(--red); }

.form-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .375rem .625rem;
  font-size: .875rem;
  color: var(--text-primary);
}
.form-input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,180,166,.2);
}
