/* ============================================================ */
/* RC Garage · Multidrone — estilos                             */
/* Tokens, componentes, layout. Sin frameworks.                 */
/* ============================================================ */

/* ---------- TOKENS (Multidrone, valores exactos) ---------- */
    :root {
      /* Surfaces */
      --bg-0: #070e16;
      --bg-1: #0e1720;
      --bg-2: #17202a;
      --bg-3: #202a35;
      --bg-inv: #f5f6f8;

      /* Foreground */
      --fg-0: #f7f8fa;
      --fg-1: #d3d5dc;
      --fg-2: #9c9fa9;
      --fg-3: #6b6e78;

      /* Hairlines */
      --line:   rgba(255,255,255,.06);
      --line-2: rgba(255,255,255,.12);
      --line-3: rgba(255,255,255,.20);

      /* Brand */
      --accent:      #5EE6FF;
      --accent-ink:  #062330;
      --accent-soft: rgba(94,230,255,.14);
      --accent-glow: rgba(94,230,255,.45);

      --signal:      #C8FF4E;
      --signal-ink:  #1A2300;
      --signal-soft: rgba(200,255,78,.14);

      --warn:        #FFB547;
      --warn-soft:   rgba(255,181,71,.14);

      --danger:      #FF6B6B;
      --danger-soft: rgba(255,107,107,.14);

      --info: var(--accent);

      /* Halos */
      --halo-accent: 0 0 0 1px var(--accent) inset, 0 0 24px -8px var(--accent-glow);
      --halo-signal: 0 0 0 1px var(--signal) inset, 0 0 24px -8px rgba(200,255,78,.45);
      --halo-danger: 0 0 0 1px var(--danger) inset, 0 0 24px -8px rgba(255,107,107,.45);

      /* Spacing 4px base */
      --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
      --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px;

      /* Radii */
      --r-1: 4px; --r-2: 8px; --r-3: 14px; --r-pill: 999px;

      /* Motion */
      --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
      --t-fast: 120ms; --t-medium: 220ms; --t-slow: 380ms;

      color-scheme: dark;

      --nav-h: 60px;
    }

    /* ---------- iOS WebView fix · regla nº2 ---------- */
    html, body {
      height: 100%;
      min-height: 100vh;
      min-height: 100dvh;
      background: #070e16 !important;
      background-color: #070e16 !important;
      color-scheme: dark;
      margin: 0;
      /* Evita que ningún elemento hijo desbordado provoque scroll
         horizontal del viewport. Si algo se sale, lo cortamos en lugar
         de hacer la página entera más ancha que la pantalla. */
      overflow-x: hidden;
      max-width: 100vw;
    }
    html { background: #070e16; }

    /* ---------- BASE ---------- */
    *, *::before, *::after { box-sizing: border-box; }
    body {
      font-family: 'Space Grotesk', sans-serif;
      font-size: 14px;
      color: var(--fg-0);
      background: var(--bg-0) !important;
      background-color: var(--bg-0) !important;
      -webkit-font-smoothing: antialiased;
      -webkit-tap-highlight-color: transparent;
      overflow-x: hidden;
    }
    button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
    input, select, textarea { font: inherit; color: inherit; }
    img { max-width: 100%; display: block; }
    ::selection { background: var(--accent); color: var(--accent-ink); }

    /* Monospaced surfaces */
    .mono, code, pre, .num {
      font-family: 'JetBrains Mono', monospace;
      font-variant-numeric: tabular-nums;
    }

    /* ---------- LAYOUT ---------- */
    .app {
      position: relative;
      max-width: 1400px;
      margin: 0 auto;
      background: var(--bg-0);
      min-height: 100vh;
      min-height: 100dvh;
      padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + var(--s-3));
    }

    .app-header {
      position: sticky;
      top: 0;
      z-index: 50;
      background: var(--bg-0);
      border-bottom: 1px solid var(--line);
      padding: var(--s-3) var(--s-4);
      padding-top: max(var(--s-3), env(safe-area-inset-top));
      padding-left: max(var(--s-4), env(safe-area-inset-left));
      padding-right: max(var(--s-4), env(safe-area-inset-right));
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: var(--s-3);
      /* Por si algún hijo intenta crecer fuera (chips largos, contadores),
         que se corte sin descuadrar el shell. */
      min-width: 0;
      max-width: 100%;
    }
    .brand { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
    .brand-mark {
      width: 38px; height: 38px;
      display: grid; place-items: center;
      flex-shrink: 0;
    }
    .brand-mark svg { width: 100%; height: 100%; }
    .brand-text { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
    .brand-text h1 {
      font-size: 16px; font-weight: 600; letter-spacing: -0.02em;
      margin: 0;
      display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
      color: var(--fg-0);
    }
    .brand-by {
      font-size: 10px; font-weight: 400; color: var(--fg-2);
      letter-spacing: 0.08em; text-transform: uppercase;
      white-space: nowrap;
    }
    .brand-multi { color: var(--fg-1); font-weight: 600; }
    .brand-drone { color: var(--accent); font-weight: 500; }
    .brand-sub {
      font-family: 'JetBrains Mono', monospace;
      font-size: 10px;
      color: var(--fg-2);
      letter-spacing: 0.14em;
      text-transform: uppercase;
      margin-top: 4px;
    }
    .header-actions { display: flex; gap: var(--s-2); align-items: center; }
    /* Wrapper de la zona derecha del header: contiene tanto los botones
       que cambian con la vista (header-actions) como el botón persistente
       de cerrar sesión. */
    .header-right {
      display: flex;
      align-items: center;
      gap: var(--s-2);
    }
    .header-logout {
      position: relative;
      color: var(--fg-2);
    }
    .header-logout:hover {
      color: var(--danger);
      border-color: var(--danger);
    }
    /* Separador visual entre acciones de la vista y el logout, sólo
       cuando hay acciones a la izquierda. */
    .header-actions:not(:empty) + .header-logout::before {
      content: "";
      position: absolute;
      left: calc(var(--s-2) * -1);
      top: 20%;
      bottom: 20%;
      width: 1px;
      background: var(--line-2);
    }

    @media (min-width: 768px) {
      .app-header { padding: var(--s-4) var(--s-5); }
      .brand-mark { width: 44px; height: 44px; }
      .brand-text h1 { font-size: 18px; }
    }

    /* ---------- NAV INFERIOR (mobile) / TABS SUPERIOR (desktop) ---------- */
    .bottom-nav {
      position: fixed;
      left: 0; right: 0; bottom: 0;
      max-width: 1400px;
      margin: 0 auto;
      background: var(--bg-1);
      border-top: 1px solid var(--line-2);
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      z-index: 40;
      padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .nav-btn {
      padding: var(--s-3) var(--s-2);
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 4px;
      color: var(--fg-2);
      font-family: 'Space Grotesk', sans-serif;
      font-size: 10px;
      font-weight: 600;
      letter-spacing: 0.10em;
      text-transform: uppercase;
      transition: color var(--t-fast) var(--ease-out);
      position: relative;
    }
    .nav-btn svg { width: 20px; height: 20px; stroke-width: 1.5; }
    .nav-btn.active { color: var(--accent); }
    .nav-btn.active::before {
      content: ""; position: absolute; top: 0; left: 25%; right: 25%;
      height: 2px;
      background: var(--accent);
    }

    @media (min-width: 768px) {
      .bottom-nav {
        position: sticky;
        top: 60px;
        bottom: auto;
        border-top: none;
        border-bottom: 1px solid var(--line);
        background: var(--bg-0);
        grid-template-columns: repeat(3, max-content);
        gap: var(--s-5);
        justify-content: flex-start;
        padding: 0 var(--s-5);
        z-index: 49;
      }
      .nav-btn {
        flex-direction: row;
        padding: var(--s-3) 2px;
        font-size: 11px;
        letter-spacing: 0.14em;
        border-bottom: 2px solid transparent;
      }
      .nav-btn.active { border-bottom-color: var(--accent); color: var(--accent); }
      .nav-btn.active::before { display: none; }
      .nav-btn svg { width: 16px; height: 16px; }
    }

    /* ---------- VIEW ---------- */
    .view {
      padding: var(--s-5) var(--s-4) var(--s-6);
      padding-left: max(var(--s-4), env(safe-area-inset-left));
      padding-right: max(var(--s-4), env(safe-area-inset-right));
    }
    @media (min-width: 768px) {
      .view { padding: var(--s-6) var(--s-5) var(--s-7); }
    }

    .view-title-row {
      display: flex; align-items: flex-end; justify-content: space-between;
      gap: var(--s-3);
      margin-bottom: var(--s-5);
    }
    .view-title {
      font-size: 22px; font-weight: 600;
      letter-spacing: -0.02em;
      line-height: 1.1;
      margin: 0;
      color: var(--fg-0);
    }
    .view-subtitle {
      font-family: 'JetBrains Mono', monospace;
      font-size: 10.5px;
      color: var(--fg-2);
      margin-top: 6px;
      text-transform: uppercase;
      letter-spacing: 0.14em;
      font-variant-numeric: tabular-nums;
    }
    @media (min-width: 768px) {
      .view-title { font-size: 26px; }
    }

    .section-title {
      font-family: 'JetBrains Mono', monospace;
      font-size: 10.5px;
      color: var(--fg-2);
      text-transform: uppercase;
      letter-spacing: 0.14em;
      margin-bottom: var(--s-3);
      font-weight: 600;
    }

    /* ---------- BUTTONS ---------- */
    .btn {
      display: inline-flex; align-items: center; justify-content: center; gap: 6px;
      padding: 8px 14px;
      background: var(--bg-2);
      border: 1px solid var(--line-2);
      border-radius: var(--r-2);
      color: var(--fg-0);
      font-family: 'Space Grotesk', sans-serif;
      font-size: 13px; font-weight: 500;
      cursor: pointer;
      transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
      letter-spacing: 0.02em;
      white-space: nowrap;
    }
    .btn:hover { background: var(--bg-3); border-color: var(--line-3); }
    .btn:focus { outline: none; box-shadow: var(--halo-accent); }
    .btn:active { transform: translateY(1px); }
    .btn-primary {
      background: var(--accent); color: var(--accent-ink);
      border-color: var(--accent); font-weight: 600;
    }
    .btn-primary:hover { background: #7FF0FF; border-color: #7FF0FF; }
    .btn-ghost { background: transparent; border-color: var(--line); color: var(--fg-1); }
    .btn-ghost:hover { background: var(--bg-1); border-color: var(--line-2); color: var(--fg-0); }
    .btn-danger {
      background: transparent;
      color: var(--danger);
      border-color: var(--danger);
    }
    .btn-danger:hover { background: var(--danger); color: #2A0000; }
    .btn-small {
      padding: 6px 11px;
      font-size: 12px;
    }
    .btn svg { width: 14px; height: 14px; }

    .btn-icon {
      width: 36px; height: 36px;
      padding: 0;
      border-radius: var(--r-2);
      background: var(--bg-2);
      border: 1px solid var(--line);
      color: var(--fg-1);
      display: grid; place-items: center;
    }
    .btn-icon:hover { background: var(--bg-3); color: var(--fg-0); }
    .btn-icon svg { width: 16px; height: 16px; }

    /* ---------- CHIPS / BADGES ---------- */
    .chip {
      display: inline-flex; align-items: center; gap: 6px;
      padding: 5px 10px;
      background: var(--bg-1);
      border: 1px solid var(--line);
      border-radius: var(--r-pill);
      color: var(--fg-2);
      font-family: 'Space Grotesk', sans-serif;
      font-size: 10.5px;
      font-weight: 600;
      letter-spacing: 0.10em;
      text-transform: uppercase;
    }
    .chip.ok       { color: var(--signal); background: var(--signal-soft); border-color: rgba(200,255,78,.35); }
    .chip.warn     { color: var(--warn);   background: var(--warn-soft);   border-color: rgba(255,181,71,.35); }
    .chip.danger   { color: var(--danger); background: var(--danger-soft); border-color: rgba(255,107,107,.35); }
    .chip.accent   { color: var(--accent); background: var(--accent-soft); border-color: rgba(94,230,255,.35); }
    .chip-dot {
      width: 6px; height: 6px; border-radius: 50%;
      background: currentColor;
      flex-shrink: 0;
    }
    .chip svg { width: 12px; height: 12px; flex-shrink: 0; }

    /* ---------- TOOLBAR / FILTERS ---------- */
    .toolbar {
      display: flex;
      gap: 6px;
      margin-bottom: var(--s-4);
      overflow-x: auto;
      padding-bottom: 4px;
      scrollbar-width: none;
    }
    .toolbar::-webkit-scrollbar { display: none; }
    .filter-chip {
      display: inline-flex; align-items: center; gap: 6px;
      padding: 6px 12px;
      background: var(--bg-1);
      border: 1px solid var(--line);
      border-radius: var(--r-pill);
      color: var(--fg-2);
      font-family: 'Space Grotesk', sans-serif;
      font-size: 11px;
      font-weight: 600;
      letter-spacing: 0.10em;
      text-transform: uppercase;
      white-space: nowrap;
      cursor: pointer;
      transition: background-color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
    }
    .filter-chip:hover { color: var(--fg-1); border-color: var(--line-2); }
    .filter-chip.active {
      background: var(--accent-soft);
      border-color: var(--accent);
      color: var(--accent);
    }
    .filter-chip svg { width: 13px; height: 13px; }
    .filter-chip .num { letter-spacing: 0.04em; }

    /* ---------- SEARCH ---------- */
    .search-bar {
      position: relative;
      margin-bottom: var(--s-3);
    }
    .search-bar input {
      width: 100%;
      padding: 10px 14px 10px 36px;
      background: var(--bg-3);
      border: 1px solid var(--line-2);
      border-radius: var(--r-2);
      color: var(--fg-0);
      font-family: 'Space Grotesk', sans-serif;
      font-size: 13px;
      outline: none;
      transition: border-color var(--t-fast), box-shadow var(--t-fast);
    }
    .search-bar input:focus {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px rgba(94,230,255,.18);
    }
    .search-bar svg {
      position: absolute;
      left: 12px; top: 50%;
      transform: translateY(-50%);
      width: 14px; height: 14px;
      color: var(--fg-2);
    }

    /* ---------- CARDS ---------- */
    .grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
      gap: var(--s-3);
    }
    @media (min-width: 768px) {
      .grid { gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
    }

    .card {
      background: var(--bg-1);
      border: 1px solid var(--line);
      border-radius: var(--r-2);
      overflow: hidden;
      transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
      cursor: pointer;
      position: relative;
      display: flex;
      flex-direction: column;
    }
    .card:hover {
      background: var(--bg-2);
      border-color: var(--line-2);
    }
    .card.needs-attention {
      border-color: rgba(255,107,107,.35);
      box-shadow: 0 0 0 1px var(--danger) inset, 0 0 24px -8px rgba(255,107,107,.45);
    }
    .card.needs-attention::after {
      content: "";
      position: absolute; left: 0; top: 0; bottom: 0;
      width: 3px;
      background: var(--danger);
    }

    .card-image {
      aspect-ratio: 16 / 10;
      background: var(--bg-2);
      position: relative;
      overflow: hidden;
      border-bottom: 1px solid var(--line);
    }
    .card-image img { width: 100%; height: 100%; object-fit: cover; }
    .card-image.empty {
      display: grid;
      place-items: center;
      color: var(--fg-3);
    }
    .card-image.empty svg { width: 44px; height: 44px; opacity: .5; }

    .card-badges {
      position: absolute;
      top: 8px; left: 8px;
      display: flex; gap: 5px; flex-wrap: wrap;
      max-width: calc(100% - 16px);
    }

    .card-body {
      padding: var(--s-3) var(--s-3) var(--s-4);
      display: flex;
      flex-direction: column;
      gap: var(--s-2);
      flex: 1;
    }
    .card-title {
      font-size: 15px;
      font-weight: 600;
      letter-spacing: -0.01em;
      line-height: 1.25;
      color: var(--fg-0);
    }
    .card-meta {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
      font-family: 'JetBrains Mono', monospace;
      font-size: 10.5px;
      color: var(--fg-2);
      text-transform: uppercase;
      letter-spacing: 0.10em;
      font-variant-numeric: tabular-nums;
    }
    .card-meta span { display: inline-flex; gap: 4px; align-items: center; }
    .card-meta .num { color: var(--fg-1); font-weight: 500; }

    /* ---------- EMPTY STATE ---------- */
    .empty-state {
      text-align: center;
      padding: var(--s-7) var(--s-4);
      color: var(--fg-2);
    }
    .md-empty-icon {
      display: inline-grid; place-items: center;
      color: var(--fg-3);
      margin-bottom: var(--s-3);
    }
    .md-empty-icon svg { width: 56px; height: 56px; opacity: .65; }
    .empty-state h3 {
      font-size: 16px;
      color: var(--fg-0);
      font-weight: 600;
      margin: 0 0 6px;
      letter-spacing: -0.01em;
    }
    .empty-state p { margin: 0 0 var(--s-4); line-height: 1.5; font-size: 13px; color: var(--fg-2); }

    /* ---------- DETAIL HEADER ---------- */
    .detail-header {
      position: relative;
      aspect-ratio: 16 / 9;
      max-height: 320px;
      background: var(--bg-1);
      overflow: hidden;
      border-bottom: 1px solid var(--line);
    }
    .detail-header img { width: 100%; height: 100%; object-fit: cover; }
    .detail-header::after {
      content: "";
      position: absolute; inset: 0;
      background: linear-gradient(180deg, rgba(7,14,22,0) 40%, var(--bg-0) 100%);
    }
    .detail-header .back-btn,
    .detail-header .delete-btn {
      position: absolute;
      top: var(--s-3);
      width: 36px; height: 36px;
      background: rgba(7,14,22,0.75);
      backdrop-filter: blur(8px);
      border-radius: var(--r-2);
      display: grid; place-items: center;
      color: var(--fg-0);
      border: 1px solid var(--line-2);
      z-index: 5;
      transition: background var(--t-fast), border-color var(--t-fast);
    }
    .detail-header .back-btn  { left: max(var(--s-3), env(safe-area-inset-left)); }
    .detail-header .delete-btn { right: max(var(--s-3), env(safe-area-inset-right)); color: var(--danger); }
    .detail-header .back-btn:hover,
    .detail-header .delete-btn:hover { background: var(--bg-2); border-color: var(--line-3); }

    .detail-title-bar {
      padding: 0 var(--s-4) var(--s-3);
      padding-left: max(var(--s-4), env(safe-area-inset-left));
      padding-right: max(var(--s-4), env(safe-area-inset-right));
      position: relative;
      z-index: 2;
      margin-top: -36px;
    }
    .detail-title {
      font-size: 24px; font-weight: 600;
      letter-spacing: -0.02em;
      line-height: 1.15;
      margin: 0 0 var(--s-2);
      color: var(--fg-0);
    }
    .detail-meta {
      display: flex; gap: 6px; flex-wrap: wrap;
    }
    @media (min-width: 768px) {
      .detail-title-bar { padding-left: var(--s-5); padding-right: var(--s-5); }
      .detail-title { font-size: 28px; }
    }

    /* ---------- TABS ---------- */
    .tabs {
      display: flex;
      gap: var(--s-5);
      border-bottom: 1px solid var(--line);
      padding: 0 var(--s-4);
      padding-left: max(var(--s-4), env(safe-area-inset-left));
      padding-right: max(var(--s-4), env(safe-area-inset-right));
      overflow-x: auto;
      scrollbar-width: none;
      position: sticky;
      top: 60px;
      background: var(--bg-0);
      z-index: 10;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab {
      padding: var(--s-3) 2px;
      font-family: 'Space Grotesk', sans-serif;
      font-size: 12px;
      font-weight: 600;
      color: var(--fg-2);
      position: relative;
      white-space: nowrap;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      border-bottom: 2px solid transparent;
      letter-spacing: 0.10em;
      text-transform: uppercase;
      cursor: pointer;
      transition: color var(--t-fast), border-color var(--t-fast);
    }
    .tab:hover { color: var(--fg-1); }
    .tab.active { color: var(--accent); border-bottom-color: var(--accent); }
    .tab .num { letter-spacing: 0.04em; }
    .tab-badge {
      display: inline-grid; place-items: center;
      min-width: 16px; height: 16px;
      padding: 0 4px;
      border-radius: 8px;
      background: var(--danger);
      color: #2A0000;
      font-family: 'JetBrains Mono', monospace;
      font-size: 9.5px;
      font-weight: 700;
      letter-spacing: 0;
      font-variant-numeric: tabular-nums;
    }
    @media (min-width: 768px) {
      .tabs { padding: 0 var(--s-5); }
    }

    .tab-content {
      padding: var(--s-5) var(--s-4) var(--s-6);
    }
    @media (min-width: 768px) {
      .tab-content { padding: var(--s-5) var(--s-5) var(--s-6); }
    }
    .tab-section { margin-bottom: var(--s-5); }

    /* ---------- LISTS ---------- */
    .list-item {
      background: var(--bg-1);
      border: 1px solid var(--line);
      border-radius: var(--r-2);
      padding: var(--s-3);
      margin-bottom: 6px;
      display: flex;
      gap: var(--s-3);
      align-items: center;
      transition: background var(--t-fast), border-color var(--t-fast);
    }
    .list-item[data-action]:hover { background: var(--bg-2); border-color: var(--line-2); }
    .list-item-thumb {
      width: 44px; height: 44px;
      border-radius: var(--r-1);
      background: var(--bg-2);
      overflow: hidden;
      flex-shrink: 0;
      display: grid; place-items: center;
      color: var(--fg-2);
      border: 1px solid var(--line);
    }
    .list-item-thumb img { width: 100%; height: 100%; object-fit: cover; }
    .list-item-thumb svg { width: 22px; height: 22px; }
    .list-item-body { flex: 1; min-width: 0; }
    .list-item-title {
      font-weight: 500;
      font-size: 14px;
      margin-bottom: 2px;
      line-height: 1.3;
      color: var(--fg-0);
    }
    .list-item-sub {
      font-family: 'JetBrains Mono', monospace;
      font-size: 10.5px;
      color: var(--fg-2);
      text-transform: uppercase;
      letter-spacing: 0.10em;
      font-variant-numeric: tabular-nums;
    }
    .list-item-actions { display: flex; gap: 4px; flex-shrink: 0; }
    .list-item .icon-btn {
      width: 30px; height: 30px;
      border-radius: var(--r-1);
      display: grid; place-items: center;
      color: var(--fg-2);
      transition: background var(--t-fast), color var(--t-fast);
    }
    .list-item .icon-btn:hover { background: var(--bg-3); color: var(--fg-0); }
    .list-item .icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
    .list-item .icon-btn svg { width: 15px; height: 15px; }

    .checklist-item {
      display: flex;
      align-items: center;
      gap: var(--s-3);
      padding: var(--s-3);
      background: var(--bg-1);
      border: 1px solid var(--line);
      border-radius: var(--r-2);
      margin-bottom: 6px;
    }
    .checklist-item input[type="text"] {
      flex: 1;
      background: transparent;
      border: none;
      outline: none;
      font-size: 13px;
      color: var(--fg-0);
      font-family: 'Space Grotesk', sans-serif;
    }

    /* ---------- INCIDENT CARDS ---------- */
    .incident-card {
      background: var(--bg-1);
      border: 1px solid var(--line);
      border-radius: var(--r-2);
      padding: var(--s-3);
      margin-bottom: 8px;
    }
    .incident-card.unresolved {
      border-left: 3px solid var(--danger);
    }
    .incident-card.resolved {
      border-left: 3px solid var(--signal);
      opacity: 0.78;
    }
    .incident-head {
      display: flex; justify-content: space-between; align-items: center;
      gap: 8px; margin-bottom: var(--s-2);
    }
    .incident-date {
      font-family: 'JetBrains Mono', monospace;
      font-size: 10.5px;
      color: var(--fg-2);
      text-transform: uppercase;
      letter-spacing: 0.10em;
      font-variant-numeric: tabular-nums;
    }
    .incident-desc {
      font-size: 13px;
      line-height: 1.55;
      margin-bottom: var(--s-2);
      white-space: pre-wrap; word-wrap: break-word;
      color: var(--fg-1);
    }
    .incident-photo {
      max-width: 220px;
      border-radius: var(--r-1);
      margin-bottom: var(--s-2);
      cursor: zoom-in;
      border: 1px solid var(--line);
    }
    .incident-resolution {
      margin-top: var(--s-2);
      padding: var(--s-2) var(--s-3);
      background: var(--signal-soft);
      border-left: 2px solid var(--signal);
      border-radius: 0 var(--r-1) var(--r-1) 0;
      font-size: 12.5px;
      color: var(--fg-1);
      line-height: 1.5;
    }
    .incident-resolution strong {
      display: block;
      color: var(--signal);
      font-family: 'JetBrains Mono', monospace;
      font-size: 10px;
      text-transform: uppercase;
      letter-spacing: 0.14em;
      margin-bottom: 4px;
      font-weight: 600;
    }
    .incident-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: var(--s-2); }

    /* ---------- MODAL ---------- */
    .modal-overlay {
      position: fixed; inset: 0;
      background: rgba(7,14,22,0.75);
      backdrop-filter: blur(6px);
      z-index: 100;
      display: grid;
      place-items: end center;
      animation: fadeIn var(--t-fast) var(--ease-out);
    }
    @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
    @keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

    .modal {
      background: var(--bg-1);
      width: 100%;
      max-width: 560px;
      max-height: 92vh;
      border-radius: var(--r-3) var(--r-3) 0 0;
      border: 1px solid var(--line-2);
      border-bottom: none;
      display: flex;
      flex-direction: column;
      animation: slideUp var(--t-medium) var(--ease-out);
      overflow: hidden;
    }
    @media (min-width: 640px) {
      .modal-overlay { place-items: center; padding: var(--s-4); }
      .modal { border-radius: var(--r-3); border-bottom: 1px solid var(--line-2); }
    }
    .modal-header {
      padding: var(--s-4);
      border-bottom: 1px solid var(--line);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: var(--s-3);
      flex-shrink: 0;
    }
    .modal-title {
      font-size: 15px;
      font-weight: 600;
      letter-spacing: -0.01em;
      color: var(--fg-0);
    }
    .modal-close {
      width: 32px; height: 32px;
      border-radius: var(--r-1);
      display: grid; place-items: center;
      color: var(--fg-2);
      transition: background var(--t-fast), color var(--t-fast);
    }
    .modal-close:hover { background: var(--bg-3); color: var(--fg-0); }
    .modal-close svg { width: 18px; height: 18px; }
    .modal-body { padding: var(--s-4); overflow-y: auto; flex: 1; overscroll-behavior: contain; }
    .modal-footer {
      padding: var(--s-3) var(--s-4);
      border-top: 1px solid var(--line);
      display: flex;
      gap: var(--s-2);
      justify-content: flex-end;
      flex-shrink: 0;
      background: var(--bg-1);
    }
    .modal-footer .btn { min-width: 90px; }

    /* ---------- INPUTS ---------- */
    .field { margin-bottom: var(--s-4); }
    .field label {
      display: block;
      font-family: 'JetBrains Mono', monospace;
      font-size: 10px;
      color: var(--fg-2);
      text-transform: uppercase;
      letter-spacing: 0.14em;
      margin-bottom: 6px;
      font-weight: 600;
    }
    .field .hint {
      font-size: 11.5px;
      color: var(--fg-3);
      margin-top: 5px;
      font-family: 'Space Grotesk', sans-serif;
      text-transform: none;
      letter-spacing: 0;
      line-height: 1.45;
    }
    .input, .textarea, .select {
      width: 100%;
      padding: 9px 12px;
      background: var(--bg-3);
      border: 1px solid var(--line-2);
      border-radius: var(--r-2);
      color: var(--fg-0);
      font-family: 'Space Grotesk', sans-serif;
      font-size: 13px;
      outline: none;
      transition: border-color var(--t-fast), box-shadow var(--t-fast);
    }
    .input:focus, .textarea:focus, .select:focus {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px rgba(94,230,255,.18);
    }
    .input.error, .textarea.error, .select.error { border-color: var(--danger); }
    .textarea { resize: vertical; min-height: 80px; line-height: 1.55; }

    .field-error {
      font-size: 11.5px;
      color: var(--danger);
      margin-top: 5px;
      display: flex;
      align-items: center;
      gap: 4px;
      font-family: 'JetBrains Mono', monospace;
      letter-spacing: 0.04em;
      /* El texto se escribe en mayúsculas/minúsculas normales en el JS
         (mejor para lectores de pantalla) y se muestra en mayúsculas
         por estilo, no por contenido. */
      text-transform: uppercase;
    }

    /* ---------- PHOTO UPLOADER ---------- */
    .photo-uploader {
      position: relative;
      width: 100%;
      aspect-ratio: 16 / 10;
      background: var(--bg-3);
      border: 1.5px dashed var(--line-3);
      border-radius: var(--r-2);
      display: grid; place-items: center;
      overflow: hidden;
      cursor: pointer;
      transition: border-color var(--t-fast);
    }
    .photo-uploader:hover { border-color: var(--accent); }
    .photo-uploader img { width: 100%; height: 100%; object-fit: cover; }
    .photo-uploader .placeholder {
      text-align: center;
      color: var(--fg-2);
      font-size: 12px;
      letter-spacing: 0.04em;
    }
    .photo-uploader .placeholder svg { width: 28px; height: 28px; margin-bottom: 6px; color: var(--fg-3); }
    .photo-uploader .placeholder div {
      font-family: 'JetBrains Mono', monospace;
      font-size: 10.5px;
      text-transform: uppercase;
      letter-spacing: 0.14em;
    }
    .photo-uploader input[type="file"] {
      position: absolute; inset: 0;
      opacity: 0;
      cursor: pointer;
    }
    .photo-uploader .remove-photo {
      position: absolute;
      top: 8px; right: 8px;
      width: 28px; height: 28px;
      background: rgba(7,14,22,0.85);
      backdrop-filter: blur(6px);
      border-radius: var(--r-1);
      display: grid; place-items: center;
      color: var(--danger);
      border: 1px solid var(--line-2);
      z-index: 2;
    }
    .photo-uploader.small {
      aspect-ratio: 4 / 3;
      max-width: 220px;
    }

    /* ---------- SELECTABLE BATTERY ---------- */
    .selectable-battery {
      padding: 8px 12px;
      border-radius: var(--r-2);
      background: var(--bg-2);
      border: 1px solid var(--line);
      color: var(--fg-1);
      font-size: 13px;
      display: inline-flex; gap: 6px; align-items: center;
      transition: background-color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
    }
    .selectable-battery:hover { border-color: var(--line-2); background: var(--bg-3); }
    .selectable-battery.selected {
      background: var(--accent-soft);
      border-color: var(--accent);
      color: var(--accent);
    }

    /* ---------- SETTINGS ---------- */
    .settings-section {
      background: var(--bg-1);
      border: 1px solid var(--line);
      border-radius: var(--r-2);
      padding: var(--s-4);
      margin-bottom: var(--s-3);
    }
    .settings-section h3 {
      margin: 0 0 4px;
      font-size: 14px;
      font-weight: 600;
      letter-spacing: -0.01em;
      color: var(--fg-0);
    }
    .settings-section p {
      margin: 0 0 var(--s-3);
      color: var(--fg-2);
      font-size: 12.5px;
      line-height: 1.5;
    }
    .storage-bar {
      height: 6px;
      background: var(--bg-3);
      border-radius: 3px;
      overflow: hidden;
      margin-bottom: 6px;
    }
    .storage-bar-fill {
      height: 100%;
      background: var(--accent);
      transition: width var(--t-medium);
    }
    .storage-info {
      font-family: 'JetBrains Mono', monospace;
      font-size: 10.5px;
      color: var(--fg-2);
      text-transform: uppercase;
      letter-spacing: 0.10em;
      font-variant-numeric: tabular-nums;
    }

    /* ---------- TOAST ---------- */
    #toast-container {
      position: fixed;
      bottom: calc(var(--nav-h) + var(--s-4) + env(safe-area-inset-bottom, 0px));
      left: 50%;
      transform: translateX(-50%);
      z-index: 200;
      display: flex;
      flex-direction: column;
      gap: var(--s-2);
      align-items: center;
      pointer-events: none;
      width: calc(100% - 32px);
      max-width: 460px;
    }
    .toast {
      background: var(--bg-2);
      border: 1px solid var(--line-2);
      border-radius: var(--r-2);
      padding: 10px var(--s-3);
      animation: slideUp var(--t-medium) var(--ease-out);
      max-width: 100%;
      display: flex;
      gap: var(--s-2);
      align-items: center;
      font-size: 13px;
      pointer-events: auto;
      color: var(--fg-1);
    }
    .toast.success { border-left: 3px solid var(--signal); }
    .toast.error   { border-left: 3px solid var(--danger); }
    .toast.info    { border-left: 3px solid var(--accent); }
    .toast.warn    { border-left: 3px solid var(--warn); }
    .toast.success svg { color: var(--signal); }
    .toast.error svg   { color: var(--danger); }
    .toast.info svg    { color: var(--accent); }
    .toast.warn svg    { color: var(--warn); }
    .toast svg { width: 16px; height: 16px; flex-shrink: 0; }

    /* ---------- IMAGE VIEWER ---------- */
    .image-viewer {
      position: fixed; inset: 0;
      background: rgba(7,14,22,0.96);
      z-index: 300;
      display: grid;
      place-items: center;
      padding: var(--s-4);
      cursor: zoom-out;
    }
    .image-viewer img {
      max-width: 100%; max-height: 100%;
      border-radius: var(--r-2);
      object-fit: contain;
    }
    .image-viewer-close {
      position: absolute;
      top: calc(var(--s-4) + env(safe-area-inset-top, 0px));
      right: var(--s-4);
      width: 40px; height: 40px;
      display: grid; place-items: center;
      border: 1px solid rgba(255,255,255,0.18);
      border-radius: 50%;
      background: rgba(7,14,22,0.6);
      color: #fff;
      cursor: pointer;
      touch-action: manipulation;
    }
    .image-viewer-close svg { width: 22px; height: 22px; }
    .image-viewer-close:focus-visible {
      outline: 2.5px solid var(--accent);
      outline-offset: 2px;
    }

    /* ---------- VEHICLE CHIP LIST ---------- */
    .vehicle-chip-list {
      display: flex; flex-wrap: wrap; gap: 5px;
      margin-top: var(--s-2);
    }
    .vehicle-chip {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 4px 10px 4px 4px;
      background: var(--bg-2);
      border: 1px solid var(--line);
      border-radius: var(--r-pill);
      font-size: 11px;
      font-weight: 500;
      color: var(--fg-1);
    }
    .vehicle-chip-thumb {
      width: 20px; height: 20px;
      border-radius: 50%;
      background: var(--bg-3);
      overflow: hidden;
      flex-shrink: 0;
    }
    .vehicle-chip-thumb img { width: 100%; height: 100%; object-fit: cover; }

    /* ---------- STATS ---------- */
    .stats-row {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: var(--s-2);
      margin-bottom: var(--s-4);
    }
    .stat-card {
      background: var(--bg-1);
      border: 1px solid var(--line);
      border-radius: var(--r-2);
      padding: var(--s-3);
      text-align: center;
    }
    .stat-num {
      font-size: 24px;
      font-weight: 500;
      font-family: 'JetBrains Mono', monospace;
      font-variant-numeric: tabular-nums;
      line-height: 1;
      margin-bottom: 4px;
      color: var(--fg-0);
    }
    .stat-num.danger { color: var(--danger); }
    .stat-num.ok     { color: var(--signal); }
    .stat-num.warn   { color: var(--warn); }
    .stat-label {
      font-size: 9.5px;
      font-family: 'JetBrains Mono', monospace;
      color: var(--fg-2);
      text-transform: uppercase;
      letter-spacing: 0.14em;
      font-weight: 600;
    }

    /* ---------- INFO BLOCKS ---------- */
    .info-block {
      background: var(--bg-1);
      border: 1px solid var(--line);
      border-radius: var(--r-2);
      padding: var(--s-3);
      font-size: 13px;
      line-height: 1.6;
      color: var(--fg-1);
      white-space: pre-wrap;
      word-wrap: break-word;
    }
    .info-block.empty {
      color: var(--fg-3);
      font-style: normal;
      text-align: center;
      padding: var(--s-4);
      font-size: 12px;
    }

    /* ---------- WARNING BANNER (origin-banner pattern from skill) ---------- */
    .warning-banner {
      display: flex; align-items: center; gap: var(--s-3);
      background: linear-gradient(135deg, var(--danger-soft), transparent);
      border: 1px solid rgba(255,107,107,.25);
      border-left: 3px solid var(--danger);
      padding: var(--s-3);
      border-radius: var(--r-2);
      margin-bottom: var(--s-4);
    }
    .warning-banner .origin-icon {
      width: 32px; height: 32px;
      display: grid; place-items: center;
      color: var(--danger);
      flex-shrink: 0;
    }
    .warning-banner .origin-icon svg { width: 22px; height: 22px; }
    .warning-banner .origin-body { flex: 1; min-width: 0; }
    .warning-banner .origin-label {
      font-family: 'JetBrains Mono', monospace;
      font-size: 10px;
      color: var(--danger);
      text-transform: uppercase;
      letter-spacing: 0.14em;
      font-weight: 600;
      margin-bottom: 3px;
    }
    .warning-banner .origin-meta {
      font-size: 12.5px;
      color: var(--fg-1);
      line-height: 1.45;
    }

    /* ---------- CHECKBOX ---------- */
    .checkbox {
      width: 18px; height: 18px;
      border: 1.5px solid var(--line-3);
      border-radius: var(--r-1);
      background: var(--bg-3);
      display: grid; place-items: center;
      flex-shrink: 0;
      cursor: pointer;
      transition: background-color var(--t-fast), border-color var(--t-fast);
    }
    .checkbox.checked {
      background: var(--accent);
      border-color: var(--accent);
    }
    .checkbox.checked svg { width: 12px; height: 12px; color: var(--accent-ink); }
    .checkbox:not(.checked) svg { display: none; }

    /* ---------- WORDMARK reused ---------- */


/* ============================================================ */
/* SPLASH SCREEN                                                */
/* ============================================================ */
.splash {
  position: fixed;
  inset: 0;
  background: var(--bg-0);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 14px;
  transition: opacity .3s var(--ease-out);
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash-mark {
  width: 80px; height: 80px;
  background-image: url('../assets/mark.svg');
  background-size: contain;
  background-repeat: no-repeat;
  animation: spin 4s linear infinite;
}
.splash-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px; font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg-0);
}
.splash-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--fg-2);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
@keyframes spin {
  from { transform: rotate(0); }
  to   { transform: rotate(360deg); }
}

/* ============================================================ */
/* LOGIN / SIGNUP                                               */
/* ============================================================ */
.auth-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
  padding-top: max(var(--s-4), env(safe-area-inset-top));
  padding-bottom: max(var(--s-4), env(safe-area-inset-bottom));
  background: var(--bg-0);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: var(--s-6) var(--s-5);
}
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: var(--s-5);
  gap: var(--s-3);
}
.auth-brand .brand-mark {
  width: 56px; height: 56px;
}
.auth-brand h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--fg-0);
}
.auth-brand .brand-by {
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--fg-2);
}
.auth-brand .brand-multi { color: var(--fg-1); font-weight: 600; }
.auth-brand .brand-drone { color: var(--accent); font-weight: 500; }
.auth-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  border: 1px solid rgba(94,230,255,.35);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  margin-top: -8px;
}
.auth-eyebrow .chip-dot { background: var(--accent); }
.auth-toggle {
  display: flex;
  background: var(--bg-2);
  border-radius: var(--r-2);
  padding: 3px;
  margin-bottom: var(--s-5);
  border: 1px solid var(--line);
}
.auth-toggle button {
  flex: 1;
  padding: 8px 10px;
  border-radius: var(--r-1);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--fg-2);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: background-color var(--t-fast), color var(--t-fast);
}
.auth-toggle button.active {
  background: var(--bg-3);
  color: var(--fg-0);
}
.auth-form .btn {
  width: 100%;
  justify-content: center;
  padding: 11px 14px;
  font-size: 13px;
}
.auth-footer {
  margin-top: var(--s-4);
  text-align: center;
  font-size: 11.5px;
  color: var(--fg-3);
  line-height: 1.55;
}

