:root {
  --bg: #0f1115;
  --panel: #161922;
  --panel-2: #1c2030;
  --border: #2a2f3d;
  --text: #e7e9ee;
  --muted: #8a90a2;
  --primary: #5b8cff;
  --primary-2: #7aa3ff;
  --danger: #ef5a5a;
  --ok: #3fbf75;
  --warn: #e0a23a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

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

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px; background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand a { color: var(--text); font-weight: 700; font-size: 16px; }
.brand-link { display: flex; align-items: center; }
.brand-logo { height: 92px; width: auto; display: block; }
.brand-meta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.brand-sub { color: var(--muted); font-size: 11px; letter-spacing: 0.6px; text-transform: uppercase; }
.topbar nav { display: flex; gap: 16px; flex: 1; }
.topbar nav a { color: var(--muted); }
.topbar nav a:hover { color: var(--text); text-decoration: none; }
.user { display: flex; align-items: center; gap: 12px; }
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.who { color: var(--muted); font-size: 11px; margin-top: 2px; }
.tag { background: var(--primary); color: white; font-size: 10px; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

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

h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 24px 0 12px; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 16px 0; gap: 16px; }
.row-actions { display: flex; gap: 8px; align-items: center; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 6px; border: 1px solid transparent;
  cursor: pointer; font-size: 13px; font-weight: 500;
  background: var(--panel-2); color: var(--text);
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-2); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-small { padding: 4px 8px; font-size: 12px; }

/* Forms */
.form { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 20px; max-width: 800px; }
.form fieldset { border: 1px solid var(--border); border-radius: 6px; padding: 16px; margin: 0 0 16px; }
.form legend { padding: 0 8px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
label input, label select, label textarea, .form input, .form select, .form textarea {
  display: block; width: 100%;
  margin-top: 4px; padding: 8px 10px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  font: inherit;
}
label input:focus, label select:focus, label textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
textarea { resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.inline { display: inline; }

/* Auth */
.auth-card {
  max-width: 380px; margin: 60px auto;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 28px;
}
.auth-logo { display: block; width: 240px; max-width: 100%; height: auto; margin: 0 auto 18px; }
.auth-card h1 { font-size: 22px; text-align: center; }
.auth-card > .muted { text-align: center; }
.auth-card .btn { width: 100%; justify-content: center; }

/* RMA watermark — fixed overlay that stays in place while the form scrolls.
   Sits above the form but is click-through (pointer-events:none) and very faint
   so the form stays fully usable and readable. */
.rma-watermark {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
}
.rma-watermark img {
  width: min(78vw, 720px);
  height: auto;
  opacity: 0.05;
  user-select: none;
}
/* Center the RMA form (and its heading block) horizontally on screen.
   Scoped to .rma-page so the shared .form class is untouched elsewhere. */
.rma-page .form { margin-left: auto; margin-right: auto; }
.rma-page > h1,
.rma-page > p,
.rma-page > .flashes { max-width: 800px; margin-left: auto; margin-right: auto; }

/* Public RMA form: white, print-friendly presentation independent of the
   dark admin interface used everywhere else. */
.rma-public,
.rma-public body {
  background: #ffffff;
  color: #000000;
}
.rma-public .rma-page { position: relative; z-index: 10; }
.rma-public .rma-page h1,
.rma-public .rma-page p,
.rma-public .rma-page label,
.rma-public .rma-page legend,
.rma-public .rma-page .muted,
.rma-public .rma-page .small,
.rma-public .rma-page span,
.rma-public .rma-page strong { color: #000000; }
.rma-public .rma-page .form,
.rma-public .rma-page fieldset {
  background: #ffffff;
}
.rma-public .rma-page .form {
  border: 2px solid rgb(154, 194, 217);
  background: rgb(154, 194, 217);
}
.rma-public .rma-page fieldset {
  border-color: #000000;
  position: relative;
  padding-top: 42px;
}
.rma-public .rma-page fieldset legend {
  position: absolute;
  top: 12px;
  left: 16px;
  padding: 0 4px;
  background: #ffffff;
  color: #000000;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.rma-public .rma-page input,
.rma-public .rma-page select,
.rma-public .rma-page textarea {
  background: #ffffff;
  color: #000000;
  border-color: #000000;
}
.rma-public .rma-page input::placeholder,
.rma-public .rma-page textarea::placeholder { color: #000000; opacity: 1; }
.rma-public .rma-page .btn-primary {
  background: #ffffff;
  color: #000000;
  border-color: #000000;
}
.rma-public .rma-page label span[style] { color: #000000 !important; }
.rma-public .rma-watermark { z-index: 11; }
.rma-public .rma-watermark img {
  width: min(78vw, 720px);
  opacity: 0.10;
  mix-blend-mode: multiply;
}

/* Flashes */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 6px; border: 1px solid var(--border); }
.flash-ok { background: rgba(63, 191, 117, 0.1); border-color: var(--ok); color: var(--ok); }
.flash-error { background: rgba(239, 90, 90, 0.1); border-color: var(--danger); color: var(--danger); }
.flash-message { background: var(--panel); }

/* Tables */
.data { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 8px; overflow: hidden; }
.data th, .data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.data th { background: var(--panel-2); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.data tr:last-child td { border-bottom: none; }
.data tr:hover td { background: var(--panel-2); }
.active-row { background: rgba(91, 140, 255, 0.08) !important; }
.active-row em { color: var(--primary-2); font-style: normal; }

/* Status pills — color spec */
.pill { display: inline-block; padding: 3px 9px; border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; background: var(--panel-2); border: 1px solid var(--border); }
.pill-large { padding: 6px 14px; font-size: 12px; }
.pill-pending                     { color: #ffd84d; border-color: #ffd84d; background: rgba(255, 216, 77, 0.10); }
.pill-in-progress                 { color: #ff9b3d; border-color: #ff9b3d; background: rgba(255, 155, 61, 0.10); }
.pill-ready-to-quote              { color: #5cd0d6; border-color: #5cd0d6; background: rgba(92, 208, 214, 0.10); }
.pill-awaiting-parts              { color: #ef5a5a; border-color: #ef5a5a; background: rgba(239, 90, 90, 0.10); }
.pill-awaiting-customer-approval  { color: #f1f3f5; border-color: #c2c7d0; background: rgba(241, 243, 245, 0.06); }
.pill-customer-declined-repair    { color: #b0b3b8; border-color: #6e7480; background: rgba(176, 179, 184, 0.10); }
.pill-completed                   { color: #98e8b4; border-color: #98e8b4; background: rgba(152, 232, 180, 0.10); }
.pill-dispatched                  { color: #3fbf75; border-color: #3fbf75; background: rgba(63, 191, 117, 0.12); }

/* Stat grid */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 16px 0 24px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px; display: block; color: inherit; text-decoration: none; }
.stat-num { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }

/* Slow pulse for the "Ready to quote" card (only applied when count > 0) */
@keyframes pulse-rtq {
  0%   { opacity: 1; }
  50%  { opacity: 0.5; }
  100% { opacity: 1; }
}
.pulse-rtq { animation: pulse-rtq 2.8s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .pulse-rtq { animation: none; }
}

/* Headline stat row (Total jobs, Open, Customers) */
.stat-headline-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 16px 0; }
.stat-headline { padding: 22px 20px; }
.stat-headline .stat-num { font-size: 36px; }

/* Status grid (color-stripe top) */
.stat-status-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; margin: 8px 0 24px; }
.stat-status { position: relative; padding: 14px 10px 12px; padding-top: 16px; transition: transform 0.1s, border-color 0.1s; overflow: hidden; min-width: 0; }
.stat-status:hover { transform: translateY(-2px); border-color: rgba(255,255,255,0.18); text-decoration: none; }
.stat-status::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; }
.stat-status .stat-num { font-size: 22px; color: #fff; }
.stat-status .stat-label { font-size: 10.5px; letter-spacing: 0.4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.stat-status-pending::before                    { background: #ffd84d; }
.stat-status-in-progress::before                { background: #ff9b3d; }
.stat-status-ready-to-quote::before             { background: #5cd0d6; }
.stat-status-awaiting-parts::before             { background: #ef5a5a; }
.stat-status-awaiting-customer-approval::before { background: #f1f3f5; }
.stat-status-customer-declined-repair::before   { background: #8a8f99; }
.stat-status-completed::before                  { background: #98e8b4; }
.stat-status-dispatched::before                 { background: #3fbf75; }

/* Section dividers */
.dash-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--muted); margin: 22px 0 6px; font-weight: 600; }

/* Needs-attention panel */
.attention-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 8px 0 22px; }
.attention-card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; display: flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; transition: border-color 0.1s, transform 0.1s; }
.attention-card:hover { transform: translateY(-1px); text-decoration: none; }
.attention-card .att-icon { font-size: 22px; line-height: 1; }
.attention-card .att-num { font-size: 22px; font-weight: 700; line-height: 1; }
.attention-card .att-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.attention-card.att-stale { border-color: rgba(239,90,90,0.5); background: rgba(239,90,90,0.06); }
.attention-card.att-stale .att-num { color: #ef5a5a; }
.attention-card.att-stale:hover { border-color: #ef5a5a; }
.attention-card.att-info  { border-color: rgba(241,243,245,0.25); }
.attention-card.att-rma   { border-color: rgba(255,216,77,0.4); }
.attention-card.att-rma .att-num { color: #ffd84d; }

/* Quick actions on dashboard header */
.dash-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.dash-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dash-quick-search { display: flex; align-items: center; gap: 6px; }
.dash-quick-search input { padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 13px; min-width: 200px; }
.dash-quick-search input:focus { outline: none; border-color: var(--primary); }

/* Stale jobs mini-list */
.stale-list { background: var(--panel); border: 1px solid rgba(239,90,90,0.3); border-radius: 8px; padding: 12px 14px; margin-bottom: 22px; }
.stale-list h3 { margin: 0 0 8px; font-size: 13px; color: #ef5a5a; }
.stale-list ul { list-style: none; padding: 0; margin: 0; }
.stale-list li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.stale-list li:last-child { border-bottom: 0; }
.stale-list .stale-meta { color: var(--muted); font-size: 12px; }

/* Banner (active session) — compact */
.banner {
  background: linear-gradient(90deg, rgba(91,140,255,0.12), rgba(91,140,255,0.04));
  border: 1px solid rgba(91,140,255,0.4);
  padding: 8px 14px; border-radius: 6px; margin-bottom: 14px;
  font-size: 13px;
}

/* Follow-up panel (job detail) */
.followup-card { background: rgba(239,90,90,0.04); border: 1px solid rgba(239,90,90,0.25); border-radius: 8px; padding: 14px 16px; margin: 12px 0; }
.followup-card h3 { margin: 0 0 8px; font-size: 13px; color: #ef5a5a; text-transform: uppercase; letter-spacing: 0.5px; }
.followup-card textarea { width: 100%; min-height: 70px; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 13px; font-family: inherit; box-sizing: border-box; resize: vertical; }
.followup-meta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.followup-actions { display: flex; gap: 8px; margin-top: 8px; align-items: center; }

/* Info grid */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 16px 0; background: var(--panel); border: 1px solid #2c4a8a; border-radius: 8px; padding: 16px; }
.info-grid-3 { grid-template-columns: repeat(3, 1fr); }
.info-grid > div { display: flex; flex-direction: column; }
.label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }

/* Card */
.card { background: var(--panel); border: 1px solid #2c4a8a; border-radius: 8px; padding: 16px 20px; margin: 16px 0; }
.card h2 { margin-top: 0; }

.diag { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.diag p { margin: 0; white-space: pre-wrap; }

/* Status bar */
.status-bar { display: flex; align-items: center; gap: 12px; margin: 12px 0 16px; }

/* Filters */
.filter-row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.filter-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-bottom: 2px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter { padding: 6px 12px; border-radius: 6px; background: var(--panel); border: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.filter:hover { color: var(--text); text-decoration: none; }
.filter.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Photo grid */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.photo-grid figure { margin: 0; background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.photo-grid img { width: 100%; height: 160px; object-fit: cover; border-radius: 4px; display: block; }
.photo-grid form { margin: 0; }

code { background: var(--panel-2); padding: 1px 5px; border-radius: 3px; font-size: 12px; }

/* Ticket number */
.ticket-number { font-size: 13px; font-weight: 600; color: var(--primary-2); letter-spacing: 0.5px; margin-top: 4px; display: block; }

/* Warranty coverage indicators */
.warranty-yes { color: var(--ok); font-weight: 600; margin: 0; }
.warranty-no  { color: var(--muted); margin: 0; }

/* Search */
.search-form { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; }

/* Compact jobs filter bar — search + status/brand/tech selects + stale toggle on one row */
.jobs-filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 16px;
}
.jobs-filter-bar .search-input { flex: 1 1 240px; min-width: 200px; }
.filter-select {
  padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  font-size: 13px; min-width: 140px;
  font-weight: 600;
}
.filter-select:focus { outline: none; border-color: var(--primary); }
/* When a status filter is active, the select itself adopts the colored pill look. */
select.status-select.active { font-weight: 700; }
.stale-check {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: 6px;
  border: 1px solid rgba(239,90,90,0.4); color: #ef5a5a;
  font-size: 13px; cursor: pointer; user-select: none;
}
.stale-check input { width: auto; margin: 0; accent-color: #ef5a5a; }
.stale-check:has(input:checked) { background: #ef5a5a; border-color: #ef5a5a; color: #fff; }
/* Inline-editable Diagnosis card on job_detail */
.diag-edit textarea,
.diag-edit input[type="text"],
.diag-edit input[type="number"] {
  width: 100%; padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--panel-2, #1c2030); color: var(--text);
  font: inherit; box-sizing: border-box;
}
.diag-edit textarea { min-height: 60px; resize: vertical; margin-top: 4px; }
.diag-edit textarea:focus,
.diag-edit input:focus,
.diag-warranty-select:focus { outline: none; border-color: var(--primary); }

.diag-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 14px;
}
.diag-head h2 { margin: 0; }
.diag-warranty-inline {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted, #9aa3b2);
}
.diag-warranty-select {
  padding: 6px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--panel-2, #1c2030); color: var(--text);
  font-size: 13px;
}

.diag-faults {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
@media (max-width: 720px) { .diag-faults { grid-template-columns: 1fr; } }

.condition-block { margin-top: 16px; }
.condition-block .label { display: block; margin-bottom: 6px; }
.condition-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
}
.condition-grid label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 13px; color: var(--muted);
}
.condition-grid select {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
}
.condition-grid select:focus { outline: none; border-color: var(--accent, #3fbf75); }
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.doc-list li:last-child { border-bottom: none; }
.rma-docs { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
@media (max-width: 720px) { .condition-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 380px) { .condition-grid { grid-template-columns: 1fr; } }

.accessory-block { margin-top: 16px; }
.accessory-block .label { display: block; margin-bottom: 6px; }
.accessory-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.accessory-check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text);
}
.accessory-check input { width: auto; margin: 0; }
.accessory-other-input {
  flex: 1 1 200px; min-width: 160px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
}
.accessory-other-input:focus { outline: none; border-color: var(--accent, #3fbf75); }

.parts-block { margin-top: 16px; }
.parts-block .label { display: block; margin-bottom: 6px; }
.parts-table {
  width: 100%; border-collapse: collapse; margin-top: 4px;
  background: var(--panel-2, #1c2030); border: 1px solid var(--border); border-radius: 6px;
  overflow: hidden;
}
.parts-table thead th {
  text-align: left; font-size: 12px; font-weight: 600;
  color: var(--muted, #9aa3b2); padding: 8px 10px;
  background: rgba(255,255,255,0.03); border-bottom: 1px solid var(--border);
}
.parts-col-qty  { width: 70px; }
.parts-col-warr { width: 90px; }
.parts-col-act  { width: 36px; }
.part-warranty-select {
  width: 100%; padding: 5px 8px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--panel-2, #1c2030);
  color: var(--text); font-size: 13px;
}
.part-warranty-select:focus { outline: none; border-color: var(--primary); }
.parts-table tbody td { padding: 6px 8px; vertical-align: middle; border-bottom: 1px solid var(--border); }
.parts-table tbody tr:last-child td { border-bottom: none; }
.parts-table input { background: transparent; border: 1px solid transparent; }
.parts-table input:hover { border-color: var(--border); }
.parts-table input:focus { background: var(--panel-2, #1c2030); border-color: var(--primary); }
.btn-row-del {
  width: 26px; height: 26px; border-radius: 4px; border: 1px solid var(--border);
  background: transparent; color: var(--muted, #9aa3b2); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0;
}
.btn-row-del:hover { background: #ef5a5a; border-color: #ef5a5a; color: #fff; }
.parts-table-actions { display: flex; justify-content: flex-start; margin-top: 8px; }
.btn-small { padding: 5px 10px; font-size: 12px; }

.diag-actions { display: flex; justify-content: flex-end; margin-top: 16px; }

.brand-add-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.brand-rename-form { display: flex; gap: 6px; align-items: center; }
.brand-input {
  padding: 7px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font-size: 13px; min-width: 200px;
}
.brand-input:focus { outline: none; border-color: var(--primary); }
.search-input { flex: 1; padding: 8px 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 13px; }
.search-input:focus { outline: none; border-color: var(--primary); }

/* Card */
.card { background: var(--panel); border: 1px solid #2c4a8a; border-radius: 8px; padding: 18px; }

/* Code block */
.code-block { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; font-size: 12px; font-family: monospace; white-space: pre; overflow-x: auto; margin: 8px 0 0; color: var(--muted); }

/* RMA */
.rma-card { margin-bottom: 16px; }
.rma-card--done { opacity: 0.6; }
.rma-card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.rma-contact { display: flex; gap: 20px; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.rma-actions { display: flex; gap: 8px; margin-top: 12px; }
.rma-item-set { margin-bottom: 8px; }
/* Public RMA form: keep labels and fieldset headings readable on white. */
.rma-page label,
.rma-page .form legend,
.rma-page > p { color: #000000; }
.pill-converted { background: rgba(63,191,117,.15); color: var(--ok); }
.pill-dismissed { background: var(--panel-2); color: var(--muted); }
.pill-sm { font-size: 10px; padding: 2px 7px; border-radius: 10px; }

/* Days in service */
.days-badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }
.days-badge-sm { display: inline-block; padding: 2px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--panel-2); color: var(--muted); }
.days-alert .days-badge, .days-alert { background: rgba(224,162,58,.15); color: var(--warn); border-color: rgba(224,162,58,.3); }
.days-warn .days-badge, .days-warn { background: rgba(239,90,90,.15); color: var(--danger); border-color: rgba(239,90,90,.3); }

/* Activity log */
.activity-log { display: flex; flex-direction: column; gap: 0; }
.activity-row { display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.activity-row:last-child { border-bottom: none; }
.activity-active { background: rgba(91,140,255,.05); border-radius: 6px; padding: 8px 6px; }
.activity-icon { color: var(--muted); font-size: 14px; text-align: center; }
.activity-body { line-height: 1.4; }
.activity-meta { color: var(--muted); font-size: 11px; white-space: nowrap; text-align: right; }
.activity-status .activity-icon { color: var(--primary-2); }

/* Parts report */
.tech-greeting {
  font-family: 'Caveat', 'Bradley Hand', 'Segoe Script', cursive;
  font-weight: 700;
  font-size: 20px;
  line-height: 1.1;
  color: #f0a958;
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
  transform: rotate(-1.5deg);
  max-width: 280px;
  white-space: normal;
  overflow-wrap: break-word;
  text-align: right;
}
@media (max-width: 900px) {
  .tech-greeting {
    flex-basis: 100%;
    max-width: none;
    text-align: center;
    font-size: 18px;
    transform: none;
    margin-top: 4px;
    padding: 0 4px;
  }
}

.parts-cell { max-width: 420px; font-size: 12px; vertical-align: top; }
.parts-mini {
  width: 100%; border-collapse: collapse; font-size: 12px;
  background: rgba(255,255,255,0.02); border: 1px solid var(--border); border-radius: 4px;
  overflow: hidden;
}
.parts-mini thead th {
  text-align: left; font-weight: 600; padding: 4px 6px;
  color: var(--muted, #9aa3b2); background: rgba(255,255,255,0.04);
  border-bottom: 1px solid var(--border); font-size: 11px;
}
.parts-mini tbody td {
  padding: 4px 6px; border-bottom: 1px solid var(--border);
  vertical-align: top; word-break: break-word;
}
.parts-mini tbody tr:last-child td { border-bottom: none; }
.parts-mini .pm-qty  { width: 36px; }
.parts-mini .pm-warr { width: 64px; }
.parts-mini tr.labor-row td { background: rgba(240,169,88,0.08); }
.parts-table tr.labor-row td { background: rgba(240,169,88,0.06); }
.parts-table tr.labor-row input[type="number"] { width: 70px; }
.warranty-pill {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
}
.warranty-pill.warranty-yes { background: rgba(94, 199, 122, 0.18); color: #5ec77a; }
.warranty-pill.warranty-no  { background: rgba(154, 163, 178, 0.18); color: #9aa3b2; }

/* Inline technician assign */
.inline-assign-form { margin: 0; }
.inline-assign-select { background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--text); font-size: 13px; padding: 2px 6px; cursor: pointer; transition: border-color .15s, background .15s; max-width: 130px; }
.inline-assign-select:hover, .inline-assign-select:focus { background: var(--panel-2); border-color: var(--border); outline: none; }

/* Inline status dropdown (jobs + parts tabs, admin only) */
.inline-status-form { margin: 0; }
.inline-status-select {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  max-width: 170px;
  transition: filter .15s, box-shadow .15s;
}
.inline-status-select:hover { filter: brightness(1.08); }
.inline-status-select:focus { outline: none; box-shadow: 0 0 0 2px rgba(255,255,255,.25); }

/* Inline parts report fields */
.inline-parts-form { margin: 0; }
.inline-po-input { background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--text); font-size: 13px; padding: 2px 6px; width: 110px; transition: border-color .15s, background .15s; }
.inline-po-input:hover, .inline-po-input:focus { background: var(--panel-2); border-color: var(--border); outline: none; }

/* =============================================================
   Mobile / Tablet — iPhone, Android (Samsung), small browsers
   ============================================================= */

/* Tablet & below */
@media (max-width: 900px) {
  .container { padding: 16px; }
  .topbar { padding: 10px 14px; gap: 12px; flex-wrap: wrap; }
  .topbar nav { order: 3; flex-basis: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .topbar nav::-webkit-scrollbar { height: 0; }
  .topbar nav a { white-space: nowrap; padding: 4px 0; }
  .user { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
  .who { font-size: 10px; }

  .section-head { flex-wrap: wrap; gap: 10px; }
  .row-actions { flex-wrap: wrap; }

  /* Tables: keep table layout intact (so columns align), let the wrapper scroll */
  .table-scroll > table.data { white-space: nowrap; min-width: 100%; }

  /* Dashboard toolbar — search becomes full row */
  .dash-header { flex-direction: column; align-items: stretch; }
  .dash-toolbar { flex-direction: column; align-items: stretch; }
  .dash-quick-search { width: 100%; }
  .dash-quick-search input { flex: 1; min-width: 0; width: 100%; }
  .dash-toolbar .filter-form { display: flex; }
  .dash-toolbar .filter-form select { flex: 1; }
  .dash-toolbar .btn { justify-content: center; }

  /* Stat grids — denser on tablet */
  .stat-headline-row { grid-template-columns: repeat(3, 1fr); }
  .stat-headline { padding: 16px 14px; }
  .stat-headline .stat-num { font-size: 28px; }
  .stat-status-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .attention-panel { grid-template-columns: 1fr; }
}

/* Phone */
@media (max-width: 560px) {
  body { font-size: 15px; }
  h1 { font-size: 20px; }
  h2 { font-size: 16px; }

  .container { padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .topbar { padding: 8px 12px; }
  .brand a { font-size: 15px; }
  .brand-logo { height: 76px; }
  .brand-sub { font-size: 10px; }

  /* Prevent iOS Safari from zooming when focusing inputs (needs >= 16px) */
  label input, label select, label textarea,
  .form input, .form select, .form textarea,
  .search-input, .dash-quick-search input,
  .followup-card textarea, .inline-po-input {
    font-size: 16px;
  }

  /* Bigger tap targets */
  .btn { padding: 10px 14px; min-height: 40px; }
  .btn-small { padding: 6px 10px; min-height: 32px; }
  .filter { padding: 8px 12px; min-height: 36px; }
  .topbar nav a { padding: 8px 0; }

  /* Stat cards stack to 1-2 columns */
  .stat-headline-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-headline-row > :first-child { grid-column: 1 / -1; }
  .stat-headline { padding: 14px; }
  .stat-headline .stat-num { font-size: 24px; }
  .stat-status-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-status .stat-num { font-size: 18px; }

  /* Info / diagnosis grids */
  .info-grid, .diag { grid-template-columns: 1fr; gap: 10px; padding: 12px; }
  .card { padding: 14px; }

  /* Status bar wraps cleanly */
  .status-bar { flex-wrap: wrap; gap: 8px; }

  /* Stale list rows can wrap */
  .stale-list li { flex-wrap: wrap; gap: 4px 8px; }

  /* Activity rows shrink on narrow screens */
  .activity-row { grid-template-columns: 22px 1fr; font-size: 12px; }
  .activity-row > :nth-child(3) { grid-column: 1 / -1; padding-left: 30px; color: var(--muted); font-size: 11px; }

  /* Photo grid */
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
  .photo-grid img { height: 120px; }

  /* Filter chips wrap */
  .filters { gap: 6px; }

  /* Auth card fits the screen */
  .auth-card { margin: 24px 12px; padding: 20px; }

  /* Hide the secondary clear-button text spacing creep */
  .filter-form { flex-wrap: wrap; }
}

/* Very narrow phones */
@media (max-width: 380px) {
  .stat-status-grid { grid-template-columns: 1fr; }
  .stat-headline-row { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: 1fr; }
  .photo-grid img { height: 180px; }
}

/* RMA share card */
.share-card { background: linear-gradient(135deg, rgba(91,140,255,0.08), rgba(91,140,255,0.02)); border-color: rgba(91,140,255,0.3); }
.share-card-body { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.share-info { flex: 1 1 320px; min-width: 0; }
.share-url { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.share-url input { flex: 1; min-width: 200px; padding: 8px 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-family: monospace; font-size: 13px; }
.share-qr { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
.share-qr img { display: block; }
@media (max-width: 560px) {
  .share-card-body { flex-direction: column; align-items: stretch; }
  .share-qr { align-self: center; }
  .share-url { flex-direction: column; align-items: stretch; }
  .share-url input { font-size: 16px; }
}

/* Headline "Needs attention" card */
.stat-attention { display: flex; flex-direction: column; }
.stat-attention .stat-num { color: #98e8b4; }
.stat-attention.stat-attention-warn { border-color: rgba(239,90,90,0.45); background: rgba(239,90,90,0.05); }
.stat-attention.stat-attention-warn .stat-num { color: #ef5a5a; }
.stat-attention-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.att-chip { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.att-chip-stale { color: #ef5a5a; border-color: rgba(239,90,90,0.4); background: rgba(239,90,90,0.08); }
.att-chip-rma { color: #ffd84d; border-color: rgba(255,216,77,0.4); background: rgba(255,216,77,0.08); }

/* Admin: export form layout */
.export-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.export-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.export-form input[type="date"] { min-width: 160px; }
@media (max-width: 560px) {
  .export-form { gap: 10px; }
  .export-form label { flex: 1 1 calc(50% - 6px); }
  .export-form button { width: 100%; }
}

/* Nav badge for pending counts (e.g. RMA) — round red dot with number inside */
.nav-link-with-badge { display: inline-flex; align-items: center; gap: 6px; }
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  background: #ef5a5a;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 0 2px rgba(239, 90, 90, 0.18);
}
.nav-badge.nav-badge-wide { font-size: 9px; letter-spacing: -0.5px; }

/* Horizontal-scroll wrapper for any .data table */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll > table.data { display: table; }

/* Job-status filter chip tints (Jobs tab + Parts report) */
.filter-status-pending                            { color:#ffd84d; border-color:rgba(255,216,77,0.45); background:rgba(255,216,77,0.06); }
.filter-status-pending.active                     { background:#ffd84d; color:#0f1115; border-color:#ffd84d; }
.filter-status-in-progress                        { color:#ff9b3d; border-color:rgba(255,155,61,0.45); background:rgba(255,155,61,0.06); }
.filter-status-in-progress.active                 { background:#ff9b3d; color:#0f1115; border-color:#ff9b3d; }
.filter-status-ready-to-quote                     { color:#5cd0d6; border-color:rgba(92,208,214,0.45); background:rgba(92,208,214,0.06); }
.filter-status-ready-to-quote.active              { background:#5cd0d6; color:#0f1115; border-color:#5cd0d6; }
.filter-status-awaiting-parts                     { color:#ef5a5a; border-color:rgba(239,90,90,0.45); background:rgba(239,90,90,0.06); }
.filter-status-awaiting-parts.active              { background:#ef5a5a; color:#fff; border-color:#ef5a5a; }
.filter-status-awaiting-customer-approval         { color:#f1f3f5; border-color:rgba(241,243,245,0.4);  background:rgba(241,243,245,0.04); }
.filter-status-awaiting-customer-approval.active  { background:#f1f3f5; color:#0f1115; border-color:#f1f3f5; }
.filter-status-customer-declined-repair           { color:#b0b3b8; border-color:rgba(176,179,184,0.45); background:rgba(176,179,184,0.06); }
.filter-status-customer-declined-repair.active    { background:#8a8f99; color:#fff; border-color:#8a8f99; }
.filter-status-completed                          { color:#98e8b4; border-color:rgba(152,232,180,0.45); background:rgba(152,232,180,0.06); }
.filter-status-completed.active                   { background:#98e8b4; color:#0f1115; border-color:#98e8b4; }
.filter-status-dispatched                         { color:#3fbf75; border-color:rgba(63,191,117,0.45);  background:rgba(63,191,117,0.06); }
.filter-status-dispatched.active                  { background:#3fbf75; color:#fff; border-color:#3fbf75; }

/* Urgent indicator */
.urgent-flag { font-size: 1em; margin-right: 4px; }
.urgent-row td { background: rgba(239, 90, 90, 0.06); }

/* Admin → Accounts → Signup link panel */
.signup-link-panel {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  background: var(--panel-2);
}
.signup-link-status { display: flex; align-items: center; gap: 8px; color: var(--text); }
.signup-link-row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.signup-link-input {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
.signup-link-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.22);
}
.signup-link-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.signup-link-panel hr { border: none !important; border-top: 1px solid var(--border) !important; }
@media (max-width: 600px) {
  .signup-link-row { flex-direction: column; align-items: stretch; }
  .signup-link-row .btn { width: 100%; }
}
