:root {
  --bg: #08090b;
  --panel: #0f1115;
  --panel-2: #14171d;
  --raise: #1a1e26;
  --line: #232833;
  --line-soft: #1a1e26;
  --text: #e8eaef;
  --dim: #9aa2b1;
  --faint: #6b7280;
  --accent: #6c8cff;
  --accent-soft: rgba(108,140,255,.14);
  --good: #3ddc97;
  --warn: #f0b429;
  --bad: #ff5d6c;
  --r: 12px;
  --r-sm: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--dim); font-size: 13px; }
.tiny-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); }
code, pre, .mono { font-family: var(--mono); }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.015em; }

/* ================================================================ brand */

.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 650; font-size: 15px; letter-spacing: -.02em;
}
.brand.lg { font-size: 20px; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 14px var(--accent);
}

/* ================================================================ login */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

.login-card {
  width: 100%; max-width: 390px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 34px;
}
.login-card.wide { max-width: 520px; }
.login-card .sub { color: var(--dim); font-size: 13px; margin: 8px 0 24px; }

.login-card label, .field-row label {
  display: block; margin: 16px 0 6px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint);
}

.explain {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  margin: 4px 0 8px;
}
.explain h4 { font-size: 12.5px; margin-bottom: 6px; }
.explain p { margin: 0 0 8px; font-size: 13px; color: var(--dim); }
.explain p:last-child { margin-bottom: 0; }

/* ============================================================== layout */

#app-view { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex: 0 0 232px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh;
}

.app-switch select { width: 100%; margin-top: 5px; }

#nav { display: flex; flex-direction: column; gap: 1px; }

#nav button {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; color: var(--dim);
  padding: 9px 11px; border-radius: var(--r-sm);
  font-size: 13.5px; text-align: left; cursor: pointer; width: 100%;
  transition: background .12s, color .12s;
}
#nav button:hover { background: var(--panel-2); color: var(--text); }
#nav button.active { background: var(--accent-soft); color: #c3d0ff; }
#nav .ico { width: 15px; text-align: center; opacity: .75; font-size: 12px; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.who { font-size: 12px; color: var(--faint); padding: 0 2px 6px; border-top: 1px solid var(--line-soft); padding-top: 12px; }

.content { flex: 1; padding: 30px 34px 60px; max-width: 1180px; min-width: 0; }

.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 21px; }
.page-head p { margin: 6px 0 0; color: var(--dim); font-size: 13.5px; max-width: 70ch; }

.tab { display: none; }
.tab.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ================================================================ card */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.card.accent { border-color: var(--accent-soft); background: linear-gradient(180deg, rgba(108,140,255,.05), transparent 60%), var(--panel); }
.card h2 { font-size: 14.5px; }
.card > .muted { margin: 5px 0 16px; }

.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 16px; flex-wrap: wrap;
}
.card-head .muted { margin: 4px 0 0; }

/* =============================================================== steps */

.steps { list-style: none; counter-reset: s; padding: 0; margin: 14px 0 0; }
.steps li {
  counter-increment: s;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--line-soft);
}
.steps li:last-child { border-bottom: none; }
.steps li::before {
  content: counter(s);
  flex: 0 0 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%; font-size: 11.5px; font-weight: 600;
  background: var(--raise); color: var(--dim); border: 1px solid var(--line);
}
.steps li.done::before { content: "✓"; background: rgba(61,220,151,.14); color: var(--good); border-color: rgba(61,220,151,.3); }
.steps li.done .s-text { color: var(--faint); text-decoration: line-through; }
.steps .s-text { flex: 1; font-size: 13.5px; }

/* =============================================================== stats */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 12px; }

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 17px 18px;
}
.stat .n { font-size: 27px; font-weight: 640; letter-spacing: -.03em; line-height: 1.1; }
.stat .l { font-size: 11px; color: var(--faint); margin-top: 5px; }

/* =============================================================== forms */

input, select, textarea, button { font: inherit; color: var(--text); }