/* ============================================================ */
/* LOADING / ERROR STATES                                       */
/* ============================================================ */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  padding: var(--s-6) var(--s-4);
  color: var(--fg-2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.loading-state .spinner {
  width: 16px; height: 16px;
  border: 1.5px solid var(--line-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.error-state {
  background: linear-gradient(135deg, var(--danger-soft), transparent);
  border: 1px solid rgba(255,107,107,.35);
  border-left: 3px solid var(--danger);
  border-radius: var(--r-2);
  padding: var(--s-3);
  margin: var(--s-4) 0;
  display: flex;
  gap: var(--s-3);
  align-items: flex-start;
}
.error-state .origin-icon {
  color: var(--danger);
  flex-shrink: 0;
}
.error-state .origin-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--danger);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
  margin-bottom: 3px;
}
.error-state .origin-meta {
  font-size: 12.5px;
  color: var(--fg-1);
  line-height: 1.45;
}
.error-state button {
  margin-top: var(--s-2);
}

/* Tab/section helper for embedded actions in info */
.action-row {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: var(--s-4);
}

/* Saving indicator */
.saving-indicator {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-2);
}
.saving-indicator .dot {
  width: 6px; height: 6px;
  background: var(--signal);
  border-radius: 50%;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Better fitting brand text on narrow screens */
@media (max-width: 380px) {
  .brand-text h1 { font-size: 14px; }
  .brand-by { font-size: 9.5px; }
  .brand-sub { font-size: 9px; }
}

/* ============================================================
   TEXTOS LEGALES
   ============================================================ */
.legal-view { padding-bottom: 60px; }
.legal-body {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: 20px 18px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--fg-1);
}
.legal-body h2 {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--fg-0);
  margin: 22px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-2);
}
.legal-body h2:first-child { margin-top: 0; }
.legal-body p { margin: 0 0 10px; }
.legal-body ul { margin: 0 0 12px 0; padding-left: 18px; }
.legal-body li { margin-bottom: 4px; }
.legal-body strong { color: var(--fg-0); font-weight: 600; }
.legal-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent);
}
.legal-body a:hover { border-bottom-style: solid; }

