/* Grid Tayma -- app shell + shared component styles.
   Single stylesheet, plain CSS custom properties, no build step. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-sunken: #eef1f4;
  --border: #dde1e6;
  --border-strong: #c3cad4;
  --text: #1d2430;
  --text-muted: #667085;
  --sidebar-bg: #14213d;
  --sidebar-text: #cbd5e1;
  --sidebar-text-active: #ffffff;

  /* Design Direction §4.1 (revision 1): one hue family, two shades, two
     treatments -- link is text-only and lighter; action is a deep
     navy-blue solid fill drawn from the same family as --sidebar-bg.
     Never the same color doing both jobs. --accent/--accent-weak stay
     as aliases so any not-yet-retrofitted screen keeps working, but
     new/retrofitted markup should reach for --link or --action by name. */
  --link: #2f6fed;
  --link-weak: #eef2ff;
  --action: #173d8f;
  --action-weak: #e8edfa;
  --action-ink: #ffffff;
  --accent: var(--link);
  --accent-weak: var(--link-weak);

  --status-in-service: #16a34a;
  --status-out-of-service: #6b7280;
  --status-isolated: #d97706;
  --status-under-maintenance: #7c3aed;
  --status-unknown: #9ca3af;

  --status-open: #dc2626;
  --status-closed: #16a34a;

  /* Transformer installation-type badges -- a distinct hue family from
     the SCADA status colors above (never blue/link either, since these
     sit in the same table row as real links). */
  --install-ug: #475569;
  --install-pmt: #92400e;
  --install-pad: #0f766e;
  /* Separate token from --status-open (§4.2) -- validation errors and
     open outages happen to share a red today, but are named distinctly
     so a future change to one doesn't silently change the other. */
  --error: #dc2626;

  --radius: 8px;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Design Direction §6 -- six-value spacing scale. New/retrofitted
     rules should draw from these instead of inventing pixel values. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 28px;
  --space-8: 40px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
}

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

