
    :root{
      --bg: #0b1020;
      --card: rgba(255,255,255,0.06);
      --card2: rgba(255,255,255,0.08);
      --border: rgba(255,255,255,0.10);
      --text: rgba(255,255,255,0.92);
      --muted: rgba(255,255,255,0.65);
      --muted2: rgba(255,255,255,0.50);
      --brand: #0b5bd3;
      --brand2: #27c2ff;
      --ok: #22c55e;
      --warn: #f59e0b;
      --bad: #ef4444;

      --shadow: 0 18px 50px rgba(0,0,0,0.35);
      --radius: 18px;
      --radius2: 14px;

      --maxw: 1200px;
      --sidebar: 280px;
    }

    *{ box-sizing: border-box; }
    html,body{ height:100%; }
    body{
      margin:0;
      font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
      color: var(--text);
      background: radial-gradient(1200px 800px at 10% 10%, rgba(39,194,255,0.18), transparent 60%),
                  radial-gradient(900px 700px at 90% 20%, rgba(11,91,211,0.22), transparent 55%),
                  radial-gradient(800px 600px at 50% 95%, rgba(34,197,94,0.12), transparent 50%),
                  linear-gradient(180deg, #060913, #070b17 55%, #060913);
      overflow:hidden;
      overscroll-behavior: none;
    }

    /* Background ornaments */
    .bg{ position:fixed; inset:0; pointer-events:none; z-index:-1; }
    .orb{
      position:absolute; width: 460px; height: 460px; border-radius: 999px;
      filter: blur(40px); opacity: .55;
      transform: translate3d(0,0,0);
      animation: float 14s ease-in-out infinite;
    }
    .orb.o1{ left:-120px; top:-120px; background: rgba(39,194,255,0.35); }
    .orb.o2{ right:-140px; top:60px; background: rgba(11,91,211,0.35); animation-duration: 16s; }
    .orb.o3{ left:30%; bottom:-180px; background: rgba(34,197,94,0.22); animation-duration: 18s; }
    @keyframes float{
      0%,100%{ transform: translateY(0px) translateX(0px); }
      50%{ transform: translateY(22px) translateX(14px); }
    }
    .grid{
      position:absolute; inset:0;
      background-image:
        linear-gradient(to right, rgba(255,255,255,0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.05) 1px, transparent 1px);
      background-size: 64px 64px;
      mask-image: radial-gradient(closest-side at 50% 30%, rgba(0,0,0,1), rgba(0,0,0,0));
      opacity: .5;
    }

    /* Shell */
    .shell{
      display:flex;
      min-height:100vh;
      height:100vh;
      overflow:hidden;
    }
    body.auth-checking .shell,
    body:not(.auth-ready) .shell,
    body.auth-checking .settings-quick-save,
    body:not(.auth-ready) .settings-quick-save{
      visibility:hidden;
      pointer-events:none;
    }

    /*password toggle*/
    .pw-wrap {
        position: relative;
      }

      .pw-wrap input {
        width: 100%;
        padding-right: 44px; /* space for the eye button */
      }
      

      .pw-toggle {
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        border: none;
        background: transparent;
        cursor: pointer;
        font-size: 16px;
        opacity: 0.8;
      }

      /* Enhance password toggle visibility & accessibility */
      .pw-toggle{
        color: rgba(255,255,255,0.9);
        padding: 6px;
        line-height: 1;
      }

      .pw-toggle:focus{
        outline: 2px solid rgba(39,194,255,0.6);
        outline-offset: 2px;
        border-radius: 10px;
      }

      .pw-toggle:hover {
        opacity: 1;
      }


    /* Sidebar */
    .sidebar{
      width: var(--sidebar);
      padding: 18px;
      position: sticky;
      top: 0;
      height: 100vh;
      min-height: 0;
    }
    .sidecard{
      height: 100%;
      border: 1px solid var(--border);
      background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.05));
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      overflow:hidden;
      display:flex;
      flex-direction: column;
      min-height: 0;
    }
    .brandbar{
      padding: 16px 16px 14px;
      display:flex;
      align-items:center;
      gap: 12px;
      border-bottom: 1px solid var(--border);
      background: rgba(0,0,0,0.12);
    }
    .logo{
      width: 44px;
      height: 44px;
      border-radius: 14px;
      background: linear-gradient(135deg, rgba(11,91,211,0.95), rgba(39,194,255,0.85));
      display:grid;
      place-items:center;
      box-shadow: 0 10px 30px rgba(11,91,211,0.35);
      font-weight: 900;
      letter-spacing: .5px;
    }
    .logo img{
      width: 100%;
      height: 100%;
      display:block;
      border-radius: inherit;
    }
    .brandtext .name{ font-weight: 950; }
    .brandtext .tag{ color: var(--muted); font-size: 12px; margin-top: 2px; }

    .nav{
      padding: 10px;
      display:flex;
      flex-direction: column;
      gap: 6px;
      overflow:auto;
      overscroll-behavior-y: contain;
    }
    .nav .section{
      margin: 12px 8px 6px;
      font-size: 11px;
      letter-spacing: .14em;
      color: rgba(255,255,255,0.50);
      text-transform: uppercase;
    }
    .nav a{
      text-decoration:none;
      color: var(--text);
      padding: 10px 12px;
      border-radius: 14px;
      border: 1px solid transparent;
      display:flex;
      align-items:center;
      gap: 10px;
      background: transparent;
      transition: 180ms ease;
    }
    .nav a:hover{
      background: rgba(255,255,255,0.06);
      border-color: rgba(255,255,255,0.10);
    }
    .nav a.active{
      background: rgba(11,91,211,0.18);
      border-color: rgba(11,91,211,0.40);
    }
    .ico{
      width: 18px;
      height: 18px;
      display:inline-grid;
      place-items:center;
      font-size: 14px;
      opacity: .95;
    }

    .sidefooter{
      padding: 14px 16px;
      border-top: 1px solid var(--border);
      background: rgba(0,0,0,0.10);
      display:flex;
      flex-direction: column;
      align-items:flex-start;
      gap: 10px;
    }
    .sidefooter-actions{
      display:flex;
      align-items:center;
      gap: 10px;
      width: 100%;
      justify-content: space-between;
      flex-wrap: wrap;
    }
    .sidecredit{
      font-size: 11px;
      color: rgba(255,255,255,0.65);
      font-weight: 800;
      line-height: 1.4;
    }
    .pill{
      display:inline-flex;
      align-items:center;
      gap: 8px;
      padding: 8px 10px;
      border-radius: 999px;
      border: 1px solid rgba(255,255,255,0.12);
      background: rgba(255,255,255,0.06);
      color: var(--text);
      font-weight: 800;
      font-size: 12px;
      cursor:pointer;
      user-select:none;
      text-decoration:none;
      transition: 180ms ease;
      white-space: nowrap;
    }
    .pill:hover{ transform: translateY(-1px); background: rgba(255,255,255,0.09); }
    .pill.primary{
      border-color: rgba(11,91,211,0.45);
      background: rgba(11,91,211,0.22);
    }
    .pill.outline{
      background: transparent;
      border-color: rgba(255,255,255,0.14);
    }

    /* Main */
    .main{
      flex:1;
      min-width: 0;
      min-height: 0;
      height: 100vh;
      padding: 18px 18px 40px;
      overflow-y: auto;
      overscroll-behavior-y: contain;
      scrollbar-gutter: stable;
    }
    .wrap{
      max-width: var(--maxw);
      margin: 0 auto;
      display:flex;
      flex-direction: column;
      gap: 14px;
    }

    /* Topbar */
    .topbar{
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.06);
      backdrop-filter: blur(10px);
      border-radius: var(--radius);
      padding: 12px 14px;
      box-shadow: var(--shadow);
      display:flex;
      align-items:center;
      justify-content: space-between;
      gap: 12px;
    }
    .lefthead{
      display:flex;
      flex-direction: column;
      gap: 2px;
      min-width: 220px;
    }
    .title{ font-size: 16px; font-weight: 950; letter-spacing: .2px; }
    .subtitle{ font-size: 12px; color: var(--muted); }

    .topactions{
      display:flex;
      align-items:center;
      gap: 10px;
      flex-wrap: wrap;
      justify-content: flex-end;
    }
    .search{
      display:flex;
      align-items:center;
      gap: 8px;
      padding: 10px 12px;
      border-radius: 999px;
      border: 1px solid rgba(255,255,255,0.12);
      background: rgba(0,0,0,0.16);
      min-width: 260px;
    }
    .search input{
      background: transparent;
      border:0;
      outline:none;
      color: var(--text);
      width: 100%;
      font-weight: 700;
      font-size: 13px;
    }
    .search input::placeholder{ color: rgba(255,255,255,0.45); }

    .btn{
      border: 1px solid rgba(255,255,255,0.14);
      background: rgba(255,255,255,0.06);
      color: var(--text);
      border-radius: 999px;
      padding: 10px 12px;
      font-weight: 900;
      font-size: 13px;
      cursor:pointer;
      transition: 180ms ease;
      display:inline-flex;
      align-items:center;
      gap: 8px;
      user-select:none;
      white-space: nowrap;
    }
    .btn:hover{ transform: translateY(-1px); background: rgba(255,255,255,0.10); }
    .btn:focus-visible{
      outline: 2px solid rgba(39,194,255,0.62);
      outline-offset: 2px;
    }
    .btn:disabled{
      opacity: 0.55;
      cursor: not-allowed;
      transform: none !important;
    }
    .btn.primary{
      border-color: rgba(11,91,211,0.45);
      background: linear-gradient(135deg, rgba(11,91,211,0.75), rgba(39,194,255,0.55));
    }
    .btn.bad{
      border-color: rgba(239,68,68,0.45);
      background: rgba(239,68,68,0.18);
      color: rgba(255,242,242,0.96);
    }
    .btn.bad:hover{ background: rgba(239,68,68,0.26); }
    .btn.ghost{ background: transparent; }

    /* Cards */
    .grid2{ display:grid; grid-template-columns: 1.2fr .8fr; gap: 14px; }
    .grid3{ display:grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
    .card{
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.06);
      backdrop-filter: blur(8px);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      overflow:hidden;
      overflow: clip;
    }
    .card .head{
      padding: 14px 14px 12px;
      border-bottom: 1px solid var(--border);
      display:flex;
      align-items:center;
      justify-content: space-between;
      gap: 10px;
      background: rgba(0,0,0,0.10);
    }
    .card .head .h{ font-weight: 950; letter-spacing: .2px; }
    .card .head .mut{ color: var(--muted); font-size: 12px; font-weight: 750; }
    .card .body{ padding: 14px; }

    .kpis{
      display:grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 12px;
    }
    .kpi{
      border: 1px solid rgba(255,255,255,0.10);
      background: rgba(0,0,0,0.14);
      border-radius: var(--radius2);
      padding: 12px;
    }
    .kpi .label{ color: var(--muted); font-size: 12px; font-weight: 800; }
    .kpi .value{ font-size: 22px; font-weight: 1000; margin-top: 6px; letter-spacing: .2px; }
    .kpi .delta{ margin-top: 8px; font-size: 12px; font-weight: 850; color: rgba(255,255,255,0.75); }
    .usage-chart{
      width: 100%;
      min-height: 240px;
    }
    .usage-summary{
      display:grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 10px;
      margin: 12px 0;
    }
    .usage-summary .kpi{
      box-shadow: none;
    }
    .usage-alerts{
      display:grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
      margin: 10px 0 12px;
    }
    .usage-alert{
      border: 1px solid rgba(245,158,11,0.35);
      background: linear-gradient(135deg, rgba(245,158,11,0.16), rgba(15,23,42,0.30));
      border-radius: var(--radius2);
      padding: 12px;
    }
    .usage-alert strong{ display:block; margin-bottom:4px; }
    .voucher-ledger-summary{
      grid-template-columns: repeat(3, minmax(0, 1fr));
      margin-bottom: 14px;
    }
    .voucher-ledger-summary .kpi{
      min-width: 0;
      box-shadow: none;
    }
    .voucher-ledger-summary .value{
      overflow-wrap: anywhere;
    }
    .voucher-ledger-tabs{
      display:flex;
      gap:8px;
      flex-wrap:wrap;
      margin: 0 0 12px;
    }
    .voucher-ledger-tabs .btn[aria-pressed="true"]{
      border-color: rgba(39,194,255,0.58);
      background: rgba(39,194,255,0.18);
      box-shadow: 0 0 0 2px rgba(39,194,255,0.10);
    }
    .voucher-ledger-truth-note{
      margin: 12px 0;
      padding: 10px 12px;
      border: 1px solid rgba(59,130,246,0.30);
      border-radius: var(--radius2);
      background: rgba(59,130,246,0.09);
      color: rgba(225,239,255,0.90);
      font-size: 12px;
      font-weight: 750;
      line-height: 1.45;
    }
    .voucher-ledger-pager{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:10px;
      flex-wrap:wrap;
      margin-top:12px;
    }
    @media (max-width: 820px){
      .usage-summary{ grid-template-columns: 1fr; }
      .usage-alerts{ grid-template-columns: 1fr; }
      .voucher-ledger-summary{ grid-template-columns: 1fr; }
    }

    .dot{
      width: 8px; height: 8px; border-radius: 999px; display:inline-block;
      background: rgba(255,255,255,0.35);
      margin-right: 8px;
    }
    .dot.ok{ background: rgba(34,197,94,0.9); }
    .dot.warn{ background: rgba(245,158,11,0.95); }
    .dot.bad{ background: rgba(239,68,68,0.95); }

    /* Table */
    .table{
      width:100%;
      border-collapse: collapse;
      overflow:hidden;
      border-radius: var(--radius2);
      border: 1px solid rgba(255,255,255,0.10);
      background: rgba(0,0,0,0.14);
    }
    .table th, .table td{
      text-align:left;
      padding: 10px 10px;
      border-bottom: 1px solid rgba(255,255,255,0.08);
      font-size: 13px;
      vertical-align: middle;
      line-height: 1.35;
    }
    .table th{
      font-size: 11px;
      letter-spacing: .12em;
      text-transform: uppercase;
      color: rgba(255,255,255,0.60);
      font-weight: 950;
      background: rgba(0,0,0,0.16);
      position: sticky;
      top: 0;
      z-index: 1;
    }
    .table tr:hover td{ background: rgba(255,255,255,0.04); }
    .table tr.clickable-row{ cursor:pointer; }
    .table tr.clickable-row:hover td{ background: rgba(39,194,255,0.08); }
    .table td a{
      color: rgba(156,221,255,0.98);
      text-decoration: none;
      border-bottom: 1px dotted rgba(156,221,255,0.55);
    }
    .table td a:hover{ border-bottom-color: rgba(156,221,255,0.92); }
    .table-scroll{
      display: block;
      width: 100%;
      max-width: 100%;
      overflow-x: auto;
      overflow-y: hidden;
      overscroll-behavior-x: contain;
      scrollbar-gutter: stable both-edges;
      padding-bottom: 6px;
    }
    .table-scroll .table{
      min-width: 100%;
      margin: 0;
    }
    .table-scroll .table.wide{
      min-width: 1234px;
    }
    .table tbody tr.row-opens-view{ cursor:pointer; }
    .table tbody tr.row-opens-view:hover td{ background:rgba(39,194,255,.055); }
    .settings-quick-save{
      display:none; position:fixed; right:20px; bottom:20px; z-index:55;
      width:auto !important; box-shadow:0 14px 34px rgba(0,0,0,.38);
    }
    .settings-quick-save.show{ display:inline-flex; }

    .badge{
      display:inline-flex;
      align-items:center;
      gap: 8px;
      padding: 7px 10px;
      border-radius: 999px;
      border: 1px solid rgba(255,255,255,0.12);
      background: rgba(255,255,255,0.06);
      font-weight: 900;
      font-size: 12px;
      color: rgba(255,255,255,0.85);
      white-space: nowrap;
    }
    .badge.ok{ border-color: rgba(34,197,94,0.35); background: rgba(34,197,94,0.14); }
    .badge.warn{ border-color: rgba(245,158,11,0.35); background: rgba(245,158,11,0.14); }
    .badge.bad{ border-color: rgba(239,68,68,0.35); background: rgba(239,68,68,0.14); }
    .badge.info{ border-color: rgba(59,130,246,0.35); background: rgba(59,130,246,0.14); }
    .badge.soft{ border-color: rgba(168,85,247,0.35); background: rgba(168,85,247,0.14); }

    /* Forms */
    .formrow{ display:flex; gap: 10px; flex-wrap: wrap; }
    .field{
      flex:1;
      min-width: 210px;
      display:flex;
      flex-direction: column;
      gap: 6px;
    }
    .field label{ font-size: 12px; color: rgba(255,255,255,0.70); font-weight: 850; }
    .field input, .field select, .field textarea{
      padding: 10px 12px;
      border-radius: 14px;
      border: 1px solid rgba(255,255,255,0.12);
      background: rgba(0,0,0,0.18);
      color: var(--text);
      outline:none;
      font-weight: 750;
      resize: vertical;
    }
    .field input:focus, .field select:focus, .field textarea:focus{
      border-color: rgba(39,194,255,0.55);
      box-shadow: 0 0 0 2px rgba(39,194,255,0.18);
    }
    .field textarea{ min-height: 90px; }
    .field input::placeholder, .field textarea::placeholder{ color: rgba(255,255,255,0.45); }
    .help{ color: var(--muted2); font-size: 12px; font-weight: 750; }
    .field.invalid input, .field.invalid select, .field.invalid textarea{
      border-color: rgba(239,68,68,0.70);
      box-shadow: 0 0 0 2px rgba(239,68,68,0.16);
    }
    .field-error{
      color: rgba(255,176,176,0.95);
      font-size: 12px;
      font-weight: 800;
      margin-top: 2px;
    }

    /* Page switching */
    .pageview{ display:none; }
    .pageview.active{ display:block; }

    /* Toast */
    .toast{
      position: fixed;
      bottom: 18px;
      right: 18px;
      max-width: 380px;
      border-radius: 18px;
      border: 1px solid rgba(255,255,255,0.12);
      background: rgba(0,0,0,0.55);
      padding: 12px 14px;
      color: rgba(255,255,255,0.92);
      box-shadow: var(--shadow);
      display:none;
      z-index: 120; /* FIX: keep toasts above modals */
      pointer-events: none;
    }
    .toast.show{ display:block; }
    .toast .t{ font-weight: 950; }
    .toast .m{ margin-top: 4px; color: rgba(255,255,255,0.70); font-weight: 750; font-size: 12px; }

    /* Mobile */
    .mobilebar{ display:none; position: sticky; top: 0; z-index: 30; margin-bottom: 10px; }
    .mobilebar .topbar{ border-radius: 18px; }
    .hamb{ display:none; }

    @media (max-width: 980px){
      .kpis{ grid-template-columns: repeat(2, 1fr); }
      .grid2{ grid-template-columns: 1fr; }
      .grid3{ grid-template-columns: 1fr; }
      .search{ min-width: 200px; }
    }
    @media (max-width: 840px){
      .sidebar{ display:none; }
      .mobilebar{ display:block; }
      .hamb{ display:inline-flex; }
    }

    /* Drawer (mobile sidebar) */
    .drawer{ display:none; position: fixed; inset: 0; z-index: 60; }
    .drawer.show{ display:block; }
    .drawer .backdrop{ position:absolute; inset:0; background: rgba(0,0,0,0.55); }
    .drawer .panel{
      position:absolute; top: 14px; left: 14px; bottom: 14px;
      width: min(88vw, 320px);
      border-radius: 22px;
      border: 1px solid rgba(255,255,255,0.12);
      background: rgba(10,14,30,0.92);
      box-shadow: var(--shadow);
      overflow:hidden;
      display:flex; flex-direction: column;
      overscroll-behavior-y: contain;
    }
    .drawer .nav{
      padding: 10px;
      overscroll-behavior-y: contain;
    }
    .drawer .brandbar{ background: rgba(0,0,0,0.20); }

    /* Phone-first admin polish */
    @media (max-width: 760px){
      html, body{
        height:auto;
        min-height:100%;
        overflow:auto;
        overscroll-behavior-y:auto;
        overflow-x:clip;
      }
      body{
        background-attachment: fixed;
      }
      .shell{
        height:auto;
        min-height:100vh;
        overflow:visible;
        display:block;
      }
      .main{
        width:100%;
        min-width:0;
        height:auto;
        min-height:100vh;
        overflow:visible;
        padding:12px;
      }
      .wrap, .pageview, .card, .head, .body, .topbar{
        width:100%;
        max-width:100%;
        min-width:0;
      }
      .pageview:not(.active){
        display:none !important;
      }
      .mobilebar{
        position:sticky;
        top:8px;
        z-index:40;
      }
      .topbar, .head{
        flex-direction:column;
        align-items:stretch;
        gap:10px;
      }
      .topbar > *, .head > *{
        min-width:0;
      }
      .head > div:last-child, .top-actions, .actions{
        display:grid !important;
        grid-template-columns:1fr;
        width:100%;
        gap:8px !important;
      }
      .btn, button.btn, select.btn, input.btn{
        width:100%;
        min-height:44px;
        justify-content:center;
      }
      .card{
        border-radius:18px;
      }
      .body{
        padding:12px;
      }
      .kpis, .grid2, .grid3, .usage-summary, .usage-alerts{
        grid-template-columns:1fr !important;
      }
      .formrow{
        display:grid;
        grid-template-columns:1fr;
        gap:10px;
      }
      .field{
        min-width:0 !important;
        max-width:none !important;
        width:100%;
      }
      .field input, .field select, .field textarea, input, select, textarea{
        font-size:16px;
        min-height:44px;
      }
      .table-scroll{
        margin-left:-4px;
        margin-right:-4px;
        padding-left:4px;
        padding-right:4px;
      }
      .table{
        min-width:720px;
      }
      .toast{
        left:12px;
        right:12px;
        bottom:12px;
        max-width:none;
      }
      .settings-quick-save{
        left:12px; right:12px; bottom:12px; width:calc(100% - 24px) !important;
      }
      .lock{
        align-items:flex-start;
        padding:12px;
      }
      .lockcard{
        width:100%;
        margin-top:8px;
      }
      .lockhead{
        align-items:flex-start;
        flex-direction:column;
      }
      .lockactions{
        display:grid;
        grid-template-columns:1fr;
      }
      .modal .panel{
        left:8px;
        right:8px;
        top:8px;
        bottom:8px;
        width:auto;
        max-height:none;
        transform:none;
        border-radius:18px;
      }
      .modal .mhead, .modal .mfoot{
        flex-direction:column;
        align-items:stretch;
      }
    }

    @media (max-width: 420px){
      .main{ padding:10px; }
      .brandtext .tag, .mut, .help{ font-size:11px; }
      .h{ font-size:18px; }
      .kpi .v{ font-size:24px; }
    }

    /* Login overlay */
    .lock{
      position: fixed; inset: 0; z-index: 80;
      display:none; place-items: center; padding: 18px;
      background: radial-gradient(900px 600px at 20% 20%, rgba(39,194,255,0.18), transparent 60%),
                  radial-gradient(900px 600px at 80% 20%, rgba(11,91,211,0.22), transparent 60%),
                  linear-gradient(180deg, rgba(0,0,0,0.80), rgba(0,0,0,0.75));
      backdrop-filter: blur(10px);
      overflow:auto;
      overscroll-behavior-y: contain;
    }
    .lock.show{ display:grid; }
    .lockcard{
      width: min(560px, 100%);
      border-radius: 22px;
      border: 1px solid rgba(255,255,255,0.12);
      background: rgba(255,255,255,0.06);
      box-shadow: var(--shadow);
      overflow:hidden;
    }
    .lockhead{
      padding: 16px;
      border-bottom: 1px solid rgba(255,255,255,0.12);
      display:flex; align-items:center; justify-content: space-between; gap: 10px;
      background: rgba(0,0,0,0.18);
    }
    .lockbody{ padding: 16px; }
    .locktitle{ font-weight: 1000; }
    .locksub{ margin-top: 4px; color: var(--muted); font-weight: 750; font-size: 12px; }
    .lockgrid{ display:grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
    .lockgrid .field{ min-width: 0; }
    .lockactions{ display:flex; gap: 10px; margin-top: 12px; justify-content: flex-end; flex-wrap: wrap; }
    .locknote{ margin-top: 10px; color: rgba(255,255,255,0.55); font-weight: 750; font-size: 12px; line-height: 1.35; }
    @media (max-width: 520px){
      .lockgrid{ grid-template-columns: 1fr; }
      .lock{ padding:10px; place-items:start center; }
      .lockcard{ margin:10px 0; }
      .lockhead{ align-items:flex-start; }
      .locktitle{ font-size:20px; line-height:1.15; }
    }

    /* Modal (for Create/Edit Branch + Create/Edit Router + Create/Edit Plan) */
    .modal{ display:none; position: fixed; inset:0; z-index: 90; }
    .modal.show{ display:block; }
    .modal .backdrop{ position:absolute; inset:0; background: rgba(0,0,0,0.62); backdrop-filter: blur(6px); }
    .modal .panel{
    position:absolute;
    left: 50%; top: 50%;
    transform: translate(-50%,-50%);
    width: min(980px, calc(100% - 28px));   /* ✅ slightly wider */
    max-height: calc(100vh - 60px);         /* ✅ prevent offscreen */
    border-radius: 22px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(10,14,30,0.92);
    box-shadow: var(--shadow);
    overflow: auto;                         /* ✅ allow scroll instead of cutting */
    overscroll-behavior-y: contain;
  }
    .modal .mhead{
      padding: 14px 16px;
      display:flex; align-items:center; justify-content: space-between; gap: 10px;
      border-bottom: 1px solid rgba(255,255,255,0.12);
      background: rgba(0,0,0,0.18);
    }
    .modal .mhead .h{ font-weight: 1000; }
    .modal .mhead .mut{ font-size: 12px; color: var(--muted); font-weight: 750; }
    .modal .mbody{ padding: 16px; }
    .modal .mfoot{
      padding: 14px 16px;
      border-top: 1px solid rgba(255,255,255,0.12);
      background: rgba(0,0,0,0.18);
      display:flex; align-items:center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    }
    .split2{
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 12px;
    }

    .split3{
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      gap: 12px;
    }

    .split4{
      display: grid;
      grid-template-columns: repeat(4, minmax(180px, 1fr));
      gap: 12px;
    }

    @media (max-width: 980px){
      .split4{ grid-template-columns: repeat(2, minmax(180px, 1fr)); }
    }

    @media (max-width: 760px){
      .split2, .split3, .split4{ grid-template-columns: 1fr; }
    }

    /* tiny status pill for API mode */
    .modepill{
      display:inline-flex;
      align-items:center;
      gap: 8px;
      padding: 7px 10px;
      border-radius: 999px;
      border: 1px solid rgba(255,255,255,0.12);
      background: rgba(0,0,0,0.16);
      font-weight: 900;
      font-size: 12px;
      color: rgba(255,255,255,0.85);
      white-space: nowrap;
    }
    #ownerTenantSwitch{
      border-color: rgba(39,194,255,0.40);
      background: rgba(39,194,255,0.14);
      min-width: 156px;
      max-width: 220px;
      padding: 8px 10px;
      font-size: 12px;
      font-weight: 800;
    }
    #ownerTenantSwitch option{
      color: #0f172a;
      background: #ffffff;
    }
    .global-owner-return{
      border-color: rgba(34,197,94,0.42);
      background: rgba(34,197,94,0.13);
    }

    /* Chrome/Linux: force visible text in native dropdown list */
    select option{
      color: #0f172a;
      background: #ffffff;
    }

    /*
      Presentation refinements. These rules intentionally sit above the UI
      implementation rather than changing its markup or scripts: navigation,
      forms, tables and operational actions retain their existing behaviour.
    */
    html{
      color-scheme: dark;
      scrollbar-color: rgba(135, 206, 255, .42) rgba(255,255,255,.045);
    }
    ::selection{
      color:#fff;
      background:rgba(39,194,255,.42);
    }
    .sidecard,
    .topbar,
    .card,
    .drawer .panel,
    .lockcard,
    .modal .panel{
      box-shadow:0 16px 42px rgba(0,0,0,.30);
    }
    .topbar{
      position:relative;
      overflow:hidden;
      background:linear-gradient(125deg, rgba(18,31,58,.88), rgba(10,18,38,.76));
    }
    .topbar::after{
      content:"";
      position:absolute;
      inset:0;
      pointer-events:none;
      background:linear-gradient(90deg, rgba(39,194,255,.10), transparent 38%);
    }
    .topbar > *{ position:relative; z-index:1; }
    .card{
      background:linear-gradient(155deg, rgba(255,255,255,.075), rgba(255,255,255,.045));
    }
    .card .head{
      background:linear-gradient(90deg, rgba(7,14,30,.46), rgba(7,14,30,.22));
    }
    .card .head .h{
      font-size:14px;
    }
    .nav a{
      position:relative;
      font-weight:780;
    }
    .nav a::before{
      content:"";
      position:absolute;
      left:0;
      top:10px;
      bottom:10px;
      width:3px;
      border-radius:999px;
      background:transparent;
      transition:background 180ms ease;
    }
    .nav a.active{
      background:linear-gradient(90deg, rgba(11,91,211,.28), rgba(39,194,255,.09));
      box-shadow:inset 0 1px rgba(255,255,255,.07);
    }
    .nav a.active::before{ background:var(--brand2); }
    .nav .section{
      font-weight:900;
      letter-spacing:.16em;
    }
    .btn.primary{
      box-shadow:0 8px 20px rgba(11,91,211,.20);
    }
    .field input,
    .field select,
    .field textarea,
    .search{
      transition:border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
    }
    .field input:hover,
    .field select:hover,
    .field textarea:hover,
    .search:hover{
      border-color:rgba(156,221,255,.32);
    }
    .table th{
      background:rgba(4,10,23,.48);
    }
    .table tbody tr:nth-child(even) td{
      background:rgba(255,255,255,.018);
    }
    .table tbody tr:hover td{
      background:rgba(39,194,255,.075);
    }
    .nav a:focus-visible,
    .pill:focus-visible,
    .field input:focus-visible,
    .field select:focus-visible,
    .field textarea:focus-visible,
    .search:focus-within{
      outline:2px solid rgba(115,214,255,.86);
      outline-offset:2px;
    }

    /*
      Mobile admin sessions often run inside lower-power WebViews. Blurred
      fixed layers force repaints during a fast flick, so touch layouts use
      opaque surfaces and the same colour hierarchy with substantially less
      compositing work. This also keeps memory use steady on long tables.
    */
    @media (hover: none), (pointer: coarse){
      .bg,
      .orb,
      .grid{
        display:none;
      }
      body{
        background:#070d1c;
        background-attachment:scroll;
      }
      .topbar,
      .card,
      .drawer .panel,
      .lockcard,
      .modal .panel{
        -webkit-backdrop-filter:none;
        backdrop-filter:none;
      }
      .topbar{
        background:linear-gradient(125deg, #14284b, #0b1832);
      }
      .card,
      .drawer .panel,
      .lockcard,
      .modal .panel{
        background:#101b31;
      }
      .lock,
      .modal .backdrop{
        -webkit-backdrop-filter:none;
        backdrop-filter:none;
      }
      .nav a,
      .pill,
      .btn,
      .table tbody tr,
      .field input,
      .field select,
      .field textarea{
        transition:background-color 140ms ease, border-color 140ms ease, color 140ms ease;
      }
      .nav a:hover,
      .pill:hover,
      .btn:hover{
        transform:none;
      }
    }
    @media (max-width:760px){
      body{ background-attachment:scroll; }
    }
    @media (prefers-reduced-motion: reduce){
      *, *::before, *::after{
        animation-duration:.01ms !important;
        animation-iteration-count:1 !important;
        scroll-behavior:auto !important;
        transition-duration:.01ms !important;
      }
    }
  