:root {
  --bg: #070a10;
  --panel: #101826;
  --panel-2: #162235;
  --line: #314760;
  --line-2: #7fd4ff;
  --text: #e8edf4;
  --muted: #9aa6b6;
  --gold: #ffd36a;
  --danger: #ff7a7a;
  --ok: #7af0b8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background:
    linear-gradient(90deg, rgba(127, 212, 255, .05) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(0deg, rgba(127, 212, 255, .04) 1px, transparent 1px) 0 0 / 18px 18px,
    #070a10;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
.link-button {
  min-height: 44px;
  border: 0;
  cursor: pointer;
  text-decoration: none;
}

input,
textarea,
select {
  width: 100%;
  color: var(--text);
  background: #0b111c;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

input {
  height: 44px;
  padding: 0 12px;
}

select {
  height: 44px;
  padding: 0 36px 0 12px;
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 18px) 18px / 6px 6px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 12px) 18px / 6px 6px no-repeat,
    #0b111c;
}

textarea {
  min-height: 138px;
  padding: 12px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--line-2);
  box-shadow: 0 0 0 3px rgba(127, 212, 255, .16);
}

label span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
p {
  margin-top: 0;
}

.hidden {
  display: none !important;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(320px, 420px);
  width: min(1040px, 100%);
  min-height: 620px;
  border: 1px solid var(--line);
  background: rgba(10, 15, 24, .92);
  box-shadow: 10px 10px 0 #03060b;
}

.brand-panel {
  display: flex;
  align-items: end;
  min-height: 420px;
  padding: 42px;
  background:
    linear-gradient(180deg, rgba(7, 10, 16, .25), rgba(7, 10, 16, .92)),
    url("/public/cover.png") center / cover;
}

.brand-copy {
  max-width: 520px;
}

.brand-copy h1 {
  margin-bottom: 12px;
  color: var(--line-2);
  font-size: clamp(34px, 6vw, 68px);
}

.brand-copy p {
  max-width: 520px;
  color: #dce7f4;
  line-height: 1.8;
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 3px;
}

.auth-panel,
.admin-login,
.tool-band,
.table-section {
  background: linear-gradient(180deg, var(--panel), #0b111c);
  border: 1px solid var(--line);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 34px;
}

.stack {
  display: grid;
  gap: 18px;
}

.code-row {
  display: grid;
  grid-template-columns: 1fr 126px;
  align-items: end;
  gap: 12px;
}

.primary,
.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0 18px;
  color: #071018;
  background: var(--line-2);
  font-weight: 700;
}

.secondary {
  color: var(--text);
  background: #1d2c42;
  border: 1px solid var(--line);
}

.primary:hover,
.secondary:hover {
  filter: brightness(1.08);
}

.text-button {
  min-height: 34px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.text-button:hover {
  color: var(--line-2);
}

.state-line,
.message,
.muted {
  color: var(--muted);
  line-height: 1.7;
}

.state-line {
  margin-bottom: 16px;
}

.message {
  margin-top: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #0b111c;
  border-radius: 6px;
}

.message.ok {
  color: var(--ok);
  border-color: rgba(122, 240, 184, .55);
}

.message.error {
  color: var(--danger);
  border-color: rgba(255, 122, 122, .55);
}

.admin-page {
  padding: 28px;
}

.admin-shell {
  width: min(1280px, 100%);
  margin: 0 auto;
}

.admin-header,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-header {
  margin-bottom: 22px;
}

.admin-header h1 {
  margin-bottom: 0;
  color: var(--line-2);
}

.admin-login {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 24px;
}

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

.stat {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.stat b {
  display: block;
  margin-top: 8px;
  color: var(--line-2);
  font-size: 24px;
}

.tool-band {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 16px;
  margin-bottom: 16px;
  padding: 16px;
}

.generate-form {
  display: grid;
  grid-template-columns: 90px 120px 1fr 140px;
  align-items: end;
  gap: 12px;
}

.table-section {
  margin-top: 16px;
  padding: 16px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid rgba(49, 71, 96, .75);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #1d2c42;
  color: var(--muted);
}

.badge.ok {
  color: #092016;
  background: var(--ok);
}

.badge.warn {
  color: #251a00;
  background: var(--gold);
}

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

.row-actions button {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 5px;
}

.admin-header-pro {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 18px 0;
  background: rgba(7, 10, 16, .88);
  backdrop-filter: blur(12px);
}

.admin-header-pro h1 {
  font-size: clamp(28px, 4vw, 42px);
}

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

.admin-login-pro {
  margin-top: 48px;
  border-color: rgba(127, 212, 255, .35);
  box-shadow: 0 20px 70px rgba(0, 0, 0, .25);
}

.stats-grid-pro {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.stats-grid-pro .stat {
  position: relative;
  min-height: 96px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(19, 31, 48, .96), rgba(9, 14, 23, .98));
}

.stats-grid-pro .stat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--line-2);
}

