/* ── Print Service · Support Dashboard ──────────────────────────────────
   Self-contained stylesheet — no build step. Kept deliberately small and
   dependency-free, mirroring how Oban Web ships its own compiled CSS.
   ────────────────────────────────────────────────────────────────────── */

:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --success-strong: #15803d;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --danger-strong: #b91c1c;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--mono); font-size: 0.86em; }
.muted { color: var(--text-muted); }

/* ── Topbar ── */

.topbar {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border-bottom: 3px solid var(--accent);
  color: #e2e8f0;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #f1f5f9;
  text-decoration: none;
}

.brand:hover { text-decoration: none; }
.brand-logo { font-size: 26px; line-height: 1; }
.brand-name { display: block; font-weight: 700; font-size: 16px; letter-spacing: 0.02em; }
.brand-sub { display: block; font-size: 12px; color: #94a3b8; margin-top: 1px; }

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #86efac;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

/* ── Layout ── */

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}

.page { display: flex; flex-direction: column; gap: 18px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.page-title { margin: 0; font-size: 22px; font-weight: 700; }
.page-subtitle { margin: 4px 0 0; color: var(--text-muted); font-size: 13.5px; }

.back-link { font-size: 13.5px; font-weight: 600; }
.back-link:hover { text-decoration: none; color: #1d4ed8; }

/* ── Cards ── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

/* ── Stats ── */

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

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font: inherit;
  text-align: left;
  color: inherit;
}

.stat-clickable { cursor: pointer; transition: transform 0.08s ease, box-shadow 0.08s ease; }
.stat-clickable:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12); }
.stat-pending { border-left-color: var(--warning); }
.stat-success { border-left-color: var(--success); }
.stat-failed { border-left-color: var(--danger); }
.stat-number { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Filters ── */

.filter-card form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filter-search { flex: 1 1 240px; }

input[type="search"], select {
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 12px;
  height: 38px;
}

input[type="search"] { width: 100%; }
input[type="search"]:focus, select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.btn {
  font: inherit;
  font-weight: 600;
  height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.btn:hover { background: #1d4ed8; border-color: #1d4ed8; text-decoration: none; }

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

.btn-ghost:hover { background: #f8fafc; border-color: #94a3b8; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn[disabled]:hover { background: var(--accent); border-color: var(--accent); }
.btn-ghost[disabled]:hover { background: #fff; border-color: #cbd5e1; }

/* ── Table ── */

.table-card { padding: 0; overflow-x: auto; }

.jobs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.jobs-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 11px 16px;
  white-space: nowrap;
}

.jobs-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.jobs-table tbody tr:last-child td { border-bottom: none; }
.jobs-table tbody tr:hover { background: #f8fafc; }
.row-failed { background: #fff5f5; }
.row-failed:hover { background: #fee9e9; }

.order-link { font-weight: 600; color: var(--accent); }
.time-cell { white-space: nowrap; color: var(--text-muted); font-size: 13px; }

/* ── Badges & chips ── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-pending { background: var(--warning-soft); color: #92400e; }
.badge-success { background: var(--success-soft); color: var(--success-strong); }
.badge-failed { background: var(--danger-soft); color: var(--danger-strong); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #f1f5f9;
  color: var(--text-muted);
  white-space: nowrap;
}

.chip-completed { background: var(--success-soft); color: var(--success-strong); }
.chip-failed { background: var(--danger-soft); color: var(--danger-strong); }
.chip-pending { background: var(--warning-soft); color: #92400e; }
.chip-test { background: #ede9fe; color: #5b21b6; margin-left: 6px; }

/* ── Empty state ── */

.empty-state { text-align: center; padding: 48px 24px; }
.empty-title { margin: 0; font-size: 17px; font-weight: 700; }
.empty-sub { margin: 6px 0 0; color: var(--text-muted); font-size: 14px; }

/* ── Pagination ── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pagination-info {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
  font-size: 13.5px;
  flex-wrap: wrap;
}

.per-page-inline-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.per-page-select-inline {
  padding: 4px 8px;
  font-size: 13px;
  height: 32px;
}

.pagination-actions { display: flex; gap: 8px; }

/* ── Job detail ── */

.job-badges { display: flex; align-items: center; gap: 8px; margin-top: 8px; }

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin: 0;
}

.meta-grid dt {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 2px;
}

.meta-grid dd { margin: 0; font-weight: 600; }

.section-title { margin: 0; font-size: 16px; font-weight: 700; }
.section-sub { margin: 4px 0 14px; color: var(--text-muted); font-size: 13.5px; }

/* ── Alerts ── */

.alert {
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 14px 18px;
}

.alert-danger {
  background: var(--danger-soft);
  border-color: #fecaca;
  color: var(--danger-strong);
}

.alert-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.alert-list { margin: 0; padding-left: 18px; }
.alert-list li { margin: 4px 0; }

/* ── Print messages ── */

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

.message-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: #fcfcfd;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-failed { border-color: #fecaca; background: #fff8f8; }

.message-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.message-device { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.device-name { font-weight: 700; font-size: 15px; }
.device-id { color: var(--text-muted); }
.device-restaurant {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: #f1f5f9;
  border-radius: 999px;
  padding: 2px 9px;
}

.message-error {
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13.5px;
}

.message-error-warn {
  background: var(--warning-soft);
  border-color: #fde68a;
  color: #92400e;
}

.error-line { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.error-label { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.message-error code { font-family: var(--mono); font-weight: 700; }

.message-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 12.5px;
}

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

/* ── Collapsible payloads ── */

details.payload {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

details.payload summary {
  cursor: pointer;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  user-select: none;
  list-style-position: inside;
}

details.payload summary:hover { color: var(--text); background: #f8fafc; }
details.payload pre {
  margin: 0;
  padding: 12px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 0 0 8px 8px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow-y: auto;
}

/* ── Topbar user menu ── */

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 16px;
  border-left: 1px solid rgba(148, 163, 184, 0.25);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  flex-shrink: 0;
}

.topbar-user {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.topbar-user .user-name { font-size: 13px; font-weight: 700; color: #f1f5f9; }
.topbar-user .user-email { font-size: 11.5px; color: #94a3b8; }

.logout-form { display: inline-flex; }

.btn-logout {
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  height: 30px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #f1f5f9;
  border-color: rgba(148, 163, 184, 0.5);
}

/* ── Login page — New split-screen design ── */

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  background: #FFFFFF;
}

/* ---------- Brand panel ---------- */
.login-brand-panel {
  position: relative;
  overflow: hidden;
  color: #EEF0FA;
  background: #161344;
  background: radial-gradient(120% 80% at 15% 0%, #4F46E5 0%, #312E81 38%, #1E1B4B 70%, #0F0D2E 100%);
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
}

.login-brand-panel::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
}

.login-brand-panel::after {
  content: "";
  position: absolute;
  right: -22%;
  bottom: -28%;
  width: 75%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.26), transparent 65%);
  pointer-events: none;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: #EEF0FA;
}

.login-logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.login-logo-mark svg {
  width: 22px;
  height: 22px;
}

.login-brand-panel h1 {
  margin: 0 0 14px;
  font-size: clamp(30px, 3.2vw, 44px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 800;
  max-width: 14ch;
  color: #FFFFFF;
}

.login-brand-panel p {
  margin: 0;
  color: #E4E6FA;
  font-size: 17px;
  line-height: 1.55;
  max-width: 38ch;
}

.login-brand-panel .foot {
  color: #B4B8E6;
  font-size: 13px;
  margin-top: 28px;
}

/* printer + receipt stage */
.login-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 24px 0;
}

.login-printer {
  width: min(340px, 100%);
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(#5B54E8, #3730A3);
  position: relative;
  z-index: 2;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.login-printer::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 9px;
  height: 7px;
  border-radius: 4px;
  background: #0A0A1F;
}

.login-led {
  position: absolute;
  right: 18px;
  top: 15px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #35D399;
  box-shadow: 0 0 10px #35D399;
}

.login-slotwrap {
  width: min(300px, 86%);
  height: 340px;
  overflow: hidden;
  margin-top: -6px;
  position: relative;
  z-index: 1;
}

.login-receipt {
  background: #FDFDFB;
  color: #1B1D2E;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  padding: 20px 20px 26px;
  transform: translateY(-100%);
  animation: receipt-feed 3.6s cubic-bezier(0.3, 0.7, 0.2, 1) 0.4s forwards;
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 14px 100%;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 14px 100%;
}

@keyframes receipt-feed {
  to { transform: translateY(0); }
}

.login-receipt .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.login-receipt .c {
  text-align: center;
}

.login-receipt hr {
  border: 0;
  border-top: 1px dashed #B8BAC8;
  margin: 8px 0;
}

.login-receipt b {
  font-weight: 500;
  letter-spacing: 0.02em;
}

.login-receipt .ok {
  display: inline-block;
  margin-top: 6px;
  padding: 1px 8px;
  border: 1.5px solid #138A5E;
  color: #138A5E;
  border-radius: 4px;
  font-weight: 500;
}

/* ---------- Form panel (White Background) ---------- */
.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  position: relative;
  background: #FFFFFF;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

.login-mobile-logo {
  display: none;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 20px;
  color: #12152B;
  margin-bottom: 24px;
}

.login-card h2 {
  margin: 0 0 8px;
  font-size: 30px;
  letter-spacing: -0.025em;
  font-weight: 800;
  line-height: 1.15;
  color: #12152B;
}

.login-card .sub {
  margin: 0 0 28px;
  color: #5B6078;
  font-size: 15.5px;
  line-height: 1.5;
}

.login-alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #FEF1F1;
  border: 1px solid #F5C2C2;
  color: #9B1C1C;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14.5px;
  line-height: 1.45;
  margin-bottom: 22px;
}

.login-alert svg {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.login-field {
  margin-bottom: 18px;
}

.login-field label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #12152B;
}

.login-input-wrap {
  position: relative;
}

.login-input-wrap input {
  width: 100%;
  height: 50px;
  border-radius: 12px;
  border: 1.5px solid #DCDFEB;
  background: #F6F7FD;
  color: #12152B;
  font: inherit;
  font-size: 16px;
  padding: 0 48px 0 14px;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.login-input-wrap input::placeholder {
  color: #5B6078;
  opacity: 0.7;
}

.login-input-wrap input:focus {
  outline: none;
  border-color: #4F46E5;
  background: #FFFFFF;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.28);
}

.login-toggle {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: #5B6078;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color 0.15s, background-color 0.15s;
}

.login-toggle:hover {
  color: #12152B;
  background: #FFFFFF;
}

.login-toggle:focus-visible,
.login-submit-btn:focus-visible {
  outline: 3px solid rgba(79, 70, 229, 0.28);
  outline-offset: 2px;
}

.login-toggle svg {
  width: 20px;
  height: 20px;
}

.login-hint {
  font-size: 12.5px;
  color: #5B6078;
  margin-top: 6px;
  min-height: 18px;
}

.login-submit-btn {
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 12px;
  background: #4F46E5;
  color: #FFFFFF;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 0.15s, transform 0.1s;
}

.login-submit-btn:hover {
  background: #4338CA;
}

.login-submit-btn:active {
  transform: translateY(1px);
}

.login-submit-btn[disabled] {
  opacity: 0.8;
  cursor: progress;
}

.login-spin {
  width: 18px;
  height: 18px;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: login-rot 0.7s linear infinite;
}

.login-spin[hidden] {
  display: none;
}

@keyframes login-rot {
  to { transform: rotate(360deg); }
}

.login-help {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid #DCDFEB;
  color: #5B6078;
  font-size: 14px;
  line-height: 1.5;
}

/* Responsive */
@media (max-width: 900px) {
  .login-shell {
    grid-template-columns: 1fr;
  }
  .login-brand-panel {
    min-height: 0;
    padding: 28px 24px;
  }
  .login-stage,
  .login-brand-panel p {
    display: none;
  }
  .login-brand-panel h1 {
    font-size: 26px;
    max-width: none;
    margin: 28px 0 0;
  }
  .login-brand-panel .foot {
    display: none;
  }
  .login-panel {
    padding: 32px 20px 48px;
    align-items: flex-start;
    background: #FFFFFF;
  }
  .login-mobile-logo {
    display: flex;
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-receipt {
    animation: none;
    transform: none;
  }
  .login-spin {
    animation: none;
  }
}

/* ── Responsive Topbar and Dashboard ── */

@media (max-width: 760px) {
  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar-inner { flex-direction: column; align-items: flex-start; gap: 8px; }
  .pagination { flex-direction: column; align-items: flex-start; }
  .user-menu { border-left: none; padding-left: 0; }
  .topbar-user { display: none; }
}