@import url('responsive.css');
/* SolSearch — Design Tokens
   Source of truth: DESIGN.md
   Do not edit colors here without updating DESIGN.md. */

:root {
  /* Sidenav design system */
  --color-deep:          #1A3FA0;  /* sidenav background — royal blue */
  --sidebar-width:       220px;    /* expanded width */
  --sidebar-col:         60px;     /* collapsed icon-rail width */

  /* Colors — Identity */
  --color-sky:           #1E90FF;  /* active nav state — SCADA blue pill */
  --color-navy:          #1e3a5f;
  --color-navy-sb:       #1e3a5f;
  --color-blue:          #3498db;
  --color-blue-deep:     #2980b9;

  /* Colors — Surfaces */
  --color-bg:            #edf0f4;
  --color-surface:       #ffffff;
  --color-surface-tinted: #f4f6f9;
  --color-navy-50:       rgba(30, 58, 95, 0.04);
  --color-blue-tint:     rgba(52, 152, 219, 0.08);

  /* Colors — Ink */
  --color-ink:           #2c3e50;
  --color-ink-muted:     #5a6c7d;

  /* Colors — Borders */
  --color-border:        #e1e8ed;
  --color-border-muted:  #bdc3c7;

  /* Colors — Severity (semantic only; never decorative) */
  --color-critical:      #e74c3c;
  --color-critical-bg:   rgba(231, 76, 60, 0.10);
  --color-critical-text: #c0392b;

  --color-warning:       #f39c12;
  --color-warning-bg:    rgba(243, 156, 18, 0.10);
  --color-warning-text:  #d68910;

  --color-caution:       #f1c40f;
  --color-caution-bg:    rgba(241, 196, 15, 0.10);
  --color-caution-text:  #7d6608;

  --color-ok:            #27ae60;
  --color-ok-bg:         rgba(39, 174, 96, 0.10);
  --color-ok-text:       #1e8449;

  /* Colors — Dark context (guide modal, notes panel) */
  --color-surface-dark:        #0e1f36;   /* deep navy dark — replaces #0f172a slate */
  --color-surface-dark-raised: #172d4a;   /* elevated dark panel — replaces #1e293b slate */
  --color-border-dark:         #2a4060;   /* border on dark — replaces #334155 slate */
  --color-ink-dark-bright:     #dde8f2;   /* headings on dark — replaces #e2e8f0 slate */
  --color-ink-dark:            #a8c0d8;   /* body text on dark — replaces #94a3b8 slate */
  --color-ink-dark-muted:      #6b8aaa;   /* muted text on dark — replaces #64748b slate */
  --color-ink-dark-subtle:     #4a6a8a;   /* subtle on dark — replaces #475569 slate */

  /* Colors — Accent orange (pending state, stage-1 thermal detection) */
  --color-orange:              #f06226;
  --color-orange-bg:           rgba(240, 98, 38, 0.12);
  --color-orange-text:         #c04a16;

  /* Typography scale — 1.2× modular ratio, html root = 15px
     label 0.8rem  → 12px   captions, secondary meta
     xs    0.867rem → 13px  secondary UI, table meta
     sm    0.933rem → 14px  sidenav labels, compact UI
     base  1rem    → 15px   body text
     h3    1.133rem → 17px  card headings (clear step above body)
     lg    1.333rem → 20px  sub-section leads
     h2    1.6rem  → 24px   section titles
     xl    1.867rem → 28px  page-level subheadings
     h1    2.2rem  → 33px   page titles                        */
  --font-size-base:  1rem;
  --font-size-sm:    0.933rem;
  --font-size-xs:    0.867rem;
  --font-size-lg:    1.333rem;
  --font-size-xl:    1.867rem;
  --font-size-h1:    2.2rem;
  --font-size-h2:    1.6rem;
  --font-size-h3:    1.133rem;
  --font-size-label: 0.8rem;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semi:   600;
  --font-weight-bold:   700;

  /* Radius */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Spacing */
  --space-xs: 6px;
  --space-sm: 12px;
  --space-md: 18px;
  --space-lg: 28px;
  --space-xl: 48px;

  /* Glassmorphism — light-mode: opaque white cards on grey page */
  --glass-bg: rgba(255, 255, 255, 0.92);
  --glass-bg-hover: rgba(255, 255, 255, 1);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-blur: 16px;
  --glass-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);

  /* Shadows */
  --shadow-card:   0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-raised: 0 4px 16px rgba(0, 0, 0, 0.10);
  --shadow-modal:  0 8px 32px rgba(0, 0, 0, 0.18);
  --shadow-btn:    0 2px 8px rgba(0, 0, 0, 0.12);

  /* Card surface — white pops clearly against #edf0f4 page bg */
  --color-card:        #ffffff;
  --shadow-card-strong: 0 1px 4px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.07);

  /* Section grouping — subtle background separates content areas */
  --color-section-bg:     rgba(255, 255, 255, 0.55);
  --color-section-border: rgba(0, 0, 0, 0.06);

  /* Z-index scale */
  --z-dropdown:       100;
  --z-sticky:         200;
  --z-modal-backdrop: 300;
  --z-modal:          400;
  --z-toast:          500;
  --z-tooltip:        600;

  /* Motion */
  --duration-fast: 150ms;
  --duration-base: 200ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark mode — toggled via html.dark-mode class; default is always light */
