/* ============================================================
   Monitoreo TI Zona Noroeste - Design System
   Corporate infrastructure monitoring dashboard
   ============================================================ */

:root {
  /* Palette */
  --bg-root: #EEF3F7;
  --bg-surface: #FFFFFF;
  --bg-raised: #F6F9FB;
  --bg-hover: #EAF1F5;
  --bg-input: #FFFFFF;
  --border: #D8E3EA;
  --border-light: #EAF0F4;
  --text: #102A3A;
  --text-secondary: #536A78;
  --text-muted: #7C909C;
  --accent: #087EA4;
  --accent-light: #0A96C2;
  --accent-dim: rgba(8, 126, 164, 0.09);
  --accent-glow: rgba(8, 126, 164, 0.18);
  --success: #059669;
  --success-light: #10B981;
  --success-dim: rgba(5, 150, 105, 0.08);
  --success-glow: rgba(5, 150, 105, 0.2);
  --danger: #DC2626;
  --danger-light: #EF4444;
  --danger-dim: rgba(220, 38, 38, 0.08);
  --danger-glow: rgba(220, 38, 38, 0.2);
  --warning: #D97706;
  --warning-light: #F59E0B;
  --warning-dim: rgba(217, 119, 6, 0.08);
  --warning-glow: rgba(217, 119, 6, 0.2);
  --blue: #2563EB;
  --blue-dim: rgba(37, 99, 235, 0.08);
  --purple: #7C3AED;
  --purple-dim: rgba(124, 58, 237, 0.08);

  /* Corporate operations language */
  --ink-strong: #17324D;
  --accent-structural: #176B87;
  --accent-interactive: #24A2B8;
  --surface-paper: #F8FBFC;
  --accent-stamp: #D8663B;
  --line-structural: #C9DAE2;
  --control-height: 44px;

  /* Typography */
  --font-body: Aptos, 'Segoe UI Variable', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

  /* Spacing */
  --radius: 6px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

  /* Transitions */
  --ease-out: 150ms cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: 200ms cubic-bezier(0.65, 0, 0.35, 1);

  /* Sidebar */
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
}

/* ============================================================
   Asset passport inventory
   ============================================================ */
.inventory-page {
  --passport-ink: #17324D;
  --passport-blue: #176B87;
  --passport-cyan: #24A2B8;
  --passport-paper: #F8FBFC;
  --passport-stamp: #D8663B;
  --passport-line: #C9DAE2;
}

.inventory-page .main-content.inventory-shell { max-width: 1480px; margin: 0 auto; padding: 30px 32px 56px; }
.inventory-modal-open { overflow: hidden; }
.inventory-live { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.offline-strip { margin: -30px -32px 22px; padding: 8px 32px; color: #713F12; background: #FEF3C7; border-bottom: 1px solid #F4D78B; font-size: .8rem; font-weight: 650; }
.inventory-masthead { display: flex; justify-content: space-between; align-items: flex-end; gap: 28px; padding: 8px 0 25px; border-bottom: 1px solid var(--passport-line); }
.inventory-kicker { display: block; margin-bottom: 6px; color: var(--passport-blue); font-family: var(--font-mono); font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.inventory-masthead h1 { color: var(--passport-ink); font-size: clamp(2rem, 3.2vw, 3.45rem); line-height: .98; letter-spacing: -.055em; }
.inventory-masthead p { max-width: 610px; margin-top: 12px; color: var(--text-secondary); font-size: .96rem; }
.inventory-head-actions { display: flex; gap: 9px; flex-shrink: 0; }
.inv-btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 15px; border: 1px solid var(--passport-line); border-radius: 7px; color: var(--passport-ink); background: var(--bg-surface); font: inherit; font-weight: 700; cursor: pointer; transition: border-color .15s, background .15s, transform .15s; }
.inv-btn:hover:not(:disabled) { border-color: var(--passport-blue); background: var(--bg-hover); }
.inv-btn:active:not(:disabled) { transform: translateY(1px); }
.inv-btn:disabled { opacity: .5; cursor: not-allowed; }
.inv-btn--primary { color: #fff; background: var(--passport-blue); border-color: var(--passport-blue); }
.inv-btn--primary:hover:not(:disabled) { color: #fff; background: #105B74; }
.inv-btn--danger { color: #9F2D23; border-color: #E9B9AF; background: #FFF8F6; }
.inv-btn--scan svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.inventory-mode-tabs { display: flex; gap: 4px; margin: 22px 0; padding: 4px; width: fit-content; background: #DDE8ED; border-radius: 9px; }
.inventory-mode-tabs button { min-height: 42px; padding: 8px 18px; border: 0; border-radius: 6px; color: #4C6573; background: transparent; font: inherit; font-weight: 700; cursor: pointer; }
.inventory-mode-tabs button.is-active { color: var(--passport-ink); background: var(--bg-surface); box-shadow: 0 1px 3px rgba(23, 50, 77, .13); }
.passport-summary { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--passport-line); border-radius: 12px; background: var(--bg-surface); overflow: hidden; }
.passport-stat { min-height: 108px; display: flex; flex-direction: column-reverse; justify-content: center; gap: 2px; padding: 18px 22px; border-right: 1px dashed var(--passport-line); }
.passport-stat:last-child { border: 0; }
.passport-stat span { color: var(--text-secondary); font-family: var(--font-mono); font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; }
.passport-stat strong { color: var(--passport-ink); font-size: 2rem; line-height: 1.1; font-variant-numeric: tabular-nums; }

.inventory-breakdown { margin: 18px 0; padding: 22px; background: var(--bg-surface); border: 1px solid var(--passport-line); border-radius: 12px; }
.inventory-breakdown-head, .inventory-section-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.inventory-breakdown-head h2, .inventory-section-title h3 { color: var(--passport-ink); letter-spacing: -.025em; }
.inventory-breakdown-head p { max-width: 650px; color: var(--text-secondary); font-size: .82rem; }
.inventory-operational-total { min-width: 135px; display: flex; flex-direction: column; align-items: flex-end; }
.inventory-operational-total strong { color: var(--passport-blue); font-size: 2.1rem; line-height: 1; font-variant-numeric: tabular-nums; }
.inventory-operational-total span, .inventory-section-title > span { color: var(--text-muted); font-family: var(--font-mono); font-size: .68rem; text-transform: uppercase; }
.inventory-type-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 8px; margin-top: 18px; }
.inventory-type-count { min-height: 64px; display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--bg-raised); border: 1px solid var(--passport-line); border-radius: 8px; }
.inventory-type-count .asset-seal { width: 34px; height: 34px; flex-basis: 34px; }
.inventory-type-count > div { display: flex; flex-direction: column; }
.inventory-type-count strong { color: var(--passport-ink); font-size: 1.25rem; line-height: 1; }
.inventory-type-count div span { color: var(--text-secondary); font-size: .72rem; }
.inventory-plaza-section, .inventory-advisor-section, .inventory-stock-summary { margin-top: 22px; padding-top: 20px; border-top: 1px dashed var(--passport-line); }
.inventory-section-title > strong { color: var(--passport-blue); font-size: 1.8rem; }
.inventory-plaza-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(245px, 1fr)); gap: 10px; margin-top: 13px; }
.inventory-plaza-card, .inventory-advisor-plazas article { padding: 14px; background: var(--passport-paper); border: 1px solid var(--passport-line); border-radius: 9px; }
.inventory-plaza-card > header, .inventory-advisor-plazas article > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 9px; border-bottom: 1px dashed var(--passport-line); }
.inventory-plaza-card header span { color: var(--text-muted); font-family: var(--font-mono); font-size: .62rem; text-transform: uppercase; }
.inventory-plaza-card h4 { color: var(--passport-ink); }
.inventory-plaza-card header > strong { color: var(--passport-blue); font-size: 1.5rem; }
.inventory-plaza-card > p, .inventory-advisor-plazas article > p, .inventory-no-plazas, .inventory-empty-inline { padding-top: 11px; color: var(--text-muted); font-size: .76rem; }
.inventory-count-list { display: grid; gap: 5px; padding-top: 9px; }
.inventory-count-list > div, .inventory-custodians > div { display: flex; justify-content: space-between; gap: 12px; color: var(--text-secondary); font-size: .77rem; }
.inventory-count-list strong, .inventory-custodians strong { color: var(--passport-ink); font-variant-numeric: tabular-nums; }
.inventory-advisor-list { display: grid; gap: 9px; margin-top: 13px; }
.inventory-advisor-card { background: var(--bg-raised); border: 1px solid var(--passport-line); border-radius: 9px; overflow: hidden; }
.inventory-advisor-card summary { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 11px 15px; cursor: pointer; list-style: none; }
.inventory-advisor-card summary::-webkit-details-marker { display: none; }
.inventory-advisor-card summary > div { display: flex; align-items: center; gap: 10px; }
.inventory-advisor-card summary div div { display: flex; flex-direction: column; }
.inventory-advisor-card summary small { color: var(--text-muted); }
.inventory-advisor-card summary > span { color: var(--text-secondary); font-size: .76rem; }
.inventory-advisor-card summary > span strong { color: var(--passport-blue); font-size: 1.25rem; }
.inventory-advisor-plazas { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; padding: 0 12px 12px; }
.inventory-advisor-plazas article > header span { color: var(--text-muted); font-size: .7rem; }
.inventory-stock-layout { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr); gap: 24px; margin-top: 12px; }
.inventory-count-list--stock { padding: 12px; background: var(--passport-paper); border: 1px solid var(--passport-line); border-radius: 8px; }
.inventory-custodians { display: grid; align-content: start; gap: 6px; padding: 12px; border-left: 2px solid var(--passport-cyan); }

.inventory-filters { display: grid; grid-template-columns: minmax(280px, 1fr) repeat(3, minmax(135px, .28fr)); gap: 10px; align-items: end; margin: 16px 0; }
.inventory-filters label, .branch-remote > label, .simple-form > label, .scanner-panel label, .progressive-form label, .inv-form-grid label { display: block; margin: 0 0 5px; color: var(--text-secondary); font-size: .72rem; font-weight: 700; letter-spacing: .025em; }
.inventory-filters select, .inventory-filters input, .branch-remote input, .simple-form input, .simple-form select, .simple-form textarea, .progressive-form input, .progressive-form select, .scanner-panel input { width: 100%; min-height: 44px; padding: 9px 11px; color: var(--text); background: var(--bg-input); border: 1px solid var(--passport-line); border-radius: 7px; font-family: inherit; font-size: 16px; }
/* Evita el zoom automatico de iOS al enfocar campos con fuente menor a 16px */
input, select, textarea { font-size: 16px; }
.simple-form textarea { resize: vertical; min-height: 86px; }
.inv-search > div, .branch-remote-input { position: relative; }
.inv-search svg, .branch-remote-input > svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--text-muted); stroke-width: 1.8; pointer-events: none; }
.inv-search input, .branch-remote input { padding-left: 39px; }
.inv-search button { position: absolute; right: 4px; top: 2px; width: 40px; height: 40px; border: 0; background: transparent; color: var(--text-muted); font-size: 1.4rem; cursor: pointer; }

