
  :root{
    --bg: #0A1615;
    --surface: #0F1E1C;
    --surface-raised: #142B28;
    --border: rgba(94,234,212,0.14);
    --border-strong: rgba(94,234,212,0.28);
    --teal: #0EA5A4;
    --teal-bright: #5EEAD4;
    --text: #EAF4F2;
    --muted: #7FA39D;
    --muted-dim: #4E6B66;
    --coral: #F4785C;
    --success: #34D399;
    --warn: #F5B942;
    --font-display: 'Space Grotesk', 'Inter', sans-serif;
    --font-body: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  }
  * { box-sizing: border-box; }
  body{
    margin:0;
    background:
      radial-gradient(ellipse 900px 500px at 15% -10%, rgba(14,165,164,0.16), transparent),
      radial-gradient(ellipse 700px 500px at 100% 10%, rgba(94,234,212,0.06), transparent),
      var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    min-height: 100vh;
    padding: 48px 24px 80px;
  }
  .wrap{ max-width: 1080px; margin: 0 auto; }
  header{ margin-bottom: 40px; display:flex; align-items:flex-end; justify-content:space-between; gap: 24px; flex-wrap: wrap; }
  .brand{ display:flex; align-items:center; gap: 14px; }
  .paw{
    width: 40px; height:40px; border-radius: 12px;
    background: linear-gradient(135deg, var(--teal), #0b7877);
    display:flex; align-items:center; justify-content:center;
    box-shadow: 0 0 0 1px var(--border-strong), 0 8px 24px -8px rgba(14,165,164,0.5);
    flex-shrink:0;
  }
  .paw svg{ width:22px; height:22px; }
  h1{ font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
  .tagline{ color: var(--muted); font-size: 13px; margin-top: 2px; letter-spacing: 0.01em; }
  .env-tag{
    font-family: var(--font-mono); font-size: 11px; color: var(--teal-bright);
    background: rgba(14,165,164,0.1); border: 1px solid var(--border);
    padding: 6px 12px; border-radius: 100px; letter-spacing: 0.02em;
  }

  .user-chip{
    display:flex; align-items:center; gap:10px;
    background: rgba(0,0,0,0.25); border:1px solid var(--border);
    border-radius: 100px; padding: 5px 14px 5px 5px;
  }
  .user-chip img{ width:26px; height:26px; border-radius:50%; }
  .user-chip .email{ font-size:12.5px; color: var(--muted); }
  .user-chip button{
    background:none; border:none; color: var(--muted-dim); font-size:11px;
    cursor:pointer; font-family: var(--font-mono); padding: 0; margin-left: 4px;
  }
  .user-chip button:hover{ color: var(--coral); }

  /* Gate screen */
  .gate{
    max-width: 420px; margin: 14vh auto 0; text-align:center;
  }
  .gate .paw{ width:64px; height:64px; margin: 0 auto 22px; border-radius:18px; }
  .gate .paw svg{ width:34px; height:34px; }
  .gate h2{ font-family: var(--font-display); font-size:21px; margin: 0 0 8px; }
  .gate p{ color: var(--muted); font-size:13.5px; line-height:1.6; margin: 0 0 28px; }
  .gsi-btn{
    display:inline-flex; align-items:center; gap:10px;
    background: var(--text); color:#0A1615; border:none;
    font-family: var(--font-body); font-weight:600; font-size:14px;
    padding: 12px 22px; border-radius: 10px; cursor:pointer;
  }
  .gsi-btn:hover{ background: var(--teal-bright); }
  .gate-error{
    margin-top:20px; padding: 12px 16px; border-radius:10px;
    background: rgba(244,120,92,0.1); border:1px solid rgba(244,120,92,0.3);
    color: var(--coral); font-size: 12.5px; display:none;
  }

  .grid{ display:grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; display:none; }
  /* min-width:0 lets cards shrink below their content width - without it, one
     long unbreakable string (e.g. a Firestore index URL in an error) blows the
     whole column out and squeezes the other card. */
  .grid > .card{ min-width: 0; }
  @media (max-width: 860px){ .grid{ grid-template-columns: 1fr; } }

  .card{ background: linear-gradient(180deg, var(--surface-raised), var(--surface)); border: 1px solid var(--border); border-radius: 18px; padding: 28px; }
  .card h2{ font-family: var(--font-display); font-size: 15px; font-weight: 600; margin: 0 0 20px; display:flex; align-items:center; gap: 8px; color: var(--text); }
  .card h2 .dot{ width:6px; height:6px; border-radius:50%; background: var(--teal-bright); }
  .card h2 .spacer{ flex:1; }

  label{ display:block; font-size: 12px; font-weight: 500; color: var(--muted); margin: 18px 0 7px; letter-spacing: 0.02em; }
  label:first-of-type{ margin-top:0; }

  .segmented{ display:flex; background: rgba(0,0,0,0.25); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; }
  .segmented button{ flex:1; background: transparent; border: none; color: var(--muted); font-family: var(--font-body); font-size: 13px; font-weight: 500; padding: 9px 12px; border-radius: 7px; cursor: pointer; transition: all .15s ease; }
  .segmented button.active{ background: var(--teal); color: #04211f; font-weight: 600; }
  .segmented button:not(.active):hover{ color: var(--text); }

  input[type=text], input[type=datetime-local], textarea, select{
    width: 100%; background: rgba(0,0,0,0.28); border: 1px solid var(--border); border-radius: 10px;
    color: var(--text); font-family: var(--font-body); font-size: 14px; padding: 11px 13px; outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
  }
  input[type=text]:focus, input[type=datetime-local]:focus, textarea:focus, select:focus{ border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14,165,164,0.15); }
  input[type=text]::placeholder, textarea::placeholder{ color: var(--muted-dim); }
  input[type=datetime-local]{ font-family: var(--font-mono); font-size: 13px; color-scheme: dark; }
  #uidField, #inspectUidField{ font-family: var(--font-mono); font-size: 13px; }
  textarea{ resize: vertical; min-height: 72px; font-family: var(--font-body); line-height:1.5; }
  select{ appearance: none; cursor:pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%237FA39D'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px;
  }

  .field-row{ display:flex; gap: 10px; }
  .field-row input{ flex:1; }
  .field-row select{ flex:1; }
  .icon-btn{ background: rgba(94,234,212,0.08); border: 1px solid var(--border); color: var(--teal-bright); border-radius: 10px; padding: 0 14px; font-size: 12px; font-family: var(--font-mono); cursor: pointer; white-space: nowrap; }
  .icon-btn:hover{ background: rgba(94,234,212,0.16); }

  .adv-toggle{ margin-top: 18px; font-size: 12px; color: var(--muted); cursor: pointer; display:flex; align-items:center; gap:6px; user-select:none; }
  .adv-toggle:hover{ color: var(--teal-bright); }
  .adv-toggle svg{ transition: transform .15s ease; width:10px; height:10px; }
  .adv-toggle.open svg{ transform: rotate(90deg); }
  .adv-body{ display:none; margin-top: 10px; }
  .adv-body.open{ display:block; }

  .kv-row{ display:flex; gap: 8px; margin-bottom: 8px; }
  .kv-row input{ flex:1; font-family: var(--font-mono); font-size:12.5px; }
  .kv-remove{ background:none; border:none; color: var(--muted-dim); cursor:pointer; font-size: 16px; width:32px; }
  .kv-remove:hover{ color: var(--coral); }
  .add-kv{ background:none; border: 1px dashed var(--border-strong); color: var(--muted); font-size: 12px; padding: 7px 12px; border-radius: 8px; cursor:pointer; width:100%; margin-top:2px; }
  .add-kv:hover{ color: var(--teal-bright); border-color: var(--teal); }

  .send-row{ display:flex; align-items:center; gap: 14px; margin-top: 26px; }
  button.send{
    flex:1; background: linear-gradient(135deg, var(--teal-bright), var(--teal)); color: #04211f; border: none;
    font-family: var(--font-display); font-weight: 600; font-size: 14px; letter-spacing: 0.01em;
    padding: 13px 20px; border-radius: 11px; cursor: pointer; transition: transform .1s ease, box-shadow .15s ease;
    box-shadow: 0 8px 20px -8px rgba(14,165,164,0.6);
  }
  button.send:hover{ transform: translateY(-1px); box-shadow: 0 10px 24px -8px rgba(14,165,164,0.75); }
  button.send:active{ transform: translateY(0); }
  button.send:disabled{ opacity:0.55; cursor:default; transform:none; box-shadow:none; }

  .pulse{ width: 9px; height:9px; border-radius:50%; background: var(--muted-dim); flex-shrink:0; }
  .pulse.active{ background: var(--teal-bright); animation: beat 0.9s ease-in-out infinite; }
  @keyframes beat{ 0%,100%{ box-shadow: 0 0 0 0 rgba(94,234,212,0.5); } 50%{ box-shadow: 0 0 0 6px rgba(94,234,212,0); } }

  .log-list{ display:flex; flex-direction:column; gap:10px; max-height: 560px; overflow-y:auto; padding-right:4px; }
  .log-list::-webkit-scrollbar{ width:6px; }
  .log-list::-webkit-scrollbar-thumb{ background: var(--border-strong); border-radius:10px; }
  .log-empty{ color: var(--muted-dim); font-size: 13px; padding: 30px 0; text-align:center; }
  .entry{ border: 1px solid var(--border); background: rgba(0,0,0,0.2); border-radius: 12px; padding: 13px 14px; font-size: 13px; }
  .entry-top{ display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:6px; }
  .entry-status{ display:flex; align-items:center; gap:7px; font-family: var(--font-mono); font-size:11px; font-weight:500; }
  .entry-status .sdot{ width:7px; height:7px; border-radius:50%; }
  .sdot.ok{ background: var(--success); }
  .sdot.fail{ background: var(--coral); }
  .sdot.partial{ background: var(--warn); }
  .sdot.pending{ background: var(--warn); }
  .sdot.cancelled{ background: var(--muted-dim); }
  .sdot.skipped{ background: var(--muted-dim); }
  .chk-row{ display:flex; align-items:center; gap:8px; margin-top:10px; cursor:pointer; font-size:13px; }
  .chk-row input{ accent-color: var(--teal, #0EA5A4); width:15px; height:15px; cursor:pointer; }
  .entry-time{ color: var(--muted-dim); font-family: var(--font-mono); font-size: 11px; }
  .entry-title{ font-weight:600; margin-bottom:2px; overflow-wrap: anywhere; }
  .entry-meta{ color: var(--muted); font-family: var(--font-mono); font-size: 11.5px; word-break: break-all; }
  .entry-err{ color: var(--coral); font-size: 12px; margin-top: 6px; overflow-wrap: anywhere; word-break: break-word; line-height: 1.5; }
  .entry-err a{
    display:inline-block; margin-top: 6px; color: var(--teal-bright);
    background: rgba(94,234,212,0.08); border: 1px solid var(--border);
    border-radius: 7px; padding: 4px 10px; font-family: var(--font-mono);
    font-size: 11px; text-decoration: none;
  }
  .entry-err a:hover{ background: rgba(94,234,212,0.16); }
  .hint{ font-size: 11.5px; color: var(--muted-dim); margin-top: 6px; line-height:1.5; }

  /* ── Scheduled queue ── */
  .cancel-btn{
    background:none; border:1px solid rgba(244,120,92,0.35); color: var(--coral);
    font-family: var(--font-mono); font-size: 10.5px; padding: 4px 10px;
    border-radius: 7px; cursor:pointer; margin-top: 8px;
  }
  .cancel-btn:hover{ background: rgba(244,120,92,0.12); }
  .refresh-btn{
    background:none; border:none; color: var(--muted); font-family: var(--font-mono);
    font-size: 11px; cursor:pointer; padding: 2px 4px;
  }
  .refresh-btn:hover{ color: var(--teal-bright); }

  /* ── Inspect: device cards + topic chips ── */
  .device-card{ border:1px solid var(--border); background: rgba(0,0,0,0.2); border-radius: 12px; padding: 14px; margin-top: 12px; }
  .device-head{ display:flex; align-items:center; justify-content:space-between; gap: 10px; margin-bottom: 8px; }
  .platform-pill{
    font-family: var(--font-mono); font-size: 11px; font-weight: 500;
    padding: 3px 10px; border-radius: 100px;
    background: rgba(94,234,212,0.1); border: 1px solid var(--border); color: var(--teal-bright);
    text-transform: uppercase; letter-spacing: 0.05em;
  }
  .validity{ font-family: var(--font-mono); font-size: 11px; display:flex; align-items:center; gap: 6px; }
  .validity .sdot{ width:7px; height:7px; border-radius:50%; }
  .device-meta{ color: var(--muted-dim); font-family: var(--font-mono); font-size: 11px; margin-bottom: 10px; word-break: break-all; line-height: 1.7; }
  .chips{ display:flex; flex-wrap: wrap; gap: 6px; }
  .chip{
    font-family: var(--font-mono); font-size: 11px; color: var(--text);
    background: rgba(14,165,164,0.14); border: 1px solid var(--border);
    padding: 4px 10px; border-radius: 100px;
  }
  .chips-empty{ color: var(--muted-dim); font-size: 12px; font-style: italic; }

  /* ── Top-level tab switcher (Push / Partners) ─────────────────────────── */
  .top-tabs{ display:none; gap:8px; margin: 0 0 24px; }
  .top-tabs button{
    background: rgba(0,0,0,0.25); border:1px solid var(--border); color: var(--muted);
    font-family: var(--font-body); font-weight:600; font-size:13px; padding:10px 18px;
    border-radius:10px; cursor:pointer; transition: all .15s ease;
  }
  .top-tabs button.active{ background: var(--teal); border-color: var(--teal); color:#04211f; }
  .top-tabs button:not(.active):hover{ color: var(--text); border-color: var(--border-strong); }

  /* ── Partners grid: wide table card + narrower side card ──────────────── */
  .partners-grid{ display:none; grid-template-columns: 1.6fr 1fr; gap: 24px; align-items: start; }
  @media (max-width: 980px){ .partners-grid{ grid-template-columns: 1fr; } }

  table.p-table{ width:100%; border-collapse: collapse; font-size: 13px; }
  table.p-table th{
    text-align:left; color: var(--muted); font-weight:500; font-size: 11px;
    letter-spacing:0.02em; text-transform:uppercase; padding: 8px 10px;
    border-bottom: 1px solid var(--border);
  }
  table.p-table td{ padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
  table.p-table tr:last-child td{ border-bottom:none; }
  table.p-table tr:hover td{ background: rgba(94,234,212,0.03); }
  .p-name{ font-weight:600; color: var(--text); }
  .p-sub{ color: var(--muted-dim); font-size:11.5px; font-family: var(--font-mono); }
  .p-owed{ font-family: var(--font-mono); font-weight:600; }
  .p-owed.has-balance{ color: var(--warn); }
  .p-owed.zero{ color: var(--muted-dim); }
  .p-status{
    font-family: var(--font-mono); font-size:10.5px; padding:3px 8px; border-radius:6px;
    border:1px solid var(--border); color: var(--muted);
  }
  .p-status.active{ color: var(--success); border-color: rgba(52,211,153,0.3); }
  .p-status.disabled{ color: var(--coral); border-color: rgba(244,120,92,0.3); }
  .p-actions{ display:flex; gap:6px; flex-wrap:wrap; }
  .p-actions button{
    background: rgba(94,234,212,0.08); border: 1px solid var(--border); color: var(--teal-bright);
    border-radius: 7px; padding: 5px 10px; font-size: 11px; font-family: var(--font-mono); cursor:pointer;
  }
  .p-actions button:hover{ border-color: var(--teal); }
  .p-actions button.danger{ color: var(--coral); }

  .form-row-2{ display:grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .form-actions{ display:flex; gap:10px; margin-top: 22px; }
  .form-actions .primary{
    flex:1; background: linear-gradient(135deg, var(--teal-bright), var(--teal)); color:#04211f;
    border:none; font-family: var(--font-display); font-weight:600; font-size:13.5px;
    padding: 12px; border-radius: 10px; cursor:pointer;
  }
  .form-actions .secondary{
    background:none; border:1px solid var(--border); color: var(--muted); font-size:13px;
    padding: 12px 18px; border-radius:10px; cursor:pointer;
  }
  .form-err{ color: var(--coral); font-size:12.5px; margin-top:12px; display:none; }
  .form-ok{ color: var(--success); font-size:12.5px; margin-top:12px; display:none; }

  .drawer{
    border:1px solid var(--border); background: rgba(0,0,0,0.2); border-radius: 12px;
    padding: 14px; margin-top: 14px;
  }
  .drawer-title{ font-family: var(--font-mono); font-size:11.5px; color: var(--teal-bright); margin-bottom:10px; display:flex; align-items:center; justify-content:space-between; }
  .drawer-close{ background:none; border:none; color: var(--muted-dim); cursor:pointer; font-size:14px; }
  .ledger-row, .payout-row{
    display:flex; justify-content:space-between; gap:10px; padding:8px 0;
    border-bottom:1px solid var(--border); font-size:12px;
  }
  .ledger-row:last-child, .payout-row:last-child{ border-bottom:none; }
  .load-more{
    width:100%; margin-top:10px; background:none; border:1px dashed var(--border-strong);
    color: var(--muted); font-size:12px; padding:8px; border-radius:8px; cursor:pointer;
  }