.stat-green::before {
  background: var(--ok) !important;
}

.stat-red::before {
  background: var(--danger) !important;
}

.stat-amber::before {
  background: var(--gold) !important;
}

.stat-violet::before {
  background: #b59cff !important;
}

.stat-blue::before {
  background: #8db7ff !important;
}

.ops-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.1fr) minmax(320px, .9fr);
  gap: 16px;
  margin-bottom: 16px;
}

.ops-panel,
.table-section-pro {
  padding: 16px;
  background: linear-gradient(180deg, rgba(16, 24, 38, .96), rgba(8, 13, 22, .98));
  border: 1px solid var(--line);
}

.compact h2 {
  margin-bottom: 0;
}

.generate-panel {
  display: grid;
  gap: 14px;
}

.generate-form-pro {
  display: grid;
  grid-template-columns: 90px 120px minmax(180px, 1fr) 120px;
  align-items: end;
  gap: 12px;
}

.panel-actions {
  justify-content: flex-end;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 12px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.status-strip div {
  padding: 12px;
  border: 1px solid rgba(49, 71, 96, .78);
  background: #0b111c;
}

.status-strip span,
.table-count {
  color: var(--muted);
  font-size: 13px;
}

.status-strip b {
  display: block;
  margin-top: 6px;
  color: var(--text);
}

.table-section-pro {
  margin-top: 16px;
}

.admin-table {
  min-width: 1120px;
}

.admin-table th {
  padding-top: 14px;
  padding-bottom: 14px;
  color: #b8c5d8;
  background: rgba(9, 14, 23, .66);
}

.admin-table td {
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: rgba(127, 212, 255, .045);
}

.admin-table code {
  color: #dce7f4;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
}

.identity-cell {
  display: grid;
  gap: 4px;
}

.identity-cell b {
  color: #f3f7fb;
}

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

.action-cluster {
  flex-wrap: wrap;
  min-width: 300px;
}

.mini {
  min-height: 30px;
  padding: 0 9px;
  font-size: 13px;
}

.danger-soft {
  color: #ffd9d9;
  border-color: rgba(255, 122, 122, .45);
  background: rgba(96, 28, 34, .55);
}

.badge.danger {
  color: #fff0f0;
  background: rgba(255, 122, 122, .22);
  border: 1px solid rgba(255, 122, 122, .45);
}

.badge.ok-soft {
  color: var(--ok);
  background: rgba(122, 240, 184, .12);
  border: 1px solid rgba(122, 240, 184, .35);
}

.is-muted {
  opacity: .68;
}

.empty-state {
  padding: 28px 12px 10px;
  color: var(--muted);
  text-align: center;
}

.floating-message {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  min-width: min(360px, calc(100vw - 48px));
  margin-top: 0;
  box-shadow: 0 16px 60px rgba(0, 0, 0, .35);
}

@media (max-width: 860px) {
  .login-page,
  .admin-page {
    padding: 14px;
  }

  .auth-shell {
    grid-template-columns: 1fr;
  }

  .brand-panel {
    min-height: 240px;
    padding: 28px;
  }

  .auth-panel {
    padding: 24px;
  }

  .code-row,
  .tool-band,
  .generate-form,
  .generate-form-pro,
  .ops-grid,
  .filter-grid,
  .status-strip {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .admin-header-pro {
    position: static;
  }

  .admin-actions {
    justify-content: stretch;
  }

  .admin-actions > * {
    flex: 1 1 auto;
  }

  .floating-message {
    right: 14px;
    bottom: 14px;
    min-width: calc(100vw - 28px);
  }
}

/* Admin console v2 */
.admin-console {
  min-height: 100vh;
  padding: 0;
  color: #1c222b;
  background: #eef2f6;
}

.admin-console .eyebrow {
  margin-bottom: 8px;
  color: #b88a2d;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 3px;
}

.admin-console h1,
.admin-console h2,
.admin-console p {
  margin-top: 0;
}

.admin-root {
  min-height: 100vh;
}

.admin-auth-gate {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(14, 17, 21, .92), rgba(14, 17, 21, .72)),
    url("/public/cover.png") center / cover;
}

.admin-auth-card {
  width: min(420px, 100%);
  padding: 34px;
  color: #f7f8fa;
  background: rgba(18, 22, 29, .94);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  box-shadow: 0 26px 90px rgba(0, 0, 0, .34);
}

.admin-auth-card h1 {
  margin-bottom: 26px;
  font-size: 30px;
}

.admin-console label span {
  color: #647184;
  font-weight: 700;
}

.admin-auth-card label span {
  color: #b8c2ce;
}

.admin-console input,
.admin-console textarea,
.admin-console select {
  color: #1d2430;
  background-color: #ffffff;
  border: 1px solid #d5dbe4;
  border-radius: 8px;
}

.admin-console input:focus,
.admin-console textarea:focus,
.admin-console select:focus {
  border-color: #0f766e;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .14);
}

.admin-auth-card input {
  color: #f7f8fa;
  background: #10151d;
  border-color: #334155;
}

.admin-console select {
  background:
    linear-gradient(45deg, transparent 50%, #647184 50%) calc(100% - 18px) 18px / 6px 6px no-repeat,
    linear-gradient(135deg, #647184 50%, transparent 50%) calc(100% - 12px) 18px / 6px 6px no-repeat,
    #ffffff;
}

.admin-console .primary,
.admin-console .secondary,
.admin-console .link-button {
  min-height: 40px;
  border-radius: 8px;
  font-weight: 800;
}

.admin-console .primary {
  color: #ffffff;
  background: #0f766e;
}

.admin-console .secondary {
  color: #1f2937;
  background: #ffffff;
  border: 1px solid #d5dbe4;
}

.admin-console .primary:hover,
.admin-console .secondary:hover {
  filter: none;
  transform: translateY(-1px);
}

.admin-app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 22px;
  color: #f7f8fa;
  background: #111418;
  border-right: 1px solid #262b33;
}

.admin-brand {
  display: grid;
  gap: 8px;
  padding-bottom: 24px;
  border-bottom: 1px solid #2a3038;
}

.admin-brand span {
  color: #f3c969;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 4px;
}

.admin-brand strong {
  font-size: 24px;
}

.admin-nav {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}

.admin-nav button {
  justify-content: flex-start;
  min-height: 44px;
  padding: 0 14px;
  color: #bdc5d0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
  font-weight: 800;
}

.admin-nav button:hover,
.admin-nav button.is-active {
  color: #ffffff;
  background: #1c232d;
  border-color: #343c48;
}

.admin-nav button.is-active {
  box-shadow: inset 3px 0 0 #5eead4;
}

.admin-side-metrics {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.admin-side-metrics div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: #181d24;
  border: 1px solid #2c333d;
  border-radius: 8px;
}

.admin-side-metrics span {
  color: #9da8b7;
  font-size: 13px;
}

.admin-side-metrics b {
  color: #f7f8fa;
}

.admin-workspace {
  min-width: 0;
  padding: 28px;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.admin-topbar h1 {
  margin-bottom: 0;
  color: #141922;
  font-size: clamp(26px, 4vw, 38px);
}

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

.admin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.admin-kpi {
  display: grid;
  gap: 8px;
  min-height: 126px;
  padding: 18px;
  background: #ffffff;
  border: 1px solid #dde3ec;
  border-radius: 8px;
  box-shadow: 0 14px 40px rgba(31, 41, 55, .06);
}

.admin-kpi span {
  color: #647184;
  font-size: 13px;
  font-weight: 800;
}

.admin-kpi b {
  color: #141922;
  font-size: 34px;
  line-height: 1;
}

.admin-kpi small {
  align-self: end;
  color: #7a8696;
}

.admin-kpi-green {
  border-top: 4px solid #22c55e;
}

.admin-kpi-red {
  border-top: 4px solid #fb7185;
}

.admin-kpi-teal {
  border-top: 4px solid #14b8a6;
}

.admin-kpi-amber {
  border-top: 4px solid #f59e0b;
}

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

.admin-panel {
  margin-bottom: 18px;
  padding: 20px;
  background: #ffffff;
  border: 1px solid #dde3ec;
  border-radius: 8px;
  box-shadow: 0 14px 40px rgba(31, 41, 55, .06);
}

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

.admin-panel-head h2 {
  margin-bottom: 0;
  color: #141922;
  font-size: 22px;
}

.admin-count {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  color: #334155;
  background: #f1f5f9;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 900;
}

.admin-status-stack {
  display: grid;
  gap: 10px;
}

.admin-status-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  background: #f7f9fc;
  border: 1px solid #e4e9f0;
  border-radius: 8px;
}

.admin-status-item span {
  color: #647184;
  font-weight: 800;
}

.admin-status-item b {
  color: #141922;
  font-size: 22px;
}

.admin-status-item small {
  color: #0f766e;
  font-weight: 900;
}

.admin-filter-bar,
.admin-generator {
  display: grid;
  grid-template-columns: minmax(260px, 1.5fr) minmax(160px, .8fr) minmax(160px, .8fr);
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.cdkey-filter-bar {
  grid-template-columns: minmax(280px, 1fr) minmax(180px, 240px);
}

.admin-generator {
  grid-template-columns: minmax(110px, 150px) minmax(120px, 160px) minmax(240px, 1fr) 120px;
}

.admin-generated-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.admin-generated-box textarea {
  min-height: 112px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
}

.admin-generated-box .row-actions {
  flex-direction: column;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid #e0e6ef;
  border-radius: 8px;
}

.admin-data-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  background: #ffffff;
}

.admin-data-table th,
.admin-data-table td {
  padding: 14px 12px;
  color: #273142;
  border-bottom: 1px solid #e7ebf2;
  text-align: left;
  white-space: nowrap;
}

.admin-data-table th {
  color: #647184;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 900;
}

.admin-data-table tr:last-child td {
  border-bottom: 0;
}

.admin-data-table tr:hover td {
  background: #f9fbfd;
}

.admin-data-table code {
  color: #0f172a;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

.admin-identity,
.admin-time-cell {
  display: grid;
  gap: 4px;
}

.admin-identity b {
  color: #111827;
  font-size: 15px;
}

.admin-identity span,
.admin-time-cell span {
  color: #647184;
  font-size: 12px;
}

.admin-action-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 330px;
}

.admin-console .mini {
  min-height: 30px;
  padding: 0 9px;
  border-radius: 6px;
  font-size: 12px;
}

.admin-console .danger-soft {
  color: #9f1239;
  border-color: #fecdd3;
  background: #fff1f2;
}

.admin-console .badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  color: #475569;
  background: #eef2f7;
  border: 1px solid #dde3ec;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.admin-console .badge.ok {
  color: #065f46;
  background: #dcfce7;
  border-color: #bbf7d0;
}

.admin-console .badge.warn {
  color: #92400e;
  background: #fef3c7;
  border-color: #fde68a;
}

.admin-console .badge.danger {
  color: #9f1239;
  background: #ffe4e6;
  border-color: #fecdd3;
}

.admin-console .badge.ok-soft {
  color: #0f766e;
  background: #ccfbf1;
  border-color: #99f6e4;
}

.admin-console .muted {
  color: #7a8696;
}

.admin-console .is-muted {
  opacity: .62;
}

.admin-console .empty-state {
  padding: 28px 12px 10px;
  color: #7a8696;
  text-align: center;
}

.admin-console .floating-message {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  min-width: min(360px, calc(100vw - 48px));
  margin-top: 0;
  color: #334155;
  background: #ffffff;
  border-color: #d5dbe4;
  border-radius: 8px;
  box-shadow: 0 16px 60px rgba(15, 23, 42, .18);
}

.admin-console .floating-message.ok {
  color: #065f46;
  border-color: #bbf7d0;
}

.admin-console .floating-message.error {
  color: #9f1239;
  border-color: #fecdd3;
}

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

  .admin-sidebar {
    position: static;
    height: auto;
  }

  .admin-nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .admin-side-metrics {
    grid-template-columns: repeat(3, 1fr);
    margin-top: 18px;
  }

  .admin-kpi-grid,
  .admin-overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .admin-workspace,
  .admin-sidebar {
    padding: 16px;
  }

  .admin-topbar,
  .admin-panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-actions,
  .admin-actions > *,
  .admin-nav,
  .admin-side-metrics,
  .admin-kpi-grid,
  .admin-overview-grid,
  .admin-filter-bar,
  .cdkey-filter-bar,
  .admin-generator,
  .admin-generated-box {
    grid-template-columns: 1fr;
  }

  .admin-actions {
    display: grid;
    width: 100%;
  }

  .admin-generated-box .row-actions {
    flex-direction: row;
  }

  .admin-console .floating-message {
    right: 14px;
    bottom: 14px;
    min-width: calc(100vw - 28px);
  }
}
