/* Two themes, picked per-person (see the toggle in base.html + localStorage)
   -- dark is the default for anyone who hasn't chosen yet, matching how the
   app already looked. Every color used anywhere below must be one of these
   variables; a hardcoded color is a color that only works in one theme. */
:root {
  --bg: #14171c;
  --panel: #1b1e25;
  --panel-2: #21252d;
  --border: #2c313a;
  --text: #e8eaed;
  --muted: #8b93a1;
  --accent: #5b84b5;
  --accent-text: #dce6f0;
  --on-accent: #11161c;
  --good: #4a9d76;
  --warn: #c99a4a;
  --danger: #c4564f;
  --stella: #c98aa3;
  --toolbar-bg: var(--panel);
  --toolbar-text: var(--text);
  --toolbar-link: var(--muted);
  --toolbar-link-hover: var(--accent);
  --flash-error-bg: #241a19;
  --flash-error-text: #dd8b86;
  --flash-error-border: #4a2c29;
  --flash-success-bg: #16211c;
  --flash-success-text: #7fbfa0;
  --flash-success-border: #2b4438;
  --radius: 2px;
  font-size: 14.5px;
}

:root[data-theme="light"] {
  --bg: #eef0f3;
  --panel: #ffffff;
  --panel-2: #f4f5f7;
  --border: #d3d7dc;
  --text: #1a1d23;
  --muted: #666e79;
  --accent: #1d5490;
  --accent-text: #0d2f52;
  --on-accent: #ffffff;
  --good: #2f7d4f;
  --warn: #a66a12;
  --danger: #b3382f;
  --stella: #a5527a;
  --toolbar-bg: #163257;
  --toolbar-text: #ffffff;
  --toolbar-link: #c3d4e8;
  --toolbar-link-hover: #ffffff;
  --flash-error-bg: #fdecea;
  --flash-error-text: #9a3327;
  --flash-error-border: #f1c1ba;
  --flash-success-bg: #e9f6ee;
  --flash-success-text: #256b41;
  --flash-success-border: #bfe3cd;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.demo-banner {
  background: var(--accent); color: var(--on-accent); text-align: center;
  padding: 9px 16px; font-size: 0.83rem; font-weight: 600;
}
.demo-banner a { color: var(--on-accent); text-decoration: underline; margin-left: 10px; font-weight: 700; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--border);
}

.brand { color: var(--toolbar-text); font-weight: 600; font-size: 1.05rem; text-decoration: none; }

.topbar-right a {
  color: var(--toolbar-link);
  text-decoration: none;
  margin-left: 18px;
  font-size: 0.92rem;
}
.topbar-right a:hover { color: var(--toolbar-link-hover); }
.topbar-right .who { color: var(--toolbar-text); margin-left: 18px; }

.theme-toggle {
  margin-left: 18px; background: transparent; color: var(--toolbar-link);
  border: 1px solid var(--toolbar-link); padding: 3px 10px; font-size: 0.78rem;
  border-radius: var(--radius); cursor: pointer; font-weight: 600;
}
.theme-toggle:hover { color: var(--toolbar-link-hover); border-color: var(--toolbar-link-hover); }

.clock-form { display: inline-block; margin-left: 18px; }
.clock-form .btn { padding: 4px 12px; font-size: 0.82rem; }
.clock-status.on {
  margin-left: 18px; color: var(--good); font-size: 0.85rem; font-weight: 600;
}
.clock-status.on::before { content: "●"; margin-right: 5px; font-size: 0.7em; }

.flash-wrap { padding: 8px 24px 0; }
.flash { padding: 9px 14px; border-radius: var(--radius); margin-bottom: 8px; font-size: 0.88rem; border: 1px solid; }
.flash-error { background: var(--flash-error-bg); color: var(--flash-error-text); border-color: var(--flash-error-border); }
.flash-success { background: var(--flash-success-bg); color: var(--flash-success-text); border-color: var(--flash-success-border); }

main { padding: 20px 28px; }

/* Kiosk board */
.board-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}
.board-header h1 { margin: 0 0 4px; font-size: 1.55rem; font-weight: 600; }
.date-line { color: var(--muted); }
.board-header-right { display: flex; align-items: center; gap: 20px; }
.clock { font-size: 1.8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.weather {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--border);
  padding: 9px 14px; border-radius: var(--radius);
}
.weather-icon { font-size: 1.6rem; }
.weather-temp { font-weight: 600; font-size: 1.1rem; }
.weather-desc { color: var(--muted); font-size: 0.9rem; }

