/* Dark always (Forgejo issue #100): the shop console's palette tokens --
   same names, same values as the admin and support portals (#99) -- and
   the same secondary colours (header #0b0d11, fields #0d0f13, tiles
   #14171e, pill tints #12291d / #241a0f / #2a1414), so every page is one
   family. No toggle, no light variant (that can come later). */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --muted: #8b92a3;
  --accent: #5b9cf6;
  --ok: #4caf7d;
  --warn: #e0a83b;
  --err: #e0605b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); font-size: 16px; line-height: 1.45; }
a, a:visited { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .4rem; }
h2 { font-size: 1.25rem; margin: 1.2rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: .8rem 0 .3rem; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.hidden { display: none !important; }
.btn, a.btn:visited { display: inline-block; padding: .6rem 1rem; border: 1px solid var(--border); border-radius: 8px; background: #0d0f13; color: var(--text); text-decoration: none; cursor: pointer; font-size: 1rem; }
.btn-primary, a.btn-primary:visited { background: var(--accent); border-color: var(--accent); color: #06101f; font-weight: 600; }
.btn-danger { border-color: #7f1d1d; background: #0d0f13; color: #f87171; }
.btn:focus-visible, .choice:focus-visible, header.top nav button:focus-visible, header.top nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-small { padding: .3rem .6rem; font-size: .9rem; }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
input, select, textarea { font: inherit; padding: .5rem; border: 1px solid var(--border); border-radius: 6px; width: 100%; background: #0d0f13; color: var(--text); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input[readonly] { color: var(--muted); }
label { display: block; margin: .6rem 0 .2rem; font-weight: 600; }
.landing { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.landing-box { background: var(--panel); border: 1px solid var(--border); padding: 2rem; border-radius: 12px; max-width: 28rem; width: 92%; box-shadow: 0 2px 12px rgba(0,0,0,.4); text-align: center; }
.landing-buttons { display: flex; gap: .8rem; justify-content: center; margin: 1.4rem 0; flex-wrap: wrap; }
header.top { background: #0b0d11; color: var(--text); border-bottom: 1px solid var(--border); padding: .7rem 1rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
header.top .title { font-weight: 700; font-size: 1.15rem; }
header.top nav { display: flex; gap: .3rem; flex-wrap: wrap; }
header.top nav button { background: transparent; color: var(--text); border: 1px solid transparent; border-radius: 6px; padding: .35rem .7rem; cursor: pointer; font-size: .95rem; }
header.top nav button.active { border-color: var(--accent); }
header.top nav a, header.top nav a:visited { color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: .35rem .7rem; font-size: .95rem; text-decoration: none; display: inline-flex; align-items: center; }
header.top nav a.hidden { display: none; }
main.app { max-width: 52rem; margin: 0 auto; padding: 1rem; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; margin: .8rem 0; }
.notice { background: #241a0f; border: 1px solid #6b4e1e; color: var(--text); border-radius: 8px; padding: .7rem .9rem; margin: .8rem 0; }
.error { background: #2a1414; border: 1px solid #7f1d1d; color: #ffb4b0; border-radius: 8px; padding: .7rem .9rem; margin: .8rem 0; }
.ok { background: #12291d; border: 1px solid #2c6646; color: var(--text); border-radius: 8px; padding: .7rem .9rem; margin: .8rem 0; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 10rem; }
.choices { display: flex; flex-wrap: wrap; gap: .5rem; margin: .4rem 0; }
.choice { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .8rem; background: #0d0f13; color: var(--text); cursor: pointer; }
.choice.selected { border-color: var(--accent); background: #14233b; }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: .35rem .3rem; border-bottom: 1px solid var(--border); font-size: .95rem; }
th { color: var(--muted); font-weight: 600; }
.tag { display: inline-block; font-size: .8rem; padding: .1rem .45rem; border-radius: 999px; background: #1d212b; color: var(--muted); margin-left: .3rem; }
.tag-warn { background: #241a0f; color: var(--warn); }
.step { border-left: 3px solid var(--accent); padding-left: .8rem; margin: 1rem 0; }

/* My visits (issue #105). The signing pad stays WHITE on the dark page
   (as the signing link's page does, #100): the stored signature is dark
   ink on white paper, and that is what prints. */
.visit-item { cursor: pointer; }
.visit-item h3 { margin-top: 0; }
.visit-money { font-weight: 600; }
.visit-section { margin: .8rem 0; }
.visit-section h3 { margin-bottom: .2rem; }
.visit-totals td:last-child, .visit-lines td:last-child, .visit-lines th:last-child { text-align: right; }
.visit-totals tr.strong td { font-weight: 700; color: var(--text); }
.terms { font-size: .9rem; color: var(--muted); background: #0d0f13; border: 1px solid var(--border); border-radius: 6px; padding: .6rem; margin: .6rem 0; max-height: 12rem; overflow-y: auto; -webkit-overflow-scrolling: touch; white-space: pre-wrap; }
canvas.sig-pad { width: 100%; height: 200px; display: block; background: #fff; border: 1px solid var(--border); border-radius: 8px; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.pad-row { display: flex; justify-content: flex-end; margin-top: .4rem; }
@media (min-width: 600px) { canvas.sig-pad { height: 180px; } }
@media (max-height: 480px) and (orientation: landscape) { canvas.sig-pad { height: 150px; } }

/* ==== Phones (Forgejo issue #85) ====
   Customers open these pages on their own phones. Rules every customer
   page follows: no sideways page scroll at 390px (long names and emails
   wrap; a table scrolls inside its own .table-wrap); every tap target at
   least 44px tall on a touch screen or a narrow window; field text 16px
   or more (iOS zooms into anything smaller); viewport-fit=cover in the
   pages' meta tag plus the safe-area padding below, so a notched phone on
   its side never hides an edge. Desktop above 900px looks as before. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-wrap: anywhere; }
input, select, textarea { font-size: 16px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.table-wrap table { min-width: 20rem; }
td a { white-space: nowrap; }
.landing { min-height: 100dvh; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
header.top { padding-top: max(.7rem, env(safe-area-inset-top)); padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
main.app { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
label.check, label.small { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
label.check input[type=checkbox], label.small input[type=checkbox] { width: 1.3rem; height: 1.3rem; flex: 0 0 auto; margin: 0; }
@media (max-width: 899.98px), (pointer: coarse) {
  .btn, .btn-small, .choice, header.top nav button, header.top nav a { min-height: 44px; }
  .btn, .btn-small { display: inline-flex; align-items: center; justify-content: center; }
  .btn-small { padding: .5rem .9rem; font-size: 1rem; }
  input:not([type=checkbox]):not([type=radio]), select { min-height: 44px; }
  label.check, label.small { min-height: 44px; }
  p.small a { display: inline-block; padding: .55rem 0; }
}
@media (max-width: 599.98px) {
  h1 { font-size: 1.4rem; }
  main.app { padding-top: .6rem; }
  .card { padding: .9rem; border-radius: 8px; }
  header.top nav { width: 100%; }
  header.top nav button { flex: 1 1 auto; padding: .45rem .5rem; }
  .choices .choice { flex: 1 1 calc(50% - .5rem); text-align: center; }
  form .btn-primary, #book-confirm, #change-save, #change-cancel, #visit-approve-go, #visit-decline-go, #visit-pdf { width: 100%; }
  .row > .btn { flex: 1 1 100%; }
  .landing-box { padding: 1.4rem 1.1rem; }
  .landing-buttons a { flex: 1 1 100%; }
}

/* Report a problem (Forgejo issue #103): a button in the bottom corner
   and a pop-up that becomes a full-screen sheet on a phone. */
.rp-open { position: fixed; right: max(12px, env(safe-area-inset-right, 0px)); bottom: max(12px, env(safe-area-inset-bottom, 0px)); min-height: 44px; z-index: 900; box-shadow: 0 2px 10px rgba(0,0,0,.5); }
.rp-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.rp-backdrop.hidden { display: none !important; }
.rp-box { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; width: 36rem; max-width: 95vw; max-height: 90vh; overflow-y: auto; overflow-wrap: anywhere; }
.rp-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.rp-head h2 { margin: 0; }
.rp-x { min-width: 44px; min-height: 44px; }
.rp-box .btn { min-height: 44px; }
.rp-box textarea, .rp-box input { font-size: 16px; }
@media (max-width: 599.98px) {
  .rp-backdrop { align-items: stretch; justify-content: stretch; }
  .rp-box { width: 100%; max-width: 100%; max-height: 100%; border-radius: 0; border: none;
    padding: max(16px, env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px)); }
}

/* Messages with the shop (issue #114): the thread, newest at the bottom.
   Text is always shown as typed (white-space: pre-wrap). */
.nav-unread { display: inline-block; min-width: 1.2rem; padding: 0 .35rem; border-radius: 999px; background: var(--accent); color: #06101f; font-size: .78rem; font-weight: 700; line-height: 1.2rem; text-align: center; margin-left: .2rem; }
.cm-thread { display: flex; flex-direction: column; gap: .5rem; max-height: 60vh; overflow-y: auto; margin: .6rem 0; padding: .2rem; }
.cm-msg { max-width: 88%; align-self: flex-start; background: #0d0f13; border: 1px solid var(--border); border-radius: 10px; padding: .5rem .7rem; }
.cm-msg.mine { align-self: flex-end; background: #14233b; border-color: #2a4a7a; }
.cm-msg.auto { border-style: dashed; }
.cm-meta { font-size: .8rem; color: var(--muted); display: flex; gap: .5rem; flex-wrap: wrap; }
.cm-meta strong { color: var(--text); }
.cm-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.cm-auto-tag { border: 1px solid var(--border); border-radius: 999px; padding: 0 .4rem; font-size: .75rem; }
.cm-list-item { cursor: pointer; }
/* Pictures in messages and undo send (issue #114, 2026-11-18). */
.cm-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
#messages-attach { position: relative; }
#messages-attach.disabled { opacity: .5; pointer-events: none; }
.cm-previews { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0; }
.cm-prev { position: relative; width: 4.5rem; height: 4.5rem; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: #0d0f13; display: flex; align-items: center; justify-content: center; font-size: .75rem; color: var(--muted); text-align: center; }
.cm-prev img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cm-prev.failed { border-color: var(--err); color: var(--err); }
.cm-prev-x { position: absolute; top: 2px; right: 2px; min-width: 1.8rem; min-height: 1.8rem; padding: 0; border-radius: 999px; border: 1px solid var(--border); background: #0d0f13; color: var(--text); cursor: pointer; }
.cm-prev-bar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--accent); width: 0; }
.cm-pics { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .3rem; }
/* Files (issue #114 files): PDF chips in messages, the visit page list. */
.cm-file-chip, .visit-file a { overflow-wrap: anywhere; }
.visit-files-list { list-style: none; padding: 0; margin: .4rem 0; display: flex; flex-direction: column; gap: .4rem; }
.visit-file { display: flex; gap: .6rem; align-items: center; }
.visit-file img { width: 3rem; height: 3rem; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); }
.cm-pic { padding: 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; width: 6rem; height: 6rem; background: #0d0f13; cursor: zoom-in; }
.cm-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cm-msg.pending { border-style: dashed; opacity: .9; }
.cm-pending-line { display: flex; gap: .6rem; align-items: center; font-weight: 600; font-size: .9rem; }
.cm-pending-line .btn { padding: .2rem .8rem; }
.cm-undo-bar { height: 3px; background: var(--accent); margin-top: .3rem; transform-origin: left center; animation-name: cm-undo-count; animation-timing-function: linear; animation-fill-mode: forwards; }
@keyframes cm-undo-count { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.cm-viewer { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; padding: .8rem; }
.cm-viewer.hidden { display: none !important; }
.cm-viewer img { max-width: 96vw; max-height: 80vh; object-fit: contain; border-radius: 6px; background: #111; }
#view-messages { padding-bottom: 4.5rem; } /* room for the Report a problem button */
#messages-thread h3 { margin-top: 0; }
#signup-texts-box { align-items: flex-start; font-weight: 400; }
#signup-texts-box input { margin-top: .15rem; }

/* Inspections (issue #106): the colour dots, counts and photo strip. */
.insp-counts { display: flex; gap: .8rem; flex-wrap: wrap; margin: .4rem 0; font-weight: 600; }
.insp-dot { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; vertical-align: middle; background: #555b68; }
.insp-dot.green { background: var(--ok); } .insp-dot.yellow { background: var(--warn); } .insp-dot.red { background: var(--err); }
.insp-items { list-style: none; padding: 0; margin: .2rem 0 .6rem; }
.insp-item { border-top: 1px solid var(--border); padding: .5rem 0; overflow-wrap: anywhere; }
.insp-thumbs { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .4rem; }
.insp-photo { margin: 0; width: 7.5rem; }
.insp-photo img { width: 7.5rem; height: 5.6rem; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); display: block; }