input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus {
  border-color: #3a4a7d;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select { cursor: pointer; }
textarea { resize: vertical; font-size: 12.5px; line-height: 1.6; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.form-field label { display: block; margin-bottom: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.form-field .hint { margin: 6px 0 0; }
.full { grid-column: 1 / -1; }

.field-row { margin-bottom: 14px; }
.field-row label { margin-top: 0; }

.copyable { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.copyable code {
  background: var(--bg); border: 1px solid var(--line);
  padding: 7px 11px; border-radius: var(--r-sm);
  font-size: 12.5px; word-break: break-all; flex: 1 1 240px;
}

.hint { font-size: 12.5px; color: var(--faint); margin: 8px 0 16px; max-width: 72ch; }
.hint strong { color: var(--dim); }

/* ============================================================= buttons */

button {
  cursor: pointer; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--raise);
  padding: 9px 15px; font-size: 13.5px;
  transition: background .12s, border-color .12s, opacity .12s;
}
button:hover { background: #20252f; }
button:disabled { opacity: .5; cursor: not-allowed; }

button.primary { background: var(--accent); border-color: var(--accent); color: #060a18; font-weight: 600; }
button.primary:hover { background: #8099ff; }
button.ghost { background: transparent; }
button.ghost:hover { background: var(--panel-2); }
button.small { padding: 5px 10px; font-size: 12px; }
button.block { width: 100%; }
button.danger { color: var(--bad); border-color: rgba(255,93,108,.25); }
button.danger:hover { background: rgba(255,93,108,.1); }
#login-btn { margin-top: 24px; }

/* ============================================================== tables */

.table-scroll { overflow-x: auto; margin: 0 -22px -20px; padding: 0 22px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--faint); font-weight: 500; padding: 0 12px 10px;
  border-bottom: 1px solid var(--line);
}
td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }
td .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
th:last-child, td:last-child { text-align: right; }

.pill {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 11px; border: 1px solid var(--line); background: var(--raise); color: var(--dim);
}
.pill.good { color: var(--good); border-color: rgba(61,220,151,.26); background: rgba(61,220,151,.09); }
.pill.warn { color: var(--warn); border-color: rgba(240,180,41,.26); background: rgba(240,180,41,.09); }
.pill.bad  { color: var(--bad);  border-color: rgba(255,93,108,.26); background: rgba(255,93,108,.09); }

/* ============================================================== empty */

.empty { text-align: center; padding: 34px 18px; }
.empty .e-title { font-size: 14px; font-weight: 550; margin-bottom: 5px; }
.empty .e-sub { font-size: 13px; color: var(--faint); max-width: 44ch; margin: 0 auto; }

/* ============================================================== modal */

.modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(4,5,8,.78);
  display: grid; place-items: center; padding: 20px;
  animation: fade .14s ease;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 24px;
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h2 { font-size: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 22px; }
.modal-body-text { color: var(--dim); font-size: 13.5px; margin: 10px 0 0; }

.keylist {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 14px; margin: 14px 0 0; font-family: var(--mono); font-size: 13px;
  max-height: 230px; overflow-y: auto; line-height: 1.9; letter-spacing: .02em;
}

.alert { padding: 10px 13px; border-radius: var(--r-sm); font-size: 13px; margin-top: 14px; }
.alert.bad  { background: rgba(255,93,108,.1); border: 1px solid rgba(255,93,108,.26); color: var(--bad); }
.alert.warn { background: rgba(240,180,41,.09); border: 1px solid rgba(240,180,41,.26); color: var(--warn); }
.alert.good { background: rgba(61,220,151,.09); border: 1px solid rgba(61,220,151,.26); color: var(--good); }
.alert strong { color: inherit; }

/* --------------------------------------------------- generated-key list -- */

.genkey-list {
  display: flex; flex-direction: column; gap: 6px;
  margin: 14px 0 0;
  max-height: 320px; overflow-y: auto;
}
.genkey-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 7px 10px;
}
.genkey-num {
  flex: 0 0 24px; text-align: right;
  font-size: 11px; color: var(--faint);
}
.genkey-value {
  flex: 1; font-family: var(--mono); font-size: 13px;
  letter-spacing: .03em; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.genkey-value:hover { color: var(--accent); }

/* license key cell with click-to-copy */
code.key-full { cursor: pointer; }
code.key-full:hover { color: var(--accent); }

/* =============================================================== misc */

.code {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 14px 16px; font-size: 12.5px; overflow-x: auto; margin: 0 0 10px;
  line-height: 1.65; color: var(--dim); white-space: pre;
}
.glossary { list-style: none; padding: 0; margin: 12px 0 0; }
.glossary li { padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; color: var(--dim); }
.glossary li:last-child { border-bottom: none; }
.glossary b { color: var(--text); font-weight: 600; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--raise); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 20px; font-size: 13px; z-index: 300;
  box-shadow: 0 12px 36px rgba(0,0,0,.6);
}
.toast.bad  { border-color: rgba(255,93,108,.3); color: var(--bad); }
.toast.good { border-color: rgba(61,220,151,.3); color: var(--good); }

/* ========================================================== responsive */

@media (max-width: 880px) {
  #app-view { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px;
    border-right: none; border-bottom: 1px solid var(--line); padding: 14px 16px;
  }
  .app-switch { flex: 1 1 160px; }
  .app-switch .tiny-label { display: none; }
  #nav { flex-direction: row; overflow-x: auto; order: 10; width: 100%; gap: 3px; }
  #nav button { white-space: nowrap; padding: 7px 11px; }
  #nav .ico { display: none; }
  .sidebar-foot { margin: 0; flex-direction: row; align-items: center; }
  .sidebar-foot .who { border: none; padding: 0; }
  .sidebar-foot button { width: auto; }
  .content { padding: 20px 16px 50px; }
  .table-scroll { margin: 0 -22px; padding: 0 22px; }
}
