:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-weak: #dbeafe;
  --danger: #dc2626;
  --ok: #15803d;
  --warn: #b45309;
  --radius: 8px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button, input, select { font: inherit; }

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 12px;
}

button:hover:not(:disabled) { border-color: #c7d2fe; color: var(--accent); }
button:disabled { cursor: not-allowed; opacity: .55; }

input, select {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 6px 10px;
  outline: none;
}

input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--accent-weak);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.login-card button[type="submit"] {
  margin-top: 16px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  padding: 9px 12px;
}
.login-card button[type="submit"]:hover:not(:disabled) { color: #fff; filter: brightness(1.05); }

.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; }

.topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { font-size: 16px; font-weight: 600; letter-spacing: .2px; }
.nav { display: flex; align-items: center; gap: 4px; align-self: stretch; }
.nav-item {
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  white-space: nowrap;
}
.nav-item:hover { color: var(--accent); }
.nav-item.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); }
.link-btn { border: 0; background: transparent; color: var(--accent); padding: 4px 6px; }

.page { padding: 18px 20px 40px; max-width: 1680px; margin: 0 auto; }

.notice {
  background: var(--accent-weak);
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
  line-height: 1.6;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.toolbar input[type="search"] { width: 240px; }
#summary { margin-left: auto; font-size: 13px; }

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  max-height: calc(100vh - 260px);
}

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 1280px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

tbody tr:hover td { background: #f8fafc; }
tbody tr:last-child td { border-bottom: 0; }

.num { text-align: right; }
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--accent); }
.sortable .arrow { display: inline-block; width: 12px; color: #94a3b8; font-size: 11px; }
.sortable.sorted .arrow { color: var(--accent); }

.col-name { min-width: 320px; }
.col-category { min-width: 150px; }
.col-status { min-width: 90px; }
.col-time { min-width: 160px; }

.product { display: flex; align-items: center; gap: 10px; min-width: 0; }
.product img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--line);
  flex: none;
}
.product .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 380px;
}
.product a { color: var(--text); text-decoration: none; }
.product a:hover { color: var(--accent); text-decoration: underline; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 20px;
  white-space: nowrap;
}
.badge.ok { background: #dcfce7; color: var(--ok); }
.badge.warn { background: #fef3c7; color: var(--warn); }
.badge.muted { background: #f1f5f9; color: var(--muted); }

.price-edit { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.price-edit input { width: 96px; text-align: right; padding: 4px 8px; }
.price-edit button { padding: 4px 8px; font-size: 13px; }

.row-status { font-size: 12px; color: var(--muted); min-width: 42px; text-align: right; }
.row-status.ok { color: var(--ok); }
.row-status.err { color: var(--danger); }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px 0 0;
}

#page-label { color: var(--muted); font-size: 13px; }

.empty, .load-error {
  text-align: center;
  color: var(--muted);
  padding: 40px 12px;
}
.load-error { color: var(--danger); }

.toast {
  position: fixed;
  right: 20px;
  bottom: 24px;
  max-width: 360px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .22);
  z-index: 50;
  font-size: 13px;
}
.toast.err { background: #991b1b; }

@media (max-width: 760px) {
  .page { padding: 12px; }
  .toolbar input[type="search"] { width: 100%; }
  #summary { margin-left: 0; }
  .table-wrap { max-height: none; }
}
