:root {
  color-scheme: dark;
  --ink: #edf2e9;
  --muted: #89918a;
  --line: #303833;
  --panel: #1b201d;
  --panel-light: #222a25;
  --background: #111513;
  --acid: #d8ff65;
  --teal: #64e5bf;
  --danger: #ff877b;
  --shadow: rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--background);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }

.topbar {
  height: 72px;
  padding: 0 5vw;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  color: var(--ink);
  font: 700 15px/1 "Courier New", monospace;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.wordmark span { color: var(--muted); font-weight: 400; }
.topbar-meta, .session-tools { display: flex; align-items: center; gap: 18px; }
.operator-label, .principal-label { color: var(--muted); font: 12px/1 "Courier New", monospace; letter-spacing: 0.05em; }

.status-dot { color: var(--muted); font: 11px/1 "Courier New", monospace; letter-spacing: 0.06em; }
.status-dot::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--muted); }
.status-ready { color: var(--teal); }
.status-ready::before { background: var(--teal); }
.status-down { color: var(--danger); }
.status-down::before { background: var(--danger); }

main { width: min(1180px, 90vw); margin: 0 auto; }
.login-view { min-height: calc(100vh - 72px); display: grid; grid-template-columns: 1.15fr 0.85fr; align-items: center; gap: 9vw; padding: 8vh 0; }
.login-intro { border-left: 2px solid var(--acid); padding-left: 30px; }
.eyebrow, .panel-kicker, .metric-label { margin: 0 0 16px; color: var(--acid); font: 11px/1 "Courier New", monospace; letter-spacing: 0.13em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 24px; font: 600 68px/0.94 Georgia, serif; letter-spacing: 0; }
h1 em { color: var(--acid); font-style: normal; }
h2 { margin-bottom: 0; font: 600 28px/1.1 Georgia, serif; }
.intro-copy { max-width: 360px; color: var(--muted); line-height: 1.75; }

.form-panel, .panel { border: 1px solid var(--line); background: var(--panel); box-shadow: 0 18px 50px var(--shadow); }
.form-panel { padding: 34px; }
.form-panel label, .issue-form label { display: grid; gap: 8px; margin-bottom: 18px; }
label span { color: var(--muted); font-size: 12px; }
input, select { width: 100%; border: 1px solid var(--line); border-radius: 0; background: var(--background); color: var(--ink); padding: 12px 13px; outline: none; }
input:focus, select:focus { border-color: var(--acid); box-shadow: 0 0 0 2px rgba(216, 255, 101, 0.14); }