html.dark-mode {
  --color-bg:              #0a1628;
  --color-surface:         #0e1f36;
  --color-surface-tinted:  #172d4a;
  --color-navy-50:         rgba(52, 152, 219, 0.06);
  --color-blue-tint:       rgba(52, 152, 219, 0.12);
  --color-ink:             #dde8f2;
  --color-ink-muted:       #a8c0d8;
  --color-border:          #2a4060;
  --color-border-muted:    #1e3050;
  --color-navy:            #7db3e8;
  /* Dark mode card surface — slightly elevated above page bg */
  --color-card:            #0e1f36;
  --shadow-card-strong:     0 2px 12px rgba(0,0,0,0.30);
  /* Dark mode sections — transparent so existing dark layout is preserved */
  --color-section-bg:     transparent;
  --color-section-border: transparent;
  /* Dark mode glassmorphism */
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-bg-hover: rgba(255, 255, 255, 0.10);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-shadow: 0 4px 24px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Global base — applies to every page that links this file */
html {
  font-size: 15px;
  font-optical-sizing: auto;
}

body {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: 1.6;
  color: var(--color-ink);
  background: var(--color-bg);
  font-kerning: normal;
}

/* ── Heading hierarchy ───────────────────────────────── */
.page-title, h1 {
  font-size: var(--font-size-h1);
  font-weight: var(--font-weight-bold);
  color: var(--color-navy);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}
.section-title, h2 {
  font-size: var(--font-size-h2);
  font-weight: var(--font-weight-semi);
  color: var(--color-navy);
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}
.card-title, h3 {
  font-size: var(--font-size-h3);
  font-weight: var(--font-weight-semi);
  color: var(--color-ink);
  line-height: 1.4;
  margin-bottom: 10px;
}
.section-label {
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-semi);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-ink-muted);
  margin-bottom: 10px;
  display: block;
}

/* ── Numeric data — tabular figures align decimal points ── */
.stat-value, .stat-card .val, [class*="stat-num"],
td[class*="num"], td[class*="count"], td[class*="amount"],
.metric-value, .badge-count {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ── Card containment ────────────────────────────────── */
/* Visible 1px edge so cards stand out from the #f5f7fa page background */
.card, .stat-card, .project-card, .upload-card {
  border: 1px solid var(--color-border) !important;
}

/* Global topbar — applies to every page */
.topbar {
  height: 54px !important;
  padding: 0 24px !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06) !important;
}
.topbar-title {
  font-size: var(--font-size-h3) !important;
  font-weight: var(--font-weight-semi) !important;
  color: var(--color-navy) !important;
  letter-spacing: -0.01em !important;
}

