:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #18212f;
  --muted: #667085;
  --line: #d9e1ec;
  --primary: #2364d2;
  --primary-strong: #184ca5;
  --danger: #c9372c;
  --success: #1f8f5f;
  --warning: #b7791f;
  --shadow: 0 16px 40px rgba(24, 33, 47, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
  transition: 140ms ease;
  white-space: nowrap;
}

button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

button.primary:hover {
  background: var(--primary-strong);
  color: #fff;
}

button.danger {
  border-color: rgba(201, 55, 44, 0.36);
  color: var(--danger);
}

button.danger:hover {
  border-color: var(--danger);
  background: rgba(201, 55, 44, 0.08);
  color: var(--danger);
}

.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
  text-decoration: none;
  transition: 140ms ease;
}

.link-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(35, 100, 210, 0.14);
}

.shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

.token-box {
  display: grid;
  grid-template-columns: minmax(190px, 260px) auto auto;
  gap: 10px;
  align-items: center;
}

.notice,
.result {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.notice.error {
  border-left-color: var(--danger);
}

.notice.success {
  border-left-color: var(--success);
}

.is-hidden {
  display: none !important;
}

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow);
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 14px;
  padding-bottom: 2px;
}

.tab {
  background: transparent;
}

.tab.is-active {
  border-color: var(--primary);
  background: #e8f0ff;
  color: var(--primary);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

label.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding-top: 22px;
  color: var(--text);
}

label.check-field input {
  width: auto;
  min-height: 0;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-2);
  color: #344054;
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.license-key-cell {
  max-width: 220px;
  margin-bottom: 6px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.license-detail-row td {
  background: #f8fafc;
  padding: 0;
}

.license-editor {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.inline-edit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.inline-edit-grid.compact-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.binding-list {
  display: grid;
  gap: 12px;
}

.binding-block {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.binding-head,
.device-edit-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.device-list {
  display: grid;
  gap: 8px;
}

.device-edit-row {
  grid-template-columns: minmax(180px, 1.3fr) minmax(140px, 1fr) minmax(120px, 0.8fr) minmax(120px, 0.8fr) auto;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--surface-2);
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

.pill.active,
.pill.allow {
  background: #e5f6ef;
  color: var(--success);
}

.pill.banned,
.pill.deny,
.pill.revoked,
.pill.expired {
  background: #fdeceb;
  color: var(--danger);
}

.pill.pending,
.pill.paused {
  background: #fff3d6;
  color: var(--warning);
}

.hash {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.output {
  min-height: 180px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101828;
  color: #e4e7ec;
  padding: 14px;
}

.user-auth {
  max-width: 760px;
}

.license-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.license-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow);
}

.license-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.license-card-head h2 {
  margin-top: 8px;
}

.key-box {
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 15px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.meta-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.meta-grid dt {
  color: var(--muted);
  font-size: 12px;
}

.meta-grid dd {
  margin: 6px 0 0;
  font-weight: 700;
}

.account-list {
  display: grid;
  gap: 8px;
}

.account-item {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.8fr auto;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.account-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.empty-state.compact {
  padding: 12px;
  text-align: left;
}

@media (max-width: 900px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .token-box,
  .form-grid,
  .stats,
  .license-grid,
  .meta-grid,
  .account-item {
    grid-template-columns: 1fr;
  }
}

:root {
  --bg: #f4f5f7;
  --surface-2: #f7f8fa;
  --text: #181818;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #ff6a00;
  --primary-strong: #e65f00;
  --primary-soft: #fff3e8;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

button,
.link-button,
input,
select,
.panel,
.stat,
.notice,
.result,
.table-wrap,
.output,
.license-card,
.key-box,
.meta-grid div,
.empty-state {
  border-radius: 2px;
}

button,
.link-button,
input,
select {
  min-height: 32px;
}

input:focus,
select:focus {
  box-shadow: 0 0 0 2px rgba(255, 106, 0, 0.16);
}

h1 {
  font-size: 22px;
}

.console-body {
  background: var(--bg);
}

.console-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  border-bottom: 1px solid #101318;
  background: #20242b;
  color: #fff;
  padding: 0 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 2px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: #c7ccd6;
  font-size: 12px;
}

.header-actions {
  display: grid;
  grid-template-columns: auto minmax(190px, 260px) auto;
  gap: 10px;
  align-items: center;
}

.header-actions.compact {
  grid-template-columns: repeat(2, auto);
}

.header-actions input {
  border-color: #3a3f48;
  background: #161a20;
  color: #fff;
}

.header-actions .link-button {
  border-color: #3a3f48;
  background: #2b3038;
  color: #fff;
}

.console-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 56px);
}

.console-sidebar {
  border-right: 1px solid var(--line);
  background: #fff;
}

.console-main {
  min-width: 0;
  padding: 18px 20px 42px;
}

.side-nav {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 12px 0;
  overflow: visible;
}

.side-nav .tab {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0;
  padding: 0 20px;
  color: #3f4856;
  text-align: left;
}

.side-nav .tab:hover {
  background: var(--surface-2);
}

.side-nav .tab.is-active {
  border-left-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.console-main .stats {
  gap: 10px;
  margin-bottom: 14px;
}

.console-main .stat {
  padding: 12px 14px;
}

.console-main .stat strong {
  margin-top: 6px;
  font-size: 22px;
}

.console-main .panel {
  padding: 0;
}

.console-main .panel-head {
  min-height: 58px;
  margin: 0;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.section-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.console-main .form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.console-main .result {
  margin: 16px;
}

.console-main .table-wrap {
  border: 0;
  border-radius: 0;
}

.console-main table {
  min-width: 920px;
}

.console-main th,
.console-main td {
  padding: 10px 12px;
}

.console-main th {
  background: #fafafa;
  color: #4b5563;
  font-weight: 600;
}

.console-main .row-actions {
  gap: 6px;
}

.console-main .row-actions button {
  padding: 0 10px;
}

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 460px);
  align-items: center;
  gap: 48px;
  padding: 48px clamp(24px, 7vw, 96px);
  background:
    linear-gradient(120deg, rgba(32, 36, 43, 0.94), rgba(32, 36, 43, 0.78)),
    radial-gradient(circle at 20% 25%, rgba(255, 106, 0, 0.26), transparent 34%),
    #20242b;
  color: #fff;
}

.login-hero {
  max-width: 680px;
}

.login-hero h1 {
  margin: 8px 0 16px;
  color: #fff;
  font-size: 42px;
}

.login-hero p:last-child {
  max-width: 520px;
  margin: 0;
  color: #d6d9df;
  font-size: 16px;
  line-height: 1.8;
}

.login-card {
  display: grid;
  gap: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  padding: 26px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
}

.login-card h2 {
  font-size: 24px;
}

.login-message {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

.user-main {
  max-width: 1280px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .console-header,
  .header-actions {
    grid-template-columns: 1fr;
  }

  .console-header {
    position: static;
    display: grid;
    gap: 12px;
    padding: 14px;
  }

  .console-layout {
    grid-template-columns: 1fr;
  }

  .login-view {
    grid-template-columns: 1fr;
    padding: 24px;
  }

  .login-hero h1 {
    font-size: 30px;
  }

  .console-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .console-main .form-grid {
    grid-template-columns: 1fr;
  }

  .inline-edit-grid,
  .inline-edit-grid.compact-grid,
  .binding-head,
  .device-edit-row {
    grid-template-columns: 1fr;
  }
}
