:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #15202b;
  --muted: #64748b;
  --line: #d9e2ec;
  --line-strong: #c7d2df;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #e4f3f1;
  --nav: #111827;
  --nav-soft: #1f2937;
  --blue: #2563eb;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --ok: #087443;
  --ok-soft: #dcfce7;
  --shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
}

.shell {
  width: min(1040px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 32px 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.narrow {
  width: min(100%, 460px);
  justify-self: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.mark {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--nav);
  color: #d6fff4;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.stack {
  display: grid;
  gap: 12px;
}

.form-row {
  display: grid;
  gap: 7px;
}

label {
  font-weight: 700;
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  font: inherit;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 148px;
  resize: vertical;
  line-height: 1.55;
  text-transform: uppercase;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  accent-color: var(--accent);
}

input[type="file"] {
  border: 0;
  padding: 0;
  min-height: auto;
}

input:focus,
textarea:focus {
  outline: 3px solid rgba(37, 99, 235, 0.14);
  border-color: var(--blue);
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  font: inherit;
  font-weight: 800;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.secondary {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.secondary:hover {
  background: #cfe9e5;
}

.danger {
  color: #fff;
  background: var(--danger);
}

.danger:hover {
  background: #8f1d14;
}

.danger.ghost {
  color: var(--danger);
  background: var(--danger-soft);
}

.danger.ghost:hover {
  background: #fecdca;
}

.ghost {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.hint {
  font-size: 12px;
  line-height: 1.5;
}

.status {
  min-height: 22px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.status.ok {
  color: var(--ok);
}

.status.error {
  color: var(--danger);
}

.batch-results {
  max-height: 220px;
  margin-top: 12px;
  display: grid;
  gap: 8px;
  overflow: auto;
}

.batch-result {
  min-height: 36px;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(0, 1.1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--panel-soft);
  font-size: 13px;
}

.batch-result span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.batch-result .code {
  overflow: hidden;
  text-overflow: ellipsis;
}

.batch-result.ok {
  border-color: #bbf7d0;
  background: var(--ok-soft);
}

.batch-result.error {
  border-color: #fecaca;
  background: var(--danger-soft);
}

.badge {
  min-width: 34px;
  height: 28px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-weight: 800;
}

.status-pill {
  min-width: 64px;
  height: 28px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.ready {
  color: var(--ok);
  background: var(--ok-soft);
}

.status-pill.used {
  color: #475569;
  background: #e2e8f0;
}

.code {
  font-family: Consolas, "Courier New", monospace;
  font-weight: 800;
}

.admin-page {
  background: #eef2f6;
}

.admin-page .admin-shell {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  align-content: stretch;
  gap: 0;
}

.admin-sidebar {
  min-height: 100vh;
  padding: 28px 22px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  align-content: start;
  gap: 18px;
  background: var(--nav);
  color: #f8fafc;
  box-shadow: 12px 0 30px rgba(15, 23, 42, 0.16);
  z-index: 1;
}

.admin-brand {
  margin-bottom: 4px;
}

.admin-brand .mark {
  background: #0f766e;
  color: #ecfeff;
}

.admin-brand h1 {
  color: #fff;
}

.admin-brand p,
.admin-sidebar .hint,
.admin-sidebar .panel-heading p,
.admin-sidebar .status {
  color: #cbd5e1;
}

.login-panel,
.security-panel {
  border: 1px solid rgba(203, 213, 225, 0.18);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.06);
}

.admin-sidebar label {
  color: #e5edf6;
}

.admin-sidebar input {
  border-color: rgba(203, 213, 225, 0.2);
  background: #0f172a;
  color: #fff;
}

.admin-sidebar input:focus {
  outline-color: rgba(45, 212, 191, 0.22);
  border-color: #5eead4;
}

.admin-app {
  display: grid;
  align-content: start;
  gap: 18px;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #dbe7f3;
  background: transparent;
  border: 1px solid rgba(203, 213, 225, 0.16);
  text-align: left;
}

.nav-tab strong {
  min-width: 28px;
  height: 24px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  padding: 0 8px;
  color: #99f6e4;
  background: rgba(45, 212, 191, 0.12);
  font-size: 12px;
}

.nav-tab:hover,
.nav-tab.active {
  color: #fff;
  border-color: rgba(45, 212, 191, 0.42);
  background: rgba(15, 118, 110, 0.35);
}

.panel-heading {
  margin-bottom: 14px;
}

.panel-heading h2 {
  color: #fff;
  font-size: 15px;
}

.compact {
  gap: 11px;
}

.admin-sidebar .secondary {
  color: #ccfbf1;
  background: rgba(20, 184, 166, 0.18);
}

.admin-sidebar .secondary:hover {
  background: rgba(20, 184, 166, 0.28);
}

.admin-sidebar .danger.ghost {
  width: 100%;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
}

.admin-sidebar .danger.ghost:hover {
  background: rgba(239, 68, 68, 0.2);
}

.admin-sidebar .status.ok {
  color: #86efac;
}

.admin-sidebar .status.error {
  color: #fca5a5;
}

.admin-main {
  min-width: 0;
  min-height: 100vh;
  padding: 28px;
  display: grid;
  align-content: start;
  gap: 18px;
}

.admin-topbar,
.upload-panel,
.data-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.06);
}

.admin-topbar {
  min-height: 98px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.title-block {
  min-width: 220px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.title-block h2 {
  font-size: 24px;
}

.toolbar {
  width: min(100%, 560px);
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 10px;
}

.upload-panel {
  padding: 16px 18px;
}

.upload-form {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(260px, 420px) auto;
  align-items: center;
  gap: 16px;
}

.upload-copy h2 {
  font-size: 17px;
}

.file-picker {
  min-height: 46px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel-soft);
}

.file-picker span {
  color: var(--text);
  font-size: 13px;
}

.file-picker small {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.data-panel {
  min-width: 0;
  overflow: hidden;
}

.section-head {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: #fff;
}

th,
td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

th {
  color: #52616f;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
}

tbody tr:hover {
  background: #f9fbfd;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.empty-cell {
  height: 86px;
  color: var(--muted);
  text-align: center;
}

.mini-actions {
  display: flex;
  gap: 8px;
}

.mini-actions button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

@media (max-width: 980px) {
  .admin-page .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    min-height: auto;
    position: static;
    grid-template-rows: auto;
    box-shadow: none;
  }

  .admin-main {
    min-height: auto;
    padding: 18px;
  }

  .admin-topbar,
  .upload-form {
    grid-template-columns: 1fr;
  }

  .admin-topbar {
    display: grid;
  }

  .toolbar {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 24px, 1040px);
    padding: 24px 0;
  }

  .panel {
    padding: 18px;
  }

  .actions,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    padding: 22px 16px;
  }

  .admin-main {
    padding: 14px;
    gap: 14px;
  }

  .section-head,
  .inline-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .file-picker {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 12px;
  }
}