.primary-button, .ghost-button, .danger-button, .icon-button { border: 1px solid transparent; border-radius: 0; transition: background 140ms ease, color 140ms ease, border-color 140ms ease, transform 140ms ease; }
.primary-button { width: 100%; padding: 13px 16px; background: var(--acid); color: #141a13; font-weight: 700; }
.primary-button:hover { background: #efffa9; transform: translateY(-1px); }
.ghost-button { padding: 8px 11px; border-color: var(--line); background: transparent; color: var(--ink); }
.ghost-button:hover { border-color: var(--ink); }
.danger-button { padding: 10px 12px; border-color: rgba(255, 135, 123, 0.5); background: transparent; color: var(--danger); font-size: 13px; }
.danger-button:hover { background: rgba(255, 135, 123, 0.1); }
.icon-button { padding: 8px 10px; border-color: var(--line); background: var(--panel-light); color: var(--acid); font: 11px "Courier New", monospace; }
.icon-button:hover { border-color: var(--acid); }
button:disabled { cursor: not-allowed; opacity: 0.45; transform: none; }
.form-error { margin: 14px 0 0; color: var(--danger); font-size: 12px; }

.dashboard-view { padding: 56px 0 80px; }
.dashboard-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 34px; }
.dashboard-heading h1 { margin-bottom: 0; font-size: 56px; }
.metric-strip { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 0; }
.metric { min-height: 86px; padding: 18px 20px; border-right: 1px solid var(--line); display: grid; align-content: center; gap: 8px; }
.metric:last-child { border-right: 0; }
.metric-label { margin: 0; color: var(--muted); }
.metric strong { font: 16px "Courier New", monospace; letter-spacing: 0.02em; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.panel { padding: 28px; box-shadow: none; }
.panel-heading { display: flex; justify-content: space-between; align-items: start; margin-bottom: 30px; }
.panel-kicker { margin-bottom: 10px; color: var(--muted); }
.panel-index { color: var(--line); font: 700 28px/1 "Courier New", monospace; }
.issue-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.issue-form label:nth-child(3), .issue-form label:nth-child(4), .issue-form .primary-button, .issue-form .form-error { grid-column: 1 / -1; }
.issue-form label { margin-bottom: 17px; }
.issue-form .primary-button { margin-top: 4px; }
.empty-state { min-height: 230px; display: grid; place-items: center; border: 1px dashed var(--line); color: var(--muted); font-size: 13px; text-align: center; }
.output-caption { color: var(--muted); font-size: 12px; line-height: 1.6; }
.code-line { display: flex; align-items: center; gap: 10px; margin: 24px 0; }
.code-line code { overflow: auto; color: var(--acid); font: 700 22px "Courier New", monospace; white-space: nowrap; }
.code-meta { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin: 0 0 26px; }
.code-meta div { min-width: 0; border-top: 1px solid var(--line); padding-top: 10px; }
.code-meta dt { color: var(--muted); font: 10px "Courier New", monospace; }
.code-meta dd { overflow: hidden; margin: 8px 0 0; color: var(--ink); font: 12px "Courier New", monospace; text-overflow: ellipsis; white-space: nowrap; }
.inline-state { min-height: 17px; margin: 12px 0 0; color: var(--teal); font-size: 12px; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: min(360px, calc(100vw - 48px)); border: 1px solid var(--line); background: var(--panel-light); color: var(--ink); padding: 13px 15px; box-shadow: 0 12px 30px var(--shadow); font-size: 13px; }

.tab-bar { min-height: 58px; margin-bottom: 28px; border-bottom: 1px solid var(--line); display: flex; align-items: end; gap: 4px; }
.tab-button { min-width: 92px; height: 42px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 13px; }
.tab-button:hover { color: var(--ink); }
.tab-button.is-active { border-bottom-color: var(--acid); color: var(--acid); }
.refresh-button { margin: 0 0 8px auto; }
.role-hidden { display: none !important; }
.tab-view { min-width: 0; }

.data-section { margin-top: 28px; border-top: 1px solid var(--line); }
.data-heading { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.data-heading h2 { font-size: 24px; }
.data-heading .panel-kicker { margin-bottom: 8px; }
.filter-control { width: 180px; display: grid; gap: 7px; }
.filter-control span { font-size: 11px; }
.filter-control select { padding: 8px 10px; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); }
table { width: 100%; min-width: 760px; border-collapse: collapse; table-layout: fixed; }
th, td { height: 48px; padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
th { height: 38px; background: var(--panel-light); color: var(--muted); font: 10px "Courier New", monospace; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(100, 229, 191, 0.035); }
.mono-cell { font-family: "Courier New", monospace; }
.table-empty { height: 120px; color: var(--muted); text-align: center; }
.state-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; }
.state-badge::before { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); content: ""; }
.state-active::before, .state-available::before, .state-redeemed::before { background: var(--teal); }
.state-suspended::before, .state-expired::before { background: #f4cf67; }
.state-revoked::before { background: var(--danger); }
.table-action { min-height: 28px; padding: 4px 8px; border: 1px solid var(--line); background: transparent; color: var(--ink); font-size: 11px; }
.table-action:hover { border-color: var(--acid); color: var(--acid); }
.table-action.is-danger { color: var(--danger); }
.table-action.is-danger:hover { border-color: var(--danger); }
.pager { min-height: 52px; display: flex; align-items: center; justify-content: flex-end; gap: 12px; color: var(--muted); font: 11px "Courier New", monospace; }
.pager button { min-width: 64px; border: 1px solid var(--line); background: transparent; color: var(--ink); padding: 6px 9px; }

.detail-dialog { width: min(660px, calc(100vw - 32px)); max-height: calc(100vh - 32px); border: 1px solid var(--line); border-radius: 0; background: var(--panel); color: var(--ink); padding: 0; box-shadow: 0 28px 80px rgba(0, 0, 0, 0.6); }
.detail-dialog::backdrop { background: rgba(5, 8, 6, 0.78); }
.dialog-shell { padding: 28px; }
.detail-list { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 0; background: var(--line); border: 1px solid var(--line); }
.detail-list div { min-width: 0; background: var(--panel); padding: 14px; }
.detail-list dt { color: var(--muted); font-size: 10px; }
.detail-list dd { overflow-wrap: anywhere; margin: 8px 0 0; font: 12px/1.45 "Courier New", monospace; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

[hidden] { display: none !important; }

@media (max-width: 760px) {
  .topbar { height: 62px; padding: 0 5vw; }
  .operator-label { display: none; }
  main { width: 90vw; }
  .login-view { min-height: auto; grid-template-columns: 1fr; gap: 40px; padding: 12vh 0 60px; }
  .login-intro { padding-left: 20px; }
  h1, .dashboard-heading h1 { font-size: 44px; }
  .form-panel, .panel { padding: 22px; }
  .dashboard-heading { align-items: start; flex-direction: column; }
  .session-tools { width: 100%; justify-content: space-between; }
  .metric-strip { grid-template-columns: 1fr; }
  .metric { min-height: 62px; border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .tab-bar { overflow-x: auto; align-items: end; }
  .tab-button { min-width: 76px; }
  .refresh-button { min-width: 70px; }
  .data-heading { align-items: end; }
  .filter-control { width: 140px; }
  .detail-list { grid-template-columns: 1fr; }
}