/* ── Micro-interactions ──────────────────────────────── */
/* Focus ring — replaces browser default, consistent across all controls */
:focus-visible {
  outline: 2px solid var(--color-blue);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Button press + lift — satisfying feedback on every action */
button,
.btn,
.topnav-item,
.topnav-logout,
.topnav-icon-btn,
a.btn,
input[type="button"],
input[type="submit"] {
  transition:
    transform       120ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow      120ms cubic-bezier(0.16, 1, 0.3, 1),
    background-color 150ms ease,
    color           150ms ease;
}
button:hover:not(:disabled),
.btn:hover:not(:disabled),
a.btn:hover {
  transform: translateY(-1px);
}
button:active:not(:disabled),
.btn:active:not(:disabled),
a.btn:active {
  transform: translateY(1px);
  transition-duration: 60ms;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Card hover lift + tinted background — portfolio-style semantic tints */
.card,
.stat-card,
.project-card,
.upload-card,
.info-card,
.summary-card,
.metric-card {
  transition:
    transform    200ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow   200ms cubic-bezier(0.16, 1, 0.3, 1),
    background   200ms ease,
    border-color 200ms ease;
}
.card:hover,
.stat-card:hover,
.project-card:hover,
.upload-card:hover,
.info-card:hover,
.summary-card:hover,
.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-raised) !important;
  background: var(--color-blue-tint) !important;
  border-color: rgba(52, 152, 219, 0.25) !important;
}

/* Semantic card hover tints — respective color per card type */
.stat-card.ok:hover, .summary-card.online:hover, .summary-card.pr:hover,
.stat-card.success:hover, .card.success:hover {
  background: var(--color-ok-bg) !important;
  border-color: rgba(39, 174, 96, 0.3) !important;
}
.stat-card.critical:hover, .summary-card.alarms:hover,
.stat-card.danger:hover, .card.danger:hover {
  background: var(--color-critical-bg) !important;
  border-color: rgba(231, 76, 60, 0.3) !important;
}
.stat-card.warning:hover, .card.warning:hover {
  background: var(--color-warning-bg) !important;
  border-color: rgba(243, 156, 18, 0.3) !important;
}
.summary-card.power:hover, .stat-card.info:hover, .card.info:hover {
  background: var(--color-blue-tint) !important;
  border-color: rgba(52, 152, 219, 0.3) !important;
}
.summary-card.energy:hover {
  background: rgba(124, 58, 237, 0.08) !important;
  border-color: rgba(124, 58, 237, 0.3) !important;
}

/* Input / select / textarea — visible outline so fields stand out */
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], input[type="tel"],
input[type="url"], input[type="date"], input[type="datetime-local"],
input[type="month"], input[type="week"], input[type="time"],
input:not([type]),
select, textarea {
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-sm) !important;
  background: var(--color-card) !important;
  transition:
    border-color 150ms ease,
    box-shadow   150ms ease;
  font-weight: 400;
}
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus,
input[type="number"]:focus, input[type="search"]:focus, input[type="tel"]:focus,
input[type="url"]:focus, input[type="date"]:focus, input[type="datetime-local"]:focus,
input[type="month"]:focus, input[type="week"]:focus, input[type="time"]:focus,
input:not([type]):focus,
select:focus, textarea:focus {
  border-color: var(--color-blue) !important;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15) !important;
}

/* Heading wrap — quiet craft: even line lengths, no orphans */
h1, h2, h3, .page-title, .section-title, .card-title {
  text-wrap: balance;
}

/* ── Section differentiation — light theme needs explicit grouping ── */
.collapsible-section,
.dashboard-section,
.content-section,
.section-block {
  background: var(--color-section-bg);
  border: 1px solid var(--color-section-border);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 16px;
}

/* ── Motion tokens ── */
:root {
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo:  cubic-bezier(0.16, 1, 0.3, 1);
  --duration-micro: 120ms;
  --duration-fast:  180ms;
  --duration-med:   250ms;
  --duration-slow:  400ms;
}

