      :root {
        --bg: #f4f6f9;
        --panel: #ffffff;
        --line: #e5e8ec;
        --text: #1f2733;
        --muted: #6b7683;
        --gold: #e0a516;
        --gold-dark: #b7791f;
        --green: #1a9c4b;
        --gray: #9aa4b0;
        --input: #ffffff;
        --hover: #f5f7fa;
        --head: #f8fafc;
        --shadow:
          0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
        --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.1);
      }
      * {
        box-sizing: border-box;
      }
      html {
        color-scheme: light;
      } /* force light native controls even in OS dark mode */
      body {
        margin: 0;
        font-family:
          -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
        background: var(--bg);
        color: var(--text);
        -webkit-font-smoothing: antialiased;
        /* app shell: fill the viewport; only <main> scrolls, not the sidebar.
           100dvh (not 100vh) so mobile browser toolbars don't cut content off. */
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
      }
      header {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 24px;
        border-bottom: 1px solid var(--line);
        background: var(--panel);
        position: relative;
        flex-shrink: 0; /* never shrink below its content -> no overlap with main */
        z-index: 5;
        box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
      }
      header h1 {
        font-size: 17px;
        margin: 0;
        font-weight: 700;
        letter-spacing: -0.2px;
      }
      .badge {
        font-size: 11px;
        padding: 3px 9px;
        border-radius: 20px;
        border: 1px solid var(--line);
        color: var(--muted);
        background: var(--bg);
      }
      .badge.live {
        color: var(--green);
        border-color: #bfe6cd;
        background: #eafaf0;
      }
      .tabs {
        display: flex;
        gap: 4px;
        margin-left: auto;
        background: var(--bg);
        padding: 4px;
        border-radius: 10px;
      }
      .tabs button {
        background: transparent;
        border: 0;
        color: var(--muted);
        padding: 7px 15px;
        border-radius: 8px;
        cursor: pointer;
        font-size: 13px;
        font-weight: 500;
      }
      .tabs button:hover {
        color: var(--text);
      }
      .tabs button.active {
        color: var(--text);
        background: var(--panel);
        box-shadow: var(--shadow);
      }
      /* ---- App shell: left icon sidebar + content ---- */
      .shell {
        display: flex;
        align-items: stretch;
        flex: 1;
        min-height: 0;
      }
      .hspacer {
        margin-left: auto;
      }
      .hamburger {
        display: none;
        background: transparent;
        border: 0;
        color: var(--text);
        cursor: pointer;
        padding: 5px;
        border-radius: 8px;
        line-height: 0;
      }
      .hamburger:hover {
        background: var(--bg);
      }
      .sidebar {
        width: 216px;
        flex-shrink: 0;
        background: var(--panel);
        border-right: 1px solid var(--line);
        padding: 16px 12px;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        z-index: 20;
      }
      /* logo + close row, shown only inside the mobile drawer */
      .sidebarHead {
        display: none;
        order: 0;
        align-items: center;
        gap: 10px;
        padding: 2px 6px 14px;
        margin-bottom: 6px;
        border-bottom: 1px solid var(--line);
      }
      .sidebarHead h2 {
        font-size: 16px;
        font-weight: 700;
        margin: 0;
        letter-spacing: -0.2px;
      }
      .sidebarClose {
        margin-left: auto;
        background: transparent;
        border: 0;
        cursor: pointer;
        color: var(--muted);
        padding: 4px;
        border-radius: 8px;
        line-height: 0;
      }
      .sidebarClose:hover {
        background: var(--bg);
        color: var(--text);
      }
      /* sign out pinned to the bottom of the panel */
      .sidebarSignout {
        order: 2;
        margin-top: auto;
        display: flex;
        align-items: center;
        gap: 11px;
        width: 100%;
        text-align: left;
        padding: 10px 12px;
        border-radius: 9px;
        background: transparent;
        border: 0;
        cursor: pointer;
        font-size: 13.5px;
        font-weight: 500;
        color: var(--muted);
      }
      .sidebarSignout svg {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
      }
      .sidebarSignout:hover {
        background: #fdeceb;
        color: #c0392b;
      }
      .sidebar .tabs {
        display: flex;
        flex-direction: column;
        gap: 2px;
        width: 100%;
        background: transparent;
        padding: 0;
        border-radius: 0;
        margin: 0;
        overflow: visible;
        order: 1; /* override the stray order:5 from the old mobile .tabs rule */
      }
      .sidebar .tabs button {
        display: flex;
        align-items: center;
        gap: 11px;
        width: 100%;
        text-align: left;
        padding: 10px 12px;
        border-radius: 9px;
        font-size: 13.5px;
        font-weight: 500;
        color: var(--muted);
        box-shadow: none;
        white-space: nowrap;
      }
      .sidebar .tabs button svg {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
        opacity: 0.9;
      }
      .sidebar .tabs button:hover {
        background: var(--bg);
        color: var(--text);
      }
      .sidebar .tabs button.active {
        background: var(--bg);
        color: var(--text);
        font-weight: 600;
        box-shadow: none;
      }
      .sidebar .tabs button.active svg {
        color: #e0a516;
        opacity: 1;
      }
      .sidebarBackdrop {
        position: fixed;
        inset: 0;
        background: rgba(16, 24, 40, 0.4);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s;
        z-index: 39;
      }
      .sidebarBackdrop.show {
        opacity: 1;
        visibility: visible;
      }
      main {
        flex: 1;
        min-width: 0;
        min-height: 0;
        overflow-y: auto; /* the ONLY scrolling region */
        padding: 28px 24px;
        max-width: 1040px;
        margin: 0 auto;
      }
      .view {
        display: none;
      }
      .view.active {
        display: block;
      }
      body.booting main {
        visibility: hidden;
      }
      .subBanner {
        display: flex;
        align-items: center;
        gap: 14px;
        flex-wrap: wrap;
        background: #fdeceb;
        border: 1px solid #f4c9c4;
        color: #a3271b;
        padding: 12px 16px;
        border-radius: 12px;
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 18px;
      }
      .subBanner.trial {
        background: #e8effe;
        border-color: #c9d8fb;
        color: #24417e;
      }
      .subBanner .grow {
        flex: 1;
      }
      .subBanner button {
        border: 0;
        border-radius: 9px;
        font-weight: 700;
        font-size: 13px;
        padding: 9px 16px;
        cursor: pointer;
        background: linear-gradient(160deg, #e9ad1e, #cf920c);
        color: #3a2a00;
      }
      .gateBlock {
        text-align: center;
        padding: 64px 24px;
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 16px;
        color: var(--muted);
      }
      .gateBlock h2 {
        margin: 0 0 8px;
        color: var(--text);
      }
      /* Activity log */
      .auditCard {
        padding: 4px 18px;
        max-height: calc(100dvh - 250px);
        overflow-y: auto;
      }
      .auditRow {
        display: flex;
        gap: 12px;
        align-items: baseline;
        padding: 11px 2px;
        border-bottom: 1px solid var(--line);
        font-size: 14px;
      }
      .auditRow:last-child {
        border-bottom: 0;
      }
      .auditWhen {
        min-width: 120px;
        font-size: 12px;
        color: var(--muted);
        white-space: nowrap;
      }
      .auditWhat {
        flex: 1;
        min-width: 0;
        word-break: break-word;
      }
      .auditWho {
        font-size: 12px;
        color: var(--muted);
        white-space: nowrap;
      }
      .auditBar {
        display: flex;
        gap: 12px;
        align-items: flex-end;
        flex-wrap: wrap;
        margin-bottom: 14px;
      }
      .auditField {
        display: flex;
        flex-direction: column;
        gap: 4px;
        font-size: 12px;
        color: var(--muted);
      }
      .auditField input {
        padding: 8px 10px;
        border: 1px solid var(--line);
        border-radius: 9px;
        background: var(--input, #fff);
        color: var(--text);
        font-size: 13px;
      }
      .auditFoot {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        flex-wrap: wrap;
        margin-top: 14px;
      }
      .auditPager {
        display: flex;
        gap: 8px;
      }
      .auditPager .btn:disabled {
        opacity: 0.45;
        cursor: not-allowed;
      }
      @media (max-width: 640px) {
        .auditCard {
          max-height: calc(100dvh - 210px);
        }
        .auditRow {
          flex-wrap: wrap;
          gap: 2px 10px;
        }
        .auditWhat {
          order: 1;
          flex-basis: 100%;
        }
        .auditWhen {
          order: 2;
          min-width: 0;
        }
        .auditWho {
          order: 3;
          margin-left: auto;
        }
      }
      /* Live alert card */
      #alertZone {
        min-height: 120px;
      }
      /* (the scrolling #alertZone rule lives further down — it already caps the
         height, so a deep alert history scrolls instead of overflowing) */
      .alert {
        border: 1px solid #f0dca0;
        border-left: 4px solid var(--gold);
        background: linear-gradient(180deg, #fffdf5, #ffffff);
        border-radius: 14px;
        padding: 22px 26px;
        margin-bottom: 14px;
        display: flex;
        align-items: center;
        gap: 20px;
        box-shadow: var(--shadow);
        animation: pop 0.35s ease;
      }
      @keyframes pop {
        from {
          transform: scale(0.98);
          opacity: 0;
        }
        to {
          transform: scale(1);
          opacity: 1;
        }
      }
      .star {
        font-size: 40px;
      }
      .avatar {
        width: 64px;
        height: 64px;
        border-radius: 12px;
        object-fit: cover;
        border: 1px solid var(--line);
      }
      .avatarLg {
        width: 96px;
        height: 96px;
        border-radius: 16px;
        object-fit: cover;
        border: 1px solid var(--line);
        float: left;
        margin-right: 20px;
      }
      .alert .name {
        font-size: 23px;
        font-weight: 700;
        letter-spacing: -0.3px;
      }
      .alert .tier {
        color: var(--gold-dark);
        font-weight: 700;
        text-transform: uppercase;
        font-size: 11px;
        letter-spacing: 1px;
      }
      .alert .meta {
        color: var(--muted);
        font-size: 14px;
        margin-top: 5px;
      }
      .alert .meta b {
        color: var(--text);
      }
      .alert .time {
        margin-left: auto;
        color: var(--muted);
        font-size: 12px;
      }
      .empty {
        color: var(--muted);
        text-align: center;
        padding: 48px;
        border: 1px dashed var(--line);
        border-radius: 14px;
        background: var(--panel);
      }
      /* Tables */
      table {
        width: 100%;
        border-collapse: collapse;
        font-size: 14px;
        background: var(--panel);
      }
      th,
      td {
        text-align: left;
        padding: 13px 16px;
        border-bottom: 1px solid var(--line);
      }
      th {
        color: var(--muted);
        font-weight: 600;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.6px;
        background: var(--head);
      }
      tbody tr:last-child td {
        border-bottom: 0;
      }
      .pill {
        font-size: 11px;
        padding: 3px 10px;
        border-radius: 20px;
        font-weight: 600;
        background: #eef1f5;
        color: var(--muted);
        border: 1px solid var(--line);
      }
      /* VIP-tier name cell: input + "enroll floor" pill stack cleanly (no overlap) */
      .tierCell {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
      }
      .tierCell .pill {
        display: inline-block;
      }
      .pill.gold {
        background: #fdf4de;
        color: var(--gold-dark);
        border-color: #f0dca0;
      }
      .pill.silver {
        background: #eef1f5;
        color: #5b6673;
      }
      .pill.platinum {
        background: #f3effc;
        color: #7c3aed;
        border-color: #ddd0f7;
      }
      .money {
        font-variant-numeric: tabular-nums;
      }
      .sub {
        color: var(--muted);
        font-size: 13px;
        margin: 0 0 16px;
        line-height: 1.5;
      }
      /* professional per-view header (title + description) */
      .viewHead {
        margin-bottom: 22px;
      }
      .viewTitle {
        font-size: 21px;
        font-weight: 700;
        letter-spacing: -0.3px;
        margin: 0 0 5px;
        color: var(--text);
      }
      .viewSub {
        color: var(--muted);
        font-size: 13.5px;
        line-height: 1.55;
        margin: 0;
        max-width: 760px;
      }
      .viewSub .legend {
        white-space: nowrap;
      }
      /* forms shouldn't stretch full-width on large screens */
      .formCard {
        max-width: 640px;
      }
      /* soft informational note (subtle yellow) */
      .note {
        margin: 12px 0 0;
        background: #fff8e1;
        border: 1px solid #f2e2a4;
        color: #856a15;
        font-size: 12.5px;
        line-height: 1.5;
        padding: 9px 12px;
        border-radius: 10px;
      }
      tr.click {
        cursor: pointer;
      }
      tr.click:hover td {
        background: var(--hover);
      }
      .back {
        background: var(--panel);
        border: 1px solid var(--line);
        color: var(--text);
        padding: 8px 14px;
        border-radius: 8px;
        cursor: pointer;
        margin-bottom: 18px;
        font-size: 13px;
        font-weight: 500;
        box-shadow: var(--shadow);
      }
      .back:hover {
        background: var(--hover);
      }
      .card {
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 14px;
        padding: 24px 26px;
        margin-bottom: 20px;
        box-shadow: var(--shadow);
      }
      .card h2 {
        margin: 0 0 8px;
        font-size: 22px;
        font-weight: 700;
        letter-spacing: -0.3px;
      }
      .kv {
        color: var(--muted);
        font-size: 14px;
        margin: 5px 0;
      }
      .kv b {
        color: var(--text);
      }
      h3 {
        font-size: 12px;
        color: var(--muted);
        text-transform: uppercase;
        letter-spacing: 0.7px;
        font-weight: 700;
        margin: 26px 0 12px;
      }
      /* form inputs (settings, record-sale) */
      #settings input:not([type="checkbox"]),
      #recordSale input {
        background: var(--input);
        border: 1px solid var(--line);
        color: var(--text);
        border-radius: 9px;
        padding: 11px 13px;
        font-size: 14px;
        width: 100%;
        transition:
          border-color 0.15s,
          box-shadow 0.15s;
      }
      #settings input:focus,
      #recordSale input:focus,
      .authCard input:not([type="checkbox"]):focus {
        outline: 0;
        border-color: var(--gold);
        box-shadow: 0 0 0 3px rgba(224, 165, 22, 0.15);
      }
      #settings label,
      #recordSale label {
        display: block;
        color: var(--muted);
        font-size: 12px;
        font-weight: 600;
        margin: 0 0 7px;
      }
      #branches input:not([type="checkbox"]),
      #team input:not([type="checkbox"]) {
        background: #fff;
        border: 1px solid var(--line);
        color: var(--text);
        border-radius: 9px;
        padding: 11px 13px;
        font-size: 14px;
        width: 100%;
      }
      #branches input:focus,
      #team input:focus {
        outline: 0;
        border-color: var(--gold);
        box-shadow: 0 0 0 3px rgba(224, 165, 22, 0.15);
      }
      /* unified dropdowns (custom arrow, cursor, theme) */
      select {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        background-color: #fff;
        color: var(--text);
        border: 1px solid var(--line);
        border-radius: 9px;
        padding: 10px 36px 10px 13px;
        font-size: 14px;
        cursor: pointer;
        box-shadow: var(--shadow);
        line-height: 1.2;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7683' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 13px center;
        background-size: 11px;
      }
      select:hover {
        border-color: #cbd2db;
      }
      select:focus {
        outline: 0;
        border-color: var(--gold);
        box-shadow: 0 0 0 3px rgba(224, 165, 22, 0.15);
      }
      select:disabled {
        background-color: #f2f4f7;
        cursor: default;
        color: var(--muted);
      }
      select option {
        background: #fff;
        color: var(--text);
      }
      /* custom dropdown (always opens BELOW the field) */
      .ddwrap {
        position: relative;
        display: inline-block;
      }
      #team .ddwrap,
      #branches .ddwrap {
        display: block;
        width: 100%;
      }
      .ddtrigger {
        background: #fff;
        color: var(--text);
        border: 1px solid var(--line);
        border-radius: 9px;
        padding: 10px 36px 10px 13px;
        font-size: 14px;
        cursor: pointer;
        box-shadow: var(--shadow);
        text-align: left;
        width: 100%;
        line-height: 1.2;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7683' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 13px center;
        background-size: 11px;
      }
      .ddtrigger:hover {
        border-color: #cbd2db;
      }
      .ddtrigger.open {
        border-color: var(--gold);
        box-shadow: 0 0 0 3px rgba(224, 165, 22, 0.15);
      }
      .ddtrigger:disabled {
        background: #f2f4f7;
        color: var(--muted);
        cursor: default;
      }
      .ddmenu {
        position: absolute;
        top: calc(100% + 6px);
        left: 0;
        min-width: 100%;
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 11px;
        box-shadow: var(--shadow-md);
        z-index: 70;
        display: none;
        overflow: auto;
        max-height: 280px;
        padding: 5px;
        white-space: nowrap;
      }
      .ddmenu.show {
        display: block;
        animation: ddin 0.12s ease;
      }
      @keyframes ddin {
        from {
          opacity: 0;
          transform: translateY(-4px);
        }
        to {
          opacity: 1;
          transform: none;
        }
      }
      .dditem {
        padding: 9px 12px;
        border-radius: 7px;
        cursor: pointer;
        font-size: 14px;
      }
      .dditem:hover {
        background: var(--hover);
      }
      .dditem.sel {
        color: var(--gold-dark);
        font-weight: 600;
      }
      header .ddwrap {
        margin-left: 10px;
        vertical-align: middle;
      }
      header .ddtrigger {
        padding: 8px 32px 8px 12px;
        font-size: 13px;
        width: auto;
      }
      #team select,
      #branches select {
        width: 100%;
      }
      #branches label,
      #team label {
        display: block;
        color: var(--muted);
        font-size: 12px;
        font-weight: 600;
        margin: 0 0 7px;
      }
      #branchBody input:not([type="checkbox"]) {
        padding: 8px 11px;
        width: 100%;
      }
      #branchBody .bName {
        min-width: 150px;
        max-width: 230px;
      }
      #branchBody .bCity {
        min-width: 100px;
        max-width: 150px;
      }
      #branchBody .bAddr {
        min-width: 200px;
      }
      #branchBody td {
        vertical-align: middle;
        white-space: nowrap;
      }
      #branchBody .idcell {
        white-space: nowrap;
        margin-right: 8px;
        font-size: 12px;
      }
      .idcell {
        font-family: ui-monospace, Menlo, monospace;
        font-size: 12px;
        color: var(--muted);
      }
      .copybtn {
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 6px 8px;
        cursor: pointer;
        box-shadow: var(--shadow);
        color: var(--muted);
        display: inline-flex;
        align-items: center;
        vertical-align: middle;
      }
      .copybtn:hover {
        color: var(--gold-dark);
        border-color: var(--gold);
      }
      #settings .card label {
        margin-top: 18px;
      }
      #settings .card > label:first-of-type {
        margin-top: 0;
      }
      #settings .card .pwWrap {
        margin-top: 7px;
      }
      #rulesBody input[type="number"] {
        max-width: 200px;
      }
      /* custom themed checkboxes */
      input[type="checkbox"] {
        -webkit-appearance: none;
        appearance: none;
        width: 18px;
        height: 18px;
        flex: none;
        border: 1.5px solid #c7cdd6;
        border-radius: 5px;
        background: #fff;
        cursor: pointer;
        vertical-align: -4px;
        position: relative;
        transition:
          background 0.12s,
          border-color 0.12s;
        margin: 0;
      }
      input[type="checkbox"]:hover {
        border-color: var(--gold);
      }
      input[type="checkbox"]:checked {
        background: var(--gold);
        border-color: var(--gold);
      }
      input[type="checkbox"]:checked::after {
        content: "";
        position: absolute;
        left: 5px;
        top: 1.5px;
        width: 4px;
        height: 9px;
        border: solid #40300a;
        border-width: 0 2px 2px 0;
        transform: rotate(45deg);
      }
      input[type="checkbox"]:focus-visible {
        outline: 0;
        box-shadow: 0 0 0 3px rgba(224, 165, 22, 0.25);
      }
      label:has(input[type="checkbox"]) {
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        gap: 8px;
      }
      /* confirm modal */
      .modalOverlay {
        position: fixed;
        inset: 0;
        background: rgba(16, 24, 40, 0.45);
        display: none;
        align-items: center;
        justify-content: center;
        overflow-y: auto;
        z-index: 200;
      }
      .modalOverlay.show {
        display: flex;
        animation: fadeIn 0.15s ease;
      }
      @keyframes fadeIn {
        from {
          opacity: 0;
        }
        to {
          opacity: 1;
        }
      }
      .modalCard {
        background: #fff;
        border-radius: 16px;
        padding: 26px 28px;
        width: 400px;
        max-width: 92vw;
        box-shadow: var(--shadow-md);
        animation: cardIn 0.2s ease;
      }
      .modalTitle {
        font-size: 18px;
        font-weight: 700;
        margin-bottom: 8px;
      }
      .modalMsg {
        color: var(--muted);
        font-size: 14px;
        line-height: 1.55;
        margin-bottom: 22px;
      }
      .modalBtns {
        display: flex;
        gap: 10px;
        justify-content: flex-end;
      }
      .btn.danger {
        background: #e5484d;
        color: #fff;
      }
      .rulesForm {
        display: flex;
        gap: 12px;
        align-items: flex-end;
        flex-wrap: wrap;
        margin-top: 18px;
      }
      .btn {
        border: 0;
        border-radius: 9px;
        padding: 11px 18px;
        font-weight: 600;
        cursor: pointer;
        font-size: 14px;
        transition: filter 0.15s;
      }
      .btn:hover {
        filter: brightness(0.97);
      }
      .btn.add {
        background: var(--panel);
        color: var(--text);
        border: 1px solid var(--line);
        box-shadow: var(--shadow);
      }
      .btn.save {
        background: var(--gold);
        color: #40300a;
      }
      .btn.ghost {
        background: var(--panel);
        color: var(--text);
        border: 1px solid var(--line);
      }
      .btn.sm {
        padding: 7px 13px;
        font-size: 13px;
      }
      /* Customer detail: Edit button floats top-right of the header card */
      #detailHead {
        position: relative;
      }
      #detailHead .editBtn {
        position: absolute;
        top: 16px;
        right: 16px;
      }
      .editForm {
        max-width: 480px;
      }
      .editForm label {
        display: block;
        margin: 12px 0 5px;
        font-size: 12px;
        font-weight: 600;
        color: var(--muted);
      }
      .editForm input,
      .editForm textarea {
        width: 100%;
        padding: 10px 12px;
        border: 1px solid var(--line);
        border-radius: 9px;
        font-size: 14px;
        font-family: inherit;
        color: var(--text);
        background: var(--panel);
      }
      .editForm input:focus,
      .editForm textarea:focus {
        outline: 0;
        border-color: var(--gold);
      }
      .editActions {
        display: flex;
        gap: 10px;
        margin-top: 16px;
      }
      .btn.del {
        background: var(--panel);
        color: #c0392b;
        border: 1px solid var(--line);
        padding: 7px 12px;
        box-shadow: var(--shadow);
      }
      #signoutBtn,
      #homeBtn {
        margin-left: 10px;
        background: var(--panel);
        border: 1px solid var(--line);
        color: var(--text);
        padding: 8px 14px;
        border-radius: 9px;
        cursor: pointer;
        font-size: 13px;
        font-weight: 500;
        display: none;
        box-shadow: var(--shadow);
        text-decoration: none;
      }
      #signoutBtn:hover,
      #homeBtn:hover {
        background: var(--hover);
        color: var(--gold-dark);
      }
      #statusBtn {
        margin-left: 8px;
        background: var(--panel);
        border: 1px solid var(--line);
        color: var(--text);
        padding: 8px 13px;
        border-radius: 9px;
        cursor: pointer;
        font-size: 13px;
        font-weight: 500;
        display: inline-flex;
        align-items: center;
        gap: 7px;
        box-shadow: var(--shadow);
        text-decoration: none;
      }
      #statusBtn:hover {
        background: var(--hover);
        color: var(--gold-dark);
      }
      #statusBtn .sdot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #17b26a;
      }
      #soundBtn,
      #notifBtn {
        margin-left: 8px;
        background: var(--panel);
        border: 1px solid var(--line);
        padding: 8px;
        border-radius: 9px;
        cursor: pointer;
        color: var(--muted);
        display: none;
        line-height: 0;
        box-shadow: var(--shadow);
      }
      #soundBtn:hover,
      #notifBtn:hover {
        color: var(--gold-dark);
        background: var(--hover);
      }
      #soundBtn.muted,
      #notifBtn.off {
        color: var(--soft, #9aa1b1);
        opacity: 0.7;
      }
      #soundBtn svg,
      #notifBtn svg {
        display: block;
      }
      #homeBtn svg {
        display: inline-block;
        vertical-align: -2px;
        margin-right: 5px;
      }
      #branchFilter {
        margin-left: 10px;
        padding: 8px 32px 8px 12px;
        font-size: 13px;
      }
      .authOverlay {
        position: fixed;
        inset: 0;
        background: var(--bg);
        display: none;
        align-items: center;
        justify-content: center;
        overflow-y: auto;
        z-index: 50;
      }
      .authCard {
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 18px;
        padding: 38px 34px;
        width: 370px;
        text-align: center;
        box-shadow: var(--shadow-md);
        animation: cardIn 0.3s ease;
      }
      .authCard h2 {
        margin: 10px 0 2px;
        font-size: 24px;
        font-weight: 700;
      }
      .authCard input:not([type="checkbox"]) {
        width: 100%;
        padding: 12px 14px;
        margin-top: 12px;
        border-radius: 10px;
        border: 1px solid var(--line);
        background: var(--input);
        color: var(--text);
        font-size: 14px;
      }
      .authCard a {
        color: var(--gold-dark);
        text-decoration: none;
        font-weight: 600;
      }
      @keyframes cardIn {
        from {
          transform: translateY(8px);
          opacity: 0;
        }
        to {
          transform: translateY(0);
          opacity: 1;
        }
      }
      /* password reveal */
      .pwWrap {
        position: relative;
        margin-top: 12px;
      }
      .authCard .pwWrap input,
      .pwWrap input {
        margin-top: 0;
        padding-right: 62px;
      }
      .pwToggle {
        position: absolute;
        right: 6px;
        top: 50%;
        transform: translateY(-50%);
        background: none;
        border: 0;
        color: var(--muted);
        cursor: pointer;
        font-size: 12px;
        font-weight: 600;
        padding: 5px 8px;
        width: auto;
      }
      .pwToggle:hover {
        color: var(--gold-dark);
      }
      /* spinner */
      .spinner {
        display: inline-block;
        width: 15px;
        height: 15px;
        border: 2px solid rgba(64, 48, 10, 0.3);
        border-top-color: #40300a;
        border-radius: 50%;
        animation: spin 0.6s linear infinite;
        vertical-align: -3px;
      }
      .spinner.light {
        border-color: rgba(0, 0, 0, 0.12);
        border-top-color: var(--gold);
      }
      @keyframes spin {
        to {
          transform: rotate(360deg);
        }
      }
      button:disabled {
        opacity: 0.6;
        cursor: default;
      }
      /* toasts */
      .toastWrap {
        position: fixed;
        top: 18px;
        right: 18px;
        z-index: 100;
        display: flex;
        flex-direction: column;
        gap: 10px;
      }
      .toast {
        background: var(--panel);
        border: 1px solid var(--line);
        border-left: 4px solid var(--gold);
        padding: 13px 18px;
        border-radius: 12px;
        color: var(--text);
        font-size: 14px;
        max-width: 340px;
        font-weight: 500;
        box-shadow: var(--shadow-md);
        animation: slideIn 0.25s ease;
      }
      .toast.success {
        border-left-color: var(--green);
      }
      .toast.error {
        border-left-color: #e5484d;
      }
      @keyframes slideIn {
        from {
          transform: translateX(24px);
          opacity: 0;
        }
        to {
          transform: translateX(0);
          opacity: 1;
        }
      }
      .loadingRow td {
        color: var(--muted);
      }
      /* inner-scroll containers so long lists don't blow up the page */
      .tableWrap {
        max-height: calc(100vh - 250px);
        overflow: auto;
        border: 1px solid var(--line);
        border-radius: 14px;
        box-shadow: var(--shadow);
      }
      .tableWrap table {
        border-collapse: separate;
        border-spacing: 0;
      }
      .tableWrap thead th {
        position: sticky;
        top: 0;
        background: var(--head);
        z-index: 1;
      }
      .tableWrap.short {
        max-height: 320px;
      }
      /* ---- Command Center -------------------------------------------------
         Cameras on the left, a live recognition rail on the right. The rail
         scrolls INTERNALLY and is never truncated, so every alert of the shift
         stays reachable without the page growing forever. */
      /* Command Center fills the viewport and scrolls INSIDE its panes, so the
         KPI row and status bar stay put while cameras and alerts scroll
         independently of each other. `main` normally owns the only scrollbar,
         so it hands that over (and its width cap) while this view is active. */
      body.cmd main {
        overflow: hidden;
        max-width: none;
        padding: 18px 20px;
      }
      body.cmd #live.view.active {
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 0;
      }
      body.cmd .ccGrid {
        flex: 1;
        min-height: 0;
      }
      body.cmd .ccCams,
      body.cmd .ccAlerts {
        display: flex;
        flex-direction: column;
        min-height: 0;
        max-height: 100%;
      }
      body.cmd .camGrid,
      body.cmd #alertZone {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        max-height: none;
      }
      /* Rows must keep their natural height inside a height-constrained grid —
         without this the tiles squash to fit and the pane never scrolls. */
      body.cmd .camGrid {
        grid-auto-rows: max-content;
        align-content: start;
      }
      /* Below the two-column breakpoint, squeezing a camera wall AND the alert
         rail into a phone screen makes both unusable — let the page scroll
         normally there and keep only the alert rail internally scrollable. */
      @media (max-width: 1100px) {
        body.cmd main {
          overflow-y: auto;
        }
        body.cmd #live.view.active {
          height: auto;
        }
        body.cmd .ccGrid {
          flex: none;
        }
        body.cmd .ccCams,
        body.cmd .ccAlerts {
          max-height: none;
        }
        body.cmd .camGrid {
          flex: none;
          overflow: visible;
        }
        body.cmd #alertZone {
          flex: none;
          max-height: 60vh;
        }
      }
      .ccKpis {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 14px;
        margin-bottom: 16px;
        flex-shrink: 0; /* pinned: never scrolls away with the panes */
      }
      .ccStatus,
      .ccHead {
        flex-shrink: 0;
      }
      /* ---- Reports ---- */
      .repCard {
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 16px;
        padding: 16px 18px;
        box-shadow: var(--shadow);
        margin-bottom: 16px;
        min-width: 0;
      }
      .repGrid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
        align-items: start;
      }
      .repGrid .repCard {
        margin-bottom: 0;
      }
      #repChart svg {
        display: block;
      }
      .chartBox {
        position: relative;
        height: 300px;
      }
      .chartBox.sm {
        height: 230px;
      }
      .repRangeBar {
        display: flex;
        align-items: flex-end;
        gap: 12px;
        flex-wrap: wrap;
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 12px;
        padding: 14px 16px;
        margin-bottom: 16px;
        box-shadow: var(--shadow);
      }
      .repRangeBar label {
        display: flex;
        flex-direction: column;
        gap: 5px;
        font-size: 11.5px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        color: var(--muted);
      }
      .repRangeBar input {
        padding: 9px 11px;
        border: 1px solid var(--line);
        border-radius: 9px;
        font: inherit;
        font-size: 13.5px;
        color: var(--text);
        background: var(--panel);
      }
      .repRangeBar input:focus {
        outline: 0;
        border-color: var(--gold);
      }
      .hintText {
        font-size: 12.5px;
        color: #b42318;
        align-self: center;
      }
      #repChart rect {
        transition: opacity 0.15s;
      }
      #repChart g:hover rect {
        opacity: 0.78;
      }
      .repCard th.num,
      .repCard td.num {
        text-align: right;
      }
      @media (max-width: 980px) {
        .repGrid {
          grid-template-columns: 1fr;
        }
      }
      /* ---- VIP Registry (Customers) ---- */
      .regKpis {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 14px;
        margin: 4px 0 16px;
      }
      .regBar {
        display: flex;
        align-items: center;
        gap: 12px;
        flex-wrap: wrap;
        margin-bottom: 12px;
      }
      .chips {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
      }
      .chips button {
        border: 1px solid var(--line);
        background: var(--panel);
        color: var(--muted);
        font: inherit;
        font-size: 13px;
        font-weight: 600;
        padding: 8px 14px;
        border-radius: 999px;
        cursor: pointer;
        transition:
          background 0.15s,
          color 0.15s;
      }
      .chips button:hover {
        color: var(--text);
      }
      .chips button.active {
        background: var(--gold);
        border-color: var(--gold);
        color: #40300a;
      }
      .regSearch {
        margin-left: auto;
        min-width: 200px;
        padding: 9px 13px;
        border: 1px solid var(--line);
        border-radius: 10px;
        font: inherit;
        font-size: 13.5px;
        background: var(--panel);
        color: var(--text);
      }
      .regSearch:focus {
        outline: 0;
        border-color: var(--gold);
      }
      .regTable th.num,
      .regTable td.num {
        text-align: right;
      }
      .regTable th.act,
      .regTable td.act {
        text-align: right;
        width: 76px;
      }
      .regClient {
        display: flex;
        align-items: center;
        gap: 12px;
        min-width: 0;
      }
      .regAv {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        object-fit: cover;
        flex-shrink: 0;
        border: 1px solid var(--line);
      }
      .regAv.ph {
        display: grid;
        place-items: center;
        background: linear-gradient(180deg, #fff6df, #fdeec2);
        color: var(--gold-dark, #b8860b);
        font-weight: 800;
        font-size: 15px;
      }
      .regName {
        font-weight: 700;
      }
      .regSubtle {
        font-size: 12px;
        color: var(--muted);
        margin-top: 1px;
      }
      .laMain {
        display: block;
      }
      .laNow {
        color: #12b76a;
        font-weight: 700;
      }
      .laSub {
        display: block;
        font-size: 12px;
        color: var(--muted);
        margin-top: 1px;
      }
      .iconBtn {
        border: 1px solid var(--line);
        background: var(--panel);
        border-radius: 9px;
        width: 32px;
        height: 30px;
        display: inline-grid;
        place-items: center;
        cursor: pointer;
        color: var(--muted);
      }
      .iconBtn svg {
        width: 16px;
        height: 16px;
      }
      .iconBtn:hover {
        color: var(--gold-dark, #b8860b);
        border-color: var(--gold);
      }
      @media (max-width: 900px) {
        .regKpis {
          grid-template-columns: 1fr 1fr;
        }
        .regSearch {
          margin-left: 0;
          width: 100%;
        }
      }
      /* segmented camera-layout control */
      .segbar {
        display: inline-flex;
        gap: 2px;
        padding: 2px;
        background: var(--bg);
        border: 1px solid var(--line);
        border-radius: 9px;
        margin-left: auto;
      }
      .segbar button {
        display: grid;
        place-items: center;
        width: 30px;
        height: 26px;
        padding: 0;
        border: 0;
        border-radius: 7px;
        background: transparent;
        color: var(--muted);
        cursor: pointer;
      }
      .segbar button svg {
        width: 15px;
        height: 15px;
      }
      .segbar button:hover {
        color: var(--text);
      }
      .segbar button.active {
        background: var(--panel);
        color: var(--gold-dark, #b8860b);
        box-shadow: var(--shadow);
      }
      .camGrid[data-cols="1"] {
        grid-template-columns: 1fr;
      }
      .camGrid[data-cols="2"] {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
      .camGrid[data-cols="3"] {
        grid-template-columns: repeat(3, minmax(0, 1fr));
      }
      /* collapsible sidebar (desktop) */
      .navToggle {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        margin-top: auto;
        padding: 9px 12px;
        border: 0;
        background: transparent;
        color: var(--muted);
        font: inherit;
        font-size: 13px;
        font-weight: 600;
        border-radius: 9px;
        cursor: pointer;
      }
      .navToggle svg {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
        transition: transform 0.18s;
      }
      .navToggle:hover {
        background: var(--bg);
        color: var(--text);
      }
      body.navmin .sidebar {
        width: 62px;
        padding-left: 8px;
        padding-right: 8px;
      }
      body.navmin .sidebar .tabs button span,
      body.navmin .sidebar .sidebarSignout span,
      body.navmin .navToggle span {
        display: none;
      }
      body.navmin .sidebar .tabs button,
      body.navmin .sidebar .sidebarSignout,
      body.navmin .navToggle {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
      }
      body.navmin .navToggle svg {
        transform: rotate(180deg);
      }
      .kpi {
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 14px;
        padding: 16px 18px;
        box-shadow: var(--shadow);
      }
      .kpi .kLabel {
        font-size: 11px;
        letter-spacing: 0.6px;
        text-transform: uppercase;
        color: var(--muted);
        font-weight: 700;
      }
      .kpi .kVal {
        font-size: 28px;
        font-weight: 800;
        letter-spacing: -0.5px;
        margin-top: 6px;
        line-height: 1.1;
      }
      .kpi .kSub {
        font-size: 12px;
        color: var(--muted);
        margin-top: 2px;
      }
      .kpi.accent {
        border-color: #f0dca0;
        background: linear-gradient(180deg, #fffdf5, #fff);
      }
      .kpi.accent .kVal {
        color: var(--gold-dark, #b8860b);
      }
      .ccGrid {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 380px;
        gap: 16px;
        align-items: start;
      }
      .ccCams,
      .ccAlerts {
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 16px;
        padding: 16px 18px;
        box-shadow: var(--shadow);
        min-width: 0;
      }
      .ccHead {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        flex-wrap: wrap; /* title/meta/controls must never overlap when narrow */
        margin-bottom: 12px;
      }
      /* "Open live wall" sat between the meta text and the layout buttons and
         wrapped mid-word on a phone. Keep it whole, and let it take its own
         line before the layout control does. */
      #ccWall {
        flex-shrink: 0;
      }
      #ccWall .btn {
        white-space: nowrap;
      }
      @media (max-width: 620px) {
        .ccHead h3 {
          flex: 1 1 auto;
        }
        #ccWall {
          order: 3;
          flex: 1 1 100%;
        }
        #ccWall .btn {
          /* the button is an <a>, so it must be block for width to apply —
             and a full-width target is far easier to hit on a phone */
          display: block;
          width: 100%;
          text-align: center;
        }
        .ccCams .segbar {
          margin-left: 0;
        }
      }
      .ccHead h3 {
        margin: 0;
        font-size: 13px;
        text-transform: uppercase;
        letter-spacing: 0.6px;
        color: var(--muted);
      }
      .ccMeta {
        font-size: 12px;
        color: var(--muted);
      }
      .camGrid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
        gap: 12px;
      }
      .camTile {
        border: 1px solid var(--line);
        border-radius: 12px;
        overflow: hidden;
        background: #0c0f13;
        position: relative;
      }
      .camTile img {
        width: 100%;
        aspect-ratio: 16 / 9;
        object-fit: contain;
        display: block;
        background: #0c0f13;
      }
      /* Before the first frame decodes, an <img> with no bytes renders the
         browser's broken-image glyph — which is what made an ordinary loading
         tile look like a fault. Hide it until it has actually loaded once; the
         tile's dark background stands in, and refreshes after that are
         double-buffered so the picture never blanks again. */
      .camTile img[data-ready="0"] {
        visibility: hidden;
      }
      .camLive[hidden] {
        display: none;
      }
      .camTile .camNone {
        aspect-ratio: 16 / 9;
        display: grid;
        place-items: center;
        color: #8b95a3;
        font-size: 12.5px;
        text-align: center;
        padding: 12px;
        line-height: 1.5;
      }
      .camBar {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 9px 12px;
        background: var(--panel);
        border-top: 1px solid var(--line);
        font-size: 13px;
        font-weight: 600;
      }
      .camBar .camWhen {
        margin-left: auto;
        font-weight: 500;
        font-size: 11.5px;
        color: var(--muted);
      }
      .camLive {
        position: absolute;
        top: 8px;
        left: 8px;
        background: rgba(18, 183, 106, 0.92);
        color: #fff;
        font-size: 10.5px;
        font-weight: 800;
        letter-spacing: 0.5px;
        padding: 3px 8px;
        border-radius: 6px;
      }
      .ccStatus {
        display: flex;
        flex-wrap: wrap;
        gap: 8px 20px;
        align-items: center;
        margin-top: 14px;
        padding: 11px 16px;
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 12px;
        font-size: 12.5px;
        color: var(--muted);
        box-shadow: var(--shadow);
      }
      .ccStatus b {
        color: var(--text);
      }
      /* health data older than the heartbeat window — make it obvious */
      .ccStatus .stale,
      .ccStatus .stale b {
        color: #b42318;
      }
      #alertZone {
        max-height: min(70vh, 720px);
        overflow-y: auto;
        padding-right: 4px;
      }
      /* compact alert cards inside the narrower rail */
      .ccAlerts .alert {
        padding: 14px 16px;
        margin-bottom: 10px;
      }
      .ccAlerts .alert .avatar {
        width: 52px;
        height: 52px;
      }
      @media (max-width: 1100px) {
        .ccGrid {
          grid-template-columns: 1fr;
        }
        #alertZone {
          max-height: 60vh;
        }
      }
      @media (max-width: 720px) {
        .ccKpis {
          grid-template-columns: 1fr 1fr;
        }
        .camGrid {
          grid-template-columns: 1fr;
        }
      }
      .saleForm {
        display: flex;
        gap: 12px;
        align-items: flex-end;
        flex-wrap: wrap;
      }
      /* responsive: phones & tablets */
      @media (max-width: 760px) {
        header {
          flex-wrap: wrap;
          gap: 8px;
          padding: 12px 14px;
        }
        header h1 {
          font-size: 16px;
        }
        .tabs {
          order: 5;
          width: 100%;
          overflow-x: auto;
          -webkit-overflow-scrolling: touch;
          margin-left: 0;
        }
        .tabs button {
          white-space: nowrap;
        }
        #signoutBtn,
        #soundBtn,
        #notifBtn {
          margin-left: 0;
        }
        main {
          padding: 16px 14px;
        }
        .authCard {
          width: 92vw;
          max-width: 370px;
          padding: 28px 22px;
        }
        .card {
          padding: 18px 18px;
        }
        .alert {
          flex-wrap: wrap;
          padding: 16px 18px;
          gap: 14px;
        }
        .alert .name {
          font-size: 20px;
        }
        .alert .time {
          margin-left: 0;
          order: 5;
        }
        .avatar {
          width: 54px;
          height: 54px;
        }
        .avatarLg {
          width: 72px;
          height: 72px;
          margin-right: 14px;
        }
        th,
        td {
          padding: 11px 12px;
          font-size: 13px;
        }
        .tableWrap {
          max-height: 62vh;
        }
        .rulesForm,
        .saleForm {
          gap: 8px;
        }
        /* sidebar becomes an off-canvas drawer toggled by the hamburger */
        .hamburger {
          display: inline-flex;
        }
        .sidebar {
          position: fixed;
          top: 0;
          left: 0;
          height: 100dvh; /* visible height, excludes the browser toolbars */
          width: 250px;
          z-index: 40;
          transform: translateX(-100%);
          transition: transform 0.22s ease;
          box-shadow: 2px 0 18px rgba(16, 24, 40, 0.16);
          /* keep Sign out clear of the phone's bottom toolbar / home bar */
          padding-bottom: calc(16px + env(safe-area-inset-bottom));
        }
        .sidebar.open {
          transform: translateX(0);
        }
        .sidebarHead {
          display: flex;
        }
        main {
          max-width: 100%;
        }
      }
      /* the sidebar carries Sign out everywhere, so hide the top-bar one */
      #signoutBtn {
        display: none;
      }

      /* ---- Branch health view ---- */
      .healthGrid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(340px, 440px));
        gap: 16px;
      }
      .hcard {
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 14px;
        padding: 18px 20px;
        box-shadow: var(--shadow);
      }
      .posOpen {
        display: block;
        margin: 14px 0 10px;
        padding: 13px 16px;
        border-radius: 10px;
        background: var(--gold, #e0a516);
        color: #40300a;
        font-weight: 700;
        font-size: 15px;
        text-align: center;
        text-decoration: none;
        transition: filter 0.15s;
      }
      .posOpen:hover {
        filter: brightness(0.97);
      }
      .posUrl {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
        margin-bottom: 8px;
      }
      .posUrl code {
        font-size: 13px;
        color: var(--muted);
        word-break: break-all;
      }
      .copyBtn {
        border: 1px solid var(--line);
        background: var(--bg);
        color: var(--text);
        border-radius: 8px;
        padding: 3px 10px;
        font-size: 12px;
        cursor: pointer;
      }
      .copyBtn:hover {
        border-color: var(--gold, #e0a516);
      }
      .hcard-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin-bottom: 6px;
      }
      .hcard-head .hname {
        font-weight: 700;
        font-size: 15px;
      }
      .hbadge {
        font-size: 11.5px;
        font-weight: 600;
        padding: 4px 10px;
        border-radius: 20px;
        display: inline-flex;
        align-items: center;
        gap: 6px;
        white-space: nowrap;
      }
      .hbadge.ok {
        color: #067647;
        background: #eafaf0;
        border: 1px solid #bfe6cd;
      }
      .hbadge.down {
        color: #b42318;
        background: #fef3f2;
        border: 1px solid #fecdca;
      }
      .hdot {
        display: inline-block;
        width: 9px;
        height: 9px;
        border-radius: 50%;
        vertical-align: middle;
      }
      .hdot.ok {
        background: #17b26a;
      }
      .hdot.down {
        background: #f04438;
      }
      .hdot.unknown {
        background: #98a2b3;
      }
      /* top-bar at-a-glance health dot */
      .healthPill {
        display: inline-flex;
        align-items: center;
        gap: 7px;
        padding: 6px 11px;
        border-radius: 20px;
        border: 1px solid var(--line);
        background: var(--panel);
        color: var(--text);
        font-size: 12.5px;
        font-weight: 600;
        cursor: pointer;
      }
      .healthPill:hover {
        background: var(--bg);
      }
      .healthPill .hdot {
        width: 8px;
        height: 8px;
      }
      .healthPill.ok {
        color: #067647;
        border-color: #bfe6cd;
        background: #eafaf0;
      }
      .healthPill.down {
        color: #b42318;
        border-color: #fecdca;
        background: #fef3f2;
      }
      @media (max-width: 600px) {
        #healthPillText {
          display: none;
        }
      }
      .hrow {
        display: flex;
        align-items: flex-start;
        gap: 10px;
        font-size: 13px;
        margin-top: 12px;
      }
      .hrow .hlabel {
        min-width: 62px;
        color: var(--muted);
        font-weight: 600;
        padding-top: 3px;
      }
      .hchips {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
      }
      .hval {
        flex: 1;
        min-width: 0;
        line-height: 1.5;
        overflow-wrap: anywhere;
      }
      .hchip {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        font-size: 12px;
        padding: 4px 9px;
        border-radius: 8px;
        border: 1px solid var(--line);
        color: var(--text);
        background: var(--bg);
      }
      .hchip .het {
        color: var(--muted);
      }
      .herrors {
        margin-top: 14px;
        border-top: 1px solid var(--line);
        padding-top: 10px;
      }
      .herrors .htitle {
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--muted);
        margin-bottom: 6px;
      }
      .herr {
        font-size: 12px;
        margin: 8px 0;
        line-height: 1.45;
        overflow-wrap: anywhere; /* long tokens wrap instead of overflowing */
      }
      .herr .herrmsg {
        color: #b42318;
        font-weight: 600;
      }
      .herr .herrhint {
        color: var(--muted);
        margin: 2px 0 1px;
      }
      .herr .het {
        color: var(--muted);
      }
      .hloc {
        color: var(--muted);
        font-size: 12.5px;
        margin: -4px 0 8px;
      }
      .hstamp {
        font-size: 11px;
        color: var(--muted);
        margin-top: 12px;
      }