/* ============================================================
   CONSENT CHECKBOX en signup
   ============================================================ */
.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  margin-bottom: var(--s-3);
  cursor: pointer;
  transition: border-color .15s;
}
.consent-row.checked { border-color: var(--accent); }
.consent-row .consent-text {
  flex: 1;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--fg-1);
}
.consent-row .consent-text a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent);
}
.consent-row.error { border-color: var(--danger); }
/* Checkbox real oculto visualmente pero accesible por teclado/lector.
   No usamos display:none ni width:0 para que siga siendo enfocable. */
.consent-input {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
/* Anillo de foco visible sobre el recuadro pintado cuando el input
   real recibe foco por teclado. */
.consent-input:focus-visible + .checkbox,
.consent-input:focus-visible + .pf-check {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   STORAGE / USAGE BAR
   ============================================================ */
.usage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
.usage-item {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: 12px;
}
.usage-item-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-2);
  margin-bottom: 4px;
}
.usage-item-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 700;
  color: var(--fg-0);
}
.usage-item-value .usage-limit {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-2);
}
.usage-bar-row {
  display: block;
  margin-top: 8px;
  height: 6px;
  background: var(--bg-1);
  border-radius: 3px;
  overflow: hidden;
}
.usage-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width .25s;
}
.usage-bar-fill.warn { background: var(--warn); }
.usage-bar-fill.danger { background: var(--danger); }