/* ── Global entrance — page wrapper resolves in, not pops in ── */
.page-wrapper {
  animation: pageResolve 250ms var(--ease-out-expo) both;
}
@keyframes pageResolve {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Card entrance stagger — cards fade-up on page load ── */
@keyframes cardEnter {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card, .stat-card, .project-card, .upload-card, .info-card, .summary-card, .metric-card {
  animation: cardEnter var(--duration-slow) var(--ease-out-expo) both;
}
.card:nth-child(1), .stat-card:nth-child(1) { animation-delay: 0ms; }
.card:nth-child(2), .stat-card:nth-child(2) { animation-delay: 60ms; }
.card:nth-child(3), .stat-card:nth-child(3) { animation-delay: 120ms; }
.card:nth-child(4), .stat-card:nth-child(4) { animation-delay: 180ms; }
.card:nth-child(5), .stat-card:nth-child(5) { animation-delay: 240ms; }
.card:nth-child(6), .stat-card:nth-child(6) { animation-delay: 300ms; }
.card:nth-child(n+7), .stat-card:nth-child(n+7) { animation-delay: 350ms; }

/* ── Collapsible section expand — smooth reveal ── */
@keyframes sectionExpand {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.collapsible-section.open {
  animation: sectionExpand var(--duration-med) var(--ease-out-expo) both;
}

/* ── Table row stagger ── */
@keyframes rowFade {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
tbody tr {
  animation: rowFade var(--duration-med) var(--ease-out-quart) both;
}
tbody tr:nth-child(1)  { animation-delay: 0ms; }
tbody tr:nth-child(2)  { animation-delay: 30ms; }
tbody tr:nth-child(3)  { animation-delay: 60ms; }
tbody tr:nth-child(4)  { animation-delay: 90ms; }
tbody tr:nth-child(5)  { animation-delay: 120ms; }
tbody tr:nth-child(n+6) { animation-delay: 150ms; }

/* ── Sidebar nav item hover slide ── */
.sn-item, .sn-action {
  transition: background var(--duration-micro) ease,
              color var(--duration-micro) ease,
              transform var(--duration-fast) var(--ease-out-expo);
}
.sn-item:hover, .sn-action:hover {
  transform: translateX(3px);
}
.sn-item.active { transform: none; }

/* ── Dropdown / sub-dropdown reveal ── */
@keyframes dropSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.sn-dropdown.open, .sn-sub-dropdown.open {
  animation: dropSlide var(--duration-fast) var(--ease-out-expo) both;
}

/* ── Modal / overlay entrance ── */
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes backdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal, .modal-content, [class*="modal"] dialog[open] {
  animation: modalIn var(--duration-slow) var(--ease-out-expo) both;
}
#sidenav-overlay.active {
  animation: backdropIn var(--duration-med) ease both;
}

/* ── Button press — tactile scale feedback ── */
button:active:not(:disabled),
.btn:active:not(:disabled),
a.btn:active {
  transform: scale(0.97);
  transition-duration: 60ms;
}

/* ── Input focus glow transition ── */
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], input[type="tel"],
input[type="url"], input[type="date"], input[type="datetime-local"],
input:not([type]),
select, textarea {
  transition: border-color var(--duration-fast) ease,
              box-shadow var(--duration-fast) ease;
}

/* ── Badge / status pulse for critical items ── */
@keyframes criticalPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.3); }
  50%      { box-shadow: 0 0 0 6px rgba(231, 76, 60, 0); }
}
.stat-card.critical, .stat-card.danger,
.badge-critical, [class*="severity-critical"] {
  animation: criticalPulse 2.5s ease-in-out 2;
}

/* ── Tooltip fade ── */
@keyframes tipFade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
[data-tooltip]:hover::after, .tooltip.show, [role="tooltip"] {
  animation: tipFade var(--duration-fast) var(--ease-out-quart) both;
}

