:root {
  color-scheme: dark;
  --bg: #090b16;
  --panel: rgba(20, 23, 43, 0.82);
  --panel-solid: #15182c;
  --panel-soft: rgba(31, 35, 63, 0.65);
  --border: rgba(159, 135, 255, 0.2);
  --text: #f5f4ff;
  --muted: #aaa9bd;
  --violet: #8f74ff;
  --violet-bright: #ae9bff;
  --cyan: #4fd9ff;
  --green: #55d99f;
  --amber: #f0bd68;
  --red: #ff7188;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.ambient { position: fixed; width: 36rem; height: 36rem; border-radius: 50%; filter: blur(120px); opacity: .17; pointer-events: none; }
.ambient-one { background: var(--violet); top: -18rem; left: -10rem; }
.ambient-two { background: var(--cyan); right: -20rem; bottom: -20rem; }
.glass-panel { background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.eyebrow { margin: 0 0 .45rem; color: var(--cyan); font-size: .7rem; font-weight: 800; letter-spacing: .18em; }
.muted { color: var(--muted); }
.brand-mark { display: grid; place-items: center; width: 3.2rem; height: 3.2rem; border-radius: 1rem; background: linear-gradient(145deg, var(--violet), #5340b8); box-shadow: 0 12px 30px rgba(115, 88, 245, .35); font-weight: 900; font-size: 1.45rem; }
.brand-mark.small { width: 2.25rem; height: 2.25rem; border-radius: .72rem; font-size: 1rem; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.login-card { width: min(28rem, 100%); border-radius: 1.5rem; padding: 2.4rem; }
.login-card h1 { margin: 1.25rem 0 .35rem; font-size: 2rem; }
form { display: grid; gap: 1rem; }
label { display: grid; gap: .45rem; color: #d4d2e4; font-size: .84rem; font-weight: 650; }
input, select { width: 100%; min-height: 2.75rem; padding: .65rem .8rem; color: var(--text); background: rgba(8, 10, 23, .78); border: 1px solid var(--border); border-radius: .72rem; outline: none; }
input:focus, select:focus { border-color: var(--violet-bright); box-shadow: 0 0 0 3px rgba(143, 116, 255, .14); }
.form-error { min-height: 1.1rem; margin: 0; color: var(--red); font-size: .82rem; }

.primary-button, .secondary-button, .danger-button, .text-button { border: 0; border-radius: .72rem; padding: .72rem 1rem; font-weight: 750; }
.primary-button { color: white; background: linear-gradient(135deg, var(--violet), #6550db); }
.primary-button:hover { filter: brightness(1.1); }
.secondary-button { color: var(--text); background: var(--panel-soft); border: 1px solid var(--border); }
.danger-button { color: #ffdce2; background: rgba(168, 43, 69, .35); border: 1px solid rgba(255, 113, 136, .3); }
.text-button { padding: .4rem 0; color: var(--violet-bright); background: transparent; }
.full-width { width: 100%; }
button:disabled { cursor: not-allowed; opacity: .45; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 15.5rem 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 1.35rem; background: rgba(12, 14, 27, .94); border-right: 1px solid var(--border); }
.brand-row { display: flex; align-items: center; gap: .8rem; margin-bottom: 2rem; }
.brand-row strong { font-size: 1.12rem; letter-spacing: .04em; }
nav { display: grid; gap: .45rem; }
.nav-button { text-align: left; padding: .78rem .9rem; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: .72rem; }
.nav-button:hover, .nav-button.active { color: var(--text); background: rgba(143, 116, 255, .12); border-color: var(--border); }
.sidebar-footer { margin-top: auto; display: grid; gap: .25rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.content-shell { min-width: 0; }
.topbar { min-height: 6rem; display: flex; align-items: center; justify-content: space-between; padding: 1.4rem 2rem; border-bottom: 1px solid var(--border); background: rgba(9, 11, 22, .72); backdrop-filter: blur(14px); }
.topbar h2 { margin: 0; font-size: 1.5rem; }
.content { padding: 1.6rem 2rem 3rem; }
.status-message { color: var(--green); font-size: .82rem; }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .9rem; }
.metric-card, .section-card { background: var(--panel); border: 1px solid var(--border); border-radius: 1rem; box-shadow: 0 12px 35px rgba(0,0,0,.2); }
.metric-card { padding: 1rem; }
.metric-card span { color: var(--muted); font-size: .76rem; }
.metric-card strong { display: block; margin-top: .45rem; font-size: 1.75rem; }
.section-card { margin-top: 1rem; padding: 1rem; }
.section-card h3 { margin: 0 0 1rem; font-size: 1rem; }
.toolbar { display: grid; grid-template-columns: minmax(12rem, 2fr) repeat(4, minmax(8rem, 1fr)) auto; gap: .65rem; margin-bottom: 1rem; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: .85rem; }
table { width: 100%; border-collapse: collapse; min-width: 68rem; }
th, td { padding: .72rem .75rem; text-align: left; border-bottom: 1px solid rgba(159,135,255,.11); font-size: .79rem; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; color: #c7c3d9; background: #171a30; font-size: .69rem; letter-spacing: .05em; text-transform: uppercase; }
tbody tr:hover { background: rgba(143,116,255,.07); }
.row-button { padding: 0; color: var(--cyan); background: transparent; border: 0; font-weight: 700; }
.badge { display: inline-flex; padding: .28rem .55rem; border-radius: 999px; background: rgba(143,116,255,.12); border: 1px solid var(--border); font-size: .7rem; font-weight: 750; }
.badge.active { color: var(--green); }
.badge.expired, .badge.suspended { color: var(--amber); }
.badge.revoked { color: var(--red); }
.empty-state { padding: 2rem; text-align: center; color: var(--muted); }

.details-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.details-header h3 { margin: .2rem 0; }
.action-row, .dialog-actions { display: flex; gap: .55rem; flex-wrap: wrap; }
.definition-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .75rem; }
.definition { padding: .75rem; background: rgba(8,10,23,.48); border-radius: .7rem; }
.definition span { display: block; color: var(--muted); font-size: .7rem; }
.definition strong { display: block; margin-top: .25rem; overflow-wrap: anywhere; }
.create-form { max-width: 46rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.create-form .wide { grid-column: 1 / -1; }
.timeline { display: grid; gap: .55rem; }
.timeline-item { display: grid; grid-template-columns: 10rem 1fr auto; gap: .75rem; padding: .7rem; background: rgba(8,10,23,.45); border-radius: .7rem; font-size: .78rem; }

.key-dialog { width: min(34rem, calc(100% - 2rem)); padding: 0; color: var(--text); background: transparent; border: 0; }
.key-dialog::backdrop { background: rgba(2, 3, 9, .78); backdrop-filter: blur(6px); }
.key-dialog .glass-panel { padding: 1.5rem; border-radius: 1.1rem; }
.license-key { display: block; margin: 1rem 0; padding: 1rem; overflow-wrap: anywhere; color: var(--cyan); background: #080a17; border: 1px dashed var(--violet); border-radius: .7rem; font-family: Consolas, monospace; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 1rem; overflow-x: auto; }
  .sidebar .brand-row { margin: 0; }
  .sidebar nav { display: flex; }
  .sidebar-footer { margin: 0 0 0 auto; border: 0; padding: 0; }
  .toolbar { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .sidebar { align-items: flex-start; flex-wrap: wrap; }
  .topbar, .content { padding-left: 1rem; padding-right: 1rem; }
  .toolbar, .create-form { grid-template-columns: 1fr; }
  .create-form .wide { grid-column: auto; }
  .timeline-item { grid-template-columns: 1fr; }
}
