:root {
  --bg: #f6f4ef;
  --surface: #fbfaf7;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #e4e8ef;
  --line-strong: #d5dce7;
  --text: #172033;
  --muted: #687386;
  --muted-2: #8a94a6;
  --navy: #0d1f3a;
  --navy-2: #132b4c;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #edf4ff;
  --teal: #13b8a6;
  --teal-soft: #e8fbf8;
  --indigo: #4658d9;
  --indigo-soft: #eef0ff;
  --success: #057a55;
  --success-bg: #e8f8f1;
  --danger: #c5292a;
  --danger-bg: #fff0f0;
  --warning: #b76b00;
  --warning-bg: #fff6df;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 28rem),
    linear-gradient(135deg, #fbfaf7 0%, #f1f5f9 52%, #eef7f5 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

a {
  color: var(--primary);
  text-decoration: none;
}

.muted {
  color: var(--muted-2);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
select:focus {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

input:disabled,
select:disabled {
  background: #f4f6f9;
  color: #9ca3af;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 14px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: #536176;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  background: #f7f9fc;
}

td {
  color: #344054;
}

tbody tr:hover td {
  background: #fbfdff;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(19, 43, 76, 0.94), rgba(9, 22, 43, 0.98)),
    var(--navy);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

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

.brand {
  margin-bottom: 30px;
  padding: 5px 6px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  flex: 0 0 auto;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.brand-title {
  font-weight: 850;
  font-size: 18px;
  letter-spacing: 0;
}

.brand-subtitle {
  margin-top: 2px;
  color: #9fb1c9;
  font-size: 12px;
  font-weight: 650;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 11px 13px 11px 16px;
  border-radius: 8px;
  color: #c7d2e4;
  font-weight: 750;
}

.nav-link::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-right: 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.55);
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-link.active::before {
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(19, 184, 166, 0.16);
}

.main {
  min-width: 0;
}

.topbar {
  min-height: 84px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 18px 34px;
  background: rgba(255, 255, 255, 0.78);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  backdrop-filter: blur(14px);
}

.page-kicker,
.eyebrow {
  color: var(--primary);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.page-title {
  margin-top: 3px;
  font-size: 24px;
  font-weight: 850;
}

.page-meta,
.card p,
.upload-card p,
.stat-note,
.filter-title span {
  color: var(--muted);
}

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

.admin-pill {
  padding: 8px 11px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: #2447a3;
  font-weight: 800;
}

.content {
  padding: 28px 34px 44px;
}

.site-footer,
.login-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.site-footer {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.site-footer a,
.login-footer a {
  color: var(--muted);
}

.site-footer a:hover,
.login-footer a:hover {
  color: var(--primary);
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
  padding: 24px;
  border: 1px solid rgba(213, 220, 231, 0.88);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(246, 250, 255, 0.92)),
    var(--panel);
  box-shadow: var(--shadow);
}

.workbench-copy h1 {
  margin: 8px 0 8px;
  font-size: 31px;
  line-height: 1.18;
  letter-spacing: 0;
}

.workbench-copy p {
  max-width: 680px;
  margin: 0;
  color: #596579;
  line-height: 1.7;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.quick-action {
  display: grid;
  align-content: center;
  min-height: 104px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.quick-action span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.quick-action strong {
  margin-top: 6px;
  color: var(--text);
  font-size: 15px;
}

.quick-action.primary {
  background: var(--navy-2);
  border-color: rgba(19, 43, 76, 0.82);
}

.quick-action.primary span {
  color: #b9d1ff;
}

.quick-action.primary strong {
  color: #fff;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card,
.card,
.upload-card,
.filter-card,
.login-panel {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(213, 220, 231, 0.92);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--line-strong);
}

.stat-card.accent-blue::before {
  background: var(--primary);
}

.stat-card.accent-teal::before {
  background: var(--teal);
}

.stat-card.accent-indigo::before {
  background: var(--indigo);
}

.stat-card.warning::before {
  background: #f59e0b;
}

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

.stat-value {
  margin-top: 8px;
  color: var(--text);
  font-size: 34px;
  line-height: 1;
  font-weight: 900;
}

.stat-note {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
}

.stat-card.warning .stat-value {
  color: var(--warning);
}

.grid.two,
.page-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.card,
.upload-card,
.filter-card {
  margin-bottom: 18px;
}

.card {
  padding: 0;
  overflow: hidden;
}

.card.narrow {
  max-width: 760px;
  padding-bottom: 22px;
}

.card-header {
  min-height: 62px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #fbfcfe);
}

.card-header h2,
.upload-card h2 {
  margin: 0;
  color: var(--text);
  font-size: 17px;
  font-weight: 850;
}

.card-header p,
.upload-card p {
  margin: 6px 0 0;
  line-height: 1.6;
}

.table-wrap {
  overflow-x: auto;
}

.empty {
  color: var(--muted-2);
  text-align: center;
}

.inline-form,
.upload-form,
.compact-form,
.actions,
.filter-card {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-form {
  padding: 18px 20px 20px;
}

.inline-form input {
  min-width: 280px;
}

.actions form {
  display: inline-flex;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 15px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 9px 18px rgba(37, 99, 235, 0.2);
}

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

.button.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--line-strong);
}

.button.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #f3c5c5;
}

.button.small {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 13px;
}

.button.full {
  width: 100%;
}

.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 850;
  background: #eef2f7;
  color: #475569;
}

.badge.success,
.badge.result-allow {
  background: var(--success-bg);
  color: var(--success);
  border-color: #bbe9d5;
}

.badge.danger,
.badge.result-error {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #f3c5c5;
}

.badge.result-deny {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: #f3d28e;
}

.badge.code-unused {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: #cfe0ff;
}

.badge.code-used {
  background: #eef2f7;
  color: #64748b;
  border-color: #dde4ee;
}

.upload-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  align-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(237, 244, 255, 0.7)),
    #fff;
}

.upload-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.upload-meta span,
.process-list span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #536176;
  font-size: 12px;
  font-weight: 800;
}

.alert {
  margin-bottom: 18px;
  padding: 13px 15px;
  border-radius: 10px;
  font-weight: 800;
}

.alert.success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #bbe9d5;
}

.alert.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #f3c5c5;
}