/* ── Smooth scroll for the whole app ── */
html { scroll-behavior: smooth; }

/* ── Skeleton shimmer — loading placeholder for cards and rows ── */
@keyframes shimmer {
  from { background-position: -200% 0; }
  to   { background-position:  200% 0; }
}
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface-tinted) 25%,
    var(--color-border) 50%,
    var(--color-surface-tinted) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
  color: transparent !important;
  pointer-events: none;
}

/* ── Blanket reduced-motion guard — covers every template ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration:       0.01ms !important;
    animation-iteration-count: 1     !important;
    transition-duration:      0.01ms !important;
    scroll-behavior:          auto   !important;
  }
}

/* Full-width content — remove narrow centered columns on all app pages */
.main-content,
.container,
.page-wrapper {
  max-width: none !important;
  width: 100% !important;
}

/* ── Global button system ─────────────────────────────────
   Uses !important so tokens.css wins over per-template <style> blocks
   which load after this file in the cascade.
   Excludes topnav controls (handled separately in each template).      */

/* .btn base — shape and layout only (no color/border overrides here so per-instance
   inline color overrides like border-color:#a855f7 on the Notes button still work).
   Excludes <select> from display:inline-flex since flex doesn't apply to selects.  */
.btn:not(select) {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-sm) !important;
  font-weight: 600 !important;
  cursor: pointer;
  text-decoration: none !important;
  border-style: solid !important;
  border-width: 1.5px !important;
  border-color: transparent;
  white-space: nowrap;
}

/* Filled variants — !important needed to beat per-template <style> blocks */
.btn-primary {
  background: var(--color-blue) !important;
  color: #fff !important;
  border-color: var(--color-blue) !important;
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-blue-deep) !important;
  border-color: var(--color-blue-deep) !important;
}

/* Outline default — blue, but WITHOUT !important on color/border-color so inline
   style="border-color:#a855f7; color:#a855f7" overrides still win per-instance.  */
.btn-outline {
  background: transparent;
  border-color: var(--color-blue);
  color: var(--color-blue);
}
.btn-outline:hover:not(:disabled) {
  background: var(--color-blue-tint);
}

.btn-success {
  background: var(--color-ok) !important;
  color: #fff !important;
  border-color: var(--color-ok) !important;
}
.btn-success:hover:not(:disabled) { background: var(--color-ok-text) !important; border-color: var(--color-ok-text) !important; }

.btn-warning {
  background: var(--color-warning) !important;
  color: #fff !important;
  border-color: var(--color-warning) !important;
}
.btn-warning:hover:not(:disabled) { background: var(--color-warning-text) !important; border-color: var(--color-warning-text) !important; }

.btn-danger {
  background: var(--color-critical) !important;
  color: #fff !important;
  border-color: var(--color-critical) !important;
}
.btn-danger:hover:not(:disabled) { background: var(--color-critical-text) !important; border-color: var(--color-critical-text) !important; }

/* ── Card contrast ─────────────────────────────────────────
   White card surface pops against #edf0f4 page background.
   Dark mode uses --color-card: #0e1f36 (overridden above).  */

.card, .stat-card, .project-card, .upload-card, .info-card, .summary-card, .metric-card {
  background: var(--color-card) !important;
  border: 1.5px solid var(--color-border) !important;
  box-shadow: var(--shadow-card-strong) !important;
  border-radius: var(--radius-md) !important;
}