.app-shell { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
}
.sidebar-brand {
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 13px;
  padding: 0 20px 16px;
  color: #fff;
}
.sidebar-nav { display: flex; flex-direction: column; }
.sidebar-nav a {
  color: var(--sidebar-text);
  padding: 9px 20px;
  font-size: 13.5px;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { color: #fff; text-decoration: none; background: rgba(255,255,255,0.05); }
.sidebar-nav a.active {
  color: var(--sidebar-text-active);
  background: rgba(255,255,255,0.08);
  border-left-color: var(--accent);
  font-weight: 600;
}
.sidebar-coming-soon {
  margin-top: auto;
  padding: 16px 20px 8px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.coming-soon-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-bottom: 8px;
}
.coming-soon-item {
  display: block;
  font-size: 12.5px;
  color: #64748b;
  padding: 4px 0;
  cursor: default;
}

/* ---- Mobile nav toggle + backdrop (hidden on desktop; see the
   responsive section at the end of this file) ---- */
.menu-toggle {
  display: none;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1090;
}

/* ---- Top bar ---- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-search { position: relative; }
.topbar-search input {
  width: 340px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
}
.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 380px;
  z-index: 1000;
}
.search-dropdown-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  padding: 6px 0;
  max-height: 70vh;
  overflow-y: auto;
}
.search-group-label {
  padding: 6px 14px 2px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.search-result-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text);
}
.search-result-row:hover { background: var(--accent-weak); text-decoration: none; }
.search-result-meta { color: var(--text-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-empty { padding: 10px 14px; color: var(--text-muted); font-size: 13px; }
.search-see-all {
  display: block;
  padding: 8px 14px 4px;
  font-size: 12.5px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.breadcrumb { color: var(--text-muted); font-size: 13px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb .sep { margin: 0 6px; color: var(--border); }

.content { padding: 24px; flex: 1; }

/* ---- Page header ---- */
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 20px; margin: 0 0 4px; }
.page-header .subtitle { color: var(--text-muted); font-size: 13.5px; }

/* ---- Cards / panels -- Tier 2 "Data card" (§8): the workhorse tier,
   quiet on purpose so the Tier 1 identity header and Tier 3 reserved
   blocks can stand out by contrast. ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: 0 1px 2px rgba(15, 27, 51, 0.04);
}
.card + .card { margin-top: 16px; }
.card h2 { font-size: 14px; margin: 0 0 12px; }

/* ---- Status strip: the Dashboard's "instrument row" (§12) ----
   Display-scale, tabular-mono numbers -- these are the first thing an
   engineer's eye should land on, sized and weighted to match, not
   competing with surrounding body text. */
.status-strip {
  display: flex;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.status-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  flex: 1;
}
.status-stat .value { font-size: 28px; font-weight: 800; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.status-stat .label { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.status-stat-alert { border-left-color: var(--status-open); border-color: #fecaca; }
.status-stat-alert .value { color: var(--status-open); }

/* ---- Dashboard grid ---- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-4);
  align-items: start;
}
.tiles-row { display: flex; gap: var(--space-3); }
.tiles-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
.tile {
  flex: 1;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  display: block;
  color: inherit;
  transition: box-shadow 0.12s ease, transform 0.12s ease;
}
.tile .tile-count { font-size: 20px; font-weight: 700; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tile .tile-label { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.tile.disabled { opacity: 0.55; }
.tile a { color: inherit; }
.tile:hover { text-decoration: none; box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08); }
.tile-good { border-left-color: var(--status-in-service); }
.tile-good .tile-count { color: var(--status-in-service); }
.tile-warn { border-left-color: var(--status-isolated); }
.tile-warn .tile-count { color: var(--status-isolated); }
.tile-critical { border-left-color: var(--status-open); }
.tile-critical .tile-count { color: var(--status-open); }

/* ---- Quick actions ---- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}
.quick-action {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  color: inherit;
}
.quick-action:hover { text-decoration: none; border-color: var(--link); box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08); }
.quick-action-label { display: block; font-weight: 600; font-size: 13.5px; }
.quick-action-hint { display: block; color: var(--text-muted); font-size: 12px; margin-top: 2px; }

.coming-soon-list {
  color: var(--text-muted);
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Tier 3 -- Auxiliary/Reserved card (§8): recedes on purpose. Dashed
   border + sunken ground (not plain white like the workhorse Tier 2
   cards) so the eye skips past "not built yet" content on a first pass. */
.coming-soon-block {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: var(--space-5);
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--surface-sunken);
}

/* ---- Tables ---- */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
}
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:hover td { background: var(--accent-weak); }
.mono { font-family: var(--font-mono); }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  color: #fff;
}
.badge-in_service { background: var(--status-in-service); }
.badge-out_of_service { background: var(--status-out-of-service); }
.badge-isolated { background: var(--status-isolated); }
.badge-under_maintenance { background: var(--status-under-maintenance); }
.badge-unknown { background: var(--status-unknown); }
.badge-open { background: var(--status-open); }
.badge-closed { background: var(--status-closed); }
/* Transformer installation-type badges (Equipment List "Type" column) --
   a separate hue family from the SCADA status colors above, so an
   installation-type badge is never mistaken for an operational status. */
.badge-install-ug { background: var(--install-ug); }
.badge-install-pmt { background: var(--install-pmt); }
.badge-install-pad { background: var(--install-pad); }
.badge-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
}

