:root {
  color-scheme: dark;
  --background: #0d1117;
  --surface: #151b23;
  --surface-2: #1b232e;
  --border: #2a3441;
  --border-strong: #3a4655;
  --text: #f2f5f8;
  --muted: #8d99a8;
  --accent: #d64747;
  --accent-hover: #e15454;
  --success: #53b483;
  --warning: #d5a34f;
  --danger: #e36a6a;
  --radius: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--background); color: var(--text); }
button, input, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.eyebrow { margin: 0 0 5px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.muted { margin: 0; color: var(--muted); line-height: 1.6; }
.small-copy { font-size: 12px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 23px; letter-spacing: -.03em; }
h2 { margin: 0; font-size: 25px; letter-spacing: -.03em; }
h3 { margin: 0; font-size: 16px; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #0d1117 0%, #11161d 50%, #0d1117 100%); }
.login-card { width: min(100%, 410px); padding: 32px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 28px 80px rgba(0, 0, 0, .38); }
.brand-lockup { display: flex; align-items: center; gap: 13px; }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: #0f141b; }
.brand-mark.small { width: 36px; height: 36px; border-radius: 8px; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.login-copy { margin: 22px 0; font-size: 14px; }

.stack { display: grid; gap: 15px; }
label { display: grid; gap: 7px; color: #cbd2db; font-size: 12px; font-weight: 650; }
input, select { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: 7px; outline: none; color: var(--text); background: #0f141b; transition: border-color 150ms, background 150ms; }
input:focus, select:focus { border-color: #667587; background: #111821; }
.button { min-height: 39px; padding: 0 15px; border: 1px solid var(--border-strong); border-radius: 7px; cursor: pointer; background: var(--surface-2); font-size: 12px; font-weight: 750; transition: background 150ms, border-color 150ms, transform 150ms; }
.button:hover { border-color: #556476; background: #222c38; }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: wait; opacity: .6; }
.button.primary { border-color: var(--accent); background: var(--accent); }
.button.primary:hover { border-color: var(--accent-hover); background: var(--accent-hover); }
.button.danger { color: #ffb0b0; border-color: #6d3437; background: #28191c; }
.button.small { min-height: 30px; padding: 0 9px; font-size: 10px; }
.wide { width: 100%; }
.text-button { padding: 0; border: 0; cursor: pointer; color: #b9c3ce; background: transparent; font-size: 11px; font-weight: 700; }
.text-button:hover { color: #fff; }
.form-error { min-height: 18px; margin: 10px 0 0; color: var(--danger); font-size: 12px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 16px 18px; border-right: 1px solid var(--border); background: #10151c; }
.sidebar-brand { padding: 0 8px 24px; }
.navigation { display: grid; gap: 4px; }
.nav-item { height: 38px; padding: 0 12px; border: 1px solid transparent; border-radius: 7px; cursor: pointer; color: var(--muted); background: transparent; text-align: left; font-size: 12px; font-weight: 700; }
.nav-item:hover { color: var(--text); background: #171e27; }
.nav-item.active { color: var(--text); border-color: var(--border); background: var(--surface-2); }
.sidebar-footer { margin-top: auto; padding: 17px 8px 0; border-top: 1px solid var(--border); }
.developer-email { display: block; max-width: 180px; margin-bottom: 8px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.main { min-width: 0; padding: 32px clamp(20px, 4vw, 50px) 60px; }
.topbar { display: flex; align-items: center; margin-bottom: 30px; }
.topbar-title { display: flex; align-items: center; gap: 12px; }
.topbar-logo { display: none; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 8px; object-fit: cover; image-rendering: pixelated; }
.badge { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); background: var(--surface); font-size: 10px; font-weight: 700; }
.badge.active { color: #97d9b5; border-color: #315742; background: #14241c; }
.badge.disabled, .badge.revoked, .badge.expired { color: #f1a4a4; border-color: #633638; background: #251719; }
.badge.unbound { color: #e5bd79; border-color: #634f2f; background: #251f16; }
.view { display: none; }
.active-view { display: block; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 18px; }
.stat-card { min-height: 108px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.stat-card strong { display: block; margin-top: 10px; font-size: 27px; letter-spacing: -.04em; }
.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.content-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 18px 19px 14px; border-bottom: 1px solid var(--border); }
.compact-list { min-height: 190px; }
.compact-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; min-height: 57px; padding: 10px 19px; border-bottom: 1px solid #222b36; }
.compact-row:last-child { border-bottom: 0; }
.compact-primary { min-width: 0; }
.compact-primary strong, .compact-primary span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-primary strong { font-size: 12px; }
.compact-primary span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.empty-state { display: grid; min-height: 170px; place-items: center; color: var(--muted); font-size: 12px; }
.release-summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 18px; padding: 18px 20px; }
.release-meta { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 11px; }
.release-version { color: var(--text); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 17px; font-weight: 800; }
.section-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.section-actions .muted { max-width: 700px; font-size: 12px; }
.table-panel { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { height: 54px; padding: 9px 15px; border-bottom: 1px solid #222b36; text-align: left; white-space: nowrap; }
th { height: 41px; color: var(--muted); background: #121820; font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
td { font-size: 11px; }
tbody tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.table-actions { display: flex; justify-content: flex-end; gap: 6px; }
.release-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(300px, .7fr); gap: 18px; }
.release-layout .panel { padding: 22px; }
.release-layout .muted { margin: 12px 0 0; font-size: 12px; }
.form-top { margin-top: 20px; }
.current-release-card { min-height: 270px; }
.current-release-card h4 { margin: 28px 0 8px; font-size: 32px; }
.release-detail { padding: 12px 0; border-bottom: 1px solid var(--border); }
.release-detail span { display: block; color: var(--muted); font-size: 10px; }
.release-detail strong { display: block; margin-top: 5px; overflow-wrap: anywhere; font-size: 12px; }

dialog { width: min(calc(100% - 32px), 430px); padding: 0; border: 1px solid var(--border-strong); border-radius: 12px; color: var(--text); background: var(--surface); box-shadow: 0 30px 100px rgba(0, 0, 0, .55); }
dialog::backdrop { background: rgba(3, 6, 10, .72); }
.dialog-card { display: grid; gap: 15px; padding: 23px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.icon-button { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; color: var(--muted); background: transparent; font-size: 20px; }
.created-key { display: block; padding: 16px; border: 1px solid var(--border); border-radius: 7px; overflow-wrap: anywhere; color: #fff; background: #0c1117; font-size: 13px; line-height: 1.7; text-align: center; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: min(360px, calc(100% - 44px)); padding: 12px 15px; border: 1px solid var(--border-strong); border-radius: 8px; opacity: 0; pointer-events: none; color: var(--text); background: #202936; font-size: 12px; transform: translateY(12px); transition: opacity 180ms, transform 180ms; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { border-color: #744044; background: #2a191c; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; padding-bottom: 68px; }
  .sidebar { position: fixed; inset: auto 0 0; z-index: 10; width: 100%; height: 66px; padding: 8px 10px; border-top: 1px solid var(--border); border-right: 0; }
  .sidebar-brand, .sidebar-footer { display: none; }
  .topbar-logo { display: block; }
  .navigation { grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .nav-item { height: 48px; padding: 0 5px; text-align: center; font-size: 10px; }
  .main { padding: 24px 18px 35px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid, .release-layout { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .login-card { padding: 25px 21px; }
  .topbar { align-items: flex-start; }
  .stats-grid { gap: 9px; }
  .stat-card { min-height: 92px; padding: 14px; }
  .stat-card strong { font-size: 23px; }
  .release-summary, .section-actions { align-items: stretch; flex-direction: column; }
  .release-meta { align-items: flex-start; flex-direction: column; gap: 4px; }
  .section-actions .button { width: 100%; }
  .navigation .nav-item { font-size: 9px; }
}