/* ── Global mobile responsiveness ───────────────────────── */
@media (max-width: 768px) {
  /* Tables: horizontal scroll instead of overflow */
  table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  thead, tbody, tr { min-width: max-content; }

  /* Grids: collapse to single column */
  .stats-grid, .grid-2, .grid-3, .grid-4,
  [class*="-grid"]:not(.topnav) {
    grid-template-columns: 1fr !important;
  }

  /* Common flex header rows: wrap instead of overflow */
  .page-header, .section-header, .topbar-inner,
  .header-actions, .filter-row, .search-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Touch targets: ensure min 44px height */
  .btn, button:not(.topnav-icon-btn):not(.topnav-hamburger),
  a.btn, input[type="submit"] {
    min-height: 44px;
  }

  /* Auth two-column layouts: stack to single column */
  .auth-grid, .login-container, .register-container {
    grid-template-columns: 1fr !important;
  }
  .login-branding, .auth-branding { display: none !important; }

  /* Cards: full width */
  .card, .stat-card, .project-card { width: 100%; }

  /* Typography: tighten headings on mobile */
  h1, .page-title { font-size: 1.6rem !important; letter-spacing: -0.01em !important; }
  h2, .section-title { font-size: 1.25rem !important; }

  /* Page padding: reduce on mobile */
  .page-wrapper, .main-content, .content-wrapper {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* Modal dialogs: full width */
  .modal-body, .modal-content, [class*="modal-"] {
    width: 96vw !important;
    max-width: 96vw !important;
    margin: 0 auto;
  }

  /* Hide non-essential columns in dense tables */
  .col-hide-mobile { display: none !important; }

  /* Flex rows that must not overflow: wrap */
  .topnav-actions { gap: 4px; }

  /* Step wizard: scroll horizontally */
  .steps-row, .wizard-steps, .step-buttons {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }
}

/* Mobile topbar is always injected by sidenav.js but hidden on desktop */
.mobile-topbar { display: none; }

/* ── Sidenav item base style ─────────────────────────────── */
.sidenav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  border-radius: var(--radius-md);
  margin-bottom: 4px;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 500;
}

/* ── Sidenav collapse toggle (desktop only) ──────────────── */
.sidenav-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border: none;
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, transform 0.25s cubic-bezier(0.16,1,0.3,1);
  font-size: 12px;
}
.sidenav-collapse-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* Collapsed state — icon-only rail */
body.sidenav-collapsed { --sidenav-width: 64px; }
body.sidenav-collapsed .sidenav { width: var(--sidebar-col, 60px) !important; overflow: hidden; }
body.sidenav-collapsed .sidenav-collapse-btn { transform: rotate(180deg); }

/* Hide text labels when collapsed */
body.sidenav-collapsed .sidenav-item span,
body.sidenav-collapsed .sidenav-action span,
body.sidenav-collapsed .sidenav-user-name,
body.sidenav-collapsed .sidenav-user-role { display: none !important; }

/* Centre icons in items */
body.sidenav-collapsed .sidenav-item,
body.sidenav-collapsed .sidenav-action {
  justify-content: center;
  padding-left: 0 !important;
  gap: 0;
}
.sidenav-item.active {
  color: #fff !important;
  background: var(--color-sky) !important;
  border-left: none !important;
  border-radius: 8px !important;
  margin: 0 8px !important;
  padding: 10px 12px !important;
}
body.sidenav-collapsed .sidenav-item.active {
  color: #fff !important;
  background: var(--color-sky) !important;
  margin: 0 4px !important;
  border-radius: 8px !important;
}
body.sidenav-collapsed .sidenav-user { justify-content: center; padding: 10px 0; }
body.sidenav-collapsed .sidenav-user-info { display: none !important; }

/* Tooltip on hover when collapsed */
body.sidenav-collapsed .sidenav-item,
body.sidenav-collapsed .sidenav-action { position: relative; }
body.sidenav-collapsed .sidenav-item::after,
body.sidenav-collapsed .sidenav-action::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%; transform: translateY(-50%);
  background: #1a1a2e; color: #fff;
  font-size: 12px; font-weight: 500;
  white-space: nowrap;
  padding: 5px 10px; border-radius: 6px;
  pointer-events: none; opacity: 0;
  transition: opacity 0.15s; z-index: 400;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
body.sidenav-collapsed .sidenav-item:hover::after,
body.sidenav-collapsed .sidenav-action:hover::after { opacity: 1; }

