  :root {
    --bg: #0a0a0c;
    --bg2: #111116;
    --bg3: #18181f;
    --bg4: #1f1f28;
    --border: rgba(255,255,255,0.07);
    --border2: rgba(255,255,255,0.12);
    --text: #f0eff5;
    --muted: #6b6a7a;
    --muted2: #9998aa;
    --accent: #7c6af7;
    --accent2: #5e4ee0;
    --accent-glow: rgba(124,106,247,0.15);
    --green: #3ecf8e;
    --green-glow: rgba(62,207,142,0.15);
    --amber: #f5a623;
    --red: #f56565;
    --radius: 10px;
    --radius-lg: 16px;
    --sel-color: #3ecf8e;
    --sel-glow: rgba(62,207,142,0.18);
    --amber-glow: rgba(245,166,35,0.15);
    --red-glow: rgba(245,101,101,0.15);
  }

  * { box-sizing: border-box; }
  html, body { margin:0; padding:0; }
  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
  }
  ::selection { background: var(--sel-glow); color: var(--text); }

  h1,h2,h3, .brand, .nav-item, .stat-label { font-family: 'Space Grotesk', 'Inter', sans-serif; }
  .mono { font-family: 'JetBrains Mono', monospace; }

  a { color: var(--accent); }

  /* ---------- layout ---------- */
  .app-shell { display:flex; min-height:100vh; }

  .sidebar {
    width: 232px;
    flex-shrink: 0;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    padding: 22px 14px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    position: sticky;
    top: 0;
    height: 100vh;
  }
  .brand {
    display:flex; align-items:center; gap:10px;
    padding: 4px 8px 12px 8px;
    border-bottom: 1px solid var(--border);
  }
  .brand-mark {
    width: 28px; height: 28px; border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    box-shadow: 0 4px 14px var(--accent-glow);
    display:flex; align-items:center; justify-content:center;
    font-weight:700; font-size:13px; color:#fff; letter-spacing:-0.5px;
  }
  .brand-text { display:flex; flex-direction:column; line-height:1.15; }
  .brand-text b { font-size: 14px; font-weight:600; }
  .brand-text span { font-size: 11px; color: var(--muted); font-family:'Inter'; }

  .nav-group { display:flex; flex-direction:column; gap:3px; flex:1; }
  .nav-item {
    display:flex; align-items:center; gap:10px;
    padding: 10px 12px; border-radius: var(--radius);
    color: var(--muted2); font-size: 13.5px; font-weight: 500;
    cursor:pointer; user-select:none;
    border: 1px solid transparent;
    transition: background .15s ease, color .15s ease;
  }
  .nav-item svg { width:16px; height:16px; flex-shrink:0; opacity:.85; }
  .nav-item:hover { background: var(--bg3); color: var(--text); }
  .nav-item.active {
    background: var(--bg4); color: var(--text);
    border-color: var(--border2);
  }
  .nav-item.active svg { opacity:1; color: var(--accent); }

  .conn-pill {
    display:flex; align-items:center; gap:8px;
    padding: 9px 12px; border-radius: var(--radius);
    background: var(--bg3); border: 1px solid var(--border);
    font-size: 12px; color: var(--muted2); font-family:'Inter';
  }
  .dot { width:7px; height:7px; border-radius:50%; flex-shrink:0; }
  .dot.on { background: var(--green); box-shadow:0 0 8px var(--green-glow); }
  .dot.off { background: var(--red); box-shadow:0 0 8px var(--red-glow); }

  .main {
    flex: 1; min-width: 0;
    padding: 40px 44px 80px;
    max-width: 880px;
    margin: 0 auto;
    width: 100%;
  }
  .page-head { margin-bottom: 26px; }
  .page-head h1 { font-size: 21px; font-weight: 600; margin: 0 0 6px; letter-spacing:-0.3px; }
  .page-head p { margin:0; color: var(--muted); font-size: 13.5px; line-height:1.5; }

  .banner {
    display:none;
    align-items:center; gap:10px;
    background: var(--amber-glow); border: 1px solid rgba(245,166,35,0.35);
    color: #f5c877; padding: 12px 16px; border-radius: var(--radius);
    font-size: 13px; margin-bottom: 22px;
  }
  .banner.show { display:flex; }
  .banner a { color: #f5c877; text-decoration: underline; font-weight:600; }

  .card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
  }
  .card + .card { margin-top: 20px; }
  .card h3 {
    font-size: 13.5px; font-weight: 600; margin: 0 0 4px;
    display:flex; align-items:center; gap:8px;
  }
  .card .hint { font-size: 12.5px; color: var(--muted); margin: 0 0 16px; line-height:1.5; }

  label {
    display:block; font-size: 12px; font-weight: 500; color: var(--muted2);
    margin-bottom: 6px; letter-spacing: 0.2px;
  }
  .field { margin-bottom: 16px; }
  .row { display:flex; gap: 14px; }
  .row > .field { flex: 1; }

  input[type=text], input[type=email], input[type=number], input[type=password], textarea {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 13.5px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
  }
  textarea { resize: vertical; min-height: 84px; font-family:'JetBrains Mono', monospace; font-size:12.5px; line-height:1.6; }
  input::placeholder, textarea::placeholder { color: var(--muted); }
  input:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
  }
  .pw-wrap { position:relative; }
  .pw-wrap input { padding-right: 40px; }
  .pw-toggle {
    position:absolute; right:8px; top:50%; transform:translateY(-50%);
    background:none; border:none; color: var(--muted); cursor:pointer;
    font-size: 11px; padding:4px 6px; font-family:'Inter';
  }
  .pw-toggle:hover { color: var(--text); }

  button { font-family:'Inter', sans-serif; cursor:pointer; border:none; }
  .btn {
    display:inline-flex; align-items:center; justify-content:center; gap:7px;
    padding: 10px 18px; border-radius: var(--radius);
    font-size: 13px; font-weight: 600; letter-spacing:0.1px;
    transition: transform .1s ease, box-shadow .15s ease, opacity .15s ease;
  }
  .btn:active { transform: scale(0.98); }
  .btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    box-shadow: 0 0 0 1px var(--border2), 0 8px 20px var(--accent-glow);
  }
  .btn-primary:hover { box-shadow: 0 0 0 1px var(--border2), 0 8px 26px var(--accent-glow); }
  .btn-primary:disabled { opacity:.45; cursor:not-allowed; box-shadow:none; }
  .btn-ghost {
    background: var(--bg3); border: 1px solid var(--border2); color: var(--text);
  }
  .btn-ghost:hover { background: var(--bg4); }
  .btn-danger { background: var(--red-glow); border:1px solid rgba(245,101,101,0.4); color:#ffb1b1; }
  .btn-danger:hover { background: rgba(245,101,101,0.22); }
  .btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
  .btn svg { width:14px; height:14px; }

  .btn-row { display:flex; gap:10px; flex-wrap:wrap; margin-top: 4px; }

  /* ---------- key chip (signature element) ---------- */
  .key-chip {
    display:inline-flex; align-items:center; gap:10px;
    font-family:'JetBrains Mono', monospace;
    font-size: 13px; font-weight: 500; letter-spacing: 0.4px;
    background: linear-gradient(180deg, var(--bg4), var(--bg3));
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    padding: 9px 12px 9px 10px;
  }
  .key-chip .dot { flex-shrink:0; }
  .key-chip button { background:none; color: var(--muted2); padding:2px; border-radius:5px; display:flex; }
  .key-chip button:hover { color: var(--text); background: var(--bg2); }
  .key-chip button svg { width:13px; height:13px; }

  .status-badge {
    display:inline-flex; align-items:center; gap:5px;
    font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
    font-family:'Inter';
  }
  .status-badge.new { background: var(--green-glow); color: var(--green); }
  .status-badge.existing { background: var(--amber-glow); color: var(--amber); }
  .status-badge.error, .status-badge.skipped { background: var(--red-glow); color: #ff9d9d; }
  .status-badge.unused { background: var(--green-glow); color: var(--green); }
  .status-badge.used { background: var(--bg4); color: var(--muted2); }
  .status-badge.revoked { background: var(--red-glow); color: #ff9d9d; }
  .status-badge.expired { background: var(--amber-glow); color: var(--amber); }

  .result-box {
    display:none;
    margin-top: 18px; padding-top: 18px;
    border-top: 1px solid var(--border);
  }
  .result-box.show { display:block; }

  /* ---------- table ---------- */
  .table-wrap { overflow-x:auto; border-radius: var(--radius); border:1px solid var(--border); }
  table { width:100%; border-collapse: collapse; font-size: 12.5px; }
  thead th {
    text-align:left; font-weight:600; color: var(--muted2);
    background: var(--bg3); padding: 9px 12px; font-size:11px;
    text-transform: uppercase; letter-spacing: 0.4px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
  }
  tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space:nowrap; }
  tbody tr:last-child td { border-bottom:none; }
  tbody tr:hover { background: var(--bg3); }
  td.email { font-family:'Inter'; color: var(--text); }
  td.mono-cell { font-family:'JetBrains Mono', monospace; font-size:12px; color: var(--muted2); }
  td.note-cell { color: var(--muted); font-size: 12px; white-space:normal; max-width:220px; }

  .empty-state {
    text-align:center; padding: 34px 20px; color: var(--muted);
  }
  .empty-state svg { width:30px; height:30px; margin-bottom:10px; opacity:.5; }
  .empty-state p { margin:0; font-size: 13px; }

  .progress-track {
    height: 6px; border-radius: 999px; background: var(--bg3);
    overflow:hidden; margin-top: 14px; border:1px solid var(--border);
  }
  .progress-fill {
    height:100%; width:0%; background: linear-gradient(90deg, var(--accent), var(--green));
    transition: width .2s ease;
  }
  .progress-label { font-size:11.5px; color: var(--muted); margin-top:6px; font-family:'JetBrains Mono', monospace; }

  .dropzone {
    border: 1.5px dashed var(--border2);
    border-radius: var(--radius);
    padding: 26px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
    background: var(--bg3);
  }
  .dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-glow); }
  .dropzone svg { width:22px; height:22px; color: var(--muted); margin-bottom:8px; }
  .dropzone p { margin:0; font-size:13px; color: var(--muted2); }
  .dropzone span { font-size: 11.5px; color: var(--muted); }
  .file-chip {
    display:none; align-items:center; gap:8px; margin-top:12px;
    background: var(--bg3); border:1px solid var(--border); border-radius: var(--radius);
    padding: 8px 12px; font-size: 12.5px;
  }
  .file-chip.show { display:flex; }
  .file-chip .fname { flex:1; font-family:'JetBrains Mono'; color:var(--text); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .file-chip button { background:none; color:var(--muted); }
  .file-chip button:hover { color: var(--red); }

  .stat-row { display:flex; gap:10px; margin-top:14px; flex-wrap:wrap; }
  .stat-chip {
    background: var(--bg3); border:1px solid var(--border); border-radius: var(--radius);
    padding: 8px 13px; font-size:12px; color: var(--muted2);
  }
  .stat-chip b { color: var(--text); font-family:'JetBrains Mono'; margin-right:4px; }

  .info-note {
    font-size: 12px; color: var(--muted); line-height:1.6;
    background: var(--bg3); border:1px solid var(--border); border-radius: var(--radius);
    padding: 12px 14px; margin-top: 6px;
  }
  .info-note b { color: var(--muted2); }

  /* ---------- toast ---------- */
  #toast-stack {
    position: fixed; bottom: 22px; right: 22px; z-index: 999;
    display:flex; flex-direction:column; gap:8px; align-items:flex-end;
  }
  .toast {
    background: var(--bg4); border:1px solid var(--border2);
    color: var(--text); padding: 11px 16px; border-radius: var(--radius);
    font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    display:flex; align-items:center; gap:9px;
    animation: toast-in .2s ease;
    max-width: 320px;
  }
  .toast.success { border-color: rgba(62,207,142,0.4); }
  .toast.success .dot { background: var(--green); box-shadow:0 0 6px var(--green-glow); }
  .toast.error { border-color: rgba(245,101,101,0.4); }
  .toast.error .dot { background: var(--red); box-shadow:0 0 6px var(--red-glow); }
  @keyframes toast-in { from { opacity:0; transform: translateY(6px);} to {opacity:1; transform:translateY(0);} }

  .page { display:none; }
  .page.active { display:block; animation: fade-in .18s ease; }
  @keyframes fade-in { from{opacity:0; transform:translateY(4px);} to{opacity:1; transform:translateY(0);} }

  /* ---------- mobile ---------- */
  .mobile-topbar { display:none; }

  @media (max-width: 820px) {
    .app-shell { flex-direction: column; }
    .sidebar {
      position: fixed; bottom:0; left:0; right:0; top:auto; height:auto;
      width:100%; flex-direction:row; align-items:center;
      padding: 8px 10px; gap:0; overflow-x:auto;
      border-right:none; border-top:1px solid var(--border);
      z-index: 50;
    }
    .brand, .conn-pill { display:none; }
    .nav-group { flex-direction:row; flex:1; justify-content:space-between; gap:2px; }
    .nav-item { flex-direction:column; font-size:10px; padding:8px 6px; gap:4px; white-space:nowrap; }
    .nav-item span.label { font-size:10px; }
    .mobile-topbar {
      display:flex; align-items:center; justify-content:space-between;
      padding: 14px 18px; border-bottom:1px solid var(--border);
      background: var(--bg2); position:sticky; top:0; z-index:40;
    }
    .main { padding: 22px 18px 100px; }
    .row { flex-direction:column; gap:0; }
    table { font-size: 11.5px; }
  }
