:root {
  --bg: #090b12;
  --panel: #12151f;
  --panel2: #171b27;
  --line: #262b39;
  --text: #f5f7fb;
  --muted: #8b94a7;
  --violet: #8b5cf6;
  --cyan: #28c8e8;
  --green: #44d7a1;
  --amber: #f6ba55;
  --danger: #ff6b7a;
  --shadow: 0 24px 80px rgba(0, 0, 0, .35);
  color-scheme: light dark;
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; min-height: 100%; background: var(--bg); scroll-behavior: smooth; }
body { min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.ambient { position: fixed; z-index: 0; border-radius: 50%; filter: blur(100px); opacity: .14; pointer-events: none; }
.ambient-one { top: -170px; right: 8%; width: 420px; height: 420px; background: #7048ff; }
.ambient-two { bottom: -190px; left: 30%; width: 340px; height: 340px; background: #1bbad8; }

.eyebrow { margin: 0 0 8px; color: #858da0; font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }
.muted { color: var(--muted); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; letter-spacing: -.025em; }
h2 { margin-bottom: 4px; font-size: 17px; }

.brand-mark { display: flex; align-items: flex-end; gap: 4px; width: 34px; height: 30px; }
.brand-mark span { display: block; width: 7px; border-radius: 10px; background: linear-gradient(#a78bfa, #6d42dd); }
.brand-mark span:nth-child(1) { height: 14px; }
.brand-mark span:nth-child(2) { height: 24px; }
.brand-mark span:nth-child(3) { height: 19px; }
.brand-mark.small { flex: 0 0 auto; transform: scale(.8); transform-origin: left center; }

.login-shell { position: relative; z-index: 1; display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login-card {
  width: min(430px, 100%);
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(24, 28, 40, .96), rgba(13, 15, 23, .96));
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 16px 0 8px; font-size: 30px; }
.login-card > .muted { margin-bottom: 28px; line-height: 1.7; }
.stack { display: grid; gap: 17px; }
label { display: grid; gap: 8px; color: #c3c9d5; font-size: 13px; font-weight: 600; }
label small { color: #737d91; font-weight: 400; line-height: 1.5; }

input, select, textarea {
  width: 100%;
  border: 1px solid #303648;
  border-radius: 11px;
  outline: 0;
  background: #0d1018;
  color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
input, select { min-height: 44px; padding: 10px 13px; }
textarea { min-height: 88px; padding: 12px 13px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: #7c5ce0; box-shadow: 0 0 0 3px rgba(124, 92, 224, .13); }
input::placeholder { color: #626b7c; }
input[type="number"] { appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { margin: 0; appearance: none; }

.custom-select { position: relative; }
.custom-select-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  border: 1px solid #303648;
  border-radius: 11px;
  background: #0d1018;
  color: var(--text);
  padding: 10px 13px;
  text-align: left;
  font-weight: 600;
  box-shadow: none;
}
.custom-select-button i { width: 9px; height: 9px; border-right: 2px solid #778196; border-bottom: 2px solid #778196; transform: translateY(-2px) rotate(45deg); transition: transform .18s; }
.custom-select.open .custom-select-button { border-color: #7c5ce0; box-shadow: 0 0 0 3px rgba(124, 92, 224, .13); }
.custom-select.open .custom-select-button i { transform: translateY(3px) rotate(225deg); }
.custom-select-options {
  position: absolute;
  z-index: 40;
  top: calc(100% + 7px);
  right: 0;
  left: 0;
  display: grid;
  gap: 4px;
  border: 1px solid #303648;
  border-radius: 13px;
  background: #151925;
  padding: 6px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, .32);
}
.custom-select-options button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 10px;
  width: 100%;
  min-height: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  padding: 10px 11px;
  text-align: left;
  box-shadow: none;
}
.custom-select-options button:hover,
.custom-select-options button.selected { background: rgba(139, 92, 246, .11); }
.custom-select-options button span { font-size: 12px; font-weight: 700; }
.custom-select-options button small { grid-column: 1; color: #778196; font-size: 9px; font-weight: 400; }
.custom-select-options button i { grid-column: 2; grid-row: 1 / 3; align-self: center; color: transparent; font-style: normal; }
.custom-select-options button.selected i { color: #a886ff; }

.primary, .ghost, .avatar {
  min-height: 40px;
  border-radius: 10px;
  padding: 10px 15px;
  border: 1px solid transparent;
  color: white;
  font-weight: 700;
}
.primary { background: linear-gradient(135deg, #8b5cf6, #7145dd); box-shadow: 0 8px 22px rgba(113, 69, 221, .24); }
.primary:hover { filter: brightness(1.08); }
.ghost { border-color: #2a3040; background: #191d29; color: #c6ccda; box-shadow: none; }
.ghost:hover { background: #202534; color: #fff; }
.avatar { display: grid; width: 40px; height: 40px; place-items: center; padding: 0; border-color: #32384a; border-radius: 50%; background: #191d29; color: #dadfea; }
button:disabled { cursor: wait; opacity: .58; }
.wide { grid-column: 1 / -1; width: 100%; }
.compact { min-height: 32px; padding: 6px 10px; font-size: 10px; }
.danger { color: #ff929d; }
.form-error { min-height: 18px; margin: 10px 0 0; color: #9d82ff; font-size: 12px; }
.form-error.error { color: #ff8290; }

.app-shell { position: relative; z-index: 1; display: grid; grid-template-columns: 196px minmax(0, 1fr); height: 100vh; overflow: hidden; }
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  align-self: start;
  flex-direction: column;
  width: 196px;
  min-height: 100vh;
  border-right: 1px solid #202430;
  background: rgba(12, 14, 21, .9);
  padding: 18px 12px;
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 8px; padding: 0 9px 20px; }
.brand > div:last-child { display: grid; }
.brand strong { font-size: 15px; }
.brand small, .sidebar-foot small { margin-top: 2px; color: #727c90; font-size: 10px; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { border: 0; border-radius: 9px; background: transparent; color: #80899c; padding: 10px 11px; text-align: left; font-size: 12px; font-weight: 650; }
.nav-item i { display: inline-block; width: 25px; font-style: normal; }
.nav-item:hover, .nav-item.active { background: #191d29; color: #f5f7fb; }
.nav-item.active { box-shadow: inset 2px 0 var(--violet); }
.sidebar-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 14px 11px; border-top: 1px solid #202430; }
.sidebar-foot > div { display: grid; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(68, 215, 161, .1); }

.content { min-width: 0; height: 100vh; overflow: auto; padding: 22px 26px 28px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 16px; }
.topbar h1 { font-size: 25px; }
.topbar .eyebrow { margin-bottom: 5px; }
.topbar-copy { margin: 8px 0 0; color: #7f899d; font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.environment, .secure-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(68, 215, 161, .22);
  border-radius: 999px;
  background: rgba(68, 215, 161, .07);
  color: #63dfb3;
  padding: 7px 11px;
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}
.environment i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(68, 215, 161, .1); }

.view-page { min-width: 0; animation: view-in .18s ease-out; }
@keyframes view-in { from { opacity: .35; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.summary-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.summary-card {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  min-width: 0;
  border: 1px solid #242938;
  border-radius: 13px;
  background: linear-gradient(145deg, #151924, #10131c);
  padding: 12px 13px;
}
.summary-card::before { content: "◈"; grid-row: 1 / 3; width: 28px; height: 28px; border-radius: 8px; background: rgba(139, 92, 246, .13); color: #a886ff; display: grid; place-items: center; }
.summary-card:nth-child(2)::before { content: "⌁"; background: rgba(40, 200, 232, .12); color: var(--cyan); }
.summary-card:nth-child(3)::before { content: "✓"; background: rgba(68, 215, 161, .12); color: var(--green); }
.summary-card:nth-child(4)::before { content: "↶"; background: rgba(246, 186, 85, .12); color: var(--amber); }
.summary-card:nth-child(5)::before { content: "×"; background: rgba(255, 107, 122, .11); color: var(--danger); }
.summary-card:nth-child(6)::before { content: "F"; }
.summary-card span { color: #7f899d; font-size: 10px; }
.summary-card strong { overflow: hidden; font-size: 18px; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }

.panel { overflow: hidden; border: 1px solid #242938; border-radius: 16px; background: linear-gradient(145deg, #131721, #0e1119); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 15px 18px; border-bottom: 1px solid #242938; }
.panel-heading p:not(.eyebrow) { margin: 0; color: #778196; font-size: 11px; }
.form-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 13px; padding: 16px 18px 4px; }
.issue-panel { max-width: none; overflow: visible; }
.dashboard-issue { position: relative; z-index: 3; margin-top: 10px; }
.issue-panel > .form-error { padding: 0 18px; }

.issued-codes { margin: 12px 22px 22px; border: 1px solid rgba(246, 186, 85, .28); border-radius: 12px; background: rgba(246, 186, 85, .06); padding: 14px; }
.issued-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #f4c875; font-size: 12px; }
pre { margin: 12px 0 0; overflow: auto; color: #f8dda4; font: 11px/1.7 "SFMono-Regular", Consolas, monospace; }

.manage-stack { display: grid; gap: 10px; }
.audit-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); max-height: 23vh; margin: 0; padding: 8px 18px 18px; overflow: auto; list-style: none; column-gap: 22px; }
.audit-list li { padding: 11px 2px; border-bottom: 1px solid var(--line); }
.audit-list li:last-child { border-bottom: 0; }
.audit-list strong, .audit-list span { display: block; }
.audit-list strong { font-size: 11px; }
.audit-list span { margin-top: 5px; color: #778196; font-size: 9px; line-height: 1.5; }

.records-panel { min-height: 0; }
.table-wrap { max-height: 44vh; overflow: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 11px 14px; border-bottom: 1px solid #242938; text-align: left; }
thead { position: sticky; z-index: 2; top: 0; }
th { background: rgba(9, 11, 18, .28); color: #758094; font-size: 9px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
td { color: #d9ddea; font-size: 10px; }
tbody tr:hover { background: rgba(139, 92, 246, .035); }
.status-chip { display: inline-flex; border-radius: 999px; padding: 5px 9px; font-size: 9px; font-weight: 750; }
.status-active { background: rgba(68, 215, 161, .1); color: #39c996; }
.status-issued { background: rgba(139, 92, 246, .12); color: #a991ff; }
.status-unbound { background: rgba(246, 186, 85, .11); color: #e7ae48; }
.status-revoked { background: rgba(255, 107, 122, .1); color: #ff8290; }
.row-actions { display: flex; gap: 7px; }
.license-code-cell { display: flex; align-items: center; gap: 7px; }
.license-code-cell code { color: var(--text); font: 9px/1.4 "SFMono-Regular", Consolas, monospace; }
.license-code-cell .ghost { padding: 5px 7px; }
.global-status { position: fixed; z-index: 50; right: 26px; bottom: 18px; min-height: 0; max-width: min(420px, calc(100% - 40px)); margin: 0; border: 1px solid rgba(139,92,246,.2); border-radius: 999px; background: var(--panel); padding: 7px 12px; text-align: center; box-shadow: 0 8px 30px rgba(0,0,0,.12); }
.global-status:empty { display: none; }
.action-dialog{width:min(430px,calc(100% - 28px));border:1px solid var(--line);border-radius:20px;background:var(--panel);color:var(--text);padding:26px;box-shadow:var(--shadow)}.action-dialog::backdrop{background:rgba(5,7,14,.68);backdrop-filter:blur(8px)}.action-dialog[open]{display:grid;grid-template-columns:46px minmax(0,1fr);gap:16px}.action-dialog-mark{display:grid;place-items:center;width:46px;height:46px;border-radius:13px;background:rgba(139,92,246,.12);color:#8b5cf6;font-size:21px}.action-dialog h2{margin:0 0 8px;font-size:19px}.action-dialog p:not(.eyebrow){margin:0;color:var(--muted);font-size:11px;line-height:1.7}.action-dialog-actions{grid-column:1/-1;display:flex;justify-content:flex-end;gap:9px;margin-top:8px}.action-dialog-actions button{min-width:96px}.action-dialog[data-danger=true] .action-dialog-mark{background:rgba(255,107,122,.1);color:#e65869}.action-dialog[data-danger=true] #confirmActionDialog{background:linear-gradient(135deg,#e55e6f,#bf3f52);box-shadow:0 8px 22px rgba(190,63,82,.2)}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fb;
    --panel: #ffffff;
    --panel2: #f7f9fc;
    --line: #e0e5ef;
    --text: #172033;
    --muted: #768095;
    --shadow: 0 24px 70px rgba(44, 58, 88, .14);
  }
  html, body { background: var(--bg); }
  .ambient { opacity: .1; }
  .login-card { border-color: #e0e5ef; background: rgba(255, 255, 255, .94); box-shadow: var(--shadow); }
  .eyebrow { color: #76678f; }
  label { color: #4d586d; }
  label small, .brand small, .sidebar-foot small { color: #7b8496; }
  input, select, textarea { border-color: #d9dee9; background: #f8f9fc; color: #172033; }
  input::placeholder { color: #9aa3b4; }
  .ghost, .avatar { border-color: #dce1eb; background: #f2f4f8; color: #4d586d; }
  .ghost:hover, .avatar:hover { background: #e9edf4; color: #172033; }
  .sidebar { border-color: #e1e5ee; background: rgba(255, 255, 255, .92); }
  .nav-item { color: #758095; }
  .nav-item:hover, .nav-item.active { background: #eef1f8; color: #172033; }
  .sidebar-foot { border-color: #e1e5ee; }
  .topbar-copy, .panel-heading p:not(.eyebrow), .audit-list span { color: #768095; }
  .summary-card, .panel { border-color: #e0e5ef; background: #ffffff; box-shadow: 0 14px 40px rgba(44, 58, 88, .07); }
  .summary-card span { color: #768095; }
  .panel-heading, .audit-list li, th, td { border-color: #e3e7ef; }
  th { background: #f7f8fb; color: #7b8496; }
  td { color: #394459; }
  tbody tr:hover { background: #faf8ff; }
  .issued-codes { border-color: rgba(205, 142, 31, .28); background: rgba(246, 186, 85, .1); }
  .issued-heading, pre { color: #9a6715; }
  .environment, .secure-pill { border-color: rgba(30, 169, 126, .25); background: rgba(30, 169, 126, .08); color: #138c69; }
  .status-active { color: #15936e; }
  .status-issued { color: #6754bc; }
  .status-unbound { color: #a66d12; }
  .status-revoked { color: #d95667; }
  .custom-select-button { border-color: #d9dee9; background: #f8f9fc; color: #172033; }
  .custom-select-options { border-color: #d9dee9; background: #ffffff; box-shadow: 0 18px 42px rgba(44, 58, 88, .16); }
  .custom-select-options button { color: #172033; }
  .custom-select-options button:hover,
  .custom-select-options button.selected { background: #f1edff; }
  .custom-select-options button small { color: #768095; }
}

@media (max-width: 1180px) {
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; padding-bottom: 74px; }
  .sidebar {
    position: fixed;
    z-index: 20;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    min-height: auto;
    border-top: 1px solid #242938;
    border-right: 0;
    padding: 8px;
  }
  .brand, .sidebar-foot { display: none; }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .nav-item { padding: 9px 4px; text-align: center; font-size: 9px; }
  .nav-item i { display: block; width: auto; margin-bottom: 4px; font-size: 13px; }
  .nav-item.active { box-shadow: inset 0 -2px var(--violet); }
  .content { padding: 26px 22px 40px; }
  .table-wrap, .audit-list { max-height: none; }
}

@media (max-width: 640px) {
  .login-shell { padding: 14px; }
  .login-card { padding: 30px 24px; border-radius: 20px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { width: 100%; flex-wrap: wrap; }
  .environment { margin-right: auto; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; padding-inline: 16px; }
  .audit-list { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .panel-heading { padding-inline: 16px; }
  .issue-panel > .form-error { padding-inline: 16px; }
  .content { padding-inline: 12px; }
}