/* ── Sidenav mobile — collapsed icon-rail by default, toggle expands ── */
@media (max-width: 768px) {
  /* No topbar — sidenav icon-rail sits on the left */
  body {
    padding-left: var(--sidebar-col, 60px) !important;
    padding-top: 0 !important;
  }

  /* Sidenav stays visible as a 60px icon rail */
  .sidenav {
    width: var(--sidebar-col, 60px) !important;
    transform: none !important;
    transition: width 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  }

  /* Collapse text/labels just like desktop collapsed state */
  .sidenav .sidenav-brand img { opacity: 0; width: 0; }
  .sidenav .sidenav-item span,
  .sidenav .sidenav-item-body,
  .sidenav .sidenav-action span,
  .sidenav .sidenav-back span,
  .sidenav .sidenav-back-label,
  .sidenav .sidenav-user-info { opacity: 0; width: 0; overflow: hidden; }
  .sidenav .sidenav-item,
  .sidenav .sidenav-action { justify-content: center; padding: 10px 0; gap: 0; border-left-width: 0; }
  .sidenav .sidenav-back { justify-content: center; padding: 10px 0; }
  .sidenav .sidenav-user { justify-content: center; padding: 8px; }

  /* When open (toggle clicked on mobile) — expand to full width */
  .sidenav.mobile-open {
    width: 260px !important;
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    z-index: 350;
  }

  /* Restore text when expanded */
  .sidenav.mobile-open .sidenav-brand img { opacity: 1; width: auto; }
  .sidenav.mobile-open .sidenav-item span,
  .sidenav.mobile-open .sidenav-item-body,
  .sidenav.mobile-open .sidenav-action span,
  .sidenav.mobile-open .sidenav-back span,
  .sidenav.mobile-open .sidenav-back-label,
  .sidenav.mobile-open .sidenav-user-info { opacity: 1; width: auto; overflow: visible; }
  .sidenav.mobile-open .sidenav-item,
  .sidenav.mobile-open .sidenav-action { justify-content: flex-start; padding: 10px 14px; gap: 12px; border-left-width: 3px; }
  .sidenav.mobile-open .sidenav-back { justify-content: flex-start; padding: 10px 14px; }
  .sidenav.mobile-open .sidenav-user { justify-content: flex-start; padding: 10px 14px; }

  /* Overlay backdrop — only when expanded */
  .sidenav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 299;
    display: none;
    cursor: pointer;
  }
  body.sidenav-open .sidenav-overlay { display: block; }

  /* Content padding */
  .page-header { padding: 16px 16px 0 !important; }
  .content-wrap { padding: 16px 16px 32px !important; }
  .page-content, .main-content-area { padding: 16px !important; }

  /* Grids collapse */
  .upload-grid, .stats-grid, .project-grid, .card-grid {
    grid-template-columns: 1fr !important;
  }

  /* Action bars stack */
  .action-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 14px !important;
  }
  .action-bar .btn-group, .action-bar .status-checks { justify-content: center; }

  /* Progress steps wrap */
  .progress-steps { flex-wrap: wrap; gap: 8px; }

  /* Misc layout helpers */
  .site-pill { flex-wrap: wrap; }
  .breadcrumb { font-size: 12px; flex-wrap: wrap; }
}

/* ── Topnav base ─────────────────────────────────────────── */
.topnav {
  background: var(--color-navy-sb);
  color: white;
}
.topnav-brand, .topnav-item, .topnav-logout, .topnav-icon-btn { color: rgba(255,255,255,0.85); }

