:root {
  --accent: #c45e5e;
  --accent-hover: #b04a4a;
  --accent-light: #fdf0f0;
  --accent-subtle: #f5dede;
  --bg: #f8f7f5;
  --surface: #ffffff;
  --border: #e8e5e0;
  --border-focus: #c45e5e;
  --text: #2d2a26;
  --text-secondary: #7a7570;
  --text-muted: #a8a29e;
  --success: #4a9e6d;
  --success-bg: #edf7f1;
  --error: #c44e4e;
  --error-bg: #fdf0f0;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(45,42,38,.06);
  --shadow-md: 0 4px 16px rgba(45,42,38,.08);
  --shadow-lg: 0 8px 32px rgba(45,42,38,.10);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font: "Noto Serif SC", "PingFang SC", "Microsoft YaHei", serif;
  --font-body: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Login ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(160deg, #faf5f2 0%, #f0e6e0 50%, #e8ddd6 100%);
}

.login-card {
  width: 400px;
  padding: 40px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-icon {
  font-size: 32px;
  margin-bottom: 8px;
  color: var(--accent);
}

.login-brand h1 {
  font-family: var(--font);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.login-card .field { margin-bottom: 20px; }

.login-card .btn-block { width: 100%; margin-top: 8px; }

.form-error {
  background: var(--error-bg);
  color: var(--error);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  animation: shake .3s var(--ease);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ── Fields ── */
.field label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.field small {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.optional {
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(196,94,94,.12);
}

/* ── File input ── */
.file-input-wrapper {
  position: relative;
}

.file-input-wrapper input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.file-input-display {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color .15s, background .15s;
  pointer-events: none;
}

.file-input-wrapper:hover .file-input-display {
  border-color: var(--accent);
  background: var(--accent-light);
}

.file-input-display.has-file {
  border-style: solid;
  border-color: var(--accent-subtle);
  background: var(--accent-light);
}

.file-icon { font-size: 20px; }

.file-text {
  font-size: 14px;
  color: var(--text-secondary);
}

.has-file .file-text { color: var(--accent); font-weight: 500; }

.photo-preview {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.photo-preview img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
}

/* ── Buttons ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 28px;
  font-size: 15px;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
}

.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-sm); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { background: #c4bfb8; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-ghost {
  background: none;
  border: 1.5px solid var(--border);
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}

.btn-ghost:hover { border-color: var(--text-secondary); color: var(--text); }

.btn-download {
  display: inline-block;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background .15s;
}

.btn-download:hover { background: var(--accent-subtle); }

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-icon {
  font-size: 20px;
  color: var(--accent);
}

.topbar h1 {
  font-family: var(--font);
  font-size: 18px;
  font-weight: 600;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

/* ── Main layout ── */
main {
  max-width: 720px;
  margin: 32px auto;
  padding: 0 24px;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  animation: fadeUp .4s var(--ease) both;
}

.card:nth-child(2) { animation-delay: .06s; }
.card:nth-child(3) { animation-delay: .12s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-header {
  margin-bottom: 24px;
}

.card-header h2 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}

.card-desc {
  font-size: 14px;
  color: var(--text-secondary);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: start;
}

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

.form-actions {
  margin-top: 24px;
}

/* ── Result card ── */
.result-card { transition: border-color .3s; }

.result-success { border-color: var(--success); }
.result-error { border-color: var(--error); }
.result-pending { border-color: var(--accent); }

.result-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.result-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

.result-detail {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.result-detail .btn-primary { margin-top: 14px; }

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

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

/* ── Table ── */
.table-wrap { overflow-x: auto; }

.record-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.record-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 0 12px 10px;
  border-bottom: 1.5px solid var(--border);
}

.record-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.record-table tr:last-child td { border-bottom: none; }
.record-table tr:hover td { background: rgba(196,94,94,.02); }

.td-time { white-space: nowrap; color: var(--text-secondary); font-size: 13px; }

.td-filename {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.td-row { color: var(--text-secondary); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-fail { background: var(--error-bg); color: var(--error); cursor: help; }

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

.empty-state {
  text-align: center;
  padding: 32px 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.empty-state p + p { margin-top: 4px; font-size: 13px; }