.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.tech-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.tech-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tech-card-head h2 { margin: 0; font-size: 1.1rem; font-weight: 600; }
.badge {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.03em;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
  padding: 1px 7px; border-radius: 3px;
}

.encouragement {
  background: var(--panel-2);
  border: 1px solid var(--stella);
  border-left: 3px solid var(--stella);
  color: var(--stella);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 12px;
}
.encouragement-big { font-size: 1rem; padding: 12px 16px; }

.progress-row { margin-bottom: 10px; }
.progress-label { font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
.progress-bar {
  height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden;
}
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s ease; }
.progress-bar-week .progress-fill { background: var(--good); }

.task-section h3 { margin: 12px 0 6px; font-size: 0.95rem; color: var(--muted); }

/* Ticket cards (board + /me + admin ticket list) */
.ticket-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.ticket-card-head {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px;
  margin-bottom: 6px;
}
.ticket-customer { font-weight: 600; }
.ticket-car { color: var(--muted); font-size: 0.9rem; }
.ticket-card .task-list { margin-top: 4px; }

.ticket-card-head-link { color: inherit; text-decoration: none; }
.ticket-card-head-link:hover .ticket-customer { color: var(--accent); }
.ticket-open-hint { margin-left: auto; color: var(--accent); font-size: 0.85rem; }
.ticket-note { margin: 0 0 8px; }

.overdue-heading { color: var(--danger); font-weight: 600; }
.overdue-card { border-left: 3px solid var(--danger); }
.overdue-due { color: var(--danger); font-weight: 600; }

.task-list { list-style: none; margin: 0; padding: 0; }
.task-list li {
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.95rem;
}
.task-list li:last-child { border-bottom: none; }
.task-list li.done .task-title, .task-list li.done { color: var(--muted); text-decoration: line-through; }
.empty { color: var(--muted); font-size: 0.9rem; }

