    :root {
      --twilight: #272771;
      --sapphire: #084AF3;
      --chalk: #F3F5F5;
      --white: #FFFFFF;
      --obsidian: #101218;
      --muted: #6B7280;
      --border: #E5E7EB;
      --ok: #16A34A;
      --ok-soft: #DCFCE7;
      --nook: #DC2626;
      --nook-soft: #FEE2E2;
      --radius: 16px;
      --radius-sm: 12px;
      --shadow: 0 4px 20px rgba(16,18,24,0.06);
      --shadow-lg: 0 12px 40px rgba(39,39,113,0.15);
      --safe-bottom: env(safe-area-inset-bottom, 0px);
    }
    * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
    html, body { height: 100%; }
    body {
      font-family: 'Montserrat', system-ui, sans-serif;
      background: var(--chalk);
      color: var(--obsidian);
      padding-bottom: calc(72px + var(--safe-bottom));
      -webkit-font-smoothing: antialiased;
    }
    body.has-checklist-bar {
      padding-bottom: calc(240px + var(--safe-bottom));
    }
    #view-checklist {
      padding-bottom: 16px;
    }
    #checklistContainer {
      padding-bottom: 24px;
    }
    .checklist-spacer {
      height: 110px;
      width: 100%;
      flex-shrink: 0;
    }

    /* Animations */
    @keyframes fadeUp {
      from { opacity: 0; transform: translateY(12px); }
      to { opacity: 1; transform: translateY(0); }
    }
    @keyframes fadeIn {
      from { opacity: 0; }
      to { opacity: 1; }
    }
    @keyframes scaleIn {
      from { opacity: 0; transform: scale(0.96); }
      to { opacity: 1; transform: scale(1); }
    }
    @keyframes pulseSoft {
      0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.35); }
      50% { box-shadow: 0 0 0 12px rgba(220,38,38,0); }
    }
    .anim-in { animation: fadeUp 0.35s ease both; }
    .anim-scale { animation: scaleIn 0.3s ease both; }

    /* LOGIN */
    #loginScreen {
      position: fixed; inset: 0; z-index: 9999;
      background: var(--twilight);
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      padding: 24px;
      transition: opacity 0.35s ease, visibility 0.35s;
    }
    #loginScreen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
    .login-install-btn {
      position: absolute; top: 18px; right: 18px;
      background: rgba(255,255,255,0.12); color: #fff;
      border: 1px solid rgba(255,255,255,0.25);
      padding: 8px 14px; border-radius: 20px;
      font-size: 0.72rem; font-weight: 600; font-family: inherit;
      cursor: pointer; backdrop-filter: blur(8px);
      transition: background 0.2s, opacity 0.2s;
    }
    .login-install-btn:active { background: rgba(255,255,255,0.22); }
    .login-install-btn.hidden { display: none; }
    .login-footer {
      position: absolute; bottom: 24px; left: 0; right: 0;
      text-align: center; color: rgba(255,255,255,0.55);
      font-size: 0.72rem; font-weight: 500; letter-spacing: 0.02em;
    }
    .login-card {
      background: var(--white); border-radius: 24px;
      padding: 32px 28px; width: 100%; max-width: 380px;
      box-shadow: var(--shadow-lg);
      animation: scaleIn 0.4s ease;
      position: relative;
    }
    .login-logo { text-align: center; margin-bottom: 28px; }
    .login-logo .logo-img {
      width: 72px; height: 72px; margin: 0 auto 14px; display: block;
      object-fit: contain;
    }
    .brand-logo {
      width: 36px; height: 36px; object-fit: contain; border-radius: 8px;
    }
    .login-logo h2 { font-size: 1.25rem; font-weight: 700; color: var(--twilight); letter-spacing: -0.02em; }
    .login-logo p { font-size: 0.8rem; color: var(--muted); margin-top: 4px; font-weight: 500; }
    .login-field { margin-bottom: 16px; }
    .login-field label {
      display: block; font-size: 0.7rem; font-weight: 600;
      color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px;
    }
    .login-field input,
    .login-field select {
      width: 100%; padding: 14px 16px; border: 1.5px solid var(--border);
      border-radius: var(--radius-sm); font-size: 1rem; font-family: inherit;
      background: var(--chalk); outline: none; transition: border-color 0.2s, background 0.2s;
      -webkit-appearance: none; appearance: none;
    }
    .login-field input:focus,
    .login-field select:focus { border-color: var(--sapphire); background: var(--white); }
    .login-error {
      color: var(--nook); font-size: 0.8rem; font-weight: 500;
      margin-bottom: 12px; display: none; text-align: center;
    }
    .login-btn {
      width: 100%; padding: 16px; margin-top: 8px;
      background: var(--sapphire); color: #fff; border: none;
      border-radius: var(--radius-sm); font-size: 1rem; font-weight: 700;
      font-family: inherit; cursor: pointer;
      transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
      box-shadow: 0 4px 14px rgba(8,74,243,0.35);
    }
    .login-btn:active { transform: scale(0.98); background: #0639c4; }

    /* APP SHELL */
    #app { display: none; min-height: 100%; }
    #app.visible { display: block; animation: fadeIn 0.3s ease; }

    header {
      background: var(--white);
      border-bottom: 1px solid var(--border);
      padding: 14px 18px;
      position: sticky; top: 0; z-index: 50;
      backdrop-filter: blur(12px);
    }
    .header-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
    .header-actions { display: flex; align-items: center; gap: 8px; }
    .pending-chip {
      display: none; align-items: center; gap: 6px;
      background: #FEF3C7; color: #92400E;
      font-size: 0.72rem; font-weight: 600;
      padding: 6px 10px; border-radius: 20px;
      white-space: nowrap; cursor: pointer;
    }
    .pending-chip.show { display: inline-flex; }
    .pending-chip.ok {
      background: #DCFCE7; color: #166534;
    }
    .pending-chip .pending-dot {
      width: 7px; height: 7px; border-radius: 50%;
      background: #F59E0B;
    }
    .pending-chip.ok .pending-dot { background: #16A34A; }
    .brand { display: flex; align-items: center; gap: 12px; }

    h1 { font-size: 1rem; font-weight: 700; color: var(--twilight); letter-spacing: -0.02em; }
    .subtitle { font-size: 0.7rem; color: var(--muted); font-weight: 500; margin-top: 1px; }
    .logout-btn {
      background: var(--chalk); border: none; padding: 8px 14px;
      border-radius: 10px; font-size: 0.75rem; font-weight: 600;
      color: var(--muted); cursor: pointer; font-family: inherit;
      transition: background 0.2s, color 0.2s;
    }
    .logout-btn:active { background: var(--border); color: var(--obsidian); }

    .view { display: none; padding: 16px 16px 24px; max-width: 680px; margin: 0 auto; }
    .view.active { display: block; animation: fadeUp 0.3s ease; }

    /* Checklist meta */
    .meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
    .meta-field label {
      font-size: 0.68rem; font-weight: 600; color: var(--muted);
      text-transform: uppercase; letter-spacing: 0.03em; display: block; margin-bottom: 5px;
    }
    .meta-field input, .meta-field select {
      width: 100%; padding: 12px 14px; border: 1.5px solid var(--border);
      border-radius: var(--radius-sm); font-size: 0.9rem; font-family: inherit;
      background: var(--white); outline: none; transition: border-color 0.2s;
      color: var(--obsidian); appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
      background-repeat: no-repeat; background-position: right 14px center;
      padding-right: 36px;
    }
    .meta-field input:focus, .meta-field select:focus { border-color: var(--sapphire); }
    .meta-field input { background-image: none; padding-right: 14px; }

    .progress-row { display: flex; justify-content: flex-end; margin-bottom: 10px; }
    #progressText {
      font-size: 0.8rem; font-weight: 700; color: var(--sapphire);
      background: rgba(8,74,243,0.08); padding: 4px 12px; border-radius: 20px;
    }

    .tabs { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 2px; }
    .tab-btn {
      flex: 1; min-width: 0; padding: 12px 10px; border: 1.5px solid var(--border);
      background: var(--white); color: var(--muted); border-radius: var(--radius-sm);
      font-size: 0.8rem; font-weight: 600; font-family: inherit; cursor: pointer;
      transition: all 0.2s ease; white-space: nowrap; text-align: center;
    }
    .tab-btn.active {
      background: var(--twilight); color: #fff; border-color: var(--twilight);
      box-shadow: 0 4px 12px rgba(39,39,113,0.25);
    }
    .tab-count { font-size: 0.7rem; opacity: 0.85; margin-left: 3px; }

    .zone-section { display: none; flex-direction: column; gap: 12px; }
    .zone-section.active { display: flex; }
    .quick-actions { display: flex; justify-content: flex-end; }
    .btn-mark-all {
      background: rgba(8,74,243,0.08); color: var(--sapphire); border: none;
      padding: 8px 14px; border-radius: 10px; font-size: 0.75rem; font-weight: 600;
      font-family: inherit; cursor: pointer; transition: background 0.2s;
    }
    .btn-mark-all:active { background: rgba(8,74,243,0.15); }

    .item-card {
      background: var(--white); border: 1.5px solid var(--border);
      border-radius: var(--radius); padding: 16px;
      transition: border-color 0.25s, box-shadow 0.25s, transform 0.2s;
      animation: fadeUp 0.35s ease both;
    }
    .item-card.has-error {
      border-color: var(--nook); background: #FFFAFA;
      box-shadow: 0 0 0 3px rgba(220,38,38,0.08);
    }
    .item-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
    .item-title { font-size: 0.92rem; font-weight: 600; color: var(--obsidian); }
    .item-normal {
      display: inline-block; margin-top: 5px; font-size: 0.72rem; font-weight: 500;
      color: var(--sapphire); background: rgba(8,74,243,0.08);
      padding: 3px 10px; border-radius: 8px;
    }
    .status-toggle { display: flex; gap: 8px; flex-shrink: 0; }
    .status-btn {
      padding: 10px 16px; border-radius: 10px; border: 1.5px solid var(--border);
      background: var(--chalk); font-size: 0.8rem; font-weight: 700;
      font-family: inherit; cursor: pointer; color: var(--muted);
      transition: all 0.2s ease; min-width: 64px;
    }
    .status-btn.ok.selected {
      background: var(--ok); color: #fff; border-color: var(--ok);
      box-shadow: 0 4px 12px rgba(22,163,74,0.3);
    }
    .status-btn.nook.selected {
      background: var(--nook); color: #fff; border-color: var(--nook);
      box-shadow: 0 4px 12px rgba(220,38,38,0.3);
    }
    .item-inputs { display: grid; grid-template-columns: 1fr; gap: 8px; }
    .item-inputs.two-cols { grid-template-columns: 130px 1fr; }
    .value-wrap { position: relative; display: flex; align-items: center; }
    .value-wrap .input-box { padding-right: 48px; }
    .unit-badge {
      position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
      font-size: 0.75rem; font-weight: 700; color: var(--sapphire);
      background: rgba(8,74,243,0.1); padding: 2px 8px; border-radius: 6px;
      pointer-events: none;
    }
    .input-box {
      width: 100%; padding: 11px 12px; border: 1.5px solid var(--border);
      border-radius: 10px; font-size: 0.85rem; font-family: inherit;
      background: var(--chalk); outline: none; transition: border-color 0.2s, background 0.2s;
    }
    .input-box:focus { border-color: var(--sapphire); background: var(--white); }
    /* hide number spinners */
    input[type=number]::-webkit-inner-spin-button,
    input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
    input[type=number] { -moz-appearance: textfield; }

    /* Bottom bar checklist */
    .bottom-bar {
      position: fixed; bottom: calc(68px + var(--safe-bottom)); left: 0; right: 0;
      background: rgba(255,255,255,0.96); backdrop-filter: blur(12px);
      border-top: 1px solid var(--border); padding: 10px 16px 12px;
      display: none; z-index: 40; justify-content: center;
    }
    .bottom-bar.show { display: flex; animation: fadeUp 0.25s ease; }
    .btn-submit {
      width: 100%; max-width: 680px; background: var(--sapphire); color: #fff;
      border: none; padding: 14px; border-radius: var(--radius-sm);
      font-size: 0.92rem; font-weight: 700; font-family: inherit; cursor: pointer;
      box-shadow: 0 6px 20px rgba(8,74,243,0.35);
      transition: transform 0.15s, box-shadow 0.2s;
    }
    .btn-submit:active { transform: scale(0.98); }
    .btn-submit:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }

    /* Bottom nav */
    .bottom-nav {
      position: fixed; bottom: 0; left: 0; right: 0;
      background: var(--white); border-top: 1px solid var(--border);
      display: flex; z-index: 60;
      padding: 6px 0 calc(6px + var(--safe-bottom));
      box-shadow: 0 -4px 20px rgba(16,18,24,0.04);
    }
    .bottom-nav-btn {
      flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
      padding: 10px 4px; background: none; border: none;
      color: var(--muted); font-size: 0.68rem; font-weight: 600;
      font-family: inherit; cursor: pointer; transition: color 0.2s;
      position: relative;
    }
    .bottom-nav-btn .nav-icon {
      width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
      transition: transform 0.2s;
    }
    .bottom-nav-btn .nav-icon svg { width: 22px; height: 22px; }
    .bottom-nav-btn.active { color: var(--sapphire); }
    .bottom-nav-btn.active .nav-icon { transform: scale(1.08); }
    .bottom-nav-btn.active::after {
      content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
      width: 28px; height: 3px; background: var(--sapphire); border-radius: 0 0 4px 4px;
    }

    /* Cortes */
    .outage-hero {
      background: var(--white); border: 1.5px solid var(--border);
      border-radius: var(--radius); padding: 28px 20px; text-align: center;
      margin-bottom: 20px; transition: all 0.3s ease;
      box-shadow: var(--shadow);
    }
    .outage-hero.active-outage {
      border-color: var(--nook); background: linear-gradient(180deg, #FFF5F5 0%, #fff 100%);
      animation: pulseSoft 2.5s ease infinite;
    }
    .outage-status { font-size: 0.88rem; color: var(--muted); margin-bottom: 14px; font-weight: 500; }
    .outage-status strong { color: var(--nook); font-weight: 700; }
    .outage-time { font-size: 1.5rem; font-weight: 700; color: var(--obsidian); margin: 8px 0 16px; letter-spacing: -0.02em; }
    .btn-outage {
      width: 100%; max-width: 300px; padding: 18px 24px; border: none;
      border-radius: 14px; font-size: 1.05rem; font-weight: 700;
      font-family: inherit; cursor: pointer; color: #fff;
      transition: transform 0.15s, box-shadow 0.2s;
    }
    .btn-outage.start {
      background: var(--nook);
      box-shadow: 0 6px 20px rgba(220,38,38,0.35);
    }
    .btn-outage.end {
      background: var(--ok);
      box-shadow: 0 6px 20px rgba(22,163,74,0.35);
    }
    .btn-outage:active { transform: scale(0.97); }

    .section-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 14px; color: var(--obsidian); }
    .outage-list { display: flex; flex-direction: column; gap: 10px; }
    .outage-card {
      background: var(--white); border: 1.5px solid var(--border);
      border-radius: var(--radius-sm); padding: 14px 16px;
      transition: transform 0.2s; animation: fadeUp 0.3s ease both;
    }
    .outage-card.activo { border-left: 4px solid var(--nook); }
    .outage-card.cerrado { border-left: 4px solid var(--ok); }
    .outage-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
    .outage-card-date { font-weight: 600; font-size: 0.9rem; }
    .outage-badge {
      font-size: 0.68rem; font-weight: 700; padding: 3px 10px; border-radius: 8px;
    }
    .outage-badge.activo { background: var(--nook-soft); color: var(--nook); }
    .outage-badge.cerrado { background: var(--ok-soft); color: var(--ok); }
    .outage-card-detail { font-size: 0.8rem; color: var(--muted); line-height: 1.4; }

    /* Modal */
    .modal-overlay {
      position: fixed; inset: 0; background: rgba(16,18,24,0.5);
      z-index: 200; display: none; align-items: flex-end; justify-content: center;
      padding: 0; backdrop-filter: blur(4px);
      transition: opacity 0.25s;
    }
    .modal-overlay.show { display: flex; animation: fadeIn 0.25s ease; }
    .modal {
      background: var(--white); border-radius: 24px 24px 0 0;
      padding: 24px 20px calc(24px + var(--safe-bottom));
      width: 100%; max-width: 480px;
      animation: fadeUp 0.3s ease;
    }
    .modal h3 { font-size: 1.1rem; margin-bottom: 16px; color: var(--twilight); font-weight: 700; }
    .modal label { font-size: 0.72rem; font-weight: 600; color: var(--muted); display: block; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.03em; }
    .modal textarea {
      width: 100%; padding: 14px; border: 1.5px solid var(--border);
      border-radius: var(--radius-sm); font-size: 0.9rem; font-family: inherit;
      margin-bottom: 16px; outline: none; resize: none; background: var(--chalk);
      transition: border-color 0.2s;
    }
    .modal textarea:focus { border-color: var(--sapphire); background: var(--white); }
    .modal-actions { display: flex; gap: 10px; }
    .modal-actions button {
      flex: 1; padding: 14px; border-radius: var(--radius-sm);
      font-weight: 700; border: none; cursor: pointer; font-family: inherit; font-size: 0.9rem;
      transition: transform 0.15s;
    }
    .modal-actions button:active { transform: scale(0.98); }
    .btn-cancel { background: var(--chalk); color: var(--obsidian); }
    .btn-confirm { background: var(--ok); color: #fff; box-shadow: 0 4px 14px rgba(22,163,74,0.3); }

    /* Dashboard */
    .stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
    .stat-card {
      background: var(--white); border: 1.5px solid var(--border);
      border-radius: var(--radius); padding: 18px 14px; text-align: center;
      box-shadow: var(--shadow); animation: fadeUp 0.35s ease both;
    }
    .stat-card:nth-child(2) { animation-delay: 0.05s; }
    .stat-card:nth-child(3) { animation-delay: 0.1s; }
    .stat-card:nth-child(4) { animation-delay: 0.15s; }
    .stat-value { font-size: 1.6rem; font-weight: 700; color: var(--twilight); letter-spacing: -0.03em; }
    .stat-label { font-size: 0.72rem; color: var(--muted); margin-top: 4px; font-weight: 500; }
    .chart-card {
      background: var(--white); border: 1.5px solid var(--border);
      border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
      box-shadow: var(--shadow); animation: fadeUp 0.4s ease both;
    }
    .chart-card h3 { font-size: 0.9rem; margin-bottom: 14px; font-weight: 600; color: var(--obsidian); }
    .chart-wrap { position: relative; height: 200px; }

    .empty-msg { text-align: center; color: var(--muted); font-size: 0.88rem; padding: 32px 0; font-weight: 500; }

    /* Toast */
    .toast {
      position: fixed; top: 16px; left: 50%; transform: translateX(-50%) translateY(-140%);
      background: var(--obsidian); color: #fff; padding: 14px 22px;
      border-radius: 14px; font-size: 0.85rem; font-weight: 500; z-index: 1000;
      transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
      max-width: 90%; text-align: center;
      box-shadow: 0 12px 30px rgba(16,18,24,0.25);
    }
    .toast.show { transform: translateX(-50%) translateY(0); }

    .draft-chip {
      display: none; align-items: center; gap: 6px;
      font-size: 0.72rem; font-weight: 600; color: var(--sapphire);
      background: rgba(8,74,243,0.1); padding: 5px 12px; border-radius: 20px;
      margin-bottom: 10px;
    }
    .draft-chip.show { display: inline-flex; }
    .draft-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sapphire); animation: pulseSoft 2s infinite; }

    .range-warn {
      font-size: 0.72rem; color: #B45309; background: #FEF3C7;
      padding: 6px 10px; border-radius: 8px; margin-top: 6px; display: none;
    }
    .range-warn.show { display: block; }
    .item-card.out-of-range { border-color: #F59E0B; }

    .live-timer {
      font-size: 2rem; font-weight: 700; color: var(--nook);
      letter-spacing: -0.03em; margin: 8px 0 4px;
      font-variant-numeric: tabular-nums;
    }
    .live-timer-label { font-size: 0.75rem; color: var(--muted); margin-bottom: 12px; }

    .retry-btn {
      display: inline-flex; align-items: center; gap: 6px;
      background: rgba(8,74,243,0.08); color: var(--sapphire); border: none;
      padding: 10px 16px; border-radius: 10px; font-size: 0.8rem; font-weight: 600;
      font-family: inherit; cursor: pointer; margin-top: 8px;
    }

    .modal-field { margin-bottom: 12px; }
    .modal-field label {
      font-size: 0.72rem; font-weight: 600; color: var(--muted);
      display: block; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.03em;
    }
    .modal-field input {
      width: 100%; padding: 12px 14px; border: 1.5px solid var(--border);
      border-radius: var(--radius-sm); font-size: 0.95rem; font-family: inherit;
      background: var(--chalk); outline: none;
    }
    .modal-field input:focus { border-color: var(--sapphire); background: var(--white); }
    .modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .modal-hint { font-size: 0.75rem; color: var(--muted); margin-top: -4px; margin-bottom: 12px; }