/* ── Topnav mobile collapse ─────────────────────────────── */
.topnav-hamburger {
  display: none;
  background: none;
  border: none;
  color: rgba(255,255,255,0.75);
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-left: auto;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.topnav-hamburger:hover { background: rgba(255,255,255,0.09); color: #fff; }
.topnav-hamburger i { transition: transform 200ms cubic-bezier(0.16,1,0.3,1); }
.topnav[data-open="1"] .topnav-hamburger i { transform: rotate(90deg); }

@media (max-width: 768px) {
  .topnav-hamburger { display: flex; }

  .topnav-links {
    display: none;
    flex-direction: column;
    position: fixed;
    top: var(--topnav-height, 54px);
    left: 0;
    right: 0;
    background: var(--color-navy-sb, #1A1F71);
    padding: 8px 12px 12px;
    gap: 2px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    z-index: 9998;
    margin-left: 0 !important;
  }

  .topnav[data-open="1"] .topnav-links { display: flex; }

  .topnav-links .topnav-item {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
  }
}

/* ── Sidenav collapse button (injected by sidenav.js) ─────────────────── */
.sidenav-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,0.08);
  border: none;
  border-radius: 6px;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
  margin-left: auto;
}
.sidenav-collapse-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.sidenav-collapse-btn i { font-size: 11px; transition: transform 0.25s; }
body.sidenav-collapsed .sidenav-collapse-btn i { transform: rotate(180deg); }

/* Body offset when sidenav is collapsed (desktop) */
@media (min-width: 769px) {
  body.sidenav-collapsed { padding-left: 60px !important; }
  body.sidenav-collapsed .sidenav { width: 60px; }
  body.sidenav-collapsed .sidenav .sidenav-brand .brand-full { display: none !important; }
  body.sidenav-collapsed .sidenav .sidenav-brand .brand-icon { display: block !important; }
  body.sidenav-collapsed .sidenav .sidenav-item span,
  body.sidenav-collapsed .sidenav .sidenav-action span { opacity: 0; pointer-events: none; }
  body.sidenav-collapsed .sidenav .sidenav-user-info { opacity: 0; width: 0; overflow: hidden; }
}

/* ── Safe area insets (notch / home indicator) ──────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .sidenav { padding-bottom: env(safe-area-inset-bottom); }
}

/* ── Touch input: larger tap targets & no hover-only states ─── */
@media (pointer: coarse) {
  .btn, button, a.btn, input[type="submit"],
  .sidenav-item, .sidenav-action,
  .topnav-item, .topnav-icon-btn {
    min-height: 44px;
    min-width: 44px;
  }
  .sidenav-item, .sidenav-action {
    padding-top: 12px !important;
    padding-bottom: 12px !important;
  }
  .sidenav-item::after, .sidenav-action::after { display: none !important; }
}
@media (hover: none) {
  .card:hover, .stat-card:hover, .project-card:hover,
  .upload-card:hover, .info-card:hover, .summary-card:hover, .metric-card:hover {
    transform: none !important;
    box-shadow: var(--shadow-card-strong) !important;
    background: var(--color-card) !important;
    border-color: var(--color-border) !important;
  }
}

/* ── Tablet (769px – 1024px): 2-col grids, tighter padding ─────── */
@media (min-width: 769px) and (max-width: 1024px) {
  .stats-grid, .grid-3, .grid-4,
  [class*="-grid"]:not(.topnav):not(.step) {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .topbar {
    height: auto; min-height: 60px; flex-wrap: wrap;
    padding: 8px 16px; gap: 8px;
  }
  .topbar-actions { flex-wrap: wrap; gap: 6px; }
  .main-content, .content-wrap, .page-content {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  .table-wrap, .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ── Small mobile (≤540px): stack topbar, full-width inputs ─── */
@media (max-width: 540px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    height: auto;
    padding: 10px 12px;
    gap: 8px;
  }
  .topbar-title { font-size: 16px !important; }
  .topbar-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .topbar-actions .btn {
    flex: 1;
    min-width: 120px;
    justify-content: center;
    font-size: 12px !important;
    padding: 8px 10px !important;
  }
  .main-content { padding-top: 8px !important; }
  .card, .stat-card, .project-card { padding: 14px !important; }
  .filter-row, .search-bar, .controls-row {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .filter-row input, .search-bar input,
  .filter-row select, .search-bar select { width: 100% !important; }
}

/* ── Semantic z-index: topnav-links at modal level (was 9998) ── */
.topnav-links { z-index: 400 !important; }
