:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-muted: #fafafa;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #e5e5ea;
  --primary: #111111;
  --primary-hover: #2c2c2e;
  --danger: #d70015;
  --success: #0a7f43;
  --warning: #a45b00;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px;
}

.login-panel {
  width: 420px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.login-panel h1 {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: 0;
}

.login-panel p {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.6;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.textarea {
  min-height: 84px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: #8e8e93;
  box-shadow: 0 0 0 3px rgba(142, 142, 147, 0.16);
}

.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #fff;
}

.brand {
  display: grid;
  gap: 4px;
  padding: 24px 22px 18px;
  border-bottom: 1px solid var(--line);
}

.brand strong {
  font-size: 18px;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 4px;
  padding: 14px;
}

.nav button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.nav button:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.nav button.active {
  color: var(--text);
  background: #f0f0f2;
  font-weight: 600;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 245, 247, 0.92);
  backdrop-filter: blur(16px);
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.userbar {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.content {
  padding: 28px;
}

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

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #fff;
  background: var(--primary);
  white-space: nowrap;
}

.btn:hover {
  background: var(--primary-hover);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.btn.secondary {
  color: var(--text);
  border-color: var(--line);
  background: #fff;
}

.btn.secondary:hover {
  background: var(--surface-muted);
}

.btn.danger {
  background: var(--danger);
}

.btn.ghost {
  min-height: auto;
  padding: 0;
  color: var(--muted);
  background: transparent;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

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

.stat strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
  letter-spacing: 0;
}

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

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

.panel-header h2 {
  margin: 0;
  font-size: 16px;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  background: var(--surface-muted);
  font-size: 12px;
  font-weight: 600;
}

.table tr:last-child td {
  border-bottom: 0;
}

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

.name-cell {
  display: grid;
  gap: 4px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #efeff4;
  color: var(--muted);
  font-size: 12px;
}

.pill.success {
  color: var(--success);
  background: #e9f8ef;
}

.pill.warning {
  color: var(--warning);
  background: #fff4e4;
}

.pill.danger {
  color: var(--danger);
  background: #fff0f0;
}

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

.empty,
.loading {
  padding: 42px;
  color: var(--muted);
  text-align: center;
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.28);
}

.modal {
  width: min(720px, 100%);
  max-height: 88vh;
  overflow: auto;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.18);
}

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

.modal-foot {
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 20px;
}

.modal-error {
  margin: 0 20px 4px;
  padding: 10px 12px;
  border: 1px solid #ffd6d6;
  border-radius: 6px;
  color: var(--danger);
  background: #fff5f5;
  font-size: 13px;
  line-height: 1.5;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.file-input {
  display: none;
}

.image-field {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-status,
.upload-value,
.upload-list {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.upload-status.error {
  color: var(--danger);
}

.upload-value {
  margin-top: 10px;
  word-break: break-all;
}

.upload-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.upload-chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.upload-chip span {
  overflow-wrap: anywhere;
}

.repeat-section {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.repeat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.repeat-head label {
  margin: 0;
}

.repeat-list {
  display: grid;
  gap: 10px;
}

.repeat-row {
  display: grid;
  gap: 8px;
  align-items: center;
}

.spec-row {
  grid-template-columns: minmax(160px, 1fr) 120px 100px auto;
}

.param-row {
  grid-template-columns: minmax(140px, 0.45fr) minmax(180px, 1fr) auto;
}

.repeat-empty {
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
}

.order-detail {
  display: grid;
  gap: 14px;
}

.order-detail h3 {
  margin: 8px 0 0;
  font-size: 15px;
}

.order-detail p {
  margin: 0;
  line-height: 1.5;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-grid > div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.table.compact th,
.table.compact td {
  padding: 8px;
}

.event-list {
  display: grid;
  gap: 8px;
}

.event-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #1d1d1f;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.toast.error {
  background: var(--danger);
}

.form-error {
  margin: 2px 0 16px;
  padding: 10px 12px;
  border: 1px solid #ffd6d6;
  border-radius: 6px;
  color: var(--danger);
  background: #fff5f5;
  font-size: 13px;
  line-height: 1.5;
}

.form-debug {
  margin: -6px 0 16px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--muted);
  background: #f5f5f7;
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
}

.site-footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 18px 24px 24px;
  color: var(--muted);
  font-size: 12px;
}

.site-footer[hidden],
.site-footer a[hidden] {
  display: none;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text);
  text-decoration: underline;
}
