:root {
  --black: #0d0d0d;
  --black-2: #171717;
  --ink: #1a1a1a;
  --muted: #6a6862;
  --line: #e6e3da;
  --bg: #f3f1eb;
  --paper: #fffcf7;
  --gold: #c4a35a;
  --gold-d: #9a7b32;
  --ok: #2c7a4b;
  --ok-bg: #e7f6ec;
  --warn: #9a5b12;
  --warn-bg: #fbf0dd;
  --err: #a32525;
  --err-bg: #fbeaea;
  --info: #1d4f8c;
  --info-bg: #e8f0fa;
  --sidebar: 248px;
  --shadow: 0 1px 2px rgba(16,16,16,.06), 0 8px 24px rgba(16,16,16,.04);
  --radius: 12px;
  --font: "Noto Sans CJK SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --thumb-w: 44px;
  --thumb-h: 62px;
  --thumb-lg-w: 120px;
  --thumb-lg-h: 168px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  letter-spacing: .01em;
}
a { color: inherit; }
img { max-width: 100%; display: block; }

/* Sidebar */
.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar);
  background: var(--black);
  color: #f4f4f4;
  display: flex; flex-direction: column;
  z-index: 20;
}
.brand {
  padding: 22px 22px 16px;
  background: #000;
  border-bottom: 3px solid var(--gold);
}
.brand img, .brand-img {
  width: 100%;
  height: auto;
  background: #000;
}
.brand-text {
  display: none;
  color: #fff;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1;
}
.brand-logo { text-decoration: none; display: block; }
.brand-sub {
  margin-top: 10px;
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: #cfc8b8;
}
.nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #d8d5ce;
  text-decoration: none;
  font-size: 14px;
}
.nav a:hover { background: #222; color: #fff; }
.nav a.active { background: #26211a; color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav .group-label {
  margin: 14px 12px 4px;
  font-size: 10px;
  letter-spacing: .18em;
  color: #8a857a;
  text-transform: uppercase;
}
.fx-chip {
  margin: 12px;
  padding: 10px 12px;
  background: #1a1a1a;
  border: 1px solid #2c2c2c;
  border-top: 2px solid var(--gold);
  border-radius: 10px;
  font-size: 12px;
  color: #cfc8b8;
}
.fx-chip strong { display: block; color: #fff; font-size: 16px; margin: 2px 0; font-variant-numeric: tabular-nums; }
.fx-chip .muted { color: #8a857a; font-size: 11px; }
.fx-chip .tag { color: var(--gold); }

/* Main */
.main {
  margin-left: var(--sidebar);
  min-height: 100vh;
  padding: 28px 32px 60px;
}
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px;
}
.page-head h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: .02em; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { display: inline-flex; margin: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--ink);
  background: var(--ink); color: #fff;
  padding: 8px 14px; border-radius: 8px;
  font-size: 13px; text-decoration: none; cursor: pointer;
  font-family: inherit; line-height: 1.2;
}
.btn:hover { background: #000; }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: #ece9e1; }
.btn-gold { background: var(--gold); border-color: var(--gold-d); color: #1a1408; font-weight: 650; }
.btn-gold:hover { background: #d4b56a; }
.btn-danger { background: transparent; color: var(--err); border-color: #e3b6b6; }
.btn-danger:hover { background: var(--err-bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Cards / panels */
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-h {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  font-weight: 650;
  gap: 12px;
}
.panel-b { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.stat { padding: 16px 18px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat a { text-decoration: none; }

/* Tables */
.table-wrap { overflow: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data th, table.data td {
  padding: 10px 12px; text-align: left; vertical-align: middle;
  border-bottom: 1px solid var(--line);
}
table.data th {
  font-size: 11px; letter-spacing: .06em; color: var(--muted);
  font-weight: 650; background: #faf8f3; white-space: nowrap;
}
table.data tbody tr:hover td { background: #fbf7ef; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .center { text-align: center; }
table.data a { text-underline-offset: 2px; }
table.data a:hover { color: var(--gold-d); }
table.data td.pick { width: 36px; text-align: center; }
table.data input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--gold-d); }

.thumb, .photo-ph.thumb {
  width: var(--thumb-w); height: var(--thumb-h);
  object-fit: cover;
  border-radius: 3px; background: #111; border: 1px solid var(--line);
  flex-shrink: 0;
}
.thumb-lg, .photo-ph.thumb-lg {
  width: var(--thumb-lg-w); height: var(--thumb-lg-h);
  object-fit: cover;
  border-radius: 4px; background: #111; border: 1px solid var(--line);
  flex-shrink: 0;
}
.thumbs { display: flex; gap: 6px; align-items: flex-start; }
.photo-ph {
  display: inline-flex; align-items: center; justify-content: center;
  background: #1a1a1a;
  color: #cfc8b8;
  border: 1px solid #2a2a2a;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .12em;
  text-align: center;
  line-height: 1.2;
  user-select: none;
}
.photo-ph.thumb-lg { font-size: 13px; letter-spacing: .16em; color: #e6dcc4; }
.photo-slot { display: flex; flex-direction: column; gap: 4px; }
.photo-slot .hint { text-align: center; }

.slot-pending {
  display: inline-block;
  min-width: 4.5em;
  padding: 3px 8px;
  border: 1px dashed #d5d1c6;
  border-radius: 4px;
  color: var(--muted);
  background: #faf8f3;
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
}

/* Badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 650; white-space: nowrap;
}
.st-received { background: #eee; color: #444; }
.st-pending_ship { background: var(--info-bg); color: var(--info); }
.st-shipped { background: #ece7fa; color: #4c2d9e; }
.st-grading { background: var(--warn-bg); color: var(--warn); }
.st-graded { background: var(--ok-bg); color: var(--ok); }
.st-returned { background: #e6f4f4; color: #1c6b6b; }
.st-delivered { background: #ececec; color: #333; }
.pay-unpaid { background: var(--err-bg); color: var(--err); }
.pay-partial { background: var(--warn-bg); color: var(--warn); }
.pay-paid { background: var(--ok-bg); color: var(--ok); }
.tag-sample { background: #111; color: #f3e6c0; font-size: 10px; letter-spacing: .08em; }

/* Forms */
form .row { display: grid; gap: 12px 16px; margin-bottom: 14px; }
form .row.cols-2 { grid-template-columns: 1fr 1fr; }
form .row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
form .row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.f, label.f { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.f > span, label.f > span { font-weight: 650; }
input[type=text], input[type=number], input[type=date], input[type=search],
input[type=tel], input[type=password], select, textarea {
  font-family: inherit; font-size: 14px; color: var(--ink);
  border: 1px solid #d5d1c6; background: #fff;
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid #e6d5a4; border-color: var(--gold);
}
.hint { font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.filterbar {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: end;
}
.filterbar label.f, .filterbar .f { min-width: 160px; }
.form-section-title {
  margin: 18px 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.photo-field {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 12px;
  background: #faf8f3;
  border: 1px dashed #d5d1c6;
  border-radius: 10px;
}
.photo-field .preview,
.photo-preview { flex-shrink: 0; }
.photo-actions { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.photo-actions input[type=file] { width: 100%; font-size: 13px; }

/* Flash / banner */
.flashes { margin-bottom: 16px; display: grid; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 8px; font-size: 13px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--err); }
.flash a { color: inherit; font-weight: 650; }
.banner {
  background: #111; color: #f3e6c0;
  padding: 8px 14px; border-radius: 8px;
  font-size: 13px; margin-bottom: 16px;
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
}
.banner a { color: var(--gold); }

/* Empty */
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}
.empty-state .empty-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 8px;
  letter-spacing: .02em;
}
.empty-state p { margin: 0 auto 16px; max-width: 36em; font-size: 13px; line-height: 1.6; }
.empty-state .actions { justify-content: center; }

/* Invoice preview on screen */
.invoice-sheet { overflow: visible; }
.invoice-sheet > .panel-b { padding: 14px 12px 12px; }
.invoice-meta { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px 24px; padding: 4px 0 16px; font-size: 13px; }
.invoice-meta .k { color: var(--muted); font-size: 11px; letter-spacing: .04em; margin-bottom: 2px; }
.invoice-meta .v-strong { font-weight: 700; font-variant-numeric: tabular-nums; }
.invoice-hero {
  background: #000; color: #fff; border-radius: var(--radius) var(--radius) 0 0;
  padding: 18px 22px; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 3px solid var(--gold);
  gap: 16px;
}
.invoice-hero img { height: 52px; width: auto; background: #000; }
.invoice-hero .inv-no { text-align: right; }
.invoice-hero .inv-no .k { color: #cfc8b8; font-size: 11px; letter-spacing: .16em; }
.invoice-hero .inv-no .v { font-size: 20px; font-weight: 700; }
.invoice-hero .hero-sum {
  margin-top: 6px;
  font-size: 12px;
  color: #f3e6c0;
  font-variant-numeric: tabular-nums;
}
.invoice-table-wrap { overflow: auto; }
.invoice-table { width: 100%; min-width: 100%; }
.invoice-table th, .invoice-table td { padding: 8px 4px; }
.invoice-table .photo-zoom { display: inline-block; line-height: 0; cursor: zoom-in; }
.invoice-table .thumb, .invoice-table .photo-ph.thumb {
  width: 120px; height: 168px;
}
.invoice-table .photo-ph.thumb { font-size: 13px; letter-spacing: .1em; }
.photo-lightbox {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,.84);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; cursor: zoom-out;
}
.photo-lightbox img {
  max-width: min(92vw, 980px);
  max-height: 92vh;
  object-fit: contain;
  background: #111;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0,0,0,.45);
}
.invoice-table td:nth-child(3),
.invoice-table td:nth-child(4),
.invoice-table td:nth-child(5) { white-space: normal; }
.invoice-table thead th {
  position: sticky; top: 0; z-index: 2;
  white-space: nowrap;
  line-height: 1.25;
  font-size: 10px;
  text-align: center;
  vertical-align: bottom;
}
.invoice-table td { white-space: nowrap; }
.invoice-table td .hint { white-space: normal; }
.invoice-table .thumbs { white-space: normal; }
.invoice-table tfoot td {
  position: sticky; bottom: 0; z-index: 2;
}
.invoice-total-label {
  text-align: right;
  font-weight: 700;
  background: #111 !important;
  color: #fff;
  border-bottom: none;
}
.invoice-total-value {
  font-weight: 700;
  background: var(--gold) !important;
  color: #1a1408;
  font-size: 14px;
  border-bottom: none;
  white-space: nowrap;
  min-width: 6.5em;
}
.invoice-total-fill {
  background: #111 !important;
  border-bottom: none;
}
.invoice-totals-bar {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 18px;
  background: #111;
  color: #fff;
  padding: 10px 18px;
  border-top: 3px solid var(--gold);
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.invoice-totals-bar .fx { color: #cfc8b8; }
.invoice-totals-bar .sum {
  background: var(--gold);
  color: #1a1408;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 15px;
}

.pay-panel { max-width: 720px; }
.pay-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.pay-stat .k { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.pay-stat .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pay-stat .v.due { color: var(--err); }

/* Settings tier table inputs */
table.data input.tiny { width: 100%; padding: 6px 8px; font-size: 13px; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .pay-stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 800px) {
  .sidebar { position: relative; width: 100%; }
  .main { margin-left: 0; padding: 16px; }
  form .row.cols-2, form .row.cols-3, form .row.cols-4 { grid-template-columns: 1fr; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .invoice-meta { grid-template-columns: 1fr; }
}

.file-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--ink);
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  width: fit-content;
}
.file-btn:hover { background: #ece9e1; }
.file-btn input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.filterbar label.f.wide, .filterbar .f.wide { min-width: 260px; }

/* Status stepper, 补出分 form, invoice pending / 付清 */
.status-stepper {
  display: flex;
  align-items: flex-start;
  gap: 0;
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  overflow-x: auto;
}
.status-stepper .step {
  flex: 1;
  min-width: 68px;
  text-align: center;
  position: relative;
  font-size: 11px;
  color: var(--muted);
}
.status-stepper .step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 8px;
  left: calc(50% + 11px);
  right: calc(-50% + 11px);
  height: 2px;
  background: var(--line);
}
.status-stepper .step.is-done:not(:last-child)::after,
.status-stepper .step.is-current:not(:last-child)::after {
  background: var(--gold);
}
.status-stepper .step-dot {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: #fff;
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
  vertical-align: top;
}
.status-stepper .step.is-done .step-dot {
  background: var(--gold);
  border-color: var(--gold-d);
}
.status-stepper .step.is-current .step-dot {
  background: #111;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(196, 163, 90, .35);
}
.status-stepper .step.is-done .step-label { color: var(--ink); }
.status-stepper .step.is-current .step-label {
  color: var(--ink);
  font-weight: 700;
}
.status-next-form, .status-next-hint { margin: 0 0 14px; }
.grade-complete-form {
  margin: 8px 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: 10px;
  background: #faf8f3;
}
.grade-complete-form[hidden] { display: none; }
.status-correct {
  margin: 4px 0 12px;
  color: var(--muted);
}
.status-correct summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  width: fit-content;
}
.status-correct summary:hover { color: var(--ink); }
.status-correct .filterbar { margin: 10px 0 0; }
.pending-grades {
  margin: 0 0 14px;
  padding: 10px 14px;
  background: var(--warn-bg);
  border: 1px solid #ead6b0;
  border-radius: 8px;
  font-size: 13px;
}
.pending-grades-title {
  font-weight: 700;
  color: var(--warn);
  margin-bottom: 6px;
}
.pending-grades ul { margin: 0; padding-left: 1.2em; }
.pending-grades li { margin: 3px 0; }
.pending-grades a,
.link-grade {
  font-weight: 650;
  color: var(--gold-d);
  text-underline-offset: 2px;
  white-space: nowrap;
}
.pay-amount-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}
.pay-amount-controls input { flex: 1; min-width: 0; }

.account-chip {
  margin: 0 12px 8px;
  padding: 10px 12px;
  background: #1a1a1a;
  border: 1px solid #2c2c2c;
  border-radius: 10px;
  font-size: 12px;
  color: #cfc8b8;
}
.account-chip strong { display: block; color: #fff; font-size: 15px; margin: 2px 0 8px; }
.account-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.account-actions a, .account-actions button {
  background: transparent; border: 0; padding: 0; color: #c4a35a;
  font-family: inherit; font-size: 12px; cursor: pointer; text-decoration: none;
}
.account-actions a:hover, .account-actions button:hover { color: #fff; }
.account-actions form { margin: 0; display: inline; }

/* Auth (login / setup) */
body.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d0d0d;
  padding: 32px 16px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: #171717;
  border: 1px solid #2c2c2c;
  border-top: 3px solid var(--gold);
  border-radius: 14px;
  padding: 28px 28px 32px;
  color: #f4f4f4;
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
}
.auth-brand { text-align: left; margin-bottom: 18px; }
.auth-brand img { width: auto; height: 44px; background: #000; }
.auth-brand .brand-sub { margin-top: 10px; color: #cfc8b8; }
.auth-card h1 { margin: 0 0 8px; font-size: 22px; color: #fff; }
.auth-card .hint { margin: 0 0 18px; color: #cfc8b8; }
.auth-card .hint strong { color: #fff; }
.auth-card .f { margin-bottom: 12px; color: #cfc8b8; }
.auth-card input[type=text],
.auth-card input[type=password] {
  background: #111; color: #fff; border-color: #3a3a3a;
}
.auth-card .auth-submit { width: 100%; margin-top: 8px; padding: 10px 14px; }
.auth-card .flashes { margin-bottom: 12px; }