.usage-item.full .usage-item-value { color: var(--danger); }

/* ============================================================
   CROPPER INLINE (dentro del PhotoUploader)
   ============================================================
   Cuando el uploader entra en modo cropper, su contenedor crece
   y muestra el editor de recorte. Al terminar, vuelve al preview. */
.photo-uploader.cropper-active {
  /* Quita los estilos cuadrados del uploader para que el cropper
     se vea como un panel libre. */
  aspect-ratio: auto;
  background: transparent;
  border: 1px solid var(--line);
  padding: 14px;
  display: block;
  cursor: default;
}
.photo-uploader.cropper-active::before,
.photo-uploader.cropper-active input[type="file"] { display: none; }

.cropper-inline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.cropper-hint {
  font-size: 12px;
  color: var(--fg-2);
  line-height: 1.4;
  text-align: center;
  max-width: 320px;
}
.cropper-stage {
  position: relative;
  background: #000;
  border-radius: var(--r-2);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  margin: 0 auto;
  /* NO usamos max-width:100% aquí porque el JS calcula el tamaño
     exacto que cabe en el contenedor y lo aplica inline. Si CSS lo
     volviera a recortar, los hijos (frame, bg) quedarían desalineados. */
  flex-shrink: 0;
}
.cropper-bg {
  display: block;
  opacity: 0.5;
  pointer-events: none;
  max-width: none;  /* vence el global `img { max-width: 100% }` */
}
.cropper-frame {
  position: absolute;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.65);
  border: 2px solid var(--accent);
  cursor: move;
  overflow: hidden;
  touch-action: none;
}
.cropper-frame-img {
  position: absolute;
  display: block;
  pointer-events: none;
  max-width: none;
}
.cropper-aspects {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.cropper-actions {
  display: flex;
  gap: 6px;
  width: 100%;
  margin-top: 4px;
}
.cropper-actions .btn { flex: 1; }

/* ============================================================
   BATTERY — serial number badge & form hints
   ============================================================ */
.serial-badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 6px;
  padding: 2px 7px;
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: rgba(0, 212, 255, 0.08);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 4px;
  line-height: 1.4;
}
.detail-title .serial-badge {
  font-size: 14px;
  padding: 3px 9px;
}

