:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #fff;
  --text: #17202a;
  --muted: #627084;
  --line: #dfe5ec;
  --accent: #1173d4;
  --danger: #bf2f2f;
  --ok: #17824c;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { border: 0; background: var(--accent); color: white; padding: 9px 13px; border-radius: 6px; cursor: pointer; }
button.ghost { background: #eef2f6; color: var(--text); }
button.active { background: #0d5ca9; }
button:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; background: white; color: var(--text); }
textarea { resize: vertical; font-family: Consolas, monospace; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }

.hidden { display: none !important; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-panel { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 28px; box-shadow: 0 10px 35px rgba(20,35,55,.08); }
.auth-panel h1 { margin: 0 0 8px; font-size: 26px; }
.auth-panel p { margin: 0 0 20px; color: var(--muted); }
.auth-panel form, .stack { display: grid; gap: 14px; }
.error { margin-top: 12px; color: var(--danger); }

.app { min-height: 100vh; display: grid; grid-template-columns: 230px 1fr; }
.sidebar { background: #192331; color: white; padding: 22px; display: flex; flex-direction: column; gap: 22px; }
.sidebar h1 { margin: 0; font-size: 22px; }
.sidebar p { margin: 6px 0 0; color: #aeb9c7; font-size: 13px; }
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav button, .sidebar .ghost { width: 100%; text-align: left; background: transparent; color: #dbe4ee; }
.sidebar nav button.active { background: #2a3a4f; }
.sidebar .ghost { margin-top: auto; background: #26364a; }

.content { padding: 24px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.topbar h2 { margin: 0; font-size: 24px; }
.topbar p { margin: 5px 0 0; color: var(--muted); }
.actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.actions.left { justify-content: flex-start; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metrics article, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.metrics span { display: block; color: var(--muted); font-size: 13px; }
.metrics strong { display: block; margin-top: 8px; font-size: 28px; }
.panel h3 { margin: 0 0 14px; font-size: 18px; }
.panel p { color: var(--muted); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.list { display: grid; gap: 10px; }
.list-item { border: 1px solid var(--line); border-radius: 7px; padding: 12px; background: #fbfcfe; }
.list-item strong { display: block; }
.list-item span { color: var(--muted); font-size: 13px; }
.status { display: inline-block; padding: 3px 8px; border-radius: 999px; background: #eef2f6; font-size: 12px; }
.status.printed { color: var(--ok); background: #e7f5ee; }
.status.error, .status.print_error { color: var(--danger); background: #f9e9e9; }
.grid-2 { display: grid; grid-template-columns: 320px 1fr; gap: 20px; }
.settings { display: grid; grid-template-columns: repeat(2, minmax(280px, 1fr)); gap: 16px; }
.settings .save { grid-column: 1 / -1; justify-self: start; }
.table-wrap { overflow: auto; }
.help { font-size: 12px; color: var(--muted); }
.toast { position: fixed; right: 18px; bottom: 18px; background: #17202a; color: white; padding: 12px 14px; border-radius: 7px; box-shadow: 0 8px 24px rgba(0,0,0,.16); max-width: 360px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .sidebar nav { grid-template-columns: repeat(4, 1fr); }
  .topbar, .panel-head { align-items: stretch; flex-direction: column; }
  .actions { justify-content: flex-start; flex-wrap: wrap; }
  .metrics, .settings, .grid-2 { grid-template-columns: 1fr; }
}