.inventory-state { min-height: 210px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 35px; text-align: center; color: var(--text-secondary); border: 1px dashed var(--passport-line); border-radius: 12px; }
.inventory-state strong { color: var(--passport-ink); font-size: 1.05rem; }
.inventory-state--error { background: var(--danger-dim); border-color: #E9B9AF; }
.asset-ledger { border: 1px solid var(--passport-line); border-radius: 12px; background: var(--bg-surface); overflow: hidden; }
.asset-ledger-head, .asset-ledger-row { display: grid; grid-template-columns: 1.15fr .8fr 1fr .5fr 112px; gap: 16px; align-items: center; }
.asset-ledger-head { min-height: 40px; padding: 6px 16px; color: var(--text-muted); background: var(--bg-raised); border-bottom: 1px solid var(--passport-line); font-family: var(--font-mono); font-size: .66rem; letter-spacing: .06em; text-transform: uppercase; }
.asset-ledger-row { min-height: 78px; padding: 10px 16px; border-bottom: 1px dashed var(--passport-line); cursor: pointer; transition: background .15s; }
.asset-ledger-row:last-child { border: 0; }
.asset-ledger-row:hover { background: rgba(36, 162, 184, .055); }
.asset-ledger-row > div:not(.asset-identity) { min-width: 0; display: flex; flex-direction: column; }
.asset-ledger-row strong { overflow: hidden; color: var(--passport-ink); text-overflow: ellipsis; white-space: nowrap; }
.asset-ledger-row small { overflow: hidden; color: var(--text-muted); text-overflow: ellipsis; white-space: nowrap; }
.asset-identity { min-width: 0; display: flex; align-items: center; gap: 12px; }
.asset-identity > div { min-width: 0; display: flex; flex-direction: column; }
.asset-identity code { overflow: hidden; color: var(--text-secondary); font-size: .73rem; text-overflow: ellipsis; white-space: nowrap; }
.asset-seal { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; color: var(--passport-blue); background: #E3F3F5; border: 1px solid #AFD8DE; border-radius: 50%; font-family: var(--font-mono); font-size: .72rem; font-weight: 800; }
.asset-status { width: fit-content; display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; color: #176141; background: #EAF8F1; border: 1px solid #B9E2CD; border-radius: 999px; font-size: .7rem; font-weight: 750; white-space: nowrap; }
.asset-status::before { content: ''; width: 6px; height: 6px; background: currentColor; border-radius: 50%; }
.asset-status.is-obsolete, .asset-status.is-pending_disposal, .asset-status.is-disposed { color: #A33A2F; background: #FFF0EC; border-color: #EDC2B8; }
.asset-status.is-in_stock { color: #315C88; background: #EDF5FC; border-color: #C4D9EC; }
.asset-open { min-height: 44px; border: 0; color: var(--passport-blue); background: transparent; font: inherit; font-size: .78rem; font-weight: 750; cursor: pointer; }
.asset-mobile-label { display: none; }
.inventory-pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 14px; }
.inventory-pagination button { min-height: 44px; padding: 7px 14px; border: 1px solid var(--passport-line); border-radius: 7px; color: var(--passport-ink); background: var(--bg-surface); cursor: pointer; }
.inventory-pagination button:disabled { opacity: .45; cursor: not-allowed; }
.inventory-pagination span { color: var(--text-secondary); font-family: var(--font-mono); font-size: .75rem; }

.branch-remote { position: relative; z-index: 5; max-width: 650px; margin-bottom: 20px; }
.branch-remote input { font-size: 16px; }
.branch-results { position: absolute; top: calc(100% + 5px); left: 0; right: 0; max-height: 360px; overflow-y: auto; padding: 5px; background: var(--bg-surface); border: 1px solid var(--passport-line); border-radius: 9px; box-shadow: var(--shadow-lg); }
.branch-results button { width: 100%; min-height: 52px; display: flex; flex-direction: column; justify-content: center; padding: 7px 11px; color: var(--text); background: transparent; border: 0; border-radius: 6px; text-align: left; font: inherit; cursor: pointer; }
.branch-results button:hover { background: var(--bg-hover); }
.branch-results button span, .branch-results p { color: var(--text-muted); font-size: .75rem; }
.branch-results p { padding: 15px; }
.mini-spinner { position: absolute; right: 14px; top: 13px; width: 18px; height: 18px; border: 2px solid var(--passport-line); border-top-color: var(--passport-blue); border-radius: 50%; animation: spin .7s linear infinite; }
.workspace { border: 1px solid var(--passport-line); border-radius: 14px; background: linear-gradient(180deg, var(--bg-surface), var(--passport-paper)); overflow: hidden; }
.workspace-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 25px 28px; color: var(--passport-ink); border-bottom: 1px solid var(--passport-line); background-image: radial-gradient(circle at 1px 1px, rgba(23, 107, 135, .12) 1px, transparent 0); background-size: 18px 18px; }
.workspace-header > div { padding: 5px 12px 5px 0; background: var(--bg-surface); }
.workspace-header h2 { font-size: 1.65rem; letter-spacing: -.03em; }
.workspace-header p { color: var(--text-secondary); }
.workspace-count { min-width: 150px; display: flex; flex-direction: column; align-items: flex-end; padding: 8px 0 8px 14px; background: var(--bg-surface); }
.workspace-count strong { font-size: 1.8rem; line-height: 1; }
.workspace-count span { color: var(--text-secondary); font-size: .73rem; }
.slot-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 18px; }
.slot-card { min-height: 190px; padding: 15px; border: 1px solid var(--passport-line); border-radius: 10px; background: var(--bg-surface); }
.slot-card.is-empty { background: repeating-linear-gradient(-45deg, transparent, transparent 8px, rgba(23, 107, 135, .025) 8px, rgba(23, 107, 135, .025) 16px); border-style: dashed; }
.slot-card-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-bottom: 11px; border-bottom: 1px dashed var(--passport-line); }
.slot-number { color: var(--passport-ink); font-family: var(--font-mono); font-size: .78rem; font-weight: 800; }
.slot-state { color: var(--text-muted); font-size: .67rem; font-weight: 700; text-transform: uppercase; }
.is-occupied .slot-state { color: #197153; }
.slot-asset { height: 125px; display: flex; flex-direction: column; justify-content: space-between; padding-top: 12px; }
.slot-passport { min-width: 0; display: flex; align-items: center; gap: 10px; padding: 0; color: var(--text); background: transparent; border: 0; text-align: left; cursor: pointer; }
.slot-passport > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.slot-passport strong, .slot-passport small, .slot-passport code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-passport small { color: var(--text-secondary); }
.slot-passport code { color: var(--text-muted); font-size: .7rem; }
.slot-actions { display: flex; gap: 6px; justify-content: flex-end; }
.slot-actions button, .slot-vacant button { min-height: 40px; padding: 6px 10px; color: var(--passport-blue); background: transparent; border: 1px solid var(--passport-line); border-radius: 6px; font: inherit; font-size: .75rem; font-weight: 700; cursor: pointer; }
.slot-vacant { min-height: 125px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; color: var(--text-muted); text-align: center; }
.slot-vacant > span { color: var(--passport-cyan); font-family: var(--font-mono); font-size: 1.7rem; line-height: 1; }
.slot-vacant p { font-size: .76rem; }
.extras-section { margin: 0 18px 18px; padding: 22px; border-top: 2px solid var(--passport-ink); background: var(--bg-surface); }
.extras-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.extras-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.extra-asset { min-height: 66px; display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 11px; padding: 10px; color: var(--text); background: var(--bg-raised); border: 1px solid var(--passport-line); border-radius: 8px; text-align: left; cursor: pointer; }
.extra-asset > span:nth-child(2) { min-width: 0; display: flex; flex-direction: column; }
.extra-asset small { color: var(--text-muted); }
.extras-empty { padding: 18px 0; color: var(--text-muted); text-align: center; }
.extras-heading-spacer { width: 0; visibility: hidden; }
.pv-group { margin-bottom: 20px; border: 1px solid var(--passport-line); border-radius: 10px; overflow: hidden; }
.pv-group:last-child { margin-bottom: 0; }
.pv-group-header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--bg-raised); border-bottom: 1px solid var(--passport-line); }
.pv-group-header h4 { margin: 0; font-size: .92rem; font-weight: 600; color: var(--passport-ink); }
.pv-group-icon { width: 28px; height: 28px; flex: 0 0 28px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.pv-group-icon svg { width: 18px; height: 18px; }
.pv-group-count { margin-left: auto; font-size: .78rem; color: var(--text-secondary); }
.pv-group .slot-grid { padding: 12px; }
.pv-group .extras-grid { padding: 0 12px 12px; }

.inv-modal-backdrop { position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; padding: 18px; background: rgba(8, 25, 39, .68); backdrop-filter: blur(4px); }
.inv-modal { width: min(760px, 100%); max-height: calc(100dvh - 36px); overflow-y: auto; color: var(--text); background: var(--bg-surface); border: 1px solid var(--passport-line); border-radius: 14px; box-shadow: 0 24px 70px rgba(7, 26, 40, .3); }
.inv-modal > header { position: sticky; top: 0; z-index: 3; display: flex; justify-content: space-between; gap: 20px; padding: 20px 24px 15px; background: color-mix(in srgb, var(--bg-surface) 94%, transparent); border-bottom: 1px solid var(--passport-line); backdrop-filter: blur(10px); }
.inv-modal > header h2 { color: var(--passport-ink); font-size: 1.35rem; letter-spacing: -.025em; }
.inv-modal-close { width: 44px; height: 44px; flex: 0 0 44px; margin: -5px -8px 0 0; color: var(--text-secondary); background: transparent; border: 0; border-radius: 7px; font-size: 1.8rem; cursor: pointer; }
.passport-sheet, .scanner-panel, .simple-form, .progressive-form { padding: 22px 24px 25px; }
.passport-cover { min-height: 150px; display: flex; align-items: center; gap: 22px; padding: 23px; color: #fff; background: var(--passport-ink); border-radius: 10px; background-image: linear-gradient(125deg, transparent 55%, rgba(36, 162, 184, .18)); }
.passport-cover h3 { margin-top: 10px; font-size: 1.6rem; letter-spacing: -.03em; }
.passport-cover p { color: #BBD0DC; }
.passport-emblem { width: 76px; height: 76px; display: grid; place-items: center; flex: 0 0 76px; color: #CDECF1; border: 2px double #77BBC8; border-radius: 50%; font-family: var(--font-mono); font-size: 1.2rem; font-weight: 800; box-shadow: inset 0 0 0 5px var(--passport-ink), inset 0 0 0 6px #77BBC8; }
.passport-cover .asset-status { color: #CDEEE1; background: rgba(42, 173, 121, .14); border-color: rgba(160, 230, 200, .38); }
.passport-cover .asset-status.is-obsolete, .passport-cover .asset-status.is-pending_disposal, .passport-cover .asset-status.is-disposed { color: #FFD2C7; background: rgba(216, 102, 59, .17); border-color: rgba(255, 186, 165, .42); }
.passport-data { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 14px; border: 1px solid var(--passport-line); border-radius: 9px; overflow: hidden; }
.passport-data div { min-height: 72px; padding: 13px; border-right: 1px dashed var(--passport-line); border-bottom: 1px dashed var(--passport-line); }
.passport-data div:nth-child(3n) { border-right: 0; }
.passport-data div:nth-last-child(-n+3) { border-bottom: 0; }
.passport-data dt { color: var(--text-muted); font-family: var(--font-mono); font-size: .65rem; text-transform: uppercase; }
.passport-data dd { margin-top: 4px; color: var(--passport-ink); font-weight: 700; }
.passport-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 24px; }
.timeline-section { padding-top: 20px; border-top: 2px solid var(--passport-ink); }
.timeline-section h3 { margin-bottom: 14px; color: var(--passport-ink); }
.passport-timeline article { position: relative; display: grid; grid-template-columns: 18px 1fr; gap: 12px; padding-bottom: 20px; }
.passport-timeline article:not(:last-child)::before { content: ''; position: absolute; left: 6px; top: 12px; bottom: -1px; border-left: 1px dashed var(--passport-line); }
.timeline-mark { position: relative; z-index: 1; width: 13px; height: 13px; margin-top: 4px; background: var(--bg-surface); border: 3px solid var(--passport-cyan); border-radius: 50%; }
.passport-timeline article > div { display: flex; flex-direction: column; }
.passport-timeline time { color: var(--text-muted); font-family: var(--font-mono); font-size: .67rem; }
.passport-timeline strong { color: var(--passport-ink); }
.passport-timeline p { color: var(--text-secondary); }
.passport-timeline small { margin-top: 3px; color: var(--text-muted); }

.progressive-form .form-section { display: grid; grid-template-columns: 36px 1fr; gap: 13px; padding: 3px 0 21px; }
.progressive-form .form-section:not(:last-of-type) { margin-bottom: 18px; border-bottom: 1px dashed var(--passport-line); }
.form-step { width: 30px; height: 30px; display: grid; place-items: center; color: var(--passport-blue); border: 1px solid var(--passport-cyan); border-radius: 50%; font-family: var(--font-mono); font-size: .73rem; font-weight: 800; }
.form-section h3 { margin: 3px 0 14px; color: var(--passport-ink); }
.inv-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.simple-form > * + *, .scanner-panel > * + * { margin-top: 15px; }
.simple-form footer, .progressive-form footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--passport-line); }
.location-choice { display: flex; gap: 8px; margin-bottom: 13px; }
.location-choice label { min-height: 44px; flex: 1; display: flex; align-items: center; gap: 8px; padding: 9px 12px; color: var(--text); background: var(--bg-raised); border: 1px solid var(--passport-line); border-radius: 7px; font-weight: 700; cursor: pointer; }
.location-choice input { width: 18px; min-height: 18px; accent-color: var(--passport-blue); }
.inline-results { max-height: 150px; overflow-y: auto; margin-top: 4px; padding: 4px; border: 1px solid var(--passport-line); border-radius: 6px; }
.inline-results button { width: 100%; min-height: 40px; padding: 6px; color: var(--text); background: transparent; border: 0; text-align: left; cursor: pointer; }
.inline-results button:hover { background: var(--bg-hover); }
.form-message { margin-top: 14px; padding: 10px 12px; color: #9F2D23; background: #FFF0EC; border: 1px solid #EDC2B8; border-radius: 7px; }
.movement-route { display: grid; grid-template-columns: 1fr 30px 1fr; align-items: stretch; gap: 8px; padding: 13px; background: var(--bg-raised); border: 1px solid var(--passport-line); border-radius: 9px; }
.movement-route > div { display: flex; flex-direction: column; }
.movement-route span, .assignment-target span { color: var(--text-muted); font-family: var(--font-mono); font-size: .65rem; text-transform: uppercase; }
.movement-route strong { color: var(--passport-ink); }
.route-arrow { align-self: center; text-align: center; font-size: 1.3rem !important; }
.assignment-target { display: flex; flex-direction: column; padding: 13px; background: #E7F5F7; border-left: 4px solid var(--passport-cyan); }
.assignment-target strong { color: var(--passport-ink); }
.assignment-target small { color: var(--text-secondary); }
.assign-results { max-height: 240px; overflow-y: auto; }
.assign-results button { width: 100%; min-height: 60px; display: flex; align-items: center; gap: 10px; padding: 8px; color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 7px; text-align: left; cursor: pointer; }
.assign-results button.is-selected { background: #E7F5F7; border-color: var(--passport-cyan); }
.assign-results button > span:last-child { display: flex; flex-direction: column; }
.assign-results small { color: var(--text-muted); }
.disposal-notice { padding: 13px 15px; color: #7C2D20; background: #FFF2ED; border-left: 4px solid var(--passport-stamp); }
.scanner-viewport { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: #07141D; border-radius: 10px; }
.scanner-viewport video { width: 100%; height: 100%; object-fit: cover; }
.scanner-frame { position: absolute; inset: 24%; border: 2px solid #7FE1EC; border-radius: 5px; box-shadow: 0 0 0 999px rgba(3, 17, 27, .45); }
.manual-scan { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

.inventory-page :is(button, input, select, textarea, [tabindex]):focus-visible { outline: 3px solid rgba(36, 162, 184, .34); outline-offset: 2px; }
.inventory-page .sidebar-user-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Administrative control center */
.admin-portal { --admin-line: var(--border, #D6E0E6); }
.admin-security-bar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 18px 0 12px; padding: 14px 16px; color: #7C2D20; background: #FFF4EE; border: 1px solid #F0C6B8; border-radius: 10px; }
.admin-security-bar.is-verified { color: #176141; background: #EAF8F1; border-color: #B9E2CD; }
.admin-security-bar > div { display: flex; flex-direction: column; }
.admin-security-bar span { font-size: .78rem; opacity: .82; }
.admin-security-bar form { display: flex; gap: 7px; }
.admin-security-bar input, .admin-table-picker select, .permission-matrix select, .admin-portal textarea { min-height: 42px; padding: 8px 10px; color: var(--text); background: var(--bg-input); border: 1px solid var(--admin-line); border-radius: 7px; }
.admin-message { margin: 8px 0; color: var(--accent); font-weight: 700; }
.admin-tabs { display: flex; gap: 4px; margin: 18px 0; padding: 4px; width: fit-content; background: var(--bg-raised); border: 1px solid var(--admin-line); border-radius: 9px; }
.admin-tabs button { min-height: 40px; padding: 8px 16px; color: var(--text-secondary); background: transparent; border: 0; border-radius: 6px; font: inherit; font-weight: 700; cursor: pointer; }
.admin-tabs button.active { color: var(--text); background: var(--bg-surface); box-shadow: var(--shadow-sm); }
.admin-metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.admin-metric-grid article { min-height: 105px; display: flex; flex-direction: column-reverse; justify-content: center; padding: 17px; background: var(--bg-surface); border: 1px solid var(--admin-line); border-radius: 10px; }
.admin-metric-grid span { color: var(--text-muted); font-size: .72rem; text-transform: uppercase; }
.admin-metric-grid strong { font-size: 1.8rem; }
.admin-panel { margin-top: 14px; padding: 18px; background: var(--bg-surface); border: 1px solid var(--admin-line); border-radius: 10px; }
.admin-panel h2, .admin-db-toolbar h2 { margin-bottom: 12px; }
.admin-count-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 7px; }
.admin-count-grid div, .removal-impact div { display: flex; justify-content: space-between; gap: 10px; padding: 9px 11px; background: var(--bg-raised); border-radius: 6px; }
.admin-count-grid span, .removal-impact span { color: var(--text-secondary); text-transform: capitalize; }
.admin-row-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.admin-db-toolbar, .admin-table-picker { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.admin-health { display: flex; flex-direction: column; margin: 13px 0; padding: 12px 14px; border-left: 4px solid; }
.admin-health.is-healthy { color: #176141; background: #EAF8F1; border-color: #2B9A6C; }
.admin-health.is-warning { color: #8A3A26; background: #FFF4EE; border-color: #D8663B; }
.admin-health span { font-size: .76rem; }
.admin-metric-grid article small { color: var(--text-muted); font-size: .72rem; margin-top: 3px; }
.sys-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.sys-toolbar h2 { margin: 0; }
.sys-toolbar-actions { display: flex; align-items: center; gap: 12px; }
.sys-updated { color: var(--text-muted); font-size: .78rem; }
.sys-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.sys-card { padding: 16px; background: var(--bg-surface); border: 1px solid var(--admin-line); border-left: 4px solid var(--line-structural); border-radius: 10px; }
.sys-card header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sys-card h3 { margin: 0; color: var(--text-secondary); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.sys-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--text-muted); }
.sys-card strong { display: block; margin-bottom: 6px; font-size: 1.45rem; }
.sys-card p { margin: 0; color: var(--text-muted); font-size: .78rem; line-height: 1.45; }
.sys-card.is-ok { border-left-color: #2B9A6C; }
.sys-card.is-ok .sys-dot { background: #2B9A6C; }
.sys-card.is-warning { border-left-color: #D8663B; }
.sys-card.is-warning .sys-dot { background: #D8663B; }
.sys-card.is-error { border-left-color: #C0392B; }
.sys-card.is-error .sys-dot { background: #C0392B; }
.sys-panel-desc { margin: 0 0 12px; color: var(--text-muted); font-size: .8rem; }
.admin-service-list { display: grid; gap: 7px; }
.admin-service-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px 14px; align-items: center; padding: 10px 12px; background: var(--bg-raised); border-radius: 6px; }
.admin-service-row .svc-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.admin-service-row .svc-name { font-weight: 700; text-transform: capitalize; }
.admin-service-row .svc-desc { color: var(--text-muted); font-size: .74rem; }
.admin-service-row .svc-status { font-weight: 800; }
.admin-service-row .svc-status.is-ok { color: #176141; }
.admin-service-row .svc-status.is-error { color: #A33A2F; }
.admin-service-row .svc-meta { color: var(--text-muted); font-size: .75rem; }
.admin-service-row .svc-error { grid-column: 1 / -1; color: #A33A2F; font-size: .75rem; }
@media (max-width: 760px) { .sys-grid { grid-template-columns: 1fr; } }
.admin-table-picker { justify-content: flex-start; margin: 12px 0; }
.admin-table-picker label { font-weight: 700; }
.admin-table-picker select { min-width: 250px; }
.admin-table-picker > span { color: var(--text-muted); font-family: var(--font-mono); font-size: .72rem; }
.admin-audit code { display: block; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-permission-modal { width: min(680px, 94vw); }
.readonly-access-notice { position: fixed; z-index: 450; right: 18px; bottom: 18px; padding: 8px 12px; color: #315C88; background: #EDF5FC; border: 1px solid #C4D9EC; border-radius: 999px; font-size: .75rem; font-weight: 800; box-shadow: var(--shadow-md); }
.permission-matrix { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; padding: 18px; }
.permission-matrix label { display: flex; flex-direction: column; gap: 4px; color: var(--text-secondary); font-size: .78rem; font-weight: 700; }
.removal-impact { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-bottom: 16px; }

@media (max-width: 760px) {
  .admin-security-bar, .admin-security-bar form, .admin-db-toolbar, .admin-table-picker { align-items: stretch; flex-direction: column; }
  .admin-tabs { width: 100%; overflow-x: auto; }
  .admin-tabs button { flex: 1 0 auto; }
  .admin-metric-grid { grid-template-columns: repeat(2, 1fr); }
  .permission-matrix, .removal-impact { grid-template-columns: 1fr; }
  .admin-table-picker select { min-width: 0; width: 100%; }
}

[data-theme="dark"] .inventory-page { --passport-ink: #D9EDF4; --passport-blue: #67C4D4; --passport-cyan: #47B6C8; --passport-paper: #121E29; --passport-line: #344B59; }
[data-theme="dark"] .inventory-mode-tabs { background: #1D303D; }
[data-theme="dark"] .workspace-header > div, [data-theme="dark"] .workspace-count { background: #14222D; }
[data-theme="dark"] .asset-seal { background: #153842; border-color: #376B78; }
[data-theme="dark"] .slot-card.is-empty { background-color: #14222D; }
[data-theme="dark"] .assignment-target { background: #15343D; }

@media (max-width: 1050px) {
  .slot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .asset-ledger-head, .asset-ledger-row { grid-template-columns: 1.1fr .75fr .85fr .5fr 90px; gap: 10px; }
}

@media (max-width: 760px) {
  .inventory-page .main-content.inventory-shell { padding: 18px 14px 88px; }
  .offline-strip { margin: -18px -14px 14px; padding: 8px 14px; }
  .inventory-masthead { align-items: flex-start; padding-top: 2px; }
  .inventory-masthead h1 { font-size: 2.15rem; }
  .inventory-masthead p { font-size: .84rem; }
  .inventory-head-actions { position: fixed; z-index: 90; left: 0; right: 0; bottom: 0; gap: 8px; padding: 9px 12px calc(9px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg-surface) 96%, transparent); border-top: 1px solid var(--passport-line); box-shadow: 0 -7px 25px rgba(13, 38, 54, .1); backdrop-filter: blur(12px); }
  .inventory-head-actions .inv-btn { flex: 1; }
  .inventory-head-actions .inv-btn--scan { color: #fff; background: var(--passport-stamp); border-color: var(--passport-stamp); }
  .inventory-mode-tabs { width: 100%; }
  .inventory-mode-tabs button { flex: 1; padding: 7px 9px; }
  .passport-summary { grid-template-columns: repeat(2, 1fr); }
  .passport-stat { min-height: 88px; padding: 14px; }
  .passport-stat:nth-child(2) { border-right: 0; }
  .passport-stat:nth-child(-n+2) { border-bottom: 1px dashed var(--passport-line); }
  .passport-stat strong { font-size: 1.6rem; }
  .inventory-breakdown { padding: 16px 13px; }
  .inventory-breakdown-head { align-items: flex-start; }
  .inventory-breakdown-head p { display: none; }
  .inventory-operational-total { min-width: 95px; }
  .inventory-operational-total strong { font-size: 1.65rem; }
  .inventory-type-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inventory-type-count { min-width: 0; }
  .inventory-section-title { align-items: flex-start; }
  .inventory-plaza-grid, .inventory-advisor-plazas, .inventory-stock-layout { grid-template-columns: 1fr; }
  .inventory-advisor-card summary { align-items: flex-start; }
  .inventory-advisor-card summary > span { text-align: right; }
  .inventory-filters { grid-template-columns: repeat(3, 1fr); }
  .inventory-filters .inv-search { grid-column: 1 / -1; }
  .inventory-filters label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .asset-ledger { border: 0; background: transparent; overflow: visible; }
  .asset-ledger-head { display: none; }
  .asset-ledger-row { min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 9px; padding: 15px; background: var(--bg-surface); border: 1px solid var(--passport-line); border-radius: 10px; box-shadow: var(--shadow-sm); }
  .asset-ledger-row .asset-identity { grid-column: 1 / -1; padding-bottom: 12px; border-bottom: 1px dashed var(--passport-line); }
  .asset-ledger-row > div:nth-child(4) { align-items: flex-start; justify-content: center; }
  .asset-open { grid-column: 1 / -1; width: 100%; border: 1px solid var(--passport-line); border-radius: 6px; }
  .asset-mobile-label { display: block; color: var(--text-muted); font-family: var(--font-mono); font-size: .62rem; text-transform: uppercase; }
  .inventory-pagination { justify-content: space-between; }
  .workspace { margin: 0 -4px; }
  .workspace-header { align-items: flex-start; padding: 19px; }
  .workspace-header h2 { font-size: 1.3rem; }
  .workspace-count { min-width: auto; }
  .workspace-count span { max-width: 80px; text-align: right; }
  .slot-grid { grid-template-columns: 1fr; padding: 10px; }
  .slot-card { min-height: 180px; }
  .extras-section { margin: 0 10px 10px; padding: 16px 10px; }
  .extras-grid { grid-template-columns: 1fr; }
  .extra-asset { grid-template-columns: 40px minmax(0, 1fr); }
  .extra-asset .asset-status { grid-column: 2; }
  .inv-modal-backdrop { align-items: end; padding: 0; }
  .inv-modal { width: 100%; max-height: calc(100dvh - 22px); border-radius: 16px 16px 0 0; }
  .inv-modal > header { padding: 17px 18px 13px; }
  .passport-sheet, .scanner-panel, .simple-form, .progressive-form { padding: 17px 16px calc(20px + env(safe-area-inset-bottom)); }
  .passport-cover { min-height: 130px; gap: 14px; padding: 17px; }
  .passport-emblem { width: 58px; height: 58px; flex-basis: 58px; }
  .passport-cover h3 { font-size: 1.25rem; }
  .passport-data { grid-template-columns: repeat(2, 1fr); }
  .passport-data div:nth-child(3n) { border-right: 1px dashed var(--passport-line); }
  .passport-data div:nth-child(2n) { border-right: 0; }
  .passport-data div:nth-last-child(3) { border-bottom: 1px dashed var(--passport-line); }
  .passport-actions .inv-btn { flex: 1 1 45%; }
  .inv-form-grid { grid-template-columns: 1fr; }
  .progressive-form .form-section { grid-template-columns: 30px 1fr; gap: 8px; }
}

@media (max-width: 420px) {
  .inventory-filters { grid-template-columns: 1fr; }
  .inventory-filters .inv-search { grid-column: auto; }
  .workspace-header { flex-direction: column; }
  .workspace-count { align-items: flex-start; padding-left: 0; }
  .workspace-count span { max-width: none; text-align: left; }
  .manual-scan { grid-template-columns: 1fr; }
  .movement-route { grid-template-columns: 1fr; }
  .route-arrow { transform: rotate(90deg); }
}

@media (prefers-reduced-motion: reduce) {
  .inventory-page * { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg-root);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}

[x-cloak] { display: none !important; }

/* ============================================================
   App Layout — Sidebar + Main
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   Sidebar (Dark Navy)
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  background: #0F172A;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  transition: width var(--ease-in-out);
  overflow: hidden;
}

.sidebar--collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
}

.sidebar-logo {
  position: relative;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-logo-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #60A5FA;
  box-shadow: 0 0 12px rgba(96, 165, 250, 0.4);
}

.sidebar-logo-ring {
  display: none;
}

.sidebar-brand-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: #F1F5F9;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  opacity: 1;
  transition: opacity var(--ease-out), width var(--ease-out);
}

.sidebar--collapsed .sidebar-brand-text {
  opacity: 0;
  width: 0;
}

.sidebar-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #64748B;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--ease-out);
  touch-action: manipulation;
}

.sidebar-toggle:hover {
  color: #F1F5F9;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 6px 12px;
  opacity: 0.6;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: #94A3B8;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--ease-out);
  white-space: nowrap;
  position: relative;
  min-height: 40px;
  touch-action: manipulation;
}

.sidebar-link:hover {
  color: #F1F5F9;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-link.active {
  color: #60A5FA;
  background: rgba(96, 165, 250, 0.12);
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: #60A5FA;
  border-radius: 0 2px 2px 0;
}

.sidebar-link svg {
  flex-shrink: 0;
  width: 19px;
  height: 19px;
  opacity: 0.8;
}

.sidebar-link.active svg {
  opacity: 1;
}

.sidebar-link-label {
  overflow: hidden;
  transition: opacity var(--ease-out), width var(--ease-out);
}

.sidebar--collapsed .sidebar-link-label {
  opacity: 0;
  width: 0;
  display: none;
}

.sidebar--collapsed .sidebar-link {
  justify-content: center;
  padding: 9px;
}

.sidebar--collapsed .sidebar-link::before {
  left: 0;
}

.sidebar--collapsed .sidebar-brand {
  justify-content: center;
  padding: 18px 8px;
}

.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user-link {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  margin: -2px -4px;
  transition: background 0.15s;
}
.sidebar-user-link:hover {
  background: rgba(255, 255, 255, 0.06);
}

.sidebar--collapsed .sidebar-user-link {
  padding: 0;
  margin: 0;
  flex: 0 0 auto;
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(96, 165, 250, 0.15);
  color: #60A5FA;
  font-weight: 700;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.sidebar-user-info {
  min-width: 0;
  overflow: hidden;
}

.sidebar-user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #F1F5F9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.7rem;
  color: #64748B;
  white-space: nowrap;
  text-transform: capitalize;
}

.sidebar-user-logout {
  margin-left: auto;
  background: none;
  border: none;
  color: #64748B;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: all var(--ease-out);
  touch-action: manipulation;
  flex-shrink: 0;
}

.sidebar-user-passkey {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #64748B;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: all var(--ease-out);
  touch-action: manipulation;
  flex-shrink: 0;
}

.sidebar-user-passkey:hover:not(:disabled) {
  color: #60A5FA;
  background: rgba(96, 165, 250, 0.12);
  border-color: #60A5FA;
}

.sidebar-user-logout:hover {
  color: #F87171;
  background: rgba(248, 113, 113, 0.12);
}

.sidebar--collapsed .sidebar-user,
.sidebar--collapsed .sidebar-user-info,
.sidebar--collapsed .sidebar-user-logout {
  justify-content: center;
  padding: 14px 8px;
}

.sidebar--collapsed .sidebar-user-info,
.sidebar--collapsed .sidebar-user-name,
.sidebar--collapsed .sidebar-user-role {
  display: none;
}

.sidebar--collapsed .sidebar-user-logout {
  margin-left: 0;
}

/* ============================================================
   Main Content Area
   ============================================================ */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: margin-left var(--ease-in-out);
  min-width: 0;
}

.sidebar--collapsed ~ .main-area {
  margin-left: var(--sidebar-collapsed);
}

.topbar-mini {
  background: var(--bg-surface);
  border-bottom: 2px solid var(--accent);
  padding: 0 20px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-burger {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--ease-out);
  touch-action: manipulation;
  flex-shrink: 0;
}

.topbar-burger:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.topbar-breadcrumb {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.topbar-spacer {
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-role-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(37, 99, 235, 0.15);
}

.topbar-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: all var(--ease-out);
  touch-action: manipulation;
}

.theme-toggle:hover {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: var(--accent);
}

.theme-toggle-float {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  background: var(--bg-surface);
  box-shadow: var(--shadow-md);
}

.main-content {
  padding: 24px;
  max-width: 1400px;
}

/* ============================================================
   Sidebar Overlay (mobile)
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 199;
  animation: fadeIn 200ms ease;
}

/* ============================================================
   Login Page
   ============================================================ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-root);
  position: relative;
  overflow: hidden;
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 16px;
  position: relative;
  z-index: 1;
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}

.login-brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
}

.login-brand h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.login-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 32px;
  letter-spacing: 0.02em;
}

/* ============================================================
   Form Elements
   ============================================================ */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.8rem;
  margin-bottom: 6px;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--font-body);
  color: var(--text);
  transition: all var(--ease-out);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-group textarea {
  resize: vertical;
  min-height: 70px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.84rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--ease-out);
  line-height: 1.4;
  white-space: nowrap;
  letter-spacing: 0.01em;
  min-height: 40px;
  touch-action: manipulation;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-light);
  border-color: var(--accent-light);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--text-muted);
  color: var(--text);
}

.btn-secondary {
  background: var(--bg-raised);
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--text-muted);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
  border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-light);
  box-shadow: var(--shadow-md);
}

.btn-success {
  background: var(--success);
  color: #FFFFFF;
  border-color: var(--success);
}

.btn-success:hover:not(:disabled) {
  background: var(--success-light);
  box-shadow: var(--shadow-md);
}

.btn-warning {
  background: var(--warning);
  color: #FFFFFF;
  border-color: var(--warning);
}

.btn-warning:hover:not(:disabled) {
  background: var(--warning-light);
  box-shadow: var(--shadow-md);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
  min-height: 34px;
  border-radius: var(--radius-sm);
}

.btn-xs {
  padding: 4px 9px;
  font-size: 0.72rem;
  min-height: 28px;
  border-radius: 4px;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--ease-out);
}

.btn-close:hover {
  color: var(--text);
  background: var(--bg-hover);
}

/* ============================================================
   Alert
   ============================================================ */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  margin-bottom: 16px;
  line-height: 1.4;
}

.alert-error {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.alert-info {
  background: var(--blue-dim);
  color: var(--blue);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

/* ============================================================
   Stats Cards
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stats-grid-dash {
  grid-template-columns: repeat(4, 1fr);
}

.stats-grid-eolicos {
  grid-template-columns: repeat(3, 1fr);
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all var(--ease-out);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  border-color: var(--text-muted);
  box-shadow: var(--shadow-md);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 3px;
  border-radius: 2px 0 0 2px;
}

.stat-total::before { background: var(--blue); }
.stat-online::before { background: var(--success); }
.stat-offline::before { background: var(--danger); }
.stat-warning::before { background: var(--warning); }

.stat-card--active {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-dim), var(--shadow-md);
}
.stat-card--active.stat-online {
  border-color: var(--success);
  box-shadow: 0 0 0 2px var(--success-dim), var(--shadow-md);
}
.stat-card--active.stat-offline {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px var(--danger-dim), var(--shadow-md);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-total .stat-icon { background: var(--blue-dim); color: var(--blue); }
.stat-online .stat-icon { background: var(--success-dim); color: var(--success); }
.stat-offline .stat-icon { background: var(--danger-dim); color: var(--danger); }
.stat-warning .stat-icon { background: var(--warning-dim); color: var(--warning); }

.stat-info { flex: 1; min-width: 0; }
.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 2px;
}

.stat-sub {
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 3px;
}

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

/* ============================================================
   Dashboard stat-card-dash variant
   ============================================================ */
.stat-card-dash {
  cursor: default;
  padding: 18px 20px;
}

.stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-total .stat-card-icon { background: var(--blue-dim); color: var(--blue); }
.stat-online .stat-card-icon { background: var(--success-dim); color: var(--success); }
.stat-offline .stat-card-icon { background: var(--danger-dim); color: var(--danger); }
.stat-warning .stat-card-icon { background: var(--warning-dim); color: var(--warning); }

.stat-card-body { min-width: 0; }
.stat-card-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.stat-card-label {
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-top: 3px;
  line-height: 1.3;
}

.stat-card-dash.stat-card-loading {
  opacity: 0.4;
  pointer-events: none;
}

/* ============================================================
   Section Headers
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 18px;
  background: var(--accent);
  border-radius: 2px;
}

.subsection-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin: 0 0 10px 0;
  padding-left: 2px;
}

/* ============================================================
   Module Cards (Dashboard)
   ============================================================ */
.module-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.module-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: all var(--ease-out);
  cursor: pointer;
}

.module-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  background: var(--bg-raised);
}

.module-card-admin {
  border-left: 3px solid var(--purple);
}

.module-card-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.module-icon-enlaces  { background: var(--blue-dim); color: var(--blue); }
.module-icon-eolicos  { background: rgba(20, 184, 166, 0.08); color: #0D9488; }
.module-icon-inventory{ background: var(--success-dim); color: var(--success); }
.module-icon-branches { background: var(--warning-dim); color: var(--warning); }
.module-icon-stock    { background: var(--purple-dim); color: var(--purple); }
.module-icon-decom    { background: var(--danger-dim); color: var(--danger); }
.module-icon-catalogs { background: var(--blue-dim); color: var(--blue); }
.module-icon-users    { background: rgba(236, 72, 153, 0.08); color: #DB2777; }

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

.module-card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
  letter-spacing: -0.01em;
}

.module-card-desc {
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.module-card-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: all var(--ease-out);
}

.module-card:hover .module-card-arrow {
  transform: translateX(3px);
  color: var(--accent);
}

/* ============================================================
   Welcome Banner (Dashboard)
   ============================================================ */
.welcome-banner {
  background: linear-gradient(135deg, #EFF6FF 0%, #FFFFFF 100%);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}

.welcome-banner-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  position: relative;
  z-index: 1;
  flex-wrap: wrap;
}

.welcome-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.welcome-greeting {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.welcome-greeting strong {
  color: var(--accent);
}

.welcome-banner-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.welcome-role {
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(37, 99, 235, 0.15);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.welcome-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Tabs
   ============================================================ */
.tab-nav {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
}

.tab-btn {
  flex: 1;
  padding: 9px 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  border-radius: 5px;
  transition: all var(--ease-out);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  touch-action: manipulation;
}

.tab-btn:hover {
  color: var(--text-secondary);
}

.tab-btn.active {
  background: var(--bg-raised);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Action Bar
   ============================================================ */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
}

.action-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  min-width: 200px;
  transition: all var(--ease-out);
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.search-box svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.85rem;
  font-family: var(--font-body);
  background: transparent;
  color: var(--text);
  min-width: 0;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.table-control {
  min-height: 34px;
  max-width: 210px;
  padding: 7px 30px 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.8rem;
}

.table-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  outline: none;
}

.refresh-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

.refresh-hint strong {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

/* ============================================================
   Data Tables
   ============================================================ */
.table-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
}

.eolicos-content,
.branches-content,
.enlaces-content {
  max-width: none;
}

@media (min-width: 769px) {
  .eolicos-content .eolicos-table-container .data-table,
  .branches-content .branches-table-container .data-table,
  .enlaces-content .enlaces-table-container .data-table {
    table-layout: auto;
  }

  .eolicos-content .eolicos-table-container .data-table { min-width: 0; }
  .branches-content .branches-table-container .data-table { min-width: 1120px; }
  .enlaces-content .enlaces-table-container .data-table { min-width: 1050px; }
}

.data-table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: var(--bg-raised);
  text-align: left;
  padding: 8px 10px;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  white-space: nowrap;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.data-table th.sortable:hover {
  color: var(--accent);
}

.data-table .table-group-row td {
  background: var(--bg-raised);
  border-bottom-color: var(--border);
  color: var(--text-secondary);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  font-size: clamp(0.74rem, 0.25vw + 0.68rem, 0.82rem);
  white-space: nowrap;
}

.data-table td.table-actions,
.data-table td[data-label="Acciones"] {
  white-space: nowrap;
}

.data-table td.table-actions .btn,
.data-table td[data-label="Acciones"] .btn {
  margin: 0;
}

.branch-map-actions { white-space: nowrap; }
.branch-map-actions .btn + .btn { margin-left: 4px; }
.external-map-modal { width: min(440px, 94vw); }
.external-map-destination { margin: -5px 0 14px; color: var(--text-secondary); font-size: .82rem; }
.external-map-options { display: grid; gap: 8px; }
.external-map-option { position: relative; display: flex; flex-direction: column; gap: 3px; padding: 13px 42px 13px 14px; color: var(--text); background: var(--bg-raised); border: 1px solid var(--border); border-radius: 8px; text-decoration: none; }
.external-map-option::after { content: '\2197'; position: absolute; right: 15px; top: 50%; color: var(--accent); font-size: 1.1rem; transform: translateY(-50%); }
.external-map-option:hover { background: var(--bg-hover); border-color: var(--accent); }
.external-map-option strong { color: var(--ink-strong, var(--text)); font-size: .88rem; }
.external-map-option span { color: var(--text-muted); font-size: .72rem; }
.external-map-note { margin: 13px 0 0; color: var(--text-muted); font-size: .68rem; }

.data-table tbody tr {
  transition: background var(--ease-out);
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.branch-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--ease-out);
}

.branch-link:hover {
  color: var(--accent-light);
}

.meter-report {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.report-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.report-link:hover {
  color: var(--accent-light);
  text-decoration: underline;
}

.row-desc {
  display: block;
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.text-muted {
  color: var(--text-secondary);
  font-size: 0.82rem;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.3;
}

.empty-state p {
  margin-bottom: 6px;
}

/* ============================================================
   Status Indicators
   ============================================================ */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.8rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--success);
}

.status-dot.offline {
  background: var(--danger);
}

.status-dot.pending {
  background: var(--warning);
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.status-online {
  background: var(--success-dim);
  color: var(--success);
}

.status-offline {
  background: var(--danger-dim);
  color: var(--danger);
}

/* ============================================================
   Offline Panel
   ============================================================ */
.dashboard-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
}

.offline-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
}

.offline-panel-header {
  background: var(--danger-dim);
  padding: 12px 16px;
  border-bottom: 1px solid rgba(220, 38, 38, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.offline-panel-header h3 {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--danger);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.offline-count {
  background: var(--danger);
  color: #FFFFFF;
  font-size: 0.7rem;
  padding: 3px 9px;
  border-radius: 12px;
  font-weight: 700;
  line-height: 1;
}

.offline-list {
  padding: 10px;
  overflow-y: auto;
  flex: 1;
}

.offline-item {
  padding: 10px 12px;
  background: var(--danger-dim);
  border: 1px solid rgba(220, 38, 38, 0.1);
  border-radius: var(--radius);
  margin-bottom: 6px;
  border-left: 3px solid var(--danger);
  transition: all var(--ease-out);
}

.offline-item:hover {
  background: rgba(220, 38, 38, 0.12);
}

.offline-item:last-child {
  margin-bottom: 0;
}

.offline-item-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 2px;
}

.offline-item-ip {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.offline-item-time {
  font-size: 0.71rem;
  color: var(--danger);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}

.offline-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.offline-empty-icon {
  font-size: 2rem;
  margin-bottom: 10px;
  opacity: 0.3;
}

/* ============================================================
   History Filters
   ============================================================ */
.history-filters {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.filter-group select,
.filter-group input {
  padding: 8px 11px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  font-family: var(--font-body);
  color: var(--text);
  min-width: 120px;
  transition: all var(--ease-out);
}

.filter-group select:focus,
.filter-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.filter-actions {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  margin-left: auto;
  flex-wrap: wrap;
}

.filter-sep {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  margin: 0 4px;
}

.history-table-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
}

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-raised);
}

.pagination-info {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.pagination-info strong {
  color: var(--text-secondary);
}

.pagination-buttons {
  display: flex;
  gap: 4px;
}

.page-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-family: var(--font-body);
  cursor: pointer;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--ease-out);
  min-height: 36px;
  min-width: 36px;
  touch-action: manipulation;
}

.page-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--text-muted);
  color: var(--text);
}

.page-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* ============================================================
   Modals
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-xl);
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in 200ms ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-sm { max-width: 420px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.modal-body {
  margin-bottom: 8px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--ease-out);
}

.modal-close:hover {
  color: var(--text);
  background: var(--bg-hover);
}

/* ============================================================
   Loading
   ============================================================ */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.loading-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--text-muted);
  gap: 10px;
  font-weight: 500;
}

/* ============================================================
   Skeleton Loading
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-raised) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-row td { padding: 10px 14px; }
.skeleton-row td .skeleton { height: 14px; width: 80%; }

/* ============================================================
   Code / Inline Elements
   ============================================================ */
code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--bg-raised);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--text-secondary);
  font-weight: 500;
  border: 1px solid var(--border-light);
}

/* ============================================================
   Event Badges
   ============================================================ */
.event-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.event-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.event-down {
  background: var(--danger-dim);
  color: var(--danger);
}
.event-down::before { background: var(--danger); }

.event-up {
  background: var(--success-dim);
  color: var(--success);
}
.event-up::before { background: var(--success); }

/* ============================================================
   Branch Detail
   ============================================================ */
.detail-back {
  margin-bottom: 20px;
}

.branch-selector {
  position: relative;
  margin-bottom: 18px;
  max-width: 560px;
}

.selector-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--ease-out);
  min-height: 44px;
}

.selector-trigger:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.selector-value {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.selector-value .status-dot {
  width: 9px;
  height: 9px;
}

.selector-ip {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.selector-placeholder {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.selector-chevron {
  color: var(--text-secondary);
  transition: transform var(--ease-out);
  flex-shrink: 0;
}

.selector-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  overflow: hidden;
}

.selector-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.selector-search input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.85rem;
  font-family: var(--font-body);
  background: transparent;
  color: var(--text);
}

.selector-search input::placeholder {
  color: var(--text-muted);
}

.selector-list {
  max-height: 260px;
  overflow-y: auto;
}

.selector-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  cursor: pointer;
  transition: background var(--ease-out);
  border-bottom: 1px solid var(--border-light);
}

.selector-option:last-child { border-bottom: none; }
.selector-option:hover { background: var(--bg-hover); }
.selector-option.selected { background: var(--accent-dim); }

.selector-option-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.selector-option-name {
  font-weight: 600;
  font-size: 0.86rem;
}

.selector-option-detail {
  font-size: 0.73rem;
  color: var(--text-secondary);
}

.selector-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.84rem;
}

/* Branch Info Card */
.detail-info-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 16px;
}

.detail-info-name {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.detail-info-name h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.detail-branch-num {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 3px 10px;
  border-radius: 12px;
}

.status-dot-lg { width: 12px; height: 12px; }

.detail-info-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 8px;
}

.detail-meta-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.detail-meta-item code {
  background: transparent;
  padding: 0;
}

.text-down { color: var(--danger); font-weight: 500; }

.maps-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 8px;
  vertical-align: middle;
}

.detail-info-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.branch-record {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line-structural, var(--border));
}

.branch-record h3 {
  margin: 0 0 12px;
  color: var(--ink-strong, var(--text));
  font-size: 0.92rem;
  font-weight: 750;
}

.branch-record-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 0;
  overflow: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--line-structural, var(--border));
  border-radius: 10px;
}

.branch-record-grid > div {
  min-width: 0;
  min-height: 82px;
  padding: 14px 15px;
  border-right: 1px dashed var(--line-structural, var(--border));
  border-bottom: 1px dashed var(--line-structural, var(--border));
}

.branch-record-grid > div:nth-child(5n) { border-right: 0; }
.branch-record-grid > div:nth-last-child(-n + 5) { border-bottom: 0; }

.branch-record-grid dt {
  margin-bottom: 7px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.63rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  line-height: 1.3;
  text-transform: uppercase;
}

.branch-record-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 650;
  line-height: 1.4;
}

.branch-record-grid a {
  color: var(--accent-structural, var(--accent));
  text-decoration: none;
}

.branch-record-grid a:hover { text-decoration: underline; }
.branch-record-grid a:focus-visible { outline: 3px solid var(--accent-glow); outline-offset: 3px; border-radius: 2px; }

.detail-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

.detail-stat-icon {
  background: var(--danger-dim);
  color: var(--danger);
}

.detail-timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.detail-timeline-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.row-ongoing { background: var(--danger-dim) !important; }
.row-ongoing:hover { background: rgba(220, 38, 38, 0.12) !important; }

.downtime-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.row-ongoing .downtime-badge {
  background: var(--danger-dim);
  color: var(--danger);
}

/* ============================================================
   Inventory
   ============================================================ */
.inventory-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0;
}

.equip-type-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.equip-monitor   { background: var(--blue-dim); color: var(--blue); }
.equip-cpu       { background: var(--purple-dim); color: var(--purple); }
.equip-scanner   { background: var(--success-dim); color: var(--success); }
.equip-pinpad    { background: var(--warning-dim); color: var(--warning); }
.equip-impresora { background: rgba(236, 72, 153, 0.08); color: #DB2777; }
.equip-nobreak   { background: rgba(99, 102, 241, 0.08); color: #4F46E5; }
.equip-router    { background: rgba(20, 184, 166, 0.08); color: #0D9488; }
.equip-switch    { background: rgba(14, 165, 233, 0.08); color: #0284C7; }
.equip-dvr_nvr   { background: var(--danger-dim); color: var(--danger); }
.equip-camaras   { background: rgba(234, 88, 12, 0.08); color: #C2410C; }

/* ============================================================
   Role Badges
   ============================================================ */
.role-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 0.76rem;
  font-weight: 600;
}

.role-admin  { background: var(--accent-dim); color: var(--accent); }
.role-user   { background: var(--blue-dim); color: var(--blue); }
.role-supervisor { background: rgba(236, 72, 153, 0.08); color: #DB2777; }

/* ============================================================
   Map
   ============================================================ */
#map-container { min-height: 300px; position: relative; }

.map-filters {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.map-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--ease-out);
  color: var(--text-secondary);
  touch-action: manipulation;
  min-height: 36px;
}

.map-filter-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.map-filter-btn--active {
  border-color: var(--blue);
  background: var(--blue-dim);
  color: var(--blue);
}

.map-filter-btn--online.map-filter-btn--active {
  border-color: var(--success);
  background: var(--success-dim);
  color: var(--success);
}

.map-filter-btn--offline.map-filter-btn--active {
  border-color: var(--danger);
  background: var(--danger-dim);
  color: var(--danger);
}

.map-filter-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.map-filter-dot--all     { background: var(--blue); }
.map-filter-dot--online  { background: var(--success); }
.map-filter-dot--offline { background: var(--danger); }

.map-filter-count {
  font-size: 0.68rem;
  background: rgba(0,0,0,0.05);
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 700;
}

.map-legend {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius);
  padding: 8px 14px;
  display: flex;
  gap: 14px;
  border: 1px solid var(--border);
  z-index: 2;
  font-size: 0.74rem;
  font-weight: 600;
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
}

.map-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.map-legend-dot--online  { background: var(--success); }
.map-legend-dot--offline { background: var(--danger); }

#map {
  width: 100%;
  height: 550px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  z-index: 1;
}

/* ============================================================
   Branch Thumbnail
   ============================================================ */
.branch-thumb {
  vertical-align: middle;
  border-radius: 4px;
  object-fit: cover;
  margin-left: 6px;
  border: 1px solid var(--border);
}

.branch-photo-detail {
  max-width: 200px;
  max-height: 150px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ============================================================
   Asesor TI Select
   ============================================================ */
.asesor-select {
  padding: 3px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-family: var(--font-body);
  color: var(--text);
  max-width: 120px;
  min-height: 36px;
}

.asesor-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ============================================================
   Import Result
   ============================================================ */
.import-result {
  font-size: 0.83rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius);
}

.import-ok   { background: var(--success-dim); color: var(--success); }
.import-warn { background: var(--warning-dim); color: var(--warning); }

/* ============================================================
   Puntos de Venta
   ============================================================ */
.pv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.pv-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all var(--ease-out);
}

.pv-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.pv-card.pv-selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.pv-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.pv-card-header strong {
  font-size: 0.9rem;
}

.pv-card-count {
  font-size: 0.73rem;
  color: var(--text-secondary);
}

.btn-close-sm {
  width: 22px;
  height: 22px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  opacity: 0.4;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--ease-out);
}

.btn-close-sm:hover {
  opacity: 1;
  background: var(--danger-dim);
  color: var(--danger);
}

/* ============================================================
   Desincorporacion
   ============================================================ */
.source-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 10px;
  font-size: 0.73rem;
  font-weight: 600;
  background: var(--purple-dim);
  color: var(--purple);
}

.row-procesado {
  opacity: 0.5;
  background: var(--bg-hover);
}

/* ============================================================
   Checkbox Grid
   ============================================================ */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 4px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  transition: background var(--ease-out);
}

.checkbox-label:hover {
  background: var(--bg-hover);
}

/* ============================================================
   Obsolescence Badges
   ============================================================ */
.obs-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 10px;
  font-size: 0.73rem;
  font-weight: 600;
}

