    /* ─── Color variables (light mode) ──────────────────────────────── */
    :root {
      --bg-body:    #f5f5f5;
      --bg-card:    #ffffff;
      --bg-th:      #f1f5f9;
      --bg-hover:   #f8fafc;
      --bg-input:   #ffffff;
      --bg-toolbar: #f1f5f9;
      --bg-picker:  #ffffff;

      --text-body:    #222222;
      --text-muted:   #6b7280;
      --text-label:   #374151;
      --text-th:      #64748b;
      --text-h1:      #1e293b;
      --text-h2:      #334155;
      --text-warning: #b45309;
      --text-danger:  #dc2626;

      --border:       #e2e8f0;
      --border-input: #d1d5db;
      --link:         #2563eb;
      --shadow-card:  0 1px 3px rgba(0,0,0,.1);

      --btn-secondary-bg:    #e2e8f0;
      --btn-secondary-text:  #334155;
      --btn-secondary-hover: #cbd5e1;

      --badge-available-bg:   #dcfce7; --badge-available-text: #166534;
      --badge-installed-bg:   #dbeafe; --badge-installed-text: #1e40af;
      --badge-retired-bg:     #f1f5f9; --badge-retired-text:   #64748b;
      --badge-warning-bg:     #fef9c3; --badge-warning-text:   #854d0e;

      --flash-success-bg: #dcfce7; --flash-success-text: #166534; --flash-success-border: #86efac;
      --flash-error-bg:   #fee2e2; --flash-error-text:   #991b1b; --flash-error-border:   #fca5a5;
      --flash-warning-bg: #fef9c3; --flash-warning-text: #854d0e; --flash-warning-border: #fde047;

      --health-good:     #166534;
      --health-warn:     #92400e;
      --health-bad:      #991b1b;
      --count-available: #166534;
      --count-installed: #1e40af;
      --count-retired:   #64748b;
    }

    /* Confirmation modal */
    #confirm-modal { display:none; position:fixed; inset:0; z-index:1000; background:rgba(0,0,0,.45); align-items:center; justify-content:center; }
    #confirm-modal.open { display:flex; }
    #confirm-modal-box { background:var(--bg-card); border-radius:8px; padding:1.5rem; max-width:400px; width:calc(100% - 2rem); box-shadow:0 8px 24px rgba(0,0,0,.25); }
    #confirm-modal-msg { margin-bottom:1.25rem; color:var(--text-body); font-size:0.95rem; line-height:1.5; }
    #confirm-modal-actions { display:flex; gap:0.75rem; justify-content:flex-end; }

    /* ─── Dark mode variables ────────────────────────────────────────── */
    @media (prefers-color-scheme: dark) {
      :root {
        --bg-body:    #0f172a;
        --bg-card:    #1e293b;
        --bg-th:      #162032;
        --bg-hover:   #243044;
        --bg-input:   #1e293b;
        --bg-toolbar: #162032;
        --bg-picker:  #1e293b;

        --text-body:    #e2e8f0;
        --text-muted:   #94a3b8;
        --text-label:   #cbd5e1;
        --text-th:      #94a3b8;
        --text-h1:      #f1f5f9;
        --text-h2:      #cbd5e1;
        --text-warning: #fbbf24;
        --text-danger:  #f87171;

        --border:       #334155;
        --border-input: #475569;
        --link:         #60a5fa;
        --shadow-card:  0 1px 3px rgba(0,0,0,.5);

        --btn-secondary-bg:    #334155;
        --btn-secondary-text:  #cbd5e1;
        --btn-secondary-hover: #475569;

        --badge-available-bg:   #14532d; --badge-available-text: #86efac;
        --badge-installed-bg:   #1e3a8a; --badge-installed-text: #93c5fd;
        --badge-retired-bg:     #273449; --badge-retired-text:   #94a3b8;
        --badge-warning-bg:     #451a03; --badge-warning-text:   #fde68a;

        --flash-success-bg: #14532d; --flash-success-text: #86efac; --flash-success-border: #166534;
        --flash-error-bg:   #450a0a; --flash-error-text:   #fca5a5; --flash-error-border:   #991b1b;
        --flash-warning-bg: #451a03; --flash-warning-text: #fde68a; --flash-warning-border: #92400e;

        --health-good:     #86efac;
        --health-warn:     #fde68a;
        --health-bad:      #fca5a5;
        --count-available: #86efac;
        --count-installed: #93c5fd;
        --count-retired:   #94a3b8;
      }
    }

    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    body { font-family: system-ui, sans-serif; font-size: 15px; background: var(--bg-body); color: var(--text-body); }
    a { color: var(--link); text-decoration: none; }
    a:hover { text-decoration: underline; }

    /* Nav */
    nav {
      background: #1e40af;
      color: #fff;
      display: flex;
      flex-wrap: nowrap;
      gap: 0.5rem;
      align-items: center;
      padding: 0.75rem 1rem;
    }
    nav .brand { font-weight: 700; font-size: 1.1rem; margin-right: auto; color: #fff; text-decoration: none; }
    nav .brand:hover { text-decoration: none; opacity: 0.9; }
    nav a { color: #bfdbfe; font-size: 0.9rem; padding: 0.25rem 0.5rem; border-radius: 4px; white-space: nowrap; }
    nav a:hover { background: #1d4ed8; color: #fff; text-decoration: none; }

    /* Layout */
    .container { max-width: 960px; margin: 1.5rem auto; padding: 0 1rem; }

    /* Flash messages */
    .flash { padding: 0.6rem 1rem; border-radius: 4px; margin-bottom: 1rem; font-size: 0.9rem; }
    .flash.success { background: var(--flash-success-bg); color: var(--flash-success-text); border: 1px solid var(--flash-success-border); }
    .flash.error   { background: var(--flash-error-bg);   color: var(--flash-error-text);   border: 1px solid var(--flash-error-border); }
    .flash.warning { background: var(--flash-warning-bg); color: var(--flash-warning-text); border: 1px solid var(--flash-warning-border); }

    /* Cards / boxes */
    .card { background: var(--bg-card); border-radius: 6px; box-shadow: var(--shadow-card); padding: 1.25rem; margin-bottom: 1rem; }

    /* Tables */
    .table-wrap { overflow-x: auto; }
    table { width: 100%; border-collapse: collapse; }
    th { text-align: left; padding: 0.5rem 0.75rem; background: var(--bg-th); font-size: 0.8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-th); border-bottom: 2px solid var(--border); }
    td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
    tr:last-child td { border-bottom: none; }
    tr:hover td { background: var(--bg-hover); }

    /* Status badges */
    .badge { display: inline-block; padding: 0.2em 0.55em; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
    .badge-available { background: var(--badge-available-bg); color: var(--badge-available-text); }
    .badge-installed { background: var(--badge-installed-bg); color: var(--badge-installed-text); }
    .badge-retired   { background: var(--badge-retired-bg);   color: var(--badge-retired-text); }
    .badge-warning   { background: var(--badge-warning-bg);   color: var(--badge-warning-text); }

    /* Buttons */
    .btn { display: inline-block; padding: 0.4rem 0.9rem; border-radius: 4px; border: none; cursor: pointer; font-size: 0.875rem; font-family: inherit; text-decoration: none; }
    .btn:hover { text-decoration: none; }
    .btn-primary  { background: #2563eb; color: #fff; }
    .btn-primary:hover  { background: #1d4ed8; }
    .btn-danger   { background: #dc2626; color: #fff; }
    .btn-danger:hover   { background: #b91c1c; }
    .btn-warning  { background: #d97706; color: #fff; }
    .btn-warning:hover  { background: #b45309; }
    .btn-secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-text); }
    .btn-secondary:hover { background: var(--btn-secondary-hover); }
    .btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }

    /* Forms */
    .form-group { margin-bottom: 1rem; }
    label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.3rem; color: var(--text-label); }
    input[type=text], input[type=number], input[type=date], select, textarea {
      width: 100%; padding: 0.45rem 0.65rem; border: 1px solid var(--border-input);
      border-radius: 4px; font-size: 0.9rem; font-family: inherit;
      background: var(--bg-input); color: var(--text-body);
    }
    input:focus, select:focus, textarea:focus { outline: 2px solid #3b82f6; border-color: #3b82f6; }
    textarea { min-height: 80px; resize: vertical; }
    .form-actions { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-top: 1.25rem; }

    /* Headings */
    h1 { font-size: 1.5rem; margin-bottom: 1rem; color: var(--text-h1); }
    h2 { font-size: 1.15rem; margin-bottom: 0.75rem; color: var(--text-h2); }

    /* Inline form (for POST buttons in tables) */
    form.inline { display: inline; }

    /* Text utilities */
    .text-warning { color: var(--text-warning); font-size: 0.8rem; }
    .text-danger  { color: var(--text-danger); }
    .text-muted   { color: var(--text-muted); font-size: 0.85rem; }

    /* Battery health classes */
    .health-good { color: var(--health-good); }
    .health-warn { color: var(--health-warn); }
    .health-bad  { color: var(--health-bad); }

    /* ─── Dark mode overrides for inline-styled elements ─────────────── */
    @media (prefers-color-scheme: dark) {
      nav { background: #0c1a3b; }
      nav a { color: #93c5fd; }
      nav a:hover { background: #1e3a8a; color: #fff; }
      nav .brand { color: #e2e8f0; }

      #bulk-toolbar    { background: var(--bg-toolbar) !important; }
      #col-picker-panel { background: var(--bg-picker) !important; border-color: var(--border) !important; }
      #col-picker-panel > div:first-child { color: var(--text-th) !important; }

      #filter-bar select, #filter-bar input,
      #bulk-toolbar select, #bulk-toolbar input[type=text],
      #device-filter-bar select, #device-filter-bar input {
        background: var(--bg-input) !important;
        color: var(--text-body) !important;
        border-color: var(--border-input) !important;
      }
      .responsive-table td select {
        background: var(--bg-input);
        color: var(--text-body);
        border-color: var(--border-input);
      }
      .device-option {
        background: var(--bg-card) !important;
        border-color: var(--border) !important;
      }
      #install-grid select, #install-grid input {
        background: var(--bg-input);
        color: var(--text-body);
        border-color: var(--border-input);
      }
    }

    /* ─── Mobile responsive ─────────────────────────────────────────── */
    @media (max-width: 640px) {

      /* Nav: compact on small screens */
      nav { padding: 0.5rem 0.75rem; gap: 0.35rem; }
      nav a { font-size: 0.8rem; padding: 0.2rem 0.35rem; }
      nav .brand { font-size: 1rem; }

      /* Tap targets */
      .btn    { padding: 0.5rem 0.9rem; }
      .btn-sm { padding: 0.35rem 0.65rem; font-size: 0.825rem; }

      /* Collapse 2-col form grids */
      .form-grid-2col { grid-template-columns: 1fr !important; }

      /* Card-style table rows */
      .responsive-table thead { display: none; }
      .responsive-table tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: 6px;
        margin-bottom: 0.75rem;
        padding: 0.25rem 0;
        background: var(--bg-card);
      }
      .responsive-table tr:hover td { background: transparent; }
      .responsive-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.4rem 0.75rem;
        border-bottom: 1px solid var(--bg-th);
        border-top: none;
        font-size: 0.875rem;
      }
      .responsive-table td:last-child { border-bottom: none; }
      .responsive-table td:empty { display: none; }
      .responsive-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-th);
        font-size: 0.8rem;
        flex-shrink: 0;
        margin-right: 0.75rem;
        white-space: nowrap;
      }
      /* Checkbox column: no label prefix, left-aligned */
      .responsive-table td[data-label=""] {
        justify-content: flex-start;
        border-bottom: none;
        padding-bottom: 0;
      }
      /* Actions column: allow wrapping, override nowrap */
      .responsive-table td[data-label="Actions"] {
        flex-wrap: wrap;
        gap: 0.35rem;
        white-space: normal !important;
      }
      .responsive-table td[data-label="Actions"] select {
        width: 100%;
        max-width: 100% !important;
      }

      /* Filter bar: full-width controls with larger tap targets */
      #filter-bar select,
      #filter-bar input[type=text] { flex: 1 1 100%; width: 100% !important; padding: 0.5rem 0.65rem !important; font-size: 0.9rem !important; }

      /* Bulk toolbar: prevent text inputs overflowing */
      #bulk-toolbar input[type=text] { width: 100% !important; }

      /* Install grid on device_detail */
      #install-grid { grid-template-columns: 1fr !important; max-width: 100% !important; }

      /* Column picker: keep panel inside viewport */
      #col-picker-panel { left: 0; right: auto !important; max-width: calc(100vw - 2rem); }

      /* form-actions: stack buttons full-width */
      .form-actions { flex-direction: column; align-items: stretch; }
      .form-actions .btn,
      .form-actions button { width: 100%; text-align: center; }
    }
