/* PrintShare — mobile-first stylesheet */
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1b2430;
  --muted: #6b7787;
  --line: #e2e7ee;
  --primary: #2f6fed;
  --primary-dark: #2559c4;
  --danger: #d64545;
  --ok: #17864a;
  --warn: #b8801a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 6px 20px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

.muted { color: var(--muted); }
.small-note { font-size: 13px; }

code {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  background: #eef2f8;
  padding: 2px 6px;
  border-radius: 6px;
  word-break: break-all;
}

/* ---------- login ---------- */

.center-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(180deg, #eaf1ff 0%, var(--bg) 45%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 22px 22px;
}

.brand { text-align: center; margin-bottom: 20px; }
.brand h1 { margin: 8px 0 2px; font-size: 22px; letter-spacing: 0.2px; }
.brand p { margin: 0; font-size: 13px; }
.logo { font-size: 40px; line-height: 1; }

.hint { text-align: center; font-size: 13px; margin: 16px 0 0; }

/* ---------- form controls ---------- */

label.field {
  display: block;
  margin-bottom: 14px;
}

label.field > span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

label.field em { font-style: normal; }

input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  padding: 12px 12px;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

select {
  background-image: linear-gradient(45deg, transparent 50%, #889 50%),
    linear-gradient(135deg, #889 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.15);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  margin: 0;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 15px;
  font-family: inherit;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #eef2f8;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.05s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:not(:disabled):hover { background: var(--primary-dark); }

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn.ghost:hover { background: #f1f5fb; }

.btn.danger {
  background: transparent;
  border-color: #f0c9c9;
  color: var(--danger);
}
.btn.danger:hover { background: #fdf1f1; }

.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; padding: 13px 16px; font-size: 16px; }

.link {
  color: var(--primary);
  font-size: 13px;
  text-decoration: none;
  padding: 6px 4px;
}
.link:hover { text-decoration: underline; }

/* ---------- layout ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-small {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.logo-small { font-size: 20px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 20px;
  background: #eaf1ff;
  color: var(--primary-dark);
}

.page {
  max-width: 620px;
  margin: 0 auto;
  padding: 16px 14px 48px;
}

.page.wide { max-width: 980px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin-bottom: 16px;
}

.card h2 { font-size: 17px; margin: 0 0 14px; }

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

.card-head h2 { margin: 0; }

/* ---------- dropzone ---------- */

.dropzone {
  border: 2px dashed #c9d4e4;
  border-radius: 12px;
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  background: #fafcff;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone.hot, .dropzone:hover {
  border-color: var(--primary);
  background: #f2f7ff;
}

.dz-icon { font-size: 26px; }
.dz-main { font-weight: 600; margin-top: 6px; }
.dz-sub { font-size: 13px; margin-top: 4px; }

.file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fafcff;
}

.file-main { min-width: 0; flex: 1; }
.file-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-meta { font-size: 13px; }

/* ---------- options ---------- */

.options { margin-top: 16px; }

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: center;
}

.progress {
  height: 6px;
  background: #e8eef7;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 12px;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--primary);
  transition: width 0.15s;
}

/* ---------- alerts ---------- */

.alert {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  margin: 12px 0;
}

.alert.error { background: #fdf1f1; color: #a42c2c; border: 1px solid #f3d3d3; }
.alert.success { background: #eefaf2; color: #166534; border: 1px solid #cdead6; }

/* ---------- job list ---------- */

.job-list { display: flex; flex-direction: column; gap: 10px; }

.empty { text-align: center; padding: 12px 0; margin: 0; }

.job-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.job-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.job-title {
  font-weight: 600;
  word-break: break-all;
}

.job-meta { font-size: 13px; margin-top: 4px; }

.job-error { font-size: 13px; color: var(--danger); margin-top: 6px; word-break: break-all; }

.job-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  justify-content: flex-end;
}

.badge {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
  background: #eef2f8;
  color: var(--muted);
}

.status-pending { background: #fff6e5; color: var(--warn); }
.status-claimed { background: #eaf1ff; color: var(--primary-dark); }
.status-printing { background: #e8f4ff; color: #0b63a8; }
.status-done { background: #e8f8ee; color: var(--ok); }
.status-failed { background: #fdecec; color: var(--danger); }
.status-cancelled { background: #f1f2f4; color: #6b7787; }

.role-admin { background: #eaf1ff; color: var(--primary-dark); }
.role-user { background: #f1f2f4; color: var(--muted); }

/* ---------- admin ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  background: var(--card);
  border-radius: 12px;
  padding: 14px 12px;
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-value { font-size: 22px; font-weight: 700; }
.stat-label { font-size: 12px; margin-top: 2px; }

.agent-list { display: flex; flex-direction: column; gap: 12px; }

.agent-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

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

.agent-name { font-weight: 600; }

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #c3cad6;
  flex: none;
}
.dot.on { background: #22a45d; box-shadow: 0 0 0 3px rgba(34, 164, 93, 0.15); }
.dot.off { background: #b7bdc8; }

.agent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.printer-list { display: flex; flex-direction: column; gap: 8px; }

.printer-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #fafcff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.printer-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.inline-input {
  padding: 8px 10px !important;
  font-size: 14px !important;
}

.user-list { display: flex; flex-direction: column; gap: 8px; }

.user-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.user-row:last-child { border-bottom: none; }
.spacer { flex: 1; }

.event-list { display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; }

.event-item {
  display: flex;
  gap: 10px;
  font-size: 13px;
  padding: 5px 0;
  border-bottom: 1px dashed #eef1f5;
}
.ev-time { flex: none; font-variant-numeric: tabular-nums; }
.ev-msg { word-break: break-word; }
.ev-error .ev-msg { color: #a42c2c; }
.ev-warn .ev-msg { color: var(--warn); }

/* ---------- modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 38, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}

.modal[hidden] { display: none; }

.modal-box {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 460px;
  max-height: 86vh;
  overflow-y: auto;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(16, 24, 40, 0.25);
}

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

.modal-head h3 { margin: 0; font-size: 17px; }

.token-box { margin-top: 14px; }
.kv {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 8px 0;
  font-size: 13px;
}
.row-gap { margin-top: 8px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: rgba(27, 36, 48, 0.94);
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 22px;
  z-index: 80;
  max-width: 88vw;
  text-align: center;
}

.toast[hidden] { display: none; }

/* ---------- small screens ---------- */

@media (max-width: 420px) {
  .grid2 { grid-template-columns: 1fr; }
  .page { padding: 12px 10px 40px; }
  .card { padding: 16px 13px; }
  .printer-info { grid-template-columns: 1fr; }
}