.task-list.interactive li { display: flex; flex-direction: column; gap: 2px; }
.task-list.interactive label { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.task-list.interactive input[type=checkbox] { width: 20px; height: 20px; }
.task-due { color: var(--muted); font-size: 0.8rem; }
.task-notes { color: var(--muted); font-size: 0.8rem; margin-left: 30px; }
.task-video {
  display: block; margin: 4px 0 0 30px; font-size: 0.8rem;
  color: var(--accent); text-decoration: none;
}
.task-video:hover { text-decoration: underline; }

/* Per-job timer: elapsed vs. book hours */
.job-timer { margin: 6px 0 2px 30px; max-width: 320px; }
.job-timer-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.job-timer-label { font-size: 0.78rem; color: var(--muted); flex: 1; }
.job-timer-elapsed { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.job-timer-bar { height: 5px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 3px; overflow: hidden; }
.job-timer-fill { height: 100%; background: var(--accent); transition: width 1s linear; }
.job-timer-fill.over { background: var(--danger); }
.timer-btn {
  background: none; border: 1px solid var(--border); color: var(--accent);
  padding: 2px 10px; font-size: 0.75rem; border-radius: var(--radius); cursor: pointer; font-weight: 600;
}
.timer-btn:hover { border-color: var(--accent); }
.timer-btn.stop { color: var(--danger); }
.timer-btn.stop:hover { border-color: var(--danger); }
.admin-table .job-timer { margin: 0; max-width: 130px; }
.admin-table .job-timer-elapsed { font-size: 0.82rem; }

/* Login */
.login-wrap { max-width: 340px; margin: 60px auto; }
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form label { font-size: 0.85rem; color: var(--muted); }
.login-form select, .login-form input, .admin-form input, .admin-form select {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 9px 11px; border-radius: var(--radius); font-size: 0.95rem;
}
button, .btn {
  background: var(--accent); color: var(--on-accent); border: 1px solid var(--accent); font-weight: 600;
  padding: 8px 15px; border-radius: var(--radius); cursor: pointer; font-size: 0.88rem;
  display: inline-block; text-align: center; text-decoration: none;
}
button.danger, .btn.danger { background: var(--panel-2); color: var(--danger); border-color: var(--danger); }
button.neutral, .btn.neutral { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }

.my-tasks-wrap h2 { margin-top: 24px; font-size: 1.1rem; color: var(--muted); }

/* Admin -- these pages are desktop-only, so give them real breathing room */
.admin-wrap { padding-bottom: 24px; }
.admin-wrap > h1 { margin: 0 0 28px; font-size: 1.4rem; font-weight: 600; }

.admin-section {
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.admin-section:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.admin-section h2 { margin: 0 0 16px; font-size: 1.05rem; font-weight: 600; }
.section-head-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.section-head-row h2 { margin: 0; }

.admin-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 260px)); gap: 16px 20px; align-items: end; }
.admin-form .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.admin-form .field label { font-size: 0.82rem; color: var(--muted); }
.admin-form input, .admin-form select { padding: 9px 12px; }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 0.87rem; }
.admin-table th { color: var(--muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; padding-bottom: 10px; }
.admin-table td { vertical-align: top; }
.admin-table td.check-cell { text-align: center; }
.admin-table td.check-cell input[type=checkbox] { width: 18px; height: 18px; }
.admin-table tr.done td { color: var(--muted); }
.admin-table form { margin: 0; }
button:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* NOT display:flex -- this class lands directly on a <td>, and setting flex
   there overrides its table-cell display, which drops it out of normal
   table layout and breaks the row's border-bottom right at that column.
   Sibling margins get the same evenly-spaced look while staying inline. */
.admin-table-actions { white-space: nowrap; vertical-align: middle; }
.admin-table-actions a { color: var(--accent); text-decoration: none; }
.admin-table-actions > * + * { margin-left: 16px; }

/* The destructive action (delete/remove) always lives in a <form> here,
   set explicitly rather than trusting it to inherit the general sibling
   gap above -- it needs real, deliberate distance from Print/Open, not
   just "a" gap, since a misclick here isn't undoable. */
.admin-table-actions form { display: inline; margin-left: 26px !important; }

/* Delete/Edit buttons here are real <button>s (for the confirm() + POST),
   but next to plain Open/Print links a bordered button looks like a
   different, oversized control. Strip the button chrome so every action
   in the row reads as the same plain text link, just colored by intent. */
.admin-table-actions button {
  background: none; border: none; padding: 0;
  font: inherit; cursor: pointer; text-decoration: none;
}
.admin-table-actions button:hover { text-decoration: underline; }
.admin-table-actions button.danger { color: var(--danger); }
.admin-table-actions button:not(.danger) { color: var(--accent); }

.ticket-filters { margin-bottom: 14px; font-size: 0.87rem; }
.ticket-filters a {
  color: var(--muted); text-decoration: none; margin-right: 4px;
  padding: 4px 10px; border-radius: var(--radius); display: inline-block;
  border: 1px solid transparent;
}
.ticket-filters a.active { color: var(--text); background: var(--panel-2); border-color: var(--border); }

.admin-table th.sortable { padding: 0; }
.admin-table th.sortable a {
  display: block; padding: 12px 14px 10px; color: var(--muted);
  text-decoration: none; font: inherit; text-transform: inherit; letter-spacing: inherit;
}
.admin-table th.sortable a:hover { color: var(--text); }
.sort-arrow { color: var(--accent); }

.status-badge {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 3px 8px; border-radius: 3px; font-weight: 600; white-space: nowrap;
  display: inline-block; border: 1px solid;
}
.status-estimate { background: transparent; color: var(--warn); border-color: var(--warn); }
.status-repair_order { background: transparent; color: var(--accent); border-color: var(--accent); }
.status-invoice { background: transparent; color: var(--good); border-color: var(--good); }

.status-form { display: flex; gap: 8px; flex-wrap: wrap; }

.approval-pending { background: transparent; color: var(--muted); border-color: var(--border); }
.approval-approved { background: transparent; color: var(--good); border-color: var(--good); }
.approval-declined { background: transparent; color: var(--danger); border-color: var(--danger); }

.quick-links {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border);
  font-size: 0.87rem;
}
.quick-links > a { color: var(--accent); }
.estimate-link-row { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.estimate-link {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 4px 8px; font-size: 0.8rem; max-width: 260px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.estimate-link-row .btn.neutral { padding: 4px 12px; font-size: 0.8rem; }

/* Digital vehicle inspection */
.inspection-list { display: flex; flex-direction: column; gap: 8px; }
.inspection-item-block {
  background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
}
.inspection-not_checked { border-left-color: var(--muted); }
.inspection-ok { border-left-color: var(--good); }
.inspection-recommended { border-left-color: var(--warn); }
.inspection-urgent { border-left-color: var(--danger); }
.inspection-item { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.inspection-item-label { font-weight: 600; min-width: 200px; flex: 1 1 200px; }
.inspection-status-select, .inspection-notes, .inspection-photo {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  padding: 6px 9px; border-radius: var(--radius); font-size: 0.85rem;
}
.inspection-notes { flex: 1 1 160px; }
.inspection-photo { flex: 1 1 160px; }
.inspection-checked-by { color: var(--muted); font-size: 0.75rem; width: 100%; }

.inspection-photos { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.inspection-photo-thumb { position: relative; width: 60px; height: 60px; }
.inspection-photo-thumb img {
  width: 60px; height: 60px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); display: block;
}
.photo-remove-btn {
  position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; padding: 0;
  border-radius: 50%; background: var(--panel); border: 1px solid var(--danger); color: var(--danger); font-size: 0.75rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.inspection-photo-upload { display: inline-block; }
.photo-upload-label {
  display: flex; align-items: center; justify-content: center; width: 60px; height: 60px;
  border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); font-size: 0.72rem;
  cursor: pointer; text-align: center;
}
.photo-upload-label:hover { border-color: var(--accent); color: var(--accent); }
.photo-upload-label input[type=file] { display: none; }

.inspection-video-player { width: 100%; max-width: 480px; border-radius: var(--radius); margin-bottom: 14px; display: block; }

.ticket-detail-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 24px; margin-bottom: 32px; padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.ticket-detail-head h1 { margin: 0 0 10px; font-size: 1.3rem; font-weight: 600; }
.ticket-detail-head .ticket-car { margin-bottom: 4px; }
.ticket-detail-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; min-width: 170px; }
.ticket-detail-actions button, .ticket-detail-actions .btn { width: 100%; }

.hint { color: var(--muted); font-size: 0.85rem; margin: -6px 0 20px; }

.admin-section > .btn { margin-top: 16px; }
.admin-section form.admin-form.hidden { display: none; }
.admin-section form.admin-form:not(.hidden) {
  margin-top: 20px; padding: 20px; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius);
}

.field.field-action-row { flex-direction: row; align-items: center; gap: 12px; }
.inline-hint { margin: 0; min-height: 1.2em; }

.totals-box { max-width: 340px; margin-top: 4px; }
.totals-row { display: flex; justify-content: space-between; padding: 6px 0; }
.totals-row.discount-row { color: var(--good); }
.totals-row.totals-grand {
  border-top: 1px solid var(--border); margin-top: 8px; padding-top: 12px;
  font-weight: 600; font-size: 1.05rem;
}
.discount-controls { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--border); }
.discount-controls .admin-form { align-items: end; }

