:root {
    --bg: #fff;
    --bg-alt: #f7f8fa;
    --text: #1a1a1a;
    --text-light: #555;
    --border: #e0e0e0;
    --accent: #7c3aed;
    --accent-light: #ede9fe;
    --red: #dc2626;
    --blue: #2563eb;
    --orange: #d97706;
    --sidebar-w: 240px;
    --header-h: 50px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: 'Inter', Arial, sans-serif; color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.7; }
button, input, select { font: inherit; }
button { border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 4px; padding: 7px 14px; cursor: pointer; font-size: 13px; font-weight: 500; transition: background .15s, border-color .15s, color .15s; }
button:hover { background: #6d28d9; border-color: #6d28d9; }
button.secondary { background: #fff; color: var(--text); border-color: var(--border); }
button.secondary:hover { background: var(--bg-alt); }
button.danger { background: var(--red); border-color: var(--red); }
button.danger:hover { background: #b91c1c; border-color: #b91c1c; }
input, select { width: 100%; border: 1px solid var(--border); border-radius: 4px; padding: 8px 10px; background: #fff; color: var(--text); font-size: 13px; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(124,58,237,.12); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bg-alt); }
.login-box { width: min(380px, 100%); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 32px; box-shadow: 0 4px 20px rgba(0,0,0,.06); }
.login-box h1 { margin: 0 0 4px; font-size: 18px; line-height: 1.25; font-weight: 700; }
.login-box p { margin: 0 0 20px; color: var(--text-light); font-size: 13px; }
label { display: grid; gap: 4px; margin-bottom: 14px; color: var(--text-light); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.login-box button { width: 100%; }
.form-error { min-height: 18px; margin-top: 10px; color: var(--red); font-size: 12px; }
.form-success { min-height: 18px; margin-top: 10px; color: #065f46; font-size: 12px; }

.app-shell { min-height: 100vh; }
.topbar { position: fixed; top: 0; left: 0; right: 0; height: var(--header-h); background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; z-index: 100; }
.logo { display: flex; align-items: center; gap: 8px; }
.logo strong { font-size: 16px; font-weight: 700; }
.version-badge { font-size: 11px; color: var(--accent); border: 1px solid var(--border); padding: 1px 8px; border-radius: 10px; }
#logoutBtn { background: transparent; border: 0; color: var(--red); padding: 0; font-size: 12px; }
#logoutBtn:hover { text-decoration: underline; background: transparent; }
.sidebar { position: fixed; top: var(--header-h); left: 0; bottom: 0; width: var(--sidebar-w); background: var(--bg-alt); border-right: 1px solid var(--border); overflow-y: auto; padding: 12px 0; z-index: 90; }
.nav-link { width: 100%; display: flex; align-items: center; gap: 8px; padding: 10px 20px; color: var(--text-light); background: transparent; border: 0; border-left: 2px solid transparent; border-radius: 0; text-align: left; font-size: 13px; font-weight: 500; transition: background .15s, color .15s; }
.nav-link:hover { color: var(--text); background: #eef1f5; border-left-color: transparent; }
.nav-link.active { color: var(--accent); border-left-color: var(--accent); background: #eef1f5; font-weight: 600; }
.content { margin-left: var(--sidebar-w); max-width: 960px; padding: calc(var(--header-h) + 24px) 32px 60px; }
.page { display: none; position: relative; }
.page.active { display: block; }
.page.is-loading::before { content: ''; position: absolute; inset: 0; min-height: 180px; background: rgba(255,255,255,.72); z-index: 20; }
.page.is-loading::after { content: ''; position: absolute; top: 74px; left: 50%; width: 28px; height: 28px; margin-left: -14px; border: 3px solid #ede9fe; border-top-color: var(--accent); border-radius: 50%; z-index: 21; animation: spin .75s linear infinite; }
.page.is-loading .page-head button { opacity: .55; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.page-head h2, .panel h2 { margin: 0; font-size: 20px; line-height: 1.3; font-weight: 700; }
.panel { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 14px; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-actions { align-self: end; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat-card { background: var(--bg-alt); border: 1px solid var(--border); border-radius: 6px; padding: 14px 16px; }
.stat-value { font-size: 24px; line-height: 1.15; font-weight: 700; color: var(--accent); }
.stat-label { color: #999; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }
.chart-panel h3 { margin: 0 0 16px; font-size: 14px; font-weight: 600; color: var(--text-light); }
.chart-container { position: relative; height: 260px; width: 100%; }
.secret-box { grid-column: 1 / -1; background: #fef9ee; border: 1px solid #f0d78c; color: #8a6800; padding: 10px 12px; border-radius: 4px; word-break: break-all; font-size: 12.5px; font-family: 'JetBrains Mono', monospace; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 13px; }
th, td { text-align: left; border-bottom: 1px solid var(--border); padding: 7px 10px; vertical-align: middle; }
th { color: var(--text); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: var(--bg-alt); }
tr:hover td { background: #f7f8fa; }
.mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.badge { display: inline-block; border-radius: 8px; padding: 2px 8px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; background: #eef2f5; color: var(--text-light); }
.badge.active, .badge.trialing, .badge.paid { color: #065f46; background: #d1fae5; }
.badge.issued { color: #92400e; background: #fef3c7; }
.badge.revoked, .badge.void { color: #991b1b; background: #fee2e2; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--text); color: #fff; padding: 10px 16px; border-radius: 6px; font-size: 13px; font-weight: 500; transform: translateY(100px); opacity: 0; pointer-events: none; transition: all .25s; z-index: 600; }
.toast.show { transform: translateY(0); opacity: 1; }
.lang-switcher a { color: var(--text); text-decoration: none; }
.lang-switcher a:hover { color: var(--accent); }
.plan-card { border: 1px solid var(--border); border-radius: 8px; padding: 20px; background: var(--bg); }
.plan-card.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.plan-card h3 { margin: 0 0 6px; font-size: 18px; }
.plan-card .price { font-size: 26px; font-weight: 700; color: var(--accent); margin: 8px 0; }
.plan-card ul { margin: 12px 0; padding-left: 18px; font-size: 13px; color: var(--text-light); }

@media (max-width: 900px) {
    .topbar { padding: 0 14px; position: sticky; }
    .sidebar { position: static; width: 100%; display: flex; overflow-x: auto; gap: 8px; padding: 8px; border-right: 0; border-bottom: 1px solid var(--border); }
    .nav-link { white-space: nowrap; width: auto; border-left: 0; border-radius: 4px; padding: 6px 12px; }
    .nav-link.active { border-left: 0; }
    .content { margin-left: 0; padding: 16px 14px 40px; }
    .form-grid { grid-template-columns: 1fr; }
}