.obs-green  { background: var(--success-dim); color: var(--success); }
.obs-yellow { background: var(--warning-dim); color: var(--warning); }
.obs-red    { background: var(--danger-dim); color: var(--danger); }

/* ============================================================
   Catalog Inline Forms
   ============================================================ */
.catalog-inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.catalog-inline-input {
  flex: 1;
  min-width: 200px;
  padding: 9px 13px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.86rem;
  font-family: var(--font-body);
  color: var(--text);
  transition: all var(--ease-out);
}

.catalog-inline-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.catalog-inline-select {
  padding: 9px 13px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.86rem;
  font-family: var(--font-body);
  color: var(--text);
  min-width: 140px;
  transition: all var(--ease-out);
}

.catalog-inline-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ============================================================
   Catalog Controls
   ============================================================ */
.catalog-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
}

.catalog-controls-right {
  display: flex;
  gap: 6px;
  align-items: center;
}

.catalog-filter-select {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.83rem;
  font-family: var(--font-body);
  color: var(--text);
  min-width: 180px;
  transition: all var(--ease-out);
}

.catalog-filter-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ============================================================
   Inline Edit
   ============================================================ */
.inline-edit-input {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-family: var(--font-body);
  color: var(--text);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.inline-edit-input:focus { outline: none; }

.inline-edit-select {
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  font-family: var(--font-body);
  color: var(--text);
  min-width: 100px;
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.inline-edit-select:focus { outline: none; }

/* ============================================================
   Row Actions
   ============================================================ */
.row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.row-deleting {
  background: var(--danger-dim) !important;
}

.delete-confirm {
  flex-wrap: wrap;
}

.delete-confirm-text {
  font-size: 0.76rem;
  color: var(--danger);
  font-weight: 500;
  white-space: nowrap;
}

/* ============================================================
   Type Name Cell / Brand Chip / Type Tag
   ============================================================ */
.type-name-cell { vertical-align: middle; }

.type-name {
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.brand-chip {
  display: inline-block;
  padding: 3px 9px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.type-tag {
  display: inline-block;
  padding: 3px 9px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  border-radius: 12px;
  font-size: 0.76rem;
  font-weight: 500;
  text-transform: capitalize;
}

/* ============================================================
   Brand Quick Add
   ============================================================ */
.brand-quick-add {
  margin-bottom: 14px;
}

.brand-quick-add-card {
  background: var(--bg-surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 18px;
}

.brand-quick-add-card h4 {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.brand-quick-add-input {
  width: 100%;
  padding: 9px 13px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.86rem;
  font-family: var(--font-body);
  color: var(--text);
  margin-bottom: 12px;
  transition: all var(--ease-out);
}

.brand-quick-add-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.brand-quick-add-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

/* ============================================================
   Model Form
   ============================================================ */
.model-form {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 14px;
}

/* ============================================================
   History Timeline (Equipment)
   ============================================================ */
.equip-row {
  cursor: pointer;
  transition: background var(--ease-out);
}

.equip-row:hover { background: var(--bg-hover); }

.history-modal { max-width: 580px; }

.history-equip-info {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  font-size: 0.83rem;
}

.history-equip-info code {
  color: var(--text-secondary);
  font-size: 0.76rem;
}

.history-timeline {
  position: relative;
  padding-left: 24px;
}

.history-timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border);
  border-radius: 1px;
}

.history-event {
  position: relative;
  padding-bottom: 20px;
}

.history-event:last-child { padding-bottom: 0; }

.history-event-dot {
  position: absolute;
  left: -17px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid var(--bg-surface);
  box-shadow: 0 0 0 2px var(--blue);
  z-index: 1;
}

.history-event--assigned .history-event-dot {
  background: var(--success);
  box-shadow: 0 0 0 2px var(--success);
}

.history-event--moved .history-event-dot {
  background: var(--warning);
  box-shadow: 0 0 0 2px var(--warning);
}

.history-event--desincorporado .history-event-dot,
.history-event--desincorporacion_pendiente .history-event-dot {
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--danger);
}

.history-event-body { font-size: 0.83rem; }

.history-event-date {
  font-size: 0.71rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.history-event-action {
  font-weight: 700;
  color: var(--text);
  font-size: 0.86rem;
}

.history-event-detail {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: 2px;
  line-height: 1.4;
}

.history-event-meta {
  color: var(--text-muted);
  font-size: 0.72rem;
  margin-top: 4px;
}

/* ============================================================
   Profile Page
   ============================================================ */
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.profile-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.profile-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.profile-card-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.profile-card-header svg {
  color: var(--accent);
  flex-shrink: 0;
}

.profile-photo-section {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}

.profile-photo-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--bg-raised);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.profile-photo-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-photo-avatar .avatar-letter {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
}

.profile-photo-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-photo-actions .btn {
  font-size: 0.8125rem;
}

.profile-photo-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.profile-card-full {
  grid-column: 1 / -1;
}

/* ============================================================
   Set Password Page
   ============================================================ */
.set-password-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-root);
  padding: 24px;
}

.set-pw-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.set-pw-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: var(--accent);
}