.praise-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel); border: 1px solid var(--stella); color: var(--stella); padding: 10px 18px; border-radius: var(--radius);
  font-weight: 600; opacity: 0; transition: all 0.25s ease; pointer-events: none;
}
.praise-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.hidden { display: none; }

/* Calendar */
.cal-nav { margin: -8px 0 24px; color: var(--muted); }
.cal-nav a { color: var(--accent); text-decoration: none; }

.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.cal-weekday {
  background: var(--panel); color: var(--muted); font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.04em; padding: 9px 12px;
}
.cal-day {
  background: var(--panel-2); min-height: 110px; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.cal-day.other-month { background: var(--bg); opacity: 0.55; }
.cal-day.today { box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day-num { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.cal-appt {
  display: block; background: var(--panel); border: 1px solid var(--accent); color: var(--accent-text);
  border-radius: 3px; padding: 2px 6px; font-size: 0.76rem; text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-appt.linked { border-color: var(--good); color: var(--good); }
.cal-add {
  color: var(--muted); font-size: 0.75rem; text-decoration: none; margin-top: auto;
}
.cal-add:hover { color: var(--accent); }

.delete-appt-form { margin-top: 20px; }
.link-ticket-form { margin-top: 16px; }

/* Team Board quick-view */
.quickview-trigger { cursor: pointer; }
.quickview-trigger:hover { border-color: var(--accent); }
.quickview-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.quickview-modal {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55);
  align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.quickview-modal.open { display: flex; }
.quickview-panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; max-width: 440px; width: 100%; max-height: 82vh; overflow-y: auto; position: relative;
}
.quickview-close {
  position: absolute; top: 14px; right: 14px; background: none; border: none;
  color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 4px;
}
.quickview-close:hover { color: var(--text); }
.quickview-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; padding-right: 24px; }
.quickview-head h3 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.quickview-panel h4 { margin: 18px 0 8px; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.quickview-panel .btn { margin-top: 18px; }