.filter-card {
  padding: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-title {
  min-width: 210px;
  display: grid;
  gap: 4px;
  margin-right: 8px;
}

.filter-title strong {
  font-size: 16px;
}

.filter-card > div:not(.filter-title) {
  display: grid;
  gap: 6px;
}

.filter-card label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.activation-code {
  margin: 20px;
  padding: 18px;
  border-radius: 12px;
  background: var(--navy);
  color: #fff;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0;
  word-break: break-all;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.card.narrow .button {
  margin-left: 20px;
}

.settings-list {
  display: grid;
  padding: 6px 20px 20px;
}

.settings-list div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.settings-list div:last-child {
  border-bottom: 0;
}

.text-success {
  color: var(--success);
}

.process-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 20px;
}

.login-body {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: center;
  justify-items: center;
  gap: 18px;
  padding: 28px 16px 18px;
  background:
    linear-gradient(90deg, rgba(244, 247, 252, 0.58), rgba(244, 247, 252, 0.28)),
    url("/static/login-bg.png") center / cover no-repeat;
}

.login-panel {
  width: min(560px, calc(100vw - 32px));
  padding: 28px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.13);
}

.login-brand {
  margin-bottom: 26px;
  gap: 18px;
}

.login-brand .brand-mark {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.11);
}

.login-brand h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.18;
}

.login-brand p {
  margin: 6px 0 0;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 9px;
}

.login-form label {
  color: #4b5563;
  font-weight: 800;
}

.login-footer {
  width: min(560px, calc(100vw - 32px));
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(8px);
}

@media (max-width: 1180px) {
  .workbench {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }

  .brand {
    margin-bottom: 14px;
    padding-bottom: 14px;
  }

  .nav {
    grid-template-columns: repeat(5, minmax(92px, 1fr));
    overflow-x: auto;
  }

  .nav-link {
    justify-content: center;
    padding: 10px;
  }

  .nav-link::before {
    display: none;
  }

  .topbar,
  .content {
    padding-left: 18px;
    padding-right: 18px;
  }

  .stats-grid,
  .grid.two,
  .page-grid {
    grid-template-columns: 1fr;
  }

  .upload-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    gap: 12px;
    padding-top: 16px;
    padding-bottom: 16px;
    flex-direction: column;
  }

  .workbench {
    padding: 18px;
  }

  .workbench-copy h1 {
    font-size: 24px;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .inline-form,
  .upload-form,
  .compact-form,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-form input {
    min-width: 0;
    width: 100%;
  }
}
