:root {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --ink: #14201d;
  --muted: #64756f;
  --line: #e1e8e5;
  --line-strong: #cbd8d3;
  --brand: #1f766b;
  --brand-dark: #155a52;
  --brand-soft: #e7f3f0;
  --amber: #a86400;
  --amber-soft: #fff4df;
  --blue: #2363a8;
  --blue-soft: #e8f1fb;
  --red: #b13b35;
  --red-soft: #fdeceb;
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 32px rgba(20, 55, 48, 0.07);
  --shadow-soft: 0 2px 10px rgba(20, 55, 48, 0.05);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
    system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1000px 500px at 10% -10%, #e3f2ed 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, #eef4ff 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

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

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

code {
  background: #edf2f0;
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 0.9em;
}

/* ---------- Shell ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(225, 232, 229, 0.9);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
}

.brand:hover {
  color: var(--ink);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(150deg, var(--brand), #2b9486);
  color: #fff;
  box-shadow: 0 5px 14px rgba(31, 118, 107, 0.28);
}

.brand-mark svg {
  width: 21px;
  height: 21px;
}

.brand strong {
  display: block;
  font-size: 15px;
  letter-spacing: 0.01em;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar-note {
  color: var(--muted);
  font-size: 12.5px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 5px 11px;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-logout {
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--muted);
}

[hidden] {
  display: none !important;
}

.app {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 56px;
  flex: 1;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  padding: 0 24px 28px;
}

.loading-screen {
  min-height: 45vh;
  display: grid;
  place-content: center;
  justify-items: center;
  color: var(--muted);
}

/* ---------- Common bits ---------- */

.page-head {
  margin-bottom: 24px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13.5px;
  margin-bottom: 12px;
}

.back-link:hover {
  color: var(--brand);
}

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

h1 {
  font-size: clamp(26px, 3.4vw, 38px);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.eyebrow {
  color: var(--brand);
  font-weight: 650;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.lede {
  color: var(--muted);
  max-width: 660px;
  margin-bottom: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 15px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  transition: border-color 0.15s ease, background 0.15s ease,
    transform 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
  background: #f7fbfa;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 6px 16px rgba(31, 118, 107, 0.2);
}

.btn-primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover {
  background: #f0f5f3;
  border-color: transparent;
}

.btn-danger {
  color: var(--red);
}

.btn-danger:hover {
  color: var(--red);
  border-color: #e5b9b6;
  background: #fff8f7;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(31, 118, 107, 0.2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Home ---------- */

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 28px;
  padding: 18px 0 28px;
}

.hero p {
  margin-bottom: 0;
}

.hero-stat {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
}

.stat {
  min-width: 104px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(225, 232, 229, 0.9);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-soft);
}

.stat strong {
  display: block;
  font-size: 24px;
  line-height: 1.2;
}

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

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 8px 0 14px;
}

.section-title h2 {
  margin: 0;
  font-size: 16px;
}

.section-title span {
  color: var(--muted);
  font-size: 12.5px;
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.type-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-soft);
  color: var(--ink);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease,
    border-color 0.18s ease;
}

.type-card::after {
  content: "";
  position: absolute;
  width: 150px;
  height: 150px;
  right: -60px;
  top: -60px;
  border-radius: 50%;
  background: var(--brand-soft);
  opacity: 0.65;
  transition: transform 0.25s ease;
}

.type-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: #bcd6cf;
  color: var(--ink);
}

.type-card:hover::after {
  transform: scale(1.12);
}

.type-icon {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--brand-soft);
  color: var(--brand);
}

.type-icon svg {
  width: 23px;
  height: 23px;
}

.type-card-body {
  position: relative;
  z-index: 1;
  flex: 1;
}

.type-card h3 {
  font-size: 18px;
  margin: 0 0 6px;
}

.type-card p {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  background: #f8fbfa;
  color: #3d534d;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
}

.type-card-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: var(--brand);
  font-weight: 600;
  font-size: 13.5px;
}

.type-card-footer .count {
  color: var(--muted);
  font-weight: 400;
  font-size: 12.5px;
}

.type-card-footer > span:last-child {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.type-card-footer svg {
  width: 18px;
  height: 18px;
}

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

.empty-panel strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

/* ---------- Type page ---------- */

.type-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  border: 1px solid #cfe4de;
  background: rgba(231, 243, 240, 0.7);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 13px;
  color: #38544d;
}

.tips span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.tips svg {
  width: 15px;
  height: 15px;
  color: var(--brand);
  flex-shrink: 0;
}

.dropzone {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  border: 1.5px dashed #b7cec7;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  padding: 22px 26px;
  margin-bottom: 18px;
  transition: border-color 0.15s ease, background 0.15s ease,
    transform 0.15s ease;
  cursor: pointer;
}

.dropzone:hover,
.dropzone.is-dragging {
  border-color: var(--brand);
  background: #f4fbf9;
}

.dropzone.is-dragging {
  transform: scale(1.003);
}

.dropzone.is-busy {
  pointer-events: none;
  opacity: 0.75;
}

.dropzone-icon {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 15px;
  background: var(--brand-soft);
  color: var(--brand);
  flex-shrink: 0;
}

.dropzone-icon svg {
  width: 25px;
  height: 25px;
}

.dropzone-text {
  flex: 1;
  min-width: 0;
}

.dropzone-text strong {
  display: block;
  font-size: 15px;
  margin-bottom: 2px;
}

.dropzone-text span {
  color: var(--muted);
  font-size: 12.5px;
}

