:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #111827;
  --muted: #64748b;
  --line: #dbe3ef;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #059669;
  --red: #dc2626;
  --amber: #d97706;
  --shadow: 0 18px 50px rgba(15, 23, 42, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, .12), transparent 30%),
    linear-gradient(180deg, #eef4ff 0%, var(--bg) 320px);
  font-family: Inter, "Microsoft YaHei", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: rgba(255, 255, 255, .9);
  border: 1px solid rgba(219, 227, 239, .9);
  border-radius: 18px;
  padding: 30px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #0f766e);
  font-weight: 800;
}

.login-card h1,
.topbar h1,
.panel h2 {
  margin: 0;
}

.login-card h1 {
  margin-top: 18px;
  font-size: 26px;
}

.login-card p,
.panel p,
#server-time {
  color: var(--muted);
}

.form-stack {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 650;
}

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

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}

.primary,
.ghost {
  min-height: 40px;
  border-radius: 10px;
  padding: 0 16px;
  font-weight: 750;
}

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

.primary:hover {
  background: var(--blue-dark);
}

.ghost {
  color: #334155;
  background: #e8eef7;
}

.ghost.danger {
  color: var(--red);
  background: #fee2e2;
}

.message {
  min-height: 20px;
  margin-top: 12px;
  color: var(--red);
  font-size: 13px;
}

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

.topbar,
.list-toolbar,
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.topbar h1 {
  font-size: 30px;
}

.top-actions {
  display: flex;
  gap: 10px;
}

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

.stat-card,
.panel,
.license-card {
  background: var(--panel);
  border: 1px solid rgba(219, 227, 239, .9);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .05);
}

.stat-card {
  padding: 18px;
}

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

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

.panel {
  padding: 20px;
  margin-bottom: 18px;
}

.create-grid {
  display: grid;
  grid-template-columns: 130px 130px 1fr auto;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
}

.new-license {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  color: #1e3a8a;
  background: #eff6ff;
  font-weight: 800;
  word-break: break-all;
}

.list-toolbar {
  margin-bottom: 16px;
}

.list-toolbar p {
  margin: 6px 0 0;
  font-size: 13px;
}

#search-input {
  max-width: 320px;
}

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

.license-card {
  overflow: hidden;
}

.license-main {
  display: grid;
  grid-template-columns: 1.4fr .8fr .8fr .8fr auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
}

.license-key {
  font-size: 17px;
  font-weight: 850;
}

.license-note {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.pill.active {
  color: #047857;
  background: #d1fae5;
}

.pill.revoked,
.pill.expired {
  color: #b91c1c;
  background: #fee2e2;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  display: block;
  margin-top: 4px;
  font-weight: 800;
}

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

.small-button {
  min-height: 32px;
  border-radius: 8px;
  padding: 0 10px;
  color: #334155;
  background: #eef2f7;
  font-size: 12px;
  font-weight: 800;
}

.small-button.red {
  color: var(--red);
  background: #fee2e2;
}

.small-button.green {
  color: var(--green);
  background: #d1fae5;
}

.device-list {
  display: none;
  border-top: 1px solid var(--line);
  background: #f8fafc;
}

.license-card.open .device-list {
  display: block;
}

.device-row {
  display: grid;
  grid-template-columns: 1.1fr .7fr .8fr .8fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid #e6edf6;
  font-size: 13px;
}

.device-row:first-child {
  border-top: 0;
}

.device-title {
  font-weight: 800;
}

.online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: #94a3b8;
}

.online-dot.on {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(5, 150, 105, .12);
}

.empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 12px;
  color: #fff;
  background: #0f172a;
  box-shadow: var(--shadow);
  font-size: 13px;
}

@media (max-width: 900px) {
  .stats-grid,
  .create-grid,
  .license-main,
  .device-row {
    grid-template-columns: 1fr;
  }

  .topbar,
  .list-toolbar,
  .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }

  #search-input {
    max-width: none;
  }

  .row-actions {
    justify-content: flex-start;
  }
}