/* ---- VIP arrival popup ----------------------------------------------------
   Announces a new detection over the page, then flies into the alert list so
   it's obvious where it went. Deliberately NOT a modal: it never blocks the
   page (pointer-events are on the card only), because staff are mid-sale when
   it appears and must be able to keep working through it. */
.vipPop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.vipPopCard {
  pointer-events: auto;
  cursor: pointer;
  width: min(340px, 86vw);
  padding: 22px 24px 20px;
  border-radius: 18px;
  text-align: center;
  background: linear-gradient(180deg, #fffdf6, #fff);
  border: 1px solid #eccf7a;
  box-shadow:
    0 24px 60px rgba(16, 24, 40, 0.24),
    0 0 0 6px rgba(224, 165, 22, 0.13);
  /* start state; .in / .out below drive the transition */
  transform: translate3d(0, 14px, 0) scale(0.94);
  opacity: 0;
  transition:
    transform 0.42s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.3s ease;
}
.vipPop.in .vipPopCard {
  transform: translate3d(0, 0, 0) scale(1);
  opacity: 1;
}
/* The flight: shrink toward the alert panel while fading, so the card visibly
   becomes the list entry rather than just vanishing. */
.vipPop.out .vipPopCard {
  transform: translate3d(var(--fx, 0), var(--fy, -40px), 0) scale(0.32);
  opacity: 0;
  transition:
    transform 0.6s cubic-bezier(0.5, 0, 0.75, 0),
    opacity 0.55s ease-in;
}
.vipPopBadge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: #8a6400;
  background: #fbeec4;
  border-radius: 999px;
  padding: 4px 11px;
  margin-bottom: 14px;
}
.vipPopFace {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto 12px;
  border: 3px solid var(--gold, #e0a516);
  background: #f3f4f6;
  box-shadow: 0 0 0 6px rgba(224, 165, 22, 0.14);
}
.vipPopFace.ph {
  display: grid;
  place-items: center;
  font-size: 38px;
}
.vipPopName {
  font-size: 21px;
  font-weight: 800;
  line-height: 1.2;
}
.vipPopTier {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--gold-dark, #b7791f);
  margin-top: 3px;
}
.vipPopSpend {
  font-size: 14px;
  font-weight: 600;
  margin-top: 9px;
}
.vipPopMeta {
  font-size: 12px;
  color: var(--muted, #6b7683);
  margin-top: 3px;
}
/* The pulsing ring reads as "something just happened" from across a shop floor,
   where nobody is looking directly at the screen. */
.vipPop.in .vipPopFace {
  animation: vipRing 1.5s ease-out 2;
}
@keyframes vipRing {
  0% {
    box-shadow: 0 0 0 0 rgba(224, 165, 22, 0.5);
  }
  70% {
    box-shadow: 0 0 0 18px rgba(224, 165, 22, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(224, 165, 22, 0);
  }
}
/* Motion sensitivity is not optional for something that fires unprompted many
   times a day: fade only, no flight, no pulse. */
@media (prefers-reduced-motion: reduce) {
  .vipPopCard,
  .vipPop.out .vipPopCard {
    transition: opacity 0.2s ease;
    transform: none;
  }
  .vipPop.in .vipPopFace {
    animation: none;
  }
}
