:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --ink: #1e2a3b;
  --muted: #6b778a;
  --line: #e2e8f0;
  --accent: #1e2a3b;
  --accent-soft: #334155;
  --accent-2: #c45c26;
  --danger: #b42318;
  --ok: #1d4ed8;
  --ok-bg: #e8effc;
  --shadow: 0 12px 32px rgba(30, 42, 59, 0.07);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background:
    radial-gradient(ellipse at top left, rgba(30, 42, 59, 0.06), transparent 42%),
    radial-gradient(ellipse at bottom right, rgba(196, 92, 38, 0.06), transparent 36%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}
.login-card h1 { margin: 0; font-size: 28px; letter-spacing: 0.02em; color: var(--ink); }
.login-card label { display: grid; gap: 6px; font-size: 14px; }
input, select, textarea, button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}
button {
  cursor: pointer;
  background: #f1f5f9;
  border: 1px solid var(--line);
}
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { background: var(--accent-soft); }
button.danger { background: #fff5f5; color: var(--danger); border-color: #fecdca; }
button.danger:hover { background: #fee4e2; }
button.ghost { background: transparent; }
button.link { border: none; background: none; color: var(--ok); padding: 0; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  backdrop-filter: blur(10px);
  z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; color: var(--ink); }
.topbar nav { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.userbox { display: flex; gap: 10px; align-items: center; font-size: 14px; }

main { padding: 20px; max-width: 1200px; margin: 0 auto; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: center; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
tr:hover td { background: rgba(30, 42, 59, 0.03); }
.money { font-variant-numeric: tabular-nums; font-weight: 600; }
.money.neg { color: var(--danger); }
.money.pos { color: var(--ok); }
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #f1f5f9;
}
.tag.closed { background: var(--ok-bg); color: var(--ok); }
.tag.open { background: #fff4e8; color: var(--accent-2); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
.card .label { color: var(--muted); font-size: 13px; }
.card .value { font-size: 24px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.report-section { margin: 28px 0 12px; font-size: 18px; color: var(--ink); }
.report-note { margin: 0 0 12px; font-size: 13px; }
.report-subnav {
  display: flex;
  gap: 0;
  margin: 4px 0 16px;
  border-bottom: 1px solid var(--line);
}
.report-subtab {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.report-subtab:hover { color: var(--ink); background: transparent; }
.report-subtab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: transparent;
}
.report-pane { margin-top: 4px; }
.role-card .value { color: var(--muted); font-weight: 600; }
.role-perms {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
}
.staff-form input, .staff-form select { min-width: 120px; }
.staff-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.form-grid label { display: grid; gap: 6px; font-size: 13px; }
.form-grid label.full { grid-column: 1 / -1; }
.form-grid label.check { display: flex; align-items: center; gap: 8px; }
.fee-field {
  display: grid;
  gap: 6px;
  font-size: 13px;
  align-content: start;
}
.fee-field input[type="number"]:disabled {
  background: #f1f5f9;
  color: var(--muted);
}
.preview { max-width: 180px; margin-top: 8px; border-radius: 8px; border: 1px solid var(--line); display: block; }
.preview.clickable { cursor: zoom-in; }
.parts-image-field {
  display: grid;
  gap: 6px;
  font-size: 13px;
  align-content: start;
}
.parts-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.parts-preview-item {
  position: relative;
  width: 96px;
}
.parts-preview-item img {
  width: 96px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: block;
  cursor: zoom-in;
  background: #fff;
}
.parts-preview-item .parts-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: #b91c1c;
  color: #fff;
  font-size: 14px;
  line-height: 22px;
  padding: 0;
  cursor: pointer;
}
.parts-preview-item .parts-remove:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.lightbox-dialog {
  border: none;
  padding: 0;
  margin: 0;
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  background: rgba(15, 23, 42, 0.78);
  place-items: center;
  cursor: zoom-out;
}
.lightbox-dialog:not([open]) {
  display: none !important;
}
.lightbox-dialog[open] {
  display: grid;
}
.lightbox-dialog::backdrop {
  background: rgba(15, 23, 42, 0.78);
}
.lightbox-dialog img {
  max-width: min(960px, 96vw);
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  background: #fff;
  cursor: default;
}
input[readonly] { background: #f8fafc; color: var(--muted); }

dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  width: min(960px, calc(100vw - 24px));
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(30, 42, 59, 0.45); }
.dialog-body { padding: 20px; }
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.dialog-head h2 { margin: 0; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.calc-box {
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  font-size: 14px;
  line-height: 1.6;
}
.audit-mini { margin-top: 12px; font-size: 12px; color: var(--muted); max-height: 120px; overflow: auto; }
.repair-section { margin-top: 16px; }
.repair-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.repair-head h3 { margin: 0; font-size: 16px; color: var(--ink); }
.repair-table input {
  width: 100%;
  min-width: 72px;
  padding: 6px 8px;
  font-size: 13px;
}
.repair-table th:nth-child(1) { min-width: 120px; }
.repair-table th:nth-child(3) { min-width: 100px; }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
}