.set-pw-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 6px;
}

.set-pw-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 28px;
  line-height: 1.5;
}

.set-pw-error {
  background: var(--danger-dim);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  margin-bottom: 16px;
}

.set-pw-success {
  background: var(--success-dim);
  color: var(--success);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  margin-bottom: 16px;
}

/* ============================================================
   Animations & Utilities
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-slide-up { animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.animate-fade-in  { animation: fadeIn 0.25s ease; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

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

/* ============================================================
   Keyboard Focus
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1280px) {
  .stats-grid-dash {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats-grid-eolicos {
    grid-template-columns: repeat(2, 1fr);
  }
  .module-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1024px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    gap: 10px;
  }

  #map {
    height: 400px;
  }

  .detail-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  /* Sidebar hidden, overlay mode */
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    z-index: 300;
    transition: transform var(--ease-in-out);
  }

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

  .sidebar-overlay {
    display: block;
  }

  .main-area {
    margin-left: 0 !important;
  }

  .topbar-burger {
    display: flex;
  }

  .sidebar--collapsed {
    width: 280px;
  }

  .sidebar--collapsed .sidebar-link {
    justify-content: flex-start;
    padding: 9px 12px;
  }

  .sidebar--collapsed .sidebar-link-label {
    opacity: 1;
    width: auto;
    display: inline;
  }

  .sidebar--collapsed .sidebar-brand-text {
    opacity: 1;
    width: auto;
  }

  .sidebar--collapsed .sidebar-user-info,
  .sidebar--collapsed .sidebar-user-name,
  .sidebar--collapsed .sidebar-user-role {
    display: block;
  }

  .sidebar--collapsed .sidebar-user {
    padding: 14px 16px;
  }

  .sidebar-toggle {
    display: none;
  }

  .main-content {
    padding: 16px 12px;
  }

  /* Stats */
  .stat-card {
    padding: 12px 14px;
    gap: 10px;
  }

  .stat-icon {
    width: 36px;
    height: 36px;
  }

  .stat-value {
    font-size: 1.3rem;
  }

  .stat-label {
    font-size: 0.63rem;
  }

  .stat-sub {
    display: none;
  }

  .stat-card-dash {
    padding: 14px 16px;
  }

  .stat-card-icon {
    width: 40px;
    height: 40px;
  }

  .stat-card-value {
    font-size: 1.35rem;
  }

  /* History */
  .history-filters {
    flex-direction: column;
  }

  .filter-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }

  /* Tabs */
  .tab-btn {
    font-size: 0.78rem;
    padding: 8px 12px;
  }

  /* Modals */
  .modal-overlay {
    padding: 8px;
    align-items: flex-end;
  }

  .modal {
    max-width: 100%;
    max-height: 95vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: modal-in-mobile 250ms ease;
  }

  @keyframes modal-in-mobile {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .modal-header h2 { font-size: 1rem; }

  /* Card tables on mobile */
  .data-table,
  .data-table thead,
  .data-table tbody,
  .data-table th,
  .data-table td,
  .data-table tr {
    display: block;
  }

  .enlaces-table-container .data-table {
    min-width: 0;
  }

  .eolicos-table-container .data-table {
    min-width: 0;
  }

  .data-table thead { display: none; }

  .data-table tbody tr {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 12px 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    align-items: center;
  }

  .data-table tbody tr:nth-child(even) {
    background: var(--bg-surface);
  }

  .data-table tbody tr:last-child {
    margin-bottom: 0;
  }

  .data-table td {
    padding: 4px 0;
    border-bottom: none;
    font-size: 0.84rem;
  }

  .data-table td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    display: block;
    margin-bottom: 2px;
    line-height: 1.3;
  }

  .action-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .action-bar-left {
    flex-wrap: wrap;
  }

  .search-box,
  .table-control {
    width: 100%;
    max-width: none;
  }

  .data-table tbody tr.table-group-row {
    padding: 8px 12px;
    background: var(--bg-raised);
  }

  .data-table .table-group-row td::before {
    display: none;
  }

  .data-table .table-group-row td {
    grid-column: 1 / -1;
  }

  .form-actions {
    flex-direction: column-reverse;
    gap: 8px;
  }

  .form-actions .btn {
    width: 100%;
  }

  .branch-selector {
    max-width: 100%;
  }

  .pv-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
  }

  #map {
    height: 300px;
  }

  .map-legend {
    bottom: 6px;
    right: 6px;
    padding: 6px 10px;
    font-size: 0.68rem;
    gap: 10px;
  }

  .map-filter-btn {
    font-size: 0.74rem;
    padding: 6px 10px;
    min-height: 32px;
  }

  .map-filter-count {
    font-size: 0.66rem;
  }

  .welcome-banner {
    padding: 20px 20px;
    border-radius: var(--radius);
  }

  .welcome-banner-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .welcome-title {
    font-size: 1.3rem;
  }

  .welcome-banner-meta {
    flex-wrap: wrap;
  }

  .stats-grid-dash {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stats-grid-eolicos {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .module-grid {
    grid-template-columns: 1fr;
  }

  .catalog-inline-form {
    flex-direction: column;
  }

  .catalog-inline-input,
  .catalog-inline-select {
    width: 100%;
    min-width: 0;
  }

  .catalog-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .catalog-controls-right {
    width: 100%;
  }

  .catalog-filter-select {
    width: 100%;
  }

  .model-form {
    flex-direction: column;
  }

  .delete-confirm-text {
    font-size: 0.71rem;
  }

  .brand-chip, .type-tag {
    font-size: 0.73rem;
  }

  .detail-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .profile-photo-section {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .stat-card {
    padding: 10px 10px;
    gap: 8px;
  }

  .stat-icon {
    width: 30px;
    height: 30px;
  }

  .stat-value {
    font-size: 1.1rem;
  }

  .stat-label {
    font-size: 0.58rem;
  }

  .detail-stats-grid {
    grid-template-columns: 1fr;
  }

  .tab-nav {
    gap: 0;
    padding: 3px;
  }

  .tab-btn {
    font-size: 0.72rem;
    padding: 7px 8px;
  }

  .tab-btn svg {
    width: 14px;
    height: 14px;
  }

  .pagination {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
    text-align: center;
  }

  .pagination-buttons {
    justify-content: center;
  }

  .page-btn {
    flex: 1;
    text-align: center;
  }

  .sidebar {
    width: 85vw;
  }
}

@media (max-width: 360px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 5px;
  }

  .tab-btn {
    font-size: 0.68rem;
  }

  .data-table tbody tr {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

/* ============================================================
   Passkey Button & Login Divider
   ============================================================ */
.btn-passkey {
  background: var(--bg-raised);
  color: var(--text);
  border-color: var(--border);
  margin-bottom: 0;
  font-weight: 600;
  gap: 10px;
}

.btn-passkey:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.btn-passkey svg {
  opacity: 0.75;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.form-group-checkbox {
  margin-bottom: 18px;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem !important;
  font-weight: 500 !important;
  color: var(--text-secondary) !important;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}

.checkbox-label:hover {
  color: var(--text) !important;
}

/* ============================================================
   Dashboard: Register Passkey Button
   ============================================================ */
.passkey-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.passkey-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.passkey-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.84rem;
}

.passkey-item-icon {
  color: var(--success);
  flex-shrink: 0;
}

.passkey-item-name {
  flex: 1;
  font-weight: 500;
  color: var(--text);
}

.passkey-item-date {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* ============================================================
   Dark Mode
   ============================================================ */
[data-theme="dark"] {
  --bg-root: #0D1117;
  --bg-surface: #161B22;
  --bg-raised: #21262D;
  --bg-hover: #30363D;
  --bg-input: #0D1117;
  --border: #30363D;
  --border-light: #21262D;
  --text: #E6EDF3;
  --text-secondary: #8B949E;
  --text-muted: #6E7681;
  --accent: #58A6FF;
  --accent-light: #79C0FF;
  --accent-dim: rgba(88, 166, 255, 0.1);
  --accent-glow: rgba(88, 166, 255, 0.2);
  --success: #3FB950;
  --success-light: #56D364;
  --success-dim: rgba(63, 185, 80, 0.1);
  --success-glow: rgba(63, 185, 80, 0.2);
  --danger: #F85149;
  --danger-light: #FF7B72;
  --danger-dim: rgba(248, 81, 73, 0.1);
  --danger-glow: rgba(248, 81, 73, 0.2);
  --warning: #D29922;
  --warning-light: #E3B341;
  --warning-dim: rgba(210, 153, 34, 0.1);
  --warning-glow: rgba(210, 153, 34, 0.2);
  --blue: #58A6FF;
  --blue-dim: rgba(88, 166, 255, 0.1);
  --purple: #BC8CFF;
  --purple-dim: rgba(188, 140, 255, 0.1);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px -1px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .sidebar {
  background: #010409;
  border-right: 1px solid #30363D;
}

[data-theme="dark"] .sidebar-brand {
  border-bottom: 1px solid #30363D;
}

[data-theme="dark"] .sidebar-logo-dot {
  background: #58A6FF;
  box-shadow: 0 0 12px rgba(88, 166, 255, 0.5);
}

[data-theme="dark"] .sidebar-brand-text {
  color: #E6EDF3;
}

[data-theme="dark"] .sidebar-toggle {
  color: #6E7681;
}

[data-theme="dark"] .sidebar-toggle:hover {
  color: #E6EDF3;
  background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .sidebar-divider {
  background: #30363D;
}

[data-theme="dark"] .sidebar-link {
  color: #8B949E;
}

[data-theme="dark"] .sidebar-link:hover {
  color: #E6EDF3;
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .sidebar-link.active {
  color: #58A6FF;
  background: rgba(88, 166, 255, 0.1);
}

[data-theme="dark"] .sidebar-link.active::before {
  background: #58A6FF;
}

[data-theme="dark"] .sidebar-user {
  border-top: 1px solid #30363D;
}

[data-theme="dark"] .sidebar-user-link:hover {
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .sidebar-user-avatar {
  background: rgba(88, 166, 255, 0.12);
  color: #58A6FF;
}

[data-theme="dark"] .sidebar-user-name {
  color: #E6EDF3;
}

[data-theme="dark"] .sidebar-user-role {
  color: #6E7681;
}

[data-theme="dark"] .sidebar-user-logout {
  color: #6E7681;
}

[data-theme="dark"] .sidebar-user-passkey {
  border: 1px solid #30363D;
  color: #6E7681;
}

[data-theme="dark"] .sidebar-user-passkey:hover:not(:disabled) {
  color: #58A6FF;
  background: rgba(88, 166, 255, 0.1);
  border-color: #58A6FF;
}

[data-theme="dark"] .sidebar-user-logout:hover {
  color: #F85149;
  background: rgba(248, 81, 73, 0.1);
}

[data-theme="dark"] .welcome-banner {
  background: linear-gradient(135deg, #161B22 0%, #0D1117 100%);
  border: 1px solid #30363D;
  border-left: 4px solid #58A6FF;
}

[data-theme="dark"] .map-legend {
  background: rgba(22, 27, 34, 0.95);
  border: 1px solid #30363D;
}

[data-theme="dark"] .map-filter-count {
  background: rgba(255, 255, 255, 0.08);
}

/* ============================================================
   Sidebar Submenu
   ============================================================ */
.sidebar-group {
  position: relative;
}

.sidebar-sub-arrow {
  margin-left: auto;
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  transition: transform 0.2s ease;
  flex-shrink: 0;
  opacity: 0.5;
}

.sidebar-sub-arrow.rotate-180 {
  transform: rotate(180deg);
}

.sidebar-submenu {
  margin: 0 0 2px 0;
  padding: 0;
}

.sidebar-sublink {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px 7px 48px;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s ease;
  border-radius: var(--radius-sm);
  margin: 0 8px;
}

.sidebar-sublink:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.sidebar-sublink.active {
  color: var(--accent);
  background: var(--accent-dim);
  font-weight: 600;
}

/* ============================================================
   Status Badge Colors (Eolico Reportes)
   ============================================================ */
.status-blue {
  background: var(--blue-dim);
  color: var(--blue);
}

.status-amber {
  background: var(--amber-dim, #FFF3E0);
  color: var(--amber, #E65100);
}

.status-green {
  background: var(--green-dim, #E8F5E9);
  color: var(--green, #2E7D32);
}

[data-theme="dark"] .status-amber {
  background: rgba(245, 158, 11, 0.15);
  color: #FBBF24;
}

[data-theme="dark"] .status-green {
  background: rgba(5, 150, 105, 0.15);
  color: #34D399;
}

[data-theme="dark"] .status-blue {
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
}

/* ============================================================
   Eolico Reportes - Checklist Sections
   ============================================================ */
.checklist-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.checklist-section h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.checklist-section h4::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
}

.ping-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ping-result {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.info-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.info-row span:first-child {
  color: var(--text-muted);
  min-width: 90px;
}

.info-row strong {
  color: var(--text);
}

.info-row code {
  font-size: 0.8rem;
}

.text-success {
  color: var(--green, #059669);
}

.file-upload-area {
  margin-bottom: 8px;
}

.file-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-thumb {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  background: rgba(220, 38, 38, 0.85);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  padding: 0;
}

.file-remove:hover {
  background: rgba(220, 38, 38, 1);
}

.action-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checklist-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text);
  transition: all var(--ease-out);
}

.checklist-item:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.checklist-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.checklist-item span {
  line-height: 1.3;
}

@media (max-width: 480px) {
  .checklist-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Mobile-first operational polish
   ============================================================ */
.sidebar {
  background: #082A3A;
}

.sidebar-brand {
  min-height: 72px;
}

.sidebar-logo-dot {
  width: 10px;
  height: 10px;
  background: #36C5F0;
  box-shadow: 0 0 0 5px rgba(54, 197, 240, 0.12), 0 0 18px rgba(54, 197, 240, 0.65);
}

.sidebar-logo::before,
.sidebar-logo::after {
  content: '';
  position: absolute;
  height: 2px;
  background: #36C5F0;
  opacity: 0.75;
}

.sidebar-logo::before {
  width: 8px;
  left: 0;
}

.sidebar-logo::after {
  width: 8px;
  right: 0;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.sidebar-brand-text strong {
  font-size: 0.98rem;
  letter-spacing: -0.01em;
}

.sidebar-brand-text small {
  margin-top: 5px;
  color: #7DD3E8;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar-mini {
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 18px rgba(16, 42, 58, 0.04);
}

.topbar-mini::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 20px;
  width: 54px;
  height: 2px;
  background: var(--accent);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.mobile-filter-toggle {
  display: none;
}

.login-page {
  background-color: var(--bg-root);
  background-image: linear-gradient(rgba(8, 126, 164, 0.045) 1px, transparent 1px), linear-gradient(90deg, rgba(8, 126, 164, 0.045) 1px, transparent 1px);
  background-size: 28px 28px;
}

.login-page,
.set-password-page {
  min-height: 100dvh;
}

.login-card {
  border-top: 3px solid var(--accent);
}

.login-brand {
  text-align: left;
}

.login-brand > div {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.login-brand h1 {
  font-size: 1.65rem;
}

.login-brand > div > span {
  margin-top: 6px;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.login-brand-signal {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  width: 34px;
  height: 34px;
  padding: 7px;
  border-radius: 9px;
  background: #082A3A;
}

.login-brand-signal i {
  width: 4px;
  border-radius: 3px;
  background: #36C5F0;
}

.login-brand-signal i:nth-child(1) { height: 7px; }
.login-brand-signal i:nth-child(2) { height: 17px; }
.login-brand-signal i:nth-child(3) { height: 11px; }

[data-theme="dark"] {
  --bg-root: #071A24;
  --bg-surface: #0D2632;
  --bg-raised: #12313F;
  --bg-hover: #173D4D;
  --bg-input: #071A24;
  --border: #254756;
  --border-light: #173D4D;
  --text: #E7F3F7;
  --text-secondary: #A0BAC5;
  --text-muted: #7795A2;
  --accent: #36C5F0;
  --accent-light: #73D8F5;
  --accent-dim: rgba(54, 197, 240, 0.1);
  --accent-glow: rgba(54, 197, 240, 0.2);
}

[data-theme="dark"] .sidebar {
  background: #03131B;
}

@media (max-width: 768px) {
  html {
    font-size: 15px;
  }

  body.mobile-nav-open {
    overflow: hidden;
  }

  .sidebar {
    width: min(88vw, 340px);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 18px 0 50px rgba(3, 19, 27, 0.28);
  }

  .sidebar-overlay {
    z-index: 250;
    background: rgba(3, 19, 27, 0.55);
    backdrop-filter: blur(3px);
  }

  .topbar-mini {
    min-height: calc(58px + env(safe-area-inset-top));
    height: auto;
    padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
    gap: 10px;
  }

  .topbar-burger,
  .theme-toggle {
    width: 44px;
    height: 44px;
  }

  .topbar-breadcrumb {
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-role-badge,
  .topbar-date {
    display: none;
  }

  .main-content {
    padding: 18px max(14px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }

  .inventory-title,
  .welcome-title {
    font-size: 1.35rem;
  }

  .stats-grid,
  .stats-grid-dash,
  .stats-grid-eolicos {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-label,
  .stat-card-label {
    font-size: 0.74rem;
    line-height: 1.25;
  }

  .module-card {
    min-height: 84px;
  }

  .action-bar-left {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    width: 100%;
  }

  .action-bar-left > * {
    min-width: 0;
    max-width: none;
  }

  .action-bar-left .search-box {
    grid-column: 1 / -1;
  }

  .mobile-filter-toggle {
    display: inline-flex;
    grid-column: 1 / -1;
    justify-content: space-between;
  }

  .mobile-filter-toggle::after {
    content: '+';
    color: var(--accent);
    font-size: 1.1rem;
    line-height: 1;
  }

  .filters-open .mobile-filter-toggle::after {
    content: '\2212';
  }

  .action-bar:not(.filters-open) .action-bar-left > :not(.search-box):not(.mobile-filter-toggle):not(.btn-primary) {
    display: none !important;
  }

  .filters-open .action-bar-left > * {
    grid-column: 1 / -1;
    width: 100%;
  }

  .search-box,
  .table-control,
  .filter-group input,
  .filter-group select,
  .form-group input,
  .form-group select,
  .form-group textarea {
    min-height: 44px;
    font-size: 16px;
  }

  .history-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .filter-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-actions .btn {
    width: 100%;
  }

  .filter-sep {
    display: none;
  }

  .data-table tbody tr {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px 16px;
    padding: 15px;
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
  }

  .data-table td {
    min-width: 0;
    padding: 0;
    font-size: 0.9rem;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .data-table td::before {
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 0.69rem;
  }

  .data-table td[data-label="Acciones"],
  .data-table td.table-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--border-light);
  }

  .data-table td[data-label="Acciones"]::before,
  .data-table td.table-actions::before {
    width: 100%;
  }

  .branch-map-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding-top: 6px !important;
    border-top: 1px solid var(--border-light) !important;
  }

  .branch-map-actions::before { width: 100%; }
  .branch-map-actions .btn + .btn { margin-left: 0; }

  .text-muted {
    white-space: normal;
  }

  .pagination {
    padding: 14px;
  }

  .page-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .modal-overlay {
    padding: env(safe-area-inset-top) 0 0;
  }

  .modal {
    max-height: calc(100dvh - env(safe-area-inset-top));
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
  }

  .modal-header {
    position: sticky;
    top: -18px;
    z-index: 3;
    margin: -18px -16px 18px;
    padding: 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
  }

  .modal-close {
    width: 44px;
    height: 44px;
  }

  .map-filter-btn {
    min-height: 44px;
  }

  #map {
    height: min(58dvh, 420px);
    border-radius: var(--radius-md);
  }
}

@media (max-width: 420px) {
  .history-filters,
  .filter-actions,
  .data-table tbody tr {
    grid-template-columns: 1fr;
  }

  .section-header {
    align-items: flex-start;
  }

  .section-header .btn {
    white-space: normal;
  }

  .login-container {
    padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  }

  .login-card {
    padding: 30px 22px;
  }

  .set-password-page {
    padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  }

  .set-pw-card {
    padding: 30px 22px;
  }
}

@media (hover: none), (pointer: coarse) {
  .btn,
  .btn-sm,
  .btn-xs,
  .btn-icon,
  .sidebar-link,
  .sidebar-user-logout,
  .sidebar-user-passkey,
  .tab-btn,
  .page-btn,
  .selector-trigger,
  .selector-option {
    min-height: 44px;
  }

  .sidebar-user-logout,
  .sidebar-user-passkey,
  .btn-icon {
    min-width: 44px;
  }
}

/* Eolicos table actions */
.data-table td.meter-actions {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 7px;
  min-width: 190px;
  white-space: nowrap;
}

@media (min-width: 769px) {
  .eolicos-content .data-table td.meter-actions {
    min-width: 0;
    flex-wrap: nowrap;
    gap: 4px;
  }

  .eolicos-content .meter-actions .btn {
    padding-inline: 6px;
  }
}

@media (min-width: 769px) {
  .eolicos-content .eolicos-table-container .data-table th {
    padding-inline: 8px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .eolicos-content .eolicos-table-container .data-table td {
    padding: 9px 8px;
  }

  .eolicos-content .eolicos-table-container .data-table td:nth-child(3),
  .eolicos-content .eolicos-table-container .data-table td:nth-child(5),
  .eolicos-content .eolicos-table-container .data-table td:nth-child(7),
  .eolicos-content .eolicos-table-container .data-table td:nth-child(9),
  .eolicos-content .eolicos-table-container .data-table td:nth-child(10),
  .eolicos-content .eolicos-table-container .data-table td:nth-child(11) {
    white-space: nowrap;
  }

  .eolicos-content .eolicos-table-container .data-table td:nth-child(4),
  .eolicos-content .eolicos-table-container .data-table td:nth-child(6) {
    max-width: 170px;
    overflow-wrap: anywhere;
  }
}

.meter-actions .btn {
  min-height: 36px;
  margin: 0;
}

.meter-action-delete {
  width: 36px;
  min-width: 36px;
  padding-inline: 0;
  font-size: 1.05rem;
}

@media (max-width: 768px) {
  .data-table td.meter-actions {
    width: 100%;
    min-width: 0;
  }

  .meter-actions .btn:not(.meter-action-delete) {
    flex: 1;
  }

  .meter-action-delete {
    width: 44px;
    min-width: 44px;
  }
}
/* Supervisor command center */
.supervisor-content { max-width: 1500px; }
.supervisor-masthead { display:flex; align-items:flex-end; justify-content:space-between; gap:24px; padding:22px 24px; margin-bottom:18px; border-left:5px solid #d89a2b; background:linear-gradient(115deg, color-mix(in srgb, var(--bg-surface) 94%, #d89a2b 6%), var(--bg-surface)); box-shadow:var(--shadow-sm); }
.supervisor-masthead h1 { margin:4px 0 6px; font-size:clamp(1.8rem,3vw,3rem); letter-spacing:-.04em; }
.supervisor-masthead p { margin:0; color:var(--text-muted); }
.supervisor-eyebrow { color:#a56b08; font-size:.7rem; font-weight:800; letter-spacing:.14em; text-transform:uppercase; }
.supervisor-seal { width:92px; height:92px; flex:0 0 92px; border:1px solid color-mix(in srgb, #d89a2b 55%, var(--border)); border-radius:50%; display:grid; place-content:center; text-align:center; }
.supervisor-seal span { font:800 2rem/1 var(--font-mono,monospace); }
.supervisor-seal small { color:var(--text-muted); font-size:.65rem; text-transform:uppercase; letter-spacing:.08em; }
.supervisor-message { padding:12px 16px; margin-bottom:14px; border:1px solid var(--border); background:var(--bg-surface); }
.supervisor-message.success { border-color:var(--success); color:var(--success); }
.supervisor-message.error { border-color:var(--danger); color:var(--danger); }
.supervisor-admin-picker { display:flex; align-items:center; gap:12px; margin-bottom:14px; }
.supervisor-admin-picker label { font-weight:700; }
.supervisor-tabs { display:flex; gap:4px; border-bottom:1px solid var(--border); margin-bottom:18px; }
.supervisor-tabs button { border:0; background:transparent; color:var(--text-muted); padding:11px 16px; font-weight:700; border-bottom:3px solid transparent; cursor:pointer; }
.supervisor-tabs button.active { color:var(--text); border-color:#d89a2b; }
.supervisor-tabs span { display:inline-grid; place-items:center; min-width:20px; height:20px; margin-left:5px; border-radius:10px; background:var(--bg-root); font-size:.7rem; }
.supervisor-command { display:flex; align-items:center; gap:30px; padding:15px 18px; margin-bottom:14px; background:var(--bg-surface); border:1px solid var(--border); }
.supervisor-command div { display:grid; gap:2px; }
.supervisor-command span { color:var(--text-muted); font-size:.72rem; text-transform:uppercase; letter-spacing:.07em; }
.supervisor-command strong { font-size:1.05rem; }
.supervisor-command-actions { margin-left:auto; display:flex !important; grid-auto-flow:column; gap:6px !important; }
.supervisor-roster { display:grid; grid-template-columns:repeat(auto-fit,minmax(300px,1fr)); gap:12px; }
.supervisor-person { background:var(--bg-surface); border:1px solid var(--border); padding:16px; position:relative; overflow:hidden; }
.supervisor-person::before { content:""; position:absolute; inset:0 auto 0 0; width:3px; background:var(--success); }
.supervisor-person.is-blocked::before { background:var(--danger); }
.supervisor-person-head { display:flex; align-items:center; gap:11px; }
.supervisor-monogram { width:42px; height:42px; display:grid; place-items:center; background:color-mix(in srgb,#d89a2b 14%,var(--bg-root)); border:1px solid color-mix(in srgb,#d89a2b 35%,var(--border)); font-weight:800; }
.supervisor-person h3 { margin:0 0 4px; font-size:1rem; }
.supervisor-branch-count { margin-left:auto; font:800 1.7rem/1 var(--font-mono,monospace); }
.supervisor-branch-count::after { content:" suc."; display:block; color:var(--text-muted); font:600 .58rem/1.5 sans-serif; text-transform:uppercase; }
.supervisor-person > p { color:var(--text-muted); min-height:20px; font-size:.78rem; }
.supervisor-person-actions { display:flex; flex-wrap:wrap; gap:6px; padding-top:10px; border-top:1px solid var(--border); }
.supervisor-timeline { position:relative; padding-left:28px; }
.supervisor-timeline::before { content:""; position:absolute; left:8px; top:8px; bottom:8px; width:1px; background:var(--border); }
.supervisor-timeline > article { position:relative; margin-bottom:12px; }
.supervisor-timeline-dot { position:absolute; left:-25px; top:18px; width:11px; height:11px; border:2px solid var(--bg-surface); border-radius:50%; background:#d89a2b; box-shadow:0 0 0 1px #d89a2b; }
.supervisor-timeline-dot.completed { background:var(--success); box-shadow:0 0 0 1px var(--success); }
.supervisor-timeline-dot.attention { background:var(--danger); box-shadow:0 0 0 1px var(--danger); }
.supervisor-timeline-card { padding:15px 17px; background:var(--bg-surface); border:1px solid var(--border); }
.supervisor-timeline-card > div { display:flex; justify-content:space-between; gap:12px; }
.supervisor-timeline-card p { margin:7px 0; }
.supervisor-timeline-card small { color:var(--text-muted); }
.supervisor-modal { max-width:680px; }
.supervisor-modal-summary { padding:12px; background:var(--bg-root); border-left:3px solid #d89a2b; color:var(--text-muted); }
.supervisor-branch-picker { max-height:260px; overflow:auto; border:1px solid var(--border); }
.supervisor-branch-picker label { display:flex; align-items:center; gap:9px; padding:9px 11px; border-bottom:1px solid var(--border); cursor:pointer; }
.supervisor-branch-picker label:last-child { border-bottom:0; }
.supervisor-check-all { position:sticky; top:0; z-index:1; background:var(--bg-root); font-weight:700; }
@media (max-width:700px) { .supervisor-masthead { align-items:center; padding:17px; } .supervisor-seal { width:68px; height:68px; flex-basis:68px; } .supervisor-command { align-items:flex-start; flex-wrap:wrap; gap:14px; } .supervisor-command .btn { width:100%; margin:0; } .supervisor-roster { grid-template-columns:1fr; } .supervisor-person-actions .btn { flex:1 1 45%; } .supervisor-tabs { overflow-x:auto; } }

/* ============================================================
   Corporate operations system
   Shared visual language for authenticated application pages
   ============================================================ */
.corporate-page {
  background-color: var(--bg-root);
  background-image:
    linear-gradient(rgba(23, 107, 135, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 107, 135, .025) 1px, transparent 1px);
  background-size: 32px 32px;
}

.corporate-page .main-area {
  background: color-mix(in srgb, var(--bg-root) 96%, transparent);
}

.corporate-page .corporate-shell {
  width: 100%;
  max-width: 1500px;
  margin-inline: auto;
  padding: 30px 32px 56px;
}

.corporate-page .topbar-mini {
  min-height: 62px;
  background: color-mix(in srgb, var(--bg-surface) 96%, transparent);
  border-bottom-color: var(--line-structural);
  box-shadow: none;
  backdrop-filter: blur(12px);
}

.corporate-page .topbar-mini > .topbar-burger { order: 0; }
.corporate-page .topbar-mini > .topbar-breadcrumb { order: 1; }
.corporate-page .topbar-mini > .topbar-spacer { order: 2; flex: 1; }
.corporate-page .topbar-mini > :not(.topbar-burger):not(.topbar-breadcrumb):not(.topbar-spacer) { order: 3; }
.corporate-page .topbar-breadcrumb { color: var(--ink-strong); font-weight: 750; }
.corporate-page .topbar-mini::after { width: 72px; background: var(--accent-interactive); }

.corporate-page .sidebar {
  background: #082B3B;
  border-right: 1px solid rgba(145, 202, 218, .14);
  box-shadow: 10px 0 32px rgba(6, 29, 40, .08);
}

.corporate-page .sidebar-brand { border-bottom-color: rgba(201, 218, 226, .12); }
.corporate-page .sidebar-divider { background: rgba(201, 218, 226, .13); }
.corporate-page .sidebar-link { border: 1px solid transparent; border-radius: 7px; }
.corporate-page .sidebar-link:hover { color: #EAF8FB; background: rgba(92, 190, 211, .09); }
.corporate-page .sidebar-link.active {
  color: #FFFFFF;
  background: rgba(71, 185, 208, .14);
  border-color: rgba(125, 211, 232, .18);
}
.corporate-page .sidebar-link.active::before { width: 3px; background: #60D2E4; }
.corporate-page .sidebar-user { border-top-color: rgba(201, 218, 226, .13); }

.page-masthead {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin: 0 0 24px;
  padding: 8px 0 25px;
  border-bottom: 1px solid var(--line-structural);
}

.page-masthead::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: clamp(88px, 12vw, 176px);
  height: 3px;
  background: linear-gradient(90deg, var(--accent-structural) 0 72%, var(--accent-interactive) 72% 86%, transparent 86% 90%, var(--accent-stamp) 90%);
}

.page-masthead-copy { min-width: 0; }
.page-kicker {
  display: block;
  margin: 0 0 7px;
  color: var(--accent-structural);
  font-family: var(--font-mono);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .14em;
  line-height: 1.35;
  text-transform: uppercase;
}
.page-title {
  margin: 0;
  color: var(--ink-strong);
  font-size: clamp(2rem, 3vw, 3.15rem);
  font-weight: 780;
  letter-spacing: -.05em;
  line-height: 1;
}
.page-description {
  max-width: 680px;
  margin: 12px 0 0;
  color: var(--text-secondary);
  font-size: .95rem;
  line-height: 1.55;
}
.page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}
.page-actions .welcome-role,
.page-actions .welcome-date {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin: 0;
  padding: 6px 10px;
  color: var(--text-secondary);
  background: var(--bg-raised);
  border: 1px solid var(--line-structural);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.corporate-page .btn,
.corporate-page .page-btn {
  min-height: var(--control-height);
  border-radius: 7px;
  box-shadow: none;
  font-weight: 720;
  transition: color .15s, background-color .15s, border-color .15s, transform .15s;
}
.corporate-page .btn-sm { min-height: 40px; }
.corporate-page .btn-xs { min-height: 34px; }
.corporate-page .btn-primary { color: #FFF; background: var(--accent-structural); border-color: var(--accent-structural); }
.corporate-page .btn-primary:hover:not(:disabled) { color: #FFF; background: #105B74; border-color: #105B74; }
.corporate-page .btn-outline { color: var(--ink-strong); background: var(--bg-surface); border-color: var(--line-structural); }
.corporate-page .btn-outline:hover:not(:disabled) { color: var(--accent-structural); background: var(--bg-hover); border-color: var(--accent-structural); }
.corporate-page .btn:active:not(:disabled),
.corporate-page .page-btn:active:not(:disabled) { transform: translateY(1px); }

.corporate-page .action-bar,
.corporate-page .history-filters,
.corporate-page .map-filters {
  margin-bottom: 14px;
  padding: 13px;
  background: var(--surface-paper);
  border: 1px solid var(--line-structural);
  border-radius: 10px;
  box-shadow: none;
}
.corporate-page .action-bar { align-items: center; }
.corporate-page .action-bar-left { gap: 8px; }
.corporate-page .search-box,
.corporate-page .table-control,
.corporate-page .filter-group input,
.corporate-page .filter-group select,
.corporate-page .form-group input,
.corporate-page .form-group select,
.corporate-page .form-group textarea {
  min-height: var(--control-height);
  color: var(--text);
  background: var(--bg-input);
  border-color: var(--line-structural);
  border-radius: 7px;
}
.corporate-page :is(input, select, textarea):focus {
  border-color: var(--accent-interactive);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-interactive) 18%, transparent);
}
.corporate-page .filter-group label,
.corporate-page .form-group label {
  color: var(--text-secondary);
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .025em;
}
.corporate-page .branch-lookup-control > div { width: 100%; }
.corporate-page .branch-lookup-control small { display: block; margin-bottom: 5px; color: var(--text-muted); }
.corporate-page .branch-lookup-control input { width: 100%; min-height: var(--control-height); padding: 9px 13px; color: var(--text); background: var(--bg-input); border: 1px solid var(--line-structural); border-radius: 7px; font-family: inherit; font-size: 16px; }
.corporate-page .refresh-hint {
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px dashed var(--line-structural);
  border-radius: 6px;
}

.corporate-page .table-container,
.corporate-page .history-table-container {
  background: var(--bg-surface);
  border: 1px solid var(--line-structural);
  border-radius: 12px;
  box-shadow: none;
}
.corporate-page .data-table { color: var(--text); }
.corporate-page .data-table thead { background: var(--bg-raised); }
.corporate-page .data-table th {
  height: 42px;
  padding: 8px 13px;
  color: var(--text-muted);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line-structural);
  font-family: var(--font-mono);
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .055em;
  line-height: 1.25;
  text-transform: uppercase;
}
.corporate-page .data-table td {
  padding: 12px 13px;
  border-bottom: 1px dashed var(--line-structural);
}
.corporate-page .data-table tbody tr:last-child td { border-bottom: 0; }
.corporate-page .data-table tbody tr:hover { background: color-mix(in srgb, var(--accent-interactive) 5%, var(--bg-surface)); }
.corporate-page .data-table code,
.corporate-page .selector-ip,
.corporate-page .pagination-info { font-family: var(--font-mono); font-size: .76rem; }
.corporate-page .sortable:hover { color: var(--accent-structural); background: var(--bg-hover); }
.corporate-page .table-group-row td {
  color: var(--accent-structural);
  background: color-mix(in srgb, var(--accent-structural) 7%, var(--bg-raised));
  border-bottom-style: solid;
}
.corporate-page .pagination {
  min-height: 58px;
  background: var(--bg-raised);
  border-top: 1px solid var(--line-structural);
}
.corporate-page .page-btn { color: var(--ink-strong); background: var(--bg-surface); border-color: var(--line-structural); }

.corporate-page .status-badge,
.corporate-page .event-badge,
.corporate-page .role-badge,
.corporate-page .source-badge {
  border-width: 1px;
  border-style: solid;
  font-size: .68rem;
  font-weight: 750;
  letter-spacing: .015em;
}
.corporate-page .status-online,
.corporate-page .event-up { border-color: #B9E2CD; }
.corporate-page .status-offline,
.corporate-page .event-down { border-color: #E9B9AF; }

.corporate-page .empty-state,
.corporate-page .loading-page {
  min-height: 180px;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px dashed var(--line-structural);
  border-radius: 12px;
}
.corporate-page .import-result,
.corporate-page .alert,
.corporate-page .set-pw-error,
.corporate-page .set-pw-success {
  border-radius: 7px;
  box-shadow: none;
}

.corporate-page .section-header {
  margin: 28px 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-structural);
}
.corporate-page .section-title,
.corporate-page .section-header h3 {
  color: var(--ink-strong);
  font-size: 1rem;
  letter-spacing: -.01em;
}
.corporate-page .subsection-label {
  margin-top: 18px;
  color: var(--accent-structural);
  font-family: var(--font-mono);
  font-size: .67rem;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.corporate-page .stats-grid { gap: 0; overflow: hidden; background: var(--bg-surface); border: 1px solid var(--line-structural); border-radius: 12px; }
.corporate-page .stat-card,
.corporate-page .stat-card-dash {
  min-height: 108px;
  margin: 0;
  padding: 18px 20px;
  background: var(--bg-surface);
  border: 0;
  border-right: 1px dashed var(--line-structural);
  border-radius: 0;
  box-shadow: none;
}
.corporate-page .stat-card:last-child { border-right: 0; }
.corporate-page .stat-card::before { display: none; }
.corporate-page .stat-card-value { color: var(--ink-strong); font-family: var(--font-mono); font-size: 2rem; font-variant-numeric: tabular-nums; }
.corporate-page .stat-card-label { color: var(--text-secondary); font-family: var(--font-mono); font-size: .66rem; letter-spacing: .055em; text-transform: uppercase; }
.corporate-page .stat-card-icon { width: 38px; height: 38px; border: 1px solid currentColor; border-radius: 50%; background: transparent; }
.corporate-page .stat-card-link { color: inherit; text-decoration: none; cursor: pointer; }
.corporate-page .stat-card-link:hover { z-index: 1; background: color-mix(in srgb, var(--accent-interactive) 6%, var(--bg-surface)); box-shadow: inset 0 -3px 0 var(--accent-interactive); transform: none; }
.corporate-page .stat-card-link:focus-visible { z-index: 2; outline: 3px solid color-mix(in srgb, var(--accent-interactive) 35%, transparent); outline-offset: -3px; }
.eolico-pending-link { width: fit-content; display: inline-flex; align-items: center; gap: 4px; margin: 9px 0 0 auto; padding: 5px 9px; color: #8A5A16; background: #FFF7DE; border: 1px solid #EACF86; border-radius: 999px; text-decoration: none; font-size: .74rem; font-weight: 700; }
.eolico-pending-link:hover { background: #FFEFBA; }

.corporate-page .module-grid { gap: 12px; }
.corporate-page .module-card {
  min-height: 112px;
  background: var(--bg-surface);
  border: 1px solid var(--line-structural);
  border-radius: 10px;
  box-shadow: none;
}
.corporate-page .module-card:hover { border-color: var(--accent-structural); box-shadow: 0 8px 22px rgba(23, 50, 77, .08); transform: translateY(-2px); }
.corporate-page .module-card-icon { border: 1px solid currentColor; border-radius: 8px; }
.corporate-page .module-card-title { color: var(--ink-strong); }
.corporate-page .module-card-arrow { color: var(--accent-structural); }

.corporate-page .tab-nav,
.corporate-page .supervisor-tabs {
  width: fit-content;
  max-width: 100%;
  gap: 4px;
  margin: 0 0 18px;
  padding: 4px;
  overflow-x: auto;
  background: color-mix(in srgb, var(--line-structural) 55%, var(--bg-root));
  border: 0;
  border-radius: 9px;
}
.corporate-page .tab-btn,
.corporate-page .supervisor-tabs button {
  min-height: 40px;
  padding: 8px 15px;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  border-radius: 6px;
  white-space: nowrap;
}
.corporate-page .tab-btn.active,
.corporate-page .supervisor-tabs button.active {
  color: var(--ink-strong);
  background: var(--bg-surface);
  border: 0;
  box-shadow: 0 1px 3px rgba(23, 50, 77, .13);
}

.corporate-page .modal-overlay { background: rgba(5, 25, 35, .62); backdrop-filter: blur(4px); }
.corporate-page .modal {
  background: var(--bg-surface);
  border: 1px solid var(--line-structural);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(5, 25, 35, .24);
}
.corporate-page .modal-header { border-bottom-color: var(--line-structural); }
.corporate-page .modal-header h2 { color: var(--ink-strong); letter-spacing: -.025em; }
.corporate-page .modal-close { color: var(--text-secondary); background: var(--bg-raised); border: 1px solid var(--line-structural); border-radius: 7px; }

.corporate-page .branch-selector,
.corporate-page .branch-detail-card,
.corporate-page .profile-card,
.corporate-page .catalog-section,
.corporate-page .checklist-section,
.corporate-page .report-detail-section,
.corporate-page .supervisor-command,
.corporate-page .supervisor-person,
.corporate-page .supervisor-timeline-card {
  background: var(--bg-surface);
  border-color: var(--line-structural);
  border-radius: 10px;
  box-shadow: none;
}
.corporate-page .profile-card { overflow: hidden; }
.corporate-page .profile-card-header,
.corporate-page .catalog-section-header { border-bottom-color: var(--line-structural); background: var(--bg-raised); }

.corporate-page .supervisor-masthead {
  margin-bottom: 24px;
  padding: 8px 0 25px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-structural);
  border-radius: 0;
  box-shadow: none;
}
.corporate-page .supervisor-seal { border-color: color-mix(in srgb, var(--accent-stamp) 55%, var(--line-structural)); }
.corporate-page .supervisor-tabs button.active { color: var(--accent-stamp); }
.corporate-page .supervisor-person { overflow: hidden; }
.corporate-page .supervisor-monogram { border-radius: 50%; }

[data-theme="dark"] {
  --ink-strong: #D9EDF4;
  --accent-structural: #67C4D4;
  --accent-interactive: #47B6C8;
  --surface-paper: #121E29;
  --accent-stamp: #E27A53;
  --line-structural: #344B59;
}
[data-theme="dark"] .corporate-page { background-image: linear-gradient(rgba(103, 196, 212, .022) 1px, transparent 1px), linear-gradient(90deg, rgba(103, 196, 212, .022) 1px, transparent 1px); }
[data-theme="dark"] .corporate-page .sidebar { background: #031923; }
[data-theme="dark"] .corporate-page .stat-card-link:hover,
[data-theme="dark"] .corporate-page .data-table tbody tr:hover { background: color-mix(in srgb, var(--accent-interactive) 8%, var(--bg-surface)); }

@media (max-width: 1050px) {
  .corporate-page .page-masthead { align-items: flex-start; }
  .corporate-page .page-actions { max-width: 48%; }
  .corporate-page .stats-grid-dash { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .corporate-page .stats-grid-dash .stat-card:nth-child(2n) { border-right: 0; }
  .corporate-page .stats-grid-dash .stat-card:nth-child(-n+2) { border-bottom: 1px dashed var(--line-structural); }
}

@media (max-width: 768px) {
  .corporate-page .corporate-shell { padding: 18px max(14px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
  .corporate-page .topbar-mini { min-height: calc(58px + env(safe-area-inset-top)); }
  .corporate-page .page-masthead { display: block; margin-bottom: 18px; padding: 2px 0 20px; }
  .corporate-page .page-title { font-size: 2rem; }
  .corporate-page .page-description { margin-top: 9px; font-size: .84rem; }
  .corporate-page .page-actions { max-width: none; justify-content: flex-start; margin-top: 16px; }
  .corporate-page .page-actions > * { flex: 1 1 auto; }
  .corporate-page .page-actions .welcome-role,
  .corporate-page .page-actions .welcome-date { flex: 0 1 auto; }
  .corporate-page .action-bar,
  .corporate-page .history-filters { padding: 11px; }
  .corporate-page .data-table tbody tr { border-left-color: var(--accent-structural); border-radius: 10px; box-shadow: none; }
  .corporate-page .data-table td { border-bottom: 0; }
  .corporate-page .table-container { background: transparent; border: 0; overflow: visible; }
  .corporate-page .data-table tbody tr { background: var(--bg-surface); border: 1px solid var(--line-structural); border-left-width: 3px; }
  .corporate-page .pagination { margin-top: 10px; border: 1px solid var(--line-structural); border-radius: 10px; }
  .corporate-page .module-grid { grid-template-columns: 1fr; }
  .corporate-page .module-card { min-height: 92px; }
  .corporate-page .modal { border-radius: 18px 18px 0 0; }
  .branch-record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .branch-record-grid > div,
  .branch-record-grid > div:nth-child(5n),
  .branch-record-grid > div:nth-last-child(-n + 5) { border-right: 1px dashed var(--line-structural, var(--border)); border-bottom: 1px dashed var(--line-structural, var(--border)); }
  .branch-record-grid > div:nth-child(2n) { border-right: 0; }
  .branch-record-grid > div:nth-last-child(-n + 2) { border-bottom: 0; }
}

@media (max-width: 460px) {
  .corporate-page .stats-grid,
  .corporate-page .stats-grid-dash,
  .corporate-page .stats-grid-eolicos { grid-template-columns: 1fr; }
  .corporate-page .stat-card,
  .corporate-page .stat-card-dash { min-height: 92px; border-right: 0; border-bottom: 1px dashed var(--line-structural); }
  .corporate-page .stats-grid .stat-card:last-child { border-bottom: 0; }
  .corporate-page .stats-grid-dash .stat-card:nth-child(-n+2) { border-bottom: 1px dashed var(--line-structural); }
  .corporate-page .page-actions { display: grid; grid-template-columns: 1fr; width: 100%; }
  .corporate-page .page-actions > * { width: 100%; }
  .branch-record-grid { grid-template-columns: 1fr; }
  .branch-record-grid > div,
  .branch-record-grid > div:nth-child(2n),
  .branch-record-grid > div:nth-last-child(-n + 2) { min-height: 0; border-right: 0; border-bottom: 1px dashed var(--line-structural, var(--border)); }
  .branch-record-grid > div:last-child { border-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .corporate-page *,
  .corporate-page *::before,
  .corporate-page *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ============================================================
   Internal branch map console
   ============================================================ */
.map-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 14px;
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--line-structural);
  border-radius: 12px;
}

.map-summary > div {
  min-height: 82px;
  display: flex;
  flex-direction: column-reverse;
  justify-content: center;
  gap: 3px;
  padding: 14px 18px;
  border-right: 1px dashed var(--line-structural);
}

.map-summary > div:last-child { border-right: 0; }
.map-summary span { color: var(--text-secondary); font-family: var(--font-mono); font-size: .62rem; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.map-summary strong { color: var(--ink-strong); font: 800 1.65rem/1 var(--font-mono); }
.map-summary .is-danger strong { color: var(--danger); }
.map-summary .is-warning strong { color: var(--warning); }

.corporate-page .map-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, .75fr) minmax(0, 2fr);
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 11px;
  background: var(--surface-paper);
  border: 1px solid var(--line-structural);
  border-radius: 10px;
}

.map-search { position: relative; }
.map-search svg { position: absolute; left: 12px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); fill: none; stroke: var(--text-muted); stroke-width: 1.8; pointer-events: none; }
.map-search input { width: 100%; min-height: 42px; padding: 9px 12px 9px 38px; color: var(--text); background: var(--bg-input); border: 1px solid var(--line-structural); border-radius: 7px; font-family: inherit; font-size: 16px; }
.corporate-page .map-toolbar .map-filters { display: flex; justify-content: flex-end; gap: 5px; margin: 0; padding: 0; background: transparent; border: 0; }
.map-filter-btn--reports.map-filter-btn--active { color: #9A5A08; background: var(--warning-dim); border-color: var(--warning); }
.map-filter-btn--issues.map-filter-btn--active { color: var(--accent-stamp); background: color-mix(in srgb, var(--accent-stamp) 10%, transparent); border-color: var(--accent-stamp); }

.map-console {
  display: grid;
  grid-template-columns: minmax(300px, 350px) minmax(0, 1fr);
  min-height: 680px;
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--line-structural);
  border-radius: 12px;
}

.map-directory { min-width: 0; display: flex; flex-direction: column; background: var(--surface-paper); border-right: 1px solid var(--line-structural); }
.map-directory > header { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line-structural); }
.map-directory > header .page-kicker { margin-bottom: 2px; }
.map-directory > header strong { color: var(--ink-strong); font-size: .8rem; }
.map-directory-list { max-height: 614px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.map-directory-item { width: 100%; display: grid; grid-template-columns: 10px minmax(0, 1fr) 14px; align-items: center; gap: 10px; padding: 13px 14px; color: var(--text); text-align: left; background: transparent; border: 0; border-bottom: 1px dashed var(--line-structural); cursor: pointer; }
.map-directory-item:hover { background: color-mix(in srgb, var(--accent-interactive) 6%, var(--bg-surface)); }
.map-directory-item.is-selected { background: color-mix(in srgb, var(--accent-structural) 10%, var(--bg-surface)); box-shadow: inset 3px 0 0 var(--accent-structural); }
.map-directory-item.is-unmapped { background-image: repeating-linear-gradient(135deg, transparent 0 8px, color-mix(in srgb, var(--accent-stamp) 5%, transparent) 8px 9px); }
.map-directory-status { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 3px var(--bg-surface); }
.map-directory-status.is-online { background: var(--success); }
.map-directory-status.is-offline { background: var(--danger); }
.map-directory-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.map-directory-copy strong, .map-directory-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-directory-copy strong { color: var(--ink-strong); font-size: .8rem; }
.map-directory-copy small { color: var(--text-muted); font-family: var(--font-mono); font-size: .66rem; }
.map-directory-copy > span { display: flex; flex-wrap: wrap; gap: 4px; }
.map-directory-copy em { padding: 2px 5px; color: var(--text-secondary); background: var(--bg-raised); border-radius: 4px; font-size: .6rem; font-style: normal; }
.map-directory-item > svg { width: 14px; height: 14px; fill: none; stroke: var(--text-muted); stroke-width: 2; }
.map-directory-more { width: 100%; min-height: 44px; padding: 9px 12px; color: var(--accent-structural); background: var(--bg-raised); border: 0; border-top: 1px solid var(--line-structural); font: 700 .72rem/1.3 var(--font-body); cursor: pointer; }
.map-directory-more:hover { background: var(--bg-hover); }
.map-directory-empty { padding: 32px 18px; color: var(--text-secondary); text-align: center; }
.map-directory-empty p { margin-top: 5px; font-size: .8rem; }

.map-stage { min-width: 0; display: flex; flex-direction: column; background: var(--bg-root); }
.map-canvas-wrap { position: relative; min-height: 500px; }
.map-canvas-wrap.is-picking { cursor: crosshair; box-shadow: inset 0 0 0 3px var(--accent-stamp); }
.map-canvas-wrap #map { height: 500px; border: 0; border-radius: 0; }
.map-local-error { position: absolute; z-index: 500; top: 12px; left: 12px; display: grid; max-width: min(390px, calc(100% - 24px)); gap: 2px; padding: 10px 12px; color: #7F1D1D; background: rgba(254, 242, 242, .96); border: 1px solid #FECACA; border-radius: 7px; box-shadow: 0 8px 24px rgba(15, 23, 42, .16); font-size: .75rem; }
.map-local-error strong { font-size: .78rem; }
.map-pick-banner { position: absolute; z-index: 500; top: 12px; left: 50%; display: flex; align-items: center; gap: 10px; padding: 8px 12px; color: #FFF; background: #78350F; border-radius: 7px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); font-size: .75rem; font-weight: 700; transform: translateX(-50%); }
.map-pick-banner button { color: #FFF; background: transparent; border: 0; text-decoration: underline; cursor: pointer; }
.map-canvas-wrap .map-legend { z-index: 500; }
.map-legend-ring { width: 11px; height: 11px; border: 2px solid var(--warning); border-radius: 50%; }

.map-pin-shell, .map-cluster-shell { background: transparent !important; border: 0 !important; }
.map-pin { position: relative; width: 27px; height: 27px; display: grid; place-items: center; border: 3px solid #FFF; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); box-shadow: 0 3px 10px rgba(5, 25, 35, .32); }
.map-pin > span { width: 7px; height: 7px; background: #FFF; border-radius: 50%; }
.map-pin.is-online { background: var(--success); }
.map-pin.is-offline { background: var(--danger); }
.map-pin.has-report { box-shadow: 0 0 0 4px #F59E0B, 0 4px 12px rgba(5, 25, 35, .35); }
.map-pin.has-issues::after { content: "!"; position: absolute; right: -8px; top: -8px; width: 15px; height: 15px; display: grid; place-items: center; color: #FFF; background: var(--accent-stamp); border: 2px solid #FFF; border-radius: 50%; font: 800 9px/1 var(--font-mono); transform: rotate(45deg); }
.map-cluster { width: 42px; height: 42px; display: grid; place-items: center; color: #FFF; background: var(--accent-structural); border: 3px solid rgba(255, 255, 255, .92); border-radius: 50%; box-shadow: 0 4px 14px rgba(5, 25, 35, .3); font: 800 .78rem/1 var(--font-mono); }
.map-cluster.has-down { background: var(--danger); }
.map-cluster.has-reports { box-shadow: 0 0 0 4px #F59E0B, 0 4px 14px rgba(5, 25, 35, .3); }

.map-inspector { min-height: 180px; padding: 16px 18px; background: var(--bg-surface); border-top: 1px solid var(--line-structural); }
.map-inspector > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 13px; }
.map-inspector h3 { margin: 0; color: var(--ink-strong); font-size: 1rem; }
.map-inspector-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; overflow: hidden; background: var(--line-structural); border: 1px solid var(--line-structural); border-radius: 8px; }
.map-inspector-grid > div { min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 9px 11px; background: var(--bg-raised); }
.map-inspector-grid span { color: var(--text-muted); font-family: var(--font-mono); font-size: .58rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.map-inspector-grid strong, .map-inspector-grid code { overflow-wrap: anywhere; color: var(--text); font-size: .74rem; }
.map-quality { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 10px; color: var(--text-secondary); font-size: .7rem; }
.map-quality em { padding: 3px 6px; color: #9F2D23; background: var(--danger-dim); border: 1px solid #E9B9AF; border-radius: 999px; font-style: normal; }
.map-inspector-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.map-inspector--empty { display: grid; place-content: center; color: var(--text-secondary); text-align: center; }
.map-inspector--empty p { margin-top: 5px; font-size: .8rem; }

.map-location-editor { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 12px; padding: 12px; background: var(--bg-raised); border: 1px solid var(--line-structural); border-radius: 8px; }
.map-location-editor label { display: block; margin-bottom: 4px; color: var(--text-secondary); font-size: .68rem; font-weight: 750; }
.map-location-editor input { width: 100%; min-height: 40px; padding: 8px 10px; color: var(--text); background: var(--bg-input); border: 1px solid var(--line-structural); border-radius: 6px; font-family: inherit; font-size: 16px; }
.map-location-tools { display: flex; flex-wrap: wrap; gap: 6px; grid-column: 1 / -1; }
.map-location-editor > p { grid-column: 1 / -1; margin: 0; color: var(--accent-stamp); font-size: .72rem; }
.map-location-editor footer { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 7px; }

[data-theme="dark"] .map-legend { color: var(--text); background: rgba(13, 38, 50, .94); }
[data-theme="dark"] .map-local-error { color: #FECACA; background: rgba(69, 10, 10, .96); border-color: #991B1B; }
[data-theme="dark"] .leaflet-control-zoom a { color: var(--text); background: var(--bg-surface); border-color: var(--line-structural); }
[data-theme="dark"] .leaflet-control-attribution { color: var(--text-secondary); background: rgba(13, 38, 50, .88); }
[data-theme="dark"] .leaflet-control-attribution a { color: var(--accent-interactive); }

@media (max-width: 1180px) {
  .map-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .map-summary > div:nth-child(3) { border-right: 0; }
  .map-summary > div:nth-child(-n + 3) { border-bottom: 1px dashed var(--line-structural); }
  .corporate-page .map-toolbar { grid-template-columns: 1fr; }
  .corporate-page .map-toolbar .map-filters { justify-content: flex-start; }
  .map-console { grid-template-columns: minmax(280px, 320px) minmax(0, 1fr); }
}

@media (max-width: 820px) {
  .map-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-summary > div, .map-summary > div:nth-child(3) { border-right: 1px dashed var(--line-structural); border-bottom: 1px dashed var(--line-structural); }
  .map-summary > div:nth-child(2n) { border-right: 0; }
  .map-summary > div:last-child { border-bottom: 0; }
  .map-console { display: flex; flex-direction: column; overflow: visible; background: transparent; border: 0; }
  .map-stage { order: 0; overflow: hidden; border: 1px solid var(--line-structural); border-radius: 12px; }
  .map-directory { order: 1; margin-top: 12px; border: 1px solid var(--line-structural); border-radius: 12px; }
  .map-directory-list { max-height: 420px; }
  .map-canvas-wrap, .map-canvas-wrap #map { min-height: 420px; height: 52dvh; }
  .map-inspector-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-legend { display: none; }
}

@media (max-width: 480px) {
  .map-summary > div { min-height: 70px; padding: 11px 12px; }
  .map-summary strong { font-size: 1.35rem; }
  .corporate-page .map-toolbar .map-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .map-filter-btn { justify-content: center; }
  .map-canvas-wrap, .map-canvas-wrap #map { min-height: 360px; height: 46dvh; }
  .map-pick-banner { top: 8px; width: calc(100% - 16px); justify-content: space-between; }
  .map-inspector-grid, .map-location-editor { grid-template-columns: 1fr; }
  .map-location-editor > *, .map-location-tools, .map-location-editor footer { grid-column: 1; }
  .map-inspector-actions { display: grid; grid-template-columns: 1fr; }
  .map-inspector-actions > * { width: 100%; }
}