.missing-filter-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
  border: 1px solid #fde68a;
  background: #fffbeb;
  border-radius: var(--radius);
  color: #92400e;
  font-size: 13px;
}
.missing-filter-banner a { color: #92400e; font-weight: 600; white-space: nowrap; }

/* ---- Filter bar ---- */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.filter-bar select, .filter-bar input[type="search"] {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}

/* ---- Type tabs (Equipment List) ---- */
.type-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.type-tabs a {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
}
.type-tabs a:hover { text-decoration: none; color: var(--text); }
.type-tabs a.active {
  /* §4.1.1: active-tab underline is informational, not an action --
     always --link, never --action. */
  color: var(--link);
  border-bottom-color: var(--link);
  font-weight: 600;
}
.type-icon { width: 15px; height: 15px; vertical-align: -3px; margin-right: 4px; flex-shrink: 0; }

/* ---- Detail header + tab strip (Equipment Detail) ---- */
.detail-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.page-header-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.detail-header h1 { font-size: 20px; margin: 0; }
.detail-subline { color: var(--text-muted); font-size: 13px; margin-bottom: 18px; }

/* ---- Equipment Detail: nameplate header (Design Direction §9/§13) ----
   Full-height left accent bar keyed to operational status (not a generic
   brand color) -- the header reads like the asset's own rating plate:
   dense, monospace, status-colored at a glance from arm's length. */
.equipment-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--status-unknown);
  border-radius: var(--radius);
  padding: var(--space-5) var(--space-6) var(--space-4);
  margin-bottom: var(--space-5);
  box-shadow: 0 1px 2px rgba(15, 27, 51, 0.05);
}
.equipment-header.status-in_service { border-left-color: var(--status-in-service); }
.equipment-header.status-out_of_service { border-left-color: var(--status-out-of-service); }
.equipment-header.status-isolated { border-left-color: var(--status-isolated); }
.equipment-header.status-under_maintenance { border-left-color: var(--status-under-maintenance); }
.equipment-header.status-unknown { border-left-color: var(--status-unknown); }
.equipment-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-5);
  flex-wrap: wrap;
}
.equipment-type-line {
  display: flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.equipment-identity h1 {
  font-size: 30px;
  font-weight: 800;
  font-family: var(--font-mono);
  margin: 0 0 2px;
  letter-spacing: -0.01em;
}
.equipment-rating { font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: var(--text-muted); margin: 0 0 8px; }
.equipment-badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.equipment-actions { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-2); }
.equipment-actions-secondary { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.equipment-meta {
  display: flex;
  gap: var(--space-6);
  flex-wrap: wrap;
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}
.equipment-meta-item { display: flex; flex-direction: column; gap: 2px; min-width: 130px; }
.equipment-meta-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.equipment-meta-value { font-size: 14px; font-weight: 500; }
.equipment-meta-value .empty { color: var(--text-muted); font-weight: 400; font-style: italic; }

.tab-strip {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tab-strip .tab-btn {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  background: none;
  border-top: none; border-left: none; border-right: none;
  cursor: pointer;
  font-family: inherit;
}
.tab-strip .tab-btn:hover { color: var(--text); }
.tab-strip .tab-btn.active {
  color: var(--link);
  border-bottom-color: var(--link);
  font-weight: 600;
}

/* htmx never ships this CSS itself -- .htmx-indicator elements are
   hidden until htmx adds .htmx-request to their nearest hx-indicator
   ancestor while a request is in flight. Previously nothing in this
   codebase defined it, so tab switches (and any other hx-indicator
   usage) had zero loading feedback. */
.htmx-indicator { opacity: 0; transition: opacity 120ms ease-in; }
.htmx-request.htmx-indicator, .htmx-request .htmx-indicator { opacity: 1; }
.tab-loading-indicator { align-self: center; font-size: 12px; color: var(--text-muted); margin-left: 4px; }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 28px; }
.field { }
.field .field-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin-bottom: 4px; }
.field .field-value { font-size: 14px; }
.field .field-value.empty { color: var(--text-muted); font-style: italic; }
.field input,
.field select {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--link);
  box-shadow: 0 0 0 1px var(--link) inset;
}

.field.field-error input,
.field.field-error select,
.field.field-error textarea {
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error) inset;
}
.field-error-message { color: var(--error); font-size: 11.5px; margin-top: 4px; }

.reserved-note {
  color: var(--text-muted);
  font-size: 13px;
  padding: 20px 0;
}

textarea.notes-input {
  width: 100%;
  min-height: 120px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13.5px;
}
/* Button hierarchy, Design Direction §10: exactly one Primary per
   screen region (solid --action fill), Secondary for common-but-not-
   the-one-action items (outline), Tertiary for actions needing a
   second thought (muted red outline), link-style for navigation. */
.btn {
  display: inline-block;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--action);
  background: var(--action);
  color: var(--action-ink);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { opacity: 0.92; text-decoration: none; }
.btn-disabled {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover { background: var(--link-weak); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-tertiary {
  background: var(--surface);
  border: 1px solid #fecaca;
  color: var(--error);
}
.btn-tertiary:hover { background: #fef2f2; }
.save-status { margin-left: 10px; font-size: 12.5px; color: var(--status-in-service); }

.pagination { display: flex; gap: 8px; margin-top: 14px; align-items: center; font-size: 13px; }
.pagination .disabled { color: var(--text-muted); }

.duplicate-flag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: #fef3c7;
  color: #92400e;
  font-weight: 600;
}

/* ---- GPS / Google Maps actions (Equipment Detail Overview) ---- */
.gps-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-2); }
.gps-map-link { color: var(--link); font-size: 12.5px; }
.copy-feedback { color: var(--status-in-service) !important; border-color: var(--status-in-service) !important; }

