/* ══════════════════════════════════════════════════════════════
   users.css
   Identity, roles, toasts + the newest feature styles.
   ══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════
   MULTI-USER: identity, roles, toasts
   ═══════════════════════════════════════════════════════════════ */
.sb-user {
  display: flex; align-items: center; gap: 9px; width: 100%; margin-bottom: 10px;
  padding: 7px 9px; border-radius: 10px; border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06); color: #fff; font-family: inherit; cursor: pointer;
  text-align: left; transition: background .14s, border-color .14s;
}
.sb-user:hover { background: rgba(255,255,255,.13); border-color: rgba(255,255,255,.25); }
.sb-user-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--cs-accent-grad); color: #fff; font-size: 10.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.sb-user-mid { display: block; min-width: 0; flex: 1; }
.sb-user-name { display: block; font-size: 12.5px; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-role { display: block; font-size: 10px; color: rgba(255,255,255,.5);
  text-transform: uppercase; letter-spacing: .06em; }
body.sb-collapsed .sb-user { justify-content: center; padding: 7px; }

/* Role key inside the users modal */
.role-key { display: flex; flex-direction: column; gap: 6px; font-size: 12px;
  color: var(--text-secondary); background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 13px; }
.role-key b { color: var(--text); }

/* User rows */
.usr-row { display: flex; align-items: center; gap: 11px; padding: 10px 4px;
  border-bottom: 1px solid var(--border); }
.usr-row:last-child { border-bottom: none; }
.usr-mid { flex: 1; min-width: 0; }
.usr-name { display: block; font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usr-at { font-weight: 500; color: var(--text-muted); font-size: 12px; }
.usr-sub { display: block; font-size: 11px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chk-line { display: flex; align-items: center; gap: 7px; font-size: 12.5px;
  color: var(--text-secondary); cursor: pointer; }
.chk-line input { width: auto; margin: 0; }

.inline-msg { font-size: 12px; border-radius: 8px; padding: 8px 11px; margin-bottom: 10px; }
.inline-msg.warn { background: var(--accent-red-bg); color: var(--accent-red-text); }
.inline-msg.ok   { background: #dcfce7; color: #166534; }

/* Toasts */
.toast-host { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 500; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: min(440px, calc(100vw - 32px)); }
.toast { display: flex; align-items: center; gap: 9px; width: 100%;
  background: #111427; color: #fff; border-radius: 11px; padding: 11px 14px;
  font-size: 12.5px; box-shadow: 0 10px 34px rgba(0,0,0,.28);
  animation: toastIn .22s ease; }
.toast i { font-size: 17px; flex-shrink: 0; }
.toast-error { background: #b91c1c; }
.toast-ok    { background: #15803d; }
.toast.out { opacity: 0; transform: translateY(8px); transition: opacity .3s, transform .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Roles without money.view: belt-and-braces hiding of anything price-shaped.
   The server already strips these values; this stops empty columns showing. */
body.no-money .money-only,
body.no-money .dash-kpi[data-money="1"],
body.no-money #tabBtnInvoices,
body.no-money #tabBtnJobReg,
body.no-money #tabBtnSales { display: none !important; }

/* When the revenue chart is hidden (no money.view) the donut takes the row. */
.dash-donut-card.dash-donut-wide { grid-column: span 12; }

/* ══ Dashboard: small period toggle in the page header ══ */
.page-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dash-period { display: inline-flex; gap: 2px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 9px; padding: 2px; }
.dash-period-btn { border: none; background: none; font: inherit; font-size: 11.5px;
  font-weight: 700; color: var(--text-muted); padding: 5px 12px; border-radius: 7px;
  cursor: pointer; transition: background .15s, color .15s, box-shadow .15s;
  white-space: nowrap; letter-spacing: .01em; }
.dash-period-btn:hover { color: var(--text); }
.dash-period-btn.is-on { background: var(--surface); color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.14); }

/* ══ Money KPI tiles as flip cards ══
   The figure lives on the back face, so it is never on show until asked for. */
.dash-kpi-flip { perspective: 900px; min-width: 0; }
.dash-flip-inner { position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform .45s cubic-bezier(.4,.2,.2,1); }
.dash-kpi-flip.is-flipped .dash-flip-inner { transform: rotateY(180deg); }
.dash-flip-face { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.dash-flip-face.is-back { position: absolute; inset: 0; transform: rotateY(180deg);
  display: flex; flex-direction: column; }
.dash-kpi-flip .dash-kpi { width: 100%; height: 100%; }
/* the little eye that turns the card, and the hide button on the back */
.dash-kpi-flip .dash-kpi-go { opacity: .5; }
.dash-kpi-flip .is-front:hover .dash-kpi-go { opacity: 1; }
.dash-flip-hide { position: absolute; top: 8px; right: 8px; border: none;
  background: none; color: var(--text-muted); cursor: pointer; padding: 3px;
  border-radius: 6px; line-height: 1; }
.dash-flip-hide:hover { color: var(--text); background: var(--bg); }
.dash-flip-hide i { font-size: 14px; }
/* the drill-through link on the revealed side */
.dash-flip-go { margin-top: auto; align-self: flex-start; border: 1px solid var(--border);
  background: var(--bg); color: var(--kpi, var(--text)); font: inherit; font-size: 11px;
  font-weight: 700; padding: 4px 10px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px; transition: all .15s; }
.dash-flip-go:hover { border-color: var(--kpi); background: var(--surface); }
.dash-flip-go i { font-size: 13px; }
.dash-kpi-flip .dash-kpi-value { font-variant-numeric: tabular-nums; }

/* the bar graph shown while the amount is hidden */
.dash-spark { display: inline-flex; align-items: flex-end; gap: 2.5px; height: 24px; }
.dash-spark i { display: block; width: 5px; border-radius: 2px;
  background: currentColor; opacity: .3; }
.dash-kpi-value.is-money { color: var(--kpi, var(--text-muted)); }

@media (prefers-reduced-motion: reduce) {
  .dash-flip-inner { transition: none; }
}
@media (max-width: 600px) {
  .dash-period-btn { padding: 5px 10px; }
}

/* ══ Car sale: quick "mark paid" buttons on register rows ══ */
.sale-pay-quick { display: inline-flex; gap: 2px; margin-right: 4px;
  padding-right: 6px; border-right: 1px solid var(--border); }
.sale-pay-btn { color: #16a34a; }
.sale-pay-btn:hover { background: rgba(22,163,74,.12); }
.sale-pay-btn:nth-child(2) { color: #1e40af; }
.sale-pay-btn:nth-child(2):hover { background: rgba(30,64,175,.12); }

/* ══════════════════════════════════════════════════════════════
   CAR SALES — register actions, printed stamp, and the sale form
   ══════════════════════════════════════════════════════════════ */

/* ── "Take payment" column, sat between the vehicle and the money columns
      so the buttons can never cover the figures ── */
.sale-pay-cell { display: flex; align-items: center; justify-content: center; gap: 2px; }
.sale-pay-cell .btn-icon { width: 30px; height: 30px; display: inline-flex;
  align-items: center; justify-content: center; border-radius: 8px; }
.sale-pay-cell .btn-icon i { font-size: 15px; }
.sale-paid-tick { color: #22c55e; opacity: .38; display: inline-flex; }
.sale-paid-tick i { font-size: 15px; }
.sale-print-cell { display: flex; align-items: center; justify-content: flex-end; }
.sale-print-cell .btn-icon { width: 30px; height: 30px; display: inline-flex;
  align-items: center; justify-content: center; border-radius: 8px; }
.sale-print-cell .btn-icon i { font-size: 15px; }
.sale-pay-btn.is-cash { color: #16a34a; }
.sale-pay-btn.is-cash:hover { background: rgba(22,163,74,.12); }
.sale-pay-btn.is-card { color: #1e40af; }
.sale-pay-btn.is-card:hover { background: rgba(30,64,175,.12); }
.sale-print-btn { color: var(--text-muted); }
.sale-print-btn:hover { color: var(--text); background: var(--bg); }

/* ── Printed sale invoice: keep the number readable ── */
.sale-inv-meta { display: flex; gap: 10px; justify-content: flex-end;
  align-items: baseline; margin-top: 3px; flex-wrap: wrap; }
.sale-inv-no { font-size: 13px; font-weight: 800; color: #111;
  background: #fff3ee; border: 1px solid #f3b9a2; border-radius: 5px;
  padding: 1px 8px; letter-spacing: .02em;
  -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.sale-inv-no b { font-weight: 700; color: #7a3418; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .05em; }
.sale-inv-date { font-size: 11px; color: #111; }

/* The PAID stamp sits low on the page, clear of the invoice number. */
.sale-paid-stamp { position: absolute; left: 50%; bottom: 96px;
  transform: translateX(-50%) rotate(-11deg);
  border: 3px solid #16a34a; color: #16a34a; font-weight: 900;
  font-size: 23px; letter-spacing: .18em; padding: 4px 18px;
  border-radius: 8px; opacity: .5; pointer-events: none; z-index: 2;
  white-space: nowrap;
  -webkit-print-color-adjust: exact; print-color-adjust: exact; }

/* ── A field the form is asking to be corrected ── */
.field-invalid { border-color: #dc2626 !important;
  box-shadow: 0 0 0 4px rgba(220,38,38,.14) !important; }

/* ══ The sale form — roomier and better organised on wide screens ══ */
.sale-modal .modal-body { padding-top: 4px; }
.sale-modal .sl-sec-title {
  display: flex; align-items: center; gap: 9px;
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-secondary);
  margin: 18px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border); }
.sale-modal .sl-sec-title::before {
  content: ''; width: 3px; height: 14px; border-radius: 2px;
  background: var(--cs-accent, #F15A24); flex: none; }
.sale-modal .sl-sec-title:first-of-type { margin-top: 4px; }
.sale-modal .sl-more-btn { margin-top: 2px; }

/* Three fields across once there is room, so the form fills the width
   instead of leaving a long empty column. */
@media (min-width: 900px) {
  .sale-modal .field-row { display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 10px 14px; align-items: end; }
  .sale-modal .field-row > .field-group { min-width: 0; }
  /* rows that only hold one field should still span sensibly */
  .sale-modal .field-row > .field-group:only-child { grid-column: span 2; }
}
@media (max-width: 899px) {
  .sale-modal .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
}
@media (max-width: 560px) {
  .sale-modal .field-row { grid-template-columns: 1fr; }
  .sale-actions { grid-template-columns: repeat(3, 28px); }
}

/* ══ Sale form — a more considered, professional layout ══ */
.sale-modal .modal-body { background: var(--bg); padding: 14px 16px 4px; }
/* every section is a card, so the form reads as grouped paperwork */
.sale-modal .sl-sec-title {
  background: var(--surface); border: 1px solid var(--border);
  border-bottom: none; border-radius: 12px 12px 0 0;
  margin: 16px 0 0; padding: 11px 14px; }
.sale-modal .sl-sec-title:first-of-type { margin-top: 0; }
.sale-modal .sl-sec-body {
  background: var(--surface); border: 1px solid var(--border);
  border-top: none; border-radius: 0 0 12px 12px;
  padding: 14px; margin-bottom: 2px; }
.sale-modal .sl-sec-body > .field-row:last-child { margin-bottom: 0; }
.sale-modal .sl-more-btn {
  width: 100%; text-align: left; margin: 10px 0 0;
  background: var(--bg); border: 1px dashed var(--border); border-radius: 9px;
  padding: 9px 12px; font-size: 12px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; transition: all .15s; }
.sale-modal .sl-more-btn:hover {
  border-color: var(--cs-accent, #F15A24); color: var(--cs-accent-2, #e0331d);
  background: var(--surface); }
/* labels + required marker + inline hints */
.sale-modal .field-group label {
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  color: var(--text-secondary); display: flex; align-items: baseline;
  gap: 6px; margin-bottom: 5px; }
.sale-modal .sl-hint { font-weight: 500; font-size: 10.5px;
  color: var(--text-muted); letter-spacing: 0; }
.sale-modal .field-group input,
.sale-modal .field-group select { height: 38px; }
.sale-modal .field-group input[type="number"] { font-variant-numeric: tabular-nums; }
/* the running total block stands out as the result of the form */
.sale-modal .inv-totals, .sale-modal .sl-summary {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; }
.sale-modal .modal-footer { background: var(--surface);
  border-top: 1px solid var(--border); }

/* ══ Editable invoice number on the invoice sheet ══ */
.inv-no-edit { outline: none; border-bottom: 1px dashed transparent; padding: 0 3px;
  border-radius: 3px; transition: background .15s, border-color .15s; cursor: text; }
.inv-no-edit:hover { background: #fff7ed; border-bottom-color: #f3b9a2; }
.inv-no-edit:focus { background: #fff; border-bottom-color: #F15A24;
  box-shadow: 0 0 0 3px rgba(241,90,36,.14); }
@media print { .inv-no-edit { background: none !important; border-bottom: none !important;
  box-shadow: none !important; } }

/* ══ Invoice numbering mode (Business Settings → Invoicing) ══ */
.num-mode { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
  background: var(--bg); margin-bottom: 14px; }
.num-mode-row { display: flex; align-items: center; gap: 14px; justify-content: space-between; }
.num-mode-title { font-size: 13.5px; font-weight: 700; color: var(--text); }
.num-mode-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.num-mode-note { font-size: 11.5px; color: var(--text-secondary); line-height: 1.55;
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
/* the switch */
.switch { position: relative; display: inline-block; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { display: block; width: 46px; height: 26px; border-radius: 999px;
  background: var(--border); transition: background .2s; position: relative; }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: transform .2s; }
.switch input:checked + .switch-track { background: linear-gradient(135deg,#F15A24,#e0331d); }
.switch input:checked + .switch-track .switch-knob { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 4px rgba(241,90,36,.22); }

/* ══ Ask-for-number dialog shown when printing ══ */
.askno-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .askno-grid { grid-template-columns: 1fr; } }
.askno-msg { font-size: 12.5px; margin-top: 8px; min-height: 1.2em; }
.askno-msg.bad { color: #A32D2D; }
.askno-hint { font-size: 11.5px; color: var(--text-muted); margin: 0 0 12px; }
.req-star { color: #dc2626; }
.askno-suggest { font-size: 11.5px; color: var(--text-muted); margin-top: 9px; }
.askno-suggest button { font: inherit; font-weight: 700; font-family: 'Courier New', monospace;
  color: var(--cs-accent-2, #e0331d); background: rgba(241,90,36,.10);
  border: 1px solid rgba(241,90,36,.32); border-radius: 7px; padding: 3px 9px;
  margin-left: 4px; cursor: pointer; transition: background .15s; }
.askno-suggest button:hover { background: rgba(241,90,36,.2); }
