:root {
  --bg: #0d1017;
  --bg2: #121620;
  --card: #161b27;
  --card2: #1b2130;
  --line: #262e40;
  --line2: #303a50;
  --text: #e6e9f2;
  --muted: #8b93a7;
  --faint: #5f677b;
  --accent: #7c8cff;
  --accent2: #36c2b4;
  --accent-soft: rgba(124, 140, 255, .14);
  --ok: #3fb68b;
  --ok-soft: rgba(63, 182, 139, .14);
  --warn: #e9a23b;
  --warn-soft: rgba(233, 162, 59, .15);
  --bad: #ef6b6b;
  --bad-soft: rgba(239, 107, 107, .14);
  --info: #4aa8e8;
  --info-soft: rgba(74, 168, 232, .14);
  --shadow: 0 10px 40px rgba(0, 0, 0, .45);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f6fb; --bg2: #eef1f7; --card: #ffffff; --card2: #f7f8fc; --line: #e3e7f0; --line2: #d5dbe8;
    --text: #151a26; --muted: #5d667a; --faint: #8d95a8; --accent: #4f5fe8; --accent-soft: rgba(79, 95, 232, .1);
    --ok: #1f9a6d; --ok-soft: rgba(31, 154, 109, .1); --warn: #c27c0e; --warn-soft: rgba(194, 124, 14, .12);
    --bad: #d64545; --bad-soft: rgba(214, 69, 69, .1); --info: #1f7fc4; --info-soft: rgba(31, 127, 196, .1);
    --shadow: 0 10px 30px rgba(20, 30, 60, .12);
  }
}
:root[data-theme="light"] {
  --bg: #f4f6fb; --bg2: #eef1f7; --card: #ffffff; --card2: #f7f8fc; --line: #e3e7f0; --line2: #d5dbe8;
  --text: #151a26; --muted: #5d667a; --faint: #8d95a8; --accent: #4f5fe8; --accent-soft: rgba(79, 95, 232, .1);
  --ok: #1f9a6d; --ok-soft: rgba(31, 154, 109, .1); --warn: #c27c0e; --warn-soft: rgba(194, 124, 14, .12);
  --bad: #d64545; --bad-soft: rgba(214, 69, 69, .1); --info: #1f7fc4; --info-soft: rgba(31, 127, 196, .1);
  --shadow: 0 10px 30px rgba(20, 30, 60, .12);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; overflow-x: hidden; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); }
.mono { font-family: var(--mono); font-size: 13px; letter-spacing: .01em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 12px; }
.between { justify-content: space-between; }
.hidden { display: none !important; }

/* boot / spinner */
.boot { display: grid; place-items: center; min-height: 100dvh; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* login */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(900px 500px at 20% -10%, rgba(124, 140, 255, .18), transparent 60%),
              radial-gradient(700px 400px at 110% 110%, rgba(54, 194, 180, .14), transparent 60%), var(--bg); }
.login { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 38px; height: 38px; border-radius: 10px; }
.brand b { font-size: 16px; letter-spacing: .01em; }
.brand span { display: block; color: var(--muted); font-size: 12px; margin-top: -2px; }
.login h1 { font-size: 20px; margin: 22px 0 4px; }
.login p { margin: 0 0 18px; color: var(--muted); }

/* layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100dvh; background: var(--bg2); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 20px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px; border: 0; background: none; border-radius: 10px; color: var(--muted); cursor: pointer; text-align: left; font-weight: 500; }
.nav button:hover { background: var(--card); color: var(--text); }
.nav button.on { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 19px; height: 19px; flex: none; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.main { min-width: 0; padding: 26px 32px 60px; max-width: 1280px; width: 100%; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.top h2 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
.top .sub { color: var(--muted); margin-top: 2px; }
.mob-top, .tabs { display: none; }

@media (max-width: 860px) {
  .shell { display: block; }
  .side { display: none; }
  .main { padding: 14px 16px calc(84px + env(safe-area-inset-bottom)); }
  .mob-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--bg2); position: sticky; top: 0; z-index: 20; }
  .tabs { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--bg2); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .tabs button { border: 0; background: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; padding: 6px 0; border-radius: 10px; cursor: pointer; }
  .tabs button.on { color: var(--accent); background: var(--accent-soft); }
  .tabs svg { width: 21px; height: 21px; }
  .top h2 { font-size: 19px; }
}

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card h3 { margin: 0 0 12px; font-size: 14.5px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.two { grid-template-columns: 1.1fr .9fr; }
@media (max-width: 1050px) { .two { grid-template-columns: 1fr; } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px; position: relative; overflow: hidden; cursor: default; }
.stat.click { cursor: pointer; }
.stat.click:hover { border-color: var(--line2); }
.stat .lbl { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 7px; }
.stat .val { font-size: 26px; font-weight: 650; margin-top: 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--accent)); }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line2); background: var(--card2); color: var(--text); cursor: pointer; font-weight: 550; white-space: nowrap; transition: background .12s, border-color .12s, opacity .12s; }
.btn:hover { border-color: var(--faint); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line2)); background: var(--bad-soft); }
.btn.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line2)); background: var(--warn-soft); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--card2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { width: 34px; padding: 0; }
.btn.block { width: 100%; }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 500; min-width: 0; }
.in { width: 100%; height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line2); background: var(--bg2); color: var(--text); outline: none; transition: border-color .12s, box-shadow .12s; }
textarea.in { height: auto; min-height: 70px; padding: 9px 12px; resize: vertical; }
.in:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.in::placeholder { color: var(--faint); }
select.in { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 16px, calc(100% - 12px) 16px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.fgrid { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); }
.fgrid.two-c { grid-template-columns: 1fr 1fr; }
@media (max-width: 620px) { .fgrid, .fgrid.two-c { grid-template-columns: 1fr; } .fgrid.keep3 { grid-template-columns: repeat(3, 1fr); } }
.hint { font-size: 12px; color: var(--faint); font-weight: 400; }
.check { display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; color: var(--text); font-size: 13.5px; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line2); background: none; color: var(--muted); cursor: pointer; font-size: 12.5px; font-weight: 550; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip .n { font-size: 11px; opacity: .8; font-variant-numeric: tabular-nums; }
.search { position: relative; flex: 1; min-width: 180px; max-width: 360px; }
.search svg { position: absolute; left: 11px; top: 11px; width: 16px; height: 16px; color: var(--faint); }
.search .in { padding-left: 34px; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--b, var(--accent-soft)); color: var(--c, var(--accent)); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.s-active { --b: var(--ok-soft); --c: var(--ok); }
.s-unused { --b: var(--info-soft); --c: var(--info); }
.s-grace { --b: var(--warn-soft); --c: var(--warn); }
.s-expired, .s-revoked { --b: var(--bad-soft); --c: var(--bad); }
.s-suspended { --b: var(--warn-soft); --c: var(--warn); }
.on-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.on-dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

/* table */
.table-wrap { overflow-x: auto; margin: 0 -18px -18px; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr { cursor: pointer; transition: background .1s; }
.t tbody tr:hover { background: var(--card2); }
.t .cust b { display: block; font-weight: 600; }
.lcards { display: none; }
@media (max-width: 860px) {
  .lt { display: none; }
  .lcards { display: flex; flex-direction: column; gap: 10px; }
}
.lcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 10px; }
.lcard .meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }

/* usage bars */
.use { display: flex; flex-direction: column; gap: 3px; min-width: 120px; }
.use .ln { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); gap: 8px; }
.use .ln b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.bar { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.bar i.w { background: var(--warn); }
.bar i.x { background: var(--bad); }
.uses { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* lists */
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.li:last-child { border-bottom: 0; }
.li .ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.li .ic svg { width: 16px; height: 16px; }
.li .ic.ok { background: var(--ok-soft); color: var(--ok); }
.li .ic.warn { background: var(--warn-soft); color: var(--warn); }
.li .ic.bad { background: var(--bad-soft); color: var(--bad); }
.li .tx { min-width: 0; flex: 1; }
.li .tx div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--faint); padding: 26px 10px; }
.empty svg { width: 34px; height: 34px; display: block; margin: 0 auto 8px; opacity: .6; }

/* drawer / modal */
.ov { position: fixed; inset: 0; background: rgba(5, 8, 15, .58); backdrop-filter: blur(3px); z-index: 50; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: var(--bg); border-left: 1px solid var(--line); z-index: 60; display: flex; flex-direction: column; animation: slide .2s ease; box-shadow: var(--shadow); }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.dh { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.dh h3 { margin: 0; font-size: 18px; word-break: break-word; }
.db { padding: 18px 20px 40px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.modal { position: fixed; z-index: 60; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); animation: pop .16s ease; }
@keyframes pop { from { transform: translate(-50%, -48%) scale(.98); opacity: 0; } }
.mh { padding: 18px 20px 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mh h3 { margin: 0; font-size: 17px; }
.mb { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.mf { padding: 0 20px 18px; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.kv > div { background: var(--card); padding: 11px 13px; min-width: 0; }
.kv .k { font-size: 11.5px; color: var(--faint); font-weight: 500; }
.kv .v { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 480px) { .kv { grid-template-columns: 1fr; } }
.keybox { display: flex; align-items: center; gap: 8px; background: var(--bg2); border: 1px dashed var(--line2); border-radius: 12px; padding: 10px 10px 10px 14px; }
.keybox .mono { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.code { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; position: relative; }
.alert { border-radius: 12px; padding: 11px 13px; display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert b { color: inherit; }
.sect { font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; margin: 6px 0 -4px; }
.tl { display: flex; flex-direction: column; }
.tl .e { display: grid; grid-template-columns: 14px 1fr; gap: 10px; padding: 7px 0; }
.tl .e i { width: 8px; height: 8px; border-radius: 50%; background: var(--line2); margin: 6px 0 0 3px; }
.tl .e i.ok { background: var(--ok); } .tl .e i.warn { background: var(--warn); } .tl .e i.bad { background: var(--bad); } .tl .e i.acc { background: var(--accent); }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; color: var(--muted); height: 30px; padding: 0 11px; border-radius: 7px; cursor: pointer; font-weight: 550; font-size: 12.5px; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.qr { background: #fff; padding: 10px; border-radius: 12px; width: fit-content; }
.qr img { display: block; width: 180px; height: 180px; image-rendering: pixelated; }
.drop { border: 1.5px dashed var(--line2); border-radius: 14px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .12s, background .12s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop svg { width: 28px; height: 28px; display: block; margin: 0 auto 6px; color: var(--accent); }
.prog { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--accent); transition: width .15s; }
details.cl summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
details.cl ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; }

/* toasts */
#toasts { position: fixed; z-index: 100; top: 14px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100% - 24px)); pointer-events: none; }
.toast { pointer-events: auto; background: var(--card); border: 1px solid var(--line2); border-left: 4px solid var(--accent); border-radius: 12px; padding: 11px 14px; box-shadow: var(--shadow); animation: pop2 .18s ease; font-size: 13.5px; }
.toast.ok { border-left-color: var(--ok); } .toast.bad { border-left-color: var(--bad); }
@keyframes pop2 { from { transform: translateY(-6px); opacity: 0; } }