/* Texto de pista debajo de un input/label, más sutil que field-error */
.field-hint {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--fg-2);
  margin-top: 4px;
}

/* ============================================================
   BATTERY — expandable inline panel
   ============================================================ */
.card .card-expand-indicator {
  position: absolute;
  right: 12px;
  bottom: 12px;
  color: var(--fg-2);
  transition: transform 0.2s ease;
  opacity: 0.7;
}
.card.expanded .card-expand-indicator {
  transform: rotate(180deg);
  color: var(--accent);
  opacity: 1;
}
.card .card-body { position: relative; }

.battery-expand {
  border-top: 1px solid var(--line);
  padding: 14px;
  background: var(--bg-2);
}

.battery-expand .stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.battery-expand .stat-cell {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: 10px 12px;
  min-width: 0;
}
.battery-expand .stat-cell-wide { grid-column: 1 / -1; }
.battery-expand .stat-label {
  font-size: 9.5px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  letter-spacing: 0.10em;
  color: var(--fg-2);
  margin-bottom: 4px;
}
.battery-expand .stat-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg-0);
  font-family: 'Space Grotesk', sans-serif;
  /* No truncamos por defecto: las fechas y números entran. El wrap
     lo permitimos solo en stat-cell-wide (nombre del vehículo). */
  white-space: nowrap;
}
.battery-expand .stat-cell-wide .stat-value {
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.battery-expand .stat-value.num {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.battery-expand-actions {
  display: flex;
  justify-content: flex-end;
}

/* Versión más amplia en pantallas grandes */
@media (min-width: 540px) {
  .battery-expand .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .battery-expand .stat-cell-wide { grid-column: span 2; }
}

/* Sub-título dentro de una sección de detalle (más pequeño que .section-title) */
.section-subtitle {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--fg-2);
  text-transform: uppercase;
  margin: 12px 0 8px;
}

.recent-sessions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.recent-sessions .list-item {
  padding: 10px 12px;
}
.recent-sessions .list-item-sub {
  font-size: 11.5px;
  letter-spacing: 0.02em;
}

/* Cuando el panel expand se reutiliza dentro de battery-detail
   (sin borde superior ni fondo distinto), mejor padding y márgen. */
.tab-section .battery-expand { margin: 0; }

/* ============================================================
   ACCESIBILIDAD GLOBAL
   ============================================================ */

/* Touch: elimina el delay de 300ms y el doble-tap-zoom en controles,
   y evita que el scroll de listas internas "arrastre" el de la página. */
.btn, .btn-icon, .nav-btn, .filter-chip, .tab, .card,
.list-item, .selectable-battery, .chip, .modal-close,
[role="button"], button, a, label, input, select, textarea {
  touch-action: manipulation;
}
.toolbar, .tabs { overscroll-behavior-x: contain; }
.modal-overlay, .image-viewer { overscroll-behavior: contain; }

/* Respeta la preferencia del sistema de movimiento reducido: anula
   animaciones (spinners incluidos), transiciones y autoscroll suave.
   Los estados de carga se siguen comunicando vía aria-live/role=status. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Foco visible garantizado por teclado en cualquier control interactivo,
   SIN depender del tema mediodía. Antes el anillo solo existía en :focus
   y vivía en el tema opcional; si se quitaba, no había indicador. */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible,
.btn:focus-visible,
.nav-btn:focus-visible,
.filter-chip:focus-visible,
.tab:focus-visible,
.card:focus-visible,
.list-item:focus-visible,
.selectable-battery:focus-visible,
.modal-close:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}
/* Los inputs ya muestran un halo (box-shadow) propio al enfocar:
   evitamos el doble anillo. */
.input:focus-visible,
.textarea:focus-visible,
.select:focus-visible,
.search-bar input:focus-visible {
  outline: none;
}