/* ---- Coordinate paste (Add/Edit Equipment Location card) ---- */
.coord-paste-status { font-size: 12px; margin-top: var(--space-1); min-height: 15px; }
.coord-paste-status.ok { color: var(--status-in-service); }
.coord-paste-status.error { color: var(--error); }
.coord-paste-status.pending { color: var(--text-muted); }

/* ---- GIS Map ---- */
.map-wrap { position: relative; height: 70vh; min-height: 420px; }
.map-canvas { width: 100%; height: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.map-canvas.map-canvas-embedded { height: 360px; }
.map-legend {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
  min-width: 160px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.map-legend-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 3px 0; cursor: pointer; }
.map-legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.map-popup { font-size: 13px; }
.map-popup-title { font-family: var(--font-mono); font-weight: 700; margin-bottom: 2px; }
.map-popup-meta { color: var(--text-muted); font-size: 12px; }
.map-popup-link { display: inline-block; margin-top: 6px; font-size: 12.5px; }

/* ---- Asset Import wizard ---- */
.import-steps { display: flex; align-items: center; margin-bottom: 22px; }
.import-steps .step { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.import-steps .step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 21px; height: 21px; border-radius: 50%;
  border: 1.5px solid var(--border); font-size: 11.5px; font-weight: 700;
  flex-shrink: 0;
}
.import-steps .step.active { color: var(--text); font-weight: 600; }
.import-steps .step.active .step-num { background: var(--accent); border-color: var(--accent); color: #fff; }
.import-steps .step.done .step-num { background: var(--status-in-service); border-color: var(--status-in-service); color: #fff; }
.import-steps .step-sep { width: 32px; height: 0; border-top: 1.5px solid var(--border); margin: 0 10px; }

.upload-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 20px;
  text-align: center;
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}
.upload-dropzone.dragover { border-color: var(--accent); background: var(--accent-weak); }
.upload-dropzone-icon { font-size: 28px; margin-bottom: 10px; }
.upload-dropzone input[type="file"] { display: block; margin: 14px auto 0; }
.upload-hint { color: var(--text-muted); font-size: 12.5px; margin-top: 10px; }

.alert { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-size: 13.5px; border: 1px solid transparent; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-info { background: var(--accent-weak); border-color: #c7d2fe; color: #3730a3; }
.alert-title { font-weight: 700; margin-bottom: 4px; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert ul li { margin-bottom: 3px; }

.documents-list { display: flex; flex-direction: column; gap: 12px; }
.document-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.document-card-filename { font-weight: 700; font-size: 14.5px; }
.document-card-meta { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.document-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.document-card-footer { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.document-history { margin-top: 12px; }
.document-viewer-card { padding: 8px; }
.document-viewer-embed { width: 100%; height: 80vh; min-height: 480px; border: none; border-radius: var(--radius); }

@media (max-width: 720px) {
  .document-card-header, .document-card-actions, .document-card-footer { flex-direction: column; align-items: stretch; }
  .document-viewer-embed { height: 65vh; }
}
.alert p { margin: 0; }
.alert p + p { margin-top: 6px; }

.import-summary { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.import-summary .status-stat { flex: 1; min-width: 110px; }
.import-summary .stat-added .value { color: var(--status-in-service); }
.import-summary .stat-updated .value { color: var(--accent); }
.import-summary .stat-skipped .value { color: var(--text-muted); }
.import-summary .stat-errors .value { color: var(--status-open); }
.import-summary .stat-warnings .value { color: var(--status-isolated); }

.diff-list { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.diff-list li { padding: 3px 0; }
.diff-field { color: var(--text-muted); margin-right: 4px; }
.diff-old { color: var(--status-open); }
.diff-new { color: var(--status-in-service); font-weight: 600; }
.diff-arrow { color: var(--text-muted); margin: 0 5px; }
.diff-empty { color: var(--text-muted); font-style: italic; }

.section-heading { display: flex; align-items: center; gap: 8px; margin: 22px 0 10px; }
.section-heading h2 { font-size: 14px; margin: 0; }
.section-heading .count-pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; background: var(--bg); color: var(--text-muted);
  border: 1px solid var(--border);
}

details.collapsible summary { cursor: pointer; color: var(--accent); font-size: 13px; padding: 4px 0; }
details.collapsible summary:hover { text-decoration: underline; }
details.collapsible[open] summary { margin-bottom: 8px; }

/* ==========================================================================
   Responsive / mobile (release-hardening follow-up, v1)

   One breakpoint (900px) covers every tested phone/tablet width (390,
   430, 768) with a single consistent behavior rather than a separate
   in-between tablet layout -- simpler to reason about and verify.
   Above 900px, nothing in this section changes desktop behavior.

   Strategy per the mobile-readiness requirements:
   - Sidebar becomes an off-canvas drawer (`.sidebar.open`, toggled by
     `.menu-toggle`, closed by the backdrop, Escape, or picking a nav
     item -- see base.html's inline script).
   - Every `table.data-table` scrolls horizontally *inside its own box*
     (the classic display:block-on-<table> trick) instead of the page
     itself overflowing sideways.
   - Multi-column grids (dashboard, field-grid, status strips, tile
     rows) collapse to a single column so nothing gets squeezed.
   ========================================================================== */

@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    max-width: 82vw;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    z-index: 1100;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.28);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open { display: block; }

  .topbar { padding: 10px 12px; gap: 10px; }
  .topbar-search { flex: 1; min-width: 0; }
  .topbar-search input { width: 100%; box-sizing: border-box; }
  .search-dropdown { width: 100%; left: 0; right: 0; }
  .breadcrumb { display: none; }

  .content { padding: 14px; }

  .page-header h1 { font-size: 18px; }

  /* minmax(0, 1fr), not plain 1fr: a grid track's implicit minimum
     width is the *content's* min-content size, not 0 -- without this,
     a track holding a wide table/heading refuses to shrink below that
     content's natural width and blows out past the viewport instead
     of the table's own overflow-x:auto ever getting a chance to kick
     in. This was the actual cause of the page-level overflow found
     during real-device verification, not a hypothetical. */
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .field-grid { grid-template-columns: minmax(0, 1fr); }

  .status-strip, .import-summary { flex-wrap: wrap; }
  .status-strip .status-stat, .import-summary .status-stat, .tile { flex: 1 1 45%; min-width: 130px; }
  .tiles-row { flex-wrap: wrap; }

  /* Same overflow strategy as tables: scroll within the tab row's own
     box rather than the page overflowing sideways (found during real-
     device verification -- six Equipment List type-tabs don't fit
     390px without this). */
  .type-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .type-tabs a { flex-shrink: 0; }

  /* Native <table> scrolls within its own box rather than the page
     scrolling sideways -- browsers keep the table layout algorithm for
     thead/tbody/tr/td even when the outer <table> itself is block-level,
     which is what makes this work without restructuring every table
     template into a wrapper div. */
  table.data-table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table.data-table thead, table.data-table tbody { display: table; width: 100%; }

  .map-wrap { height: 60vh; min-height: 320px; }
  .map-legend { min-width: 128px; padding: 10px; font-size: 12.5px; }
  .map-legend h2 { font-size: 12.5px; margin: 0 0 6px; }

  .upload-dropzone { padding: 28px 14px; }

  .import-steps { flex-wrap: wrap; row-gap: 8px; }
  .import-steps .step-sep { width: 16px; }

  .tab-strip .tab-btn { padding: 7px 10px; font-size: 12.5px; }

  /* Equipment header: identity stays on top, actions move below it and
     left-align instead of competing for the same row -- six action
     buttons right-aligned next to a mono equipment number is what
     produced the "buttons compete with each other" problem on a phone
     width in the first place. */
  .equipment-header { padding: 16px; }
  .equipment-header-top { flex-direction: column; align-items: stretch; }
  .equipment-actions { align-items: stretch; }
  .equipment-actions-secondary { justify-content: flex-start; }
  .equipment-meta { gap: 16px 24px; }
}

/* Equipment List -> Equipment Detail navigation feedback. This is a
   plain full-page <a href> navigation, not htmx -- these three elements
   give immediate visual feedback on tap, an explicit (never silent)
   message when a second tap is blocked while one is pending, and a
   manual retry affordance if navigation is taking unusually long. See
   equipment/list.html for the script that drives them. */
.nav-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 1000;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 200% 100%;
  animation: nav-progress-sweep 1.1s linear infinite;
}
.nav-progress-bar[hidden] { display: none; }

@keyframes nav-progress-sweep {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.nav-tap-message,
.nav-retry-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
.nav-tap-message[hidden],
.nav-retry-banner[hidden] { display: none; }

.nav-tap-message {
  background: var(--text);
  color: #fff;
}

.nav-retry-banner {
  background: #fff7e6;
  color: #7a4a00;
  border: 1px solid var(--status-isolated);
}
.nav-retry-banner a { color: #7a4a00; font-weight: 600; }