.progress-panel {
  display: none;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-soft);
}

.progress-panel.is-visible {
  display: flex;
}

.progress-track {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: #e8efec;
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #40a999);
  transition: width 0.25s ease;
}

.progress-label {
  min-width: 0;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46%;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-size: 16px;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #eef3f1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.panel-actions {
  display: flex;
  gap: 6px;
}

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

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

thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #fafcfb;
  border-bottom: 1px solid var(--line);
  padding: 11px 16px;
  white-space: nowrap;
}

tbody td {
  border-bottom: 1px solid #edf2f0;
  padding: 10px 16px;
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: #fbfdfc;
}

.cell-thumb {
  width: 78px;
}

.thumb-btn {
  display: block;
  width: 46px;
  height: 46px;
  border-radius: 9px;
  border: 1px solid var(--line);
  padding: 0;
  overflow: hidden;
  background: #f0f4f2;
}

.thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.thumb-btn:hover img {
  transform: scale(1.06);
}

.cell-file {
  max-width: 170px;
}

.file-name {
  display: block;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-sub {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
}

.cell-field {
  min-width: 180px;
}

.cell-input {
  width: 100%;
  min-width: 140px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.cell-input:hover {
  background: #f6faf8;
  border-color: var(--line);
}

.cell-input:focus {
  outline: none;
  background: #fff;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 118, 107, 0.12);
}

.cell-input.is-saving {
  opacity: 0.6;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-success {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.badge-verified {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge-needs_review {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-failed {
  background: var(--red-soft);
  color: var(--red);
}

.row-note {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 3px;
  max-width: 170px;
}

.cell-time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.cell-actions {
  text-align: right;
  width: 64px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.icon-btn:hover {
  color: var(--red);
  background: var(--red-soft);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

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

.table-empty strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

.table-loading {
  padding: 34px !important;
  text-align: center;
  color: var(--muted);
}

/* ---------- Login ---------- */

.login-wrap {
  min-height: 58vh;
  display: grid;
  place-items: center;
  padding: 20px 0 48px;
}

.login-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 36px;
  box-shadow: var(--shadow);
}

.login-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(150deg, var(--brand), #2b9486);
  color: #fff;
  box-shadow: 0 8px 20px rgba(31, 118, 107, 0.25);
  margin-bottom: 20px;
}

.login-mark svg {
  width: 25px;
  height: 25px;
}

.login-card h1 {
  font-size: 27px;
  margin-bottom: 8px;
}

.login-card .lede {
  font-size: 14px;
  margin-bottom: 24px;
}

.login-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 7px;
}

.login-input-row {
  position: relative;
  display: flex;
}

.login-input-row input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: #fbfdfc;
  padding: 12px 64px 12px 13px;
  font-size: 14.5px;
  letter-spacing: 0.01em;
}

.login-input-row input:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(31, 118, 107, 0.12);
}

.toggle-token {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 12.5px;
}

.toggle-token:hover {
  background: #eef4f2;
  color: var(--brand-dark);
}

.login-error {
  min-height: 21px;
  margin: 8px 0;
  color: var(--red);
  font-size: 13px;
}

.login-submit {
  width: 100%;
  padding: 12px 16px;
  font-size: 14.5px;
}

.login-hint {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(12, 26, 23, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  animation: fade-in 0.15s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.modal {
  display: flex;
  flex-direction: column;
  width: min(860px, 100%);
  max-height: min(88vh, 900px);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(5, 22, 18, 0.35);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0 0 2px;
  font-size: 16px;
}

.modal-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  word-break: break-all;
}

.modal-close {
  border: 1px solid var(--line);
  background: #fff;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.modal-close:hover {
  background: #f4f8f6;
  color: var(--ink);
}

.modal-body {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 0;
  overflow: auto;
}

.preview-pane {
  background: #eef3f1;
  padding: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
}

.preview-pane img {
  max-width: 100%;
  max-height: 66vh;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(10, 35, 29, 0.18);
}

.raw-pane {
  padding: 18px;
  overflow: auto;
  border-left: 1px solid var(--line);
}

.raw-pane h4 {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 10px;
}

.raw-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.raw-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  background: #f8fbfa;
  border: 1px solid #eaf0ee;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  word-break: break-all;
}

.raw-list li span:last-child {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.raw-empty {
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 80;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  background: #14201d;
  color: #fff;
  border-radius: 11px;
  padding: 10px 18px;
  font-size: 13.5px;
  box-shadow: 0 12px 30px rgba(8, 25, 21, 0.28);
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: min(90vw, 520px);
  text-align: center;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-error {
  background: #8f2e29;
}

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .app {
    padding: 22px 16px 42px;
  }

  .login-card {
    padding: 26px 22px;
    border-radius: 20px;
  }

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

  .topbar-inner {
    padding: 10px 16px;
  }

  .topbar-note {
    display: none;
  }

  .hero {
    display: block;
    padding-top: 4px;
  }

  .hero-stat {
    margin-top: 18px;
  }

  .type-grid {
    grid-template-columns: 1fr;
  }

  .dropzone {
    flex-wrap: wrap;
    padding: 18px;
  }

  .dropzone .btn {
    width: 100%;
  }

  .progress-label {
    max-width: 62%;
  }

  .modal-body {
    grid-template-columns: 1fr;
  }

  .preview-pane img {
    max-height: 42vh;
  }

  .raw-pane {
    border-left: none;
    border-top: 1px solid var(--line);
  }

  .cell-time,
  .th-time {
    display: none;
  }
}
