/* ObraSlip styles.
   Layout: one phone-width column, sticky brand bar on top, tab bar at the bottom.
   --brand is set per business from Settings; everything else derives from it. */
:root {
  --brand: #000A66;
  --brand-fg: #ffffff;
  --accent: var(--brand);
  --accent-fg: #ffffff;
  --accent-soft: color-mix(in srgb, var(--brand) 9%, white);
  --bg: #f4f5f9;
  --surface: #ffffff;
  --sunken: #eceef4;
  --fg: #12152b;
  --muted: #5e6480;
  --line: #e0e3ec;
  --ok: #18794e; --ok-soft: #e3f5ec;
  --warn: #8a5a00; --warn-soft: #fff4d6;
  --danger: #c0352b;
  --shadow: 0 1px 2px rgba(16, 20, 50, .05), 0 6px 20px rgba(16, 20, 50, .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Manrope", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --r: 18px;
  --tabbar-h: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: color-mix(in srgb, var(--brand) 45%, #c9cfff);
    --accent-fg: #0b0e24;
    --accent-soft: color-mix(in srgb, var(--brand) 30%, #161a2c);
    --bg: #0d0f1a; --surface: #161a2b; --sunken: #1f2438; --fg: #eceef7; --muted: #9aa0bd; --line: #2a3048;
    --ok: #5fd39a; --ok-soft: #12301f; --warn: #f3cc6b; --warn-soft: #34290f; --danger: #ff8a80;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 var(--font);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 24px);
}
[hidden] { display: none !important; }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--font-head); letter-spacing: -.01em; margin: 0; text-wrap: balance; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .85rem; }
.eyebrow { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.wrap { max-width: 640px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--brand); color: var(--brand-fg); padding-top: env(safe-area-inset-top, 0px); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 12px; }
.brandmark { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brandmark div { display: flex; flex-direction: column; min-width: 0; }
.brandmark b { font-family: var(--font-head); font-size: 1.1rem; line-height: 1.2; }
.brandmark span { font-size: .8rem; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { width: 36px; height: 36px; border-radius: 11px; background: rgba(255,255,255,.16); display: grid; place-items: center; font: 800 .85rem var(--font-head); flex: none; }
.who { position: relative; display: flex; align-items: center; gap: 8px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); background: rgba(255,255,255,.14); color: var(--brand-fg); font: 700 .95rem var(--font-head); cursor: pointer; }
.menu { position: absolute; right: 0; top: 46px; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.18); min-width: 200px; overflow: hidden; }
.menu-head { padding: 12px 14px; display: flex; flex-direction: column; border-bottom: 1px solid var(--line); }
.menu-head span { font-size: .8rem; color: var(--muted); text-transform: capitalize; }
.menu button { display: block; width: 100%; text-align: left; padding: 12px 14px; background: none; border: 0; color: var(--danger); font: 600 .95rem var(--font); cursor: pointer; }
.menu button.plain { color: var(--fg); border-bottom: 1px solid var(--line); }
.pending-pill { background: var(--warn-soft); color: var(--warn); font-size: .75rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.offline-bar { background: var(--warn-soft); color: var(--warn); font-size: .85rem; font-weight: 600; text-align: center; padding: 8px 16px; }

main { padding-block: 18px; }
.view { display: grid; gap: 16px; }
.view-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.stack { display: grid; gap: 12px; }

/* cards & forms */
.card { background: var(--surface); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); border: 1px solid var(--line); display: grid; gap: 14px; min-width: 0; }
.form { gap: 16px; }
.form-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.field { display: grid; gap: 6px; min-width: 0; }
label, .lbl { font-weight: 600; font-size: .88rem; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--fg); background: var(--sunken); border: 1.5px solid transparent;
  border-radius: 12px; padding: 12px 14px; min-height: 50px; transition: border-color .15s, background .15s;
}
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }
button:focus-visible, .tab:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input.pin { font-family: var(--font-mono); letter-spacing: .4em; font-size: 1.2rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; }
.filled { border-color: var(--ok) !important; background: var(--ok-soft) !important; }

.btn {
  appearance: none; border: 1.5px solid var(--line); background: var(--surface); color: var(--fg); font: 600 .95rem var(--font);
  border-radius: 14px; padding: 12px 18px; min-height: 50px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.ghost { background: transparent; }
.btn.big { min-height: 56px; font-size: 1.05rem; width: 100%; }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: .85rem; border-radius: 10px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.linkbtn { background: none; border: 0; color: var(--muted); font: 500 .88rem var(--font); cursor: pointer; padding: 8px; text-decoration: underline; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row-actions .primary { flex: 1 1 160px; }
.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form input:not(.swatch) { flex: 1 1 180px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--sunken); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { appearance: none; border: 0; border-radius: 11px; background: none; color: var(--muted); font: 600 .95rem var(--font); padding: 12px 8px; min-height: 46px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.hours { display: flex; align-items: baseline; justify-content: space-between; color: var(--muted); font-size: .9rem; padding: 0 4px; }
.hours strong { color: var(--fg); font-size: 1.3rem; }

/* photos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.ph { position: relative; aspect-ratio: 1; max-width: 100%; border-radius: 12px; overflow: hidden; background: var(--sunken); }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.ph .x { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; cursor: pointer; }
.addph { aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); font: 600 .8rem var(--font); cursor: pointer; background: none; }
.addph span { font-size: 1.7rem; line-height: 1; color: var(--accent); }

/* timer */
.timer { grid-template-columns: 1fr auto; align-items: center; }
.clock { font-size: 2rem; font-weight: 600; line-height: 1.2; }
.btn.round { width: 92px; height: 92px; border-radius: 50%; min-height: 0; font-size: 1.05rem; background: var(--ok); border-color: var(--ok); color: #fff; }
.timer.running .btn.round { background: var(--danger); border-color: var(--danger); }
.timer.running .clock { color: var(--ok); }

/* AI */
.ai { background: var(--accent-soft); border-color: transparent; }
.ai-head { display: flex; align-items: center; gap: 8px; }
.spark { color: var(--accent); font-size: 1.1rem; }
.ai textarea { background: var(--surface); min-height: 84px; }
.mic[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: #fff; }
.langs { display: inline-flex; background: var(--surface); border-radius: 12px; padding: 3px; border: 1px solid var(--line); }
.langs button { appearance: none; border: 0; background: none; color: var(--muted); font: 700 .8rem var(--font); padding: 8px 12px; border-radius: 9px; cursor: pointer; min-height: 40px; }
.langs button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }

/* status */
.status { font-size: .9rem; padding: 12px 14px; border-radius: 12px; }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.err { background: var(--warn-soft); color: var(--warn); }

/* lists */
.date-pill { width: auto; min-height: 42px; padding: 8px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; }
.totals { color: var(--muted); font-size: .9rem; }
.slip { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 8px; min-width: 0; box-shadow: var(--shadow); }
.slip-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip { display: inline-block; font-family: var(--font-mono); font-weight: 600; font-size: .82rem; padding: 4px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.chip.nowo { background: var(--warn-soft); color: var(--warn); font-family: var(--font); }
.chip.pending { background: var(--warn-soft); color: var(--warn); font-family: var(--font); }
.dur { font-family: var(--font-mono); font-weight: 600; }
.meta { color: var(--muted); font-size: .88rem; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.slip .photos { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
.slip .row-actions .btn { flex: 0 0 auto; }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; border: 2px dashed var(--line); border-radius: var(--r); }
.confirm { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .9rem; }

.sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.stat b { display: block; font-family: var(--font-mono); font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.worker-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 6px 2px 0; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--line); }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
td.num { text-align: right; font-family: var(--font-mono); }
.tablebox { overflow-x: auto; }

/* team, settings, admin */
.people { display: grid; }
.person { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.person.off { opacity: .55; }
.person .who-line { display: flex; align-items: center; gap: 10px; }
.mini-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font: 700 .85rem var(--font-head); }
.tag { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.invite-out { display: grid; gap: 8px; background: var(--sunken); padding: 12px; border-radius: 12px; }
.invite-out code { font-family: var(--font-mono); font-size: .8rem; overflow-wrap: anywhere; }
.swatch { width: 64px; height: 50px; padding: 4px; }
.toggles { display: grid; }
.toggle { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.toggle:last-child { border-bottom: 0; }
.toggle div { display: grid; gap: 2px; }
.toggle b { font-size: .95rem; }
.toggle.soon { opacity: .55; }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; min-height: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled { cursor: not-allowed; }
.switch input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.biz-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.biz-dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; vertical-align: middle; margin-right: 6px; }

/* auth */
.auth { padding-top: 4vh; }
.auth-card { max-width: 440px; margin: 0 auto; gap: 16px; padding: 24px; }

/* bottom tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line);
  display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
.tabbar-in { display: flex; width: 100%; max-width: 640px; }
.tab { flex: 1; appearance: none; border: 0; background: none; color: var(--muted); font: 600 .72rem var(--font); height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; position: relative; }
.tab svg { width: 24px; height: 24px; }
.tab[aria-selected="true"] { color: var(--accent); }
.tab[aria-selected="true"]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
.tab .badge { position: absolute; top: 10px; left: calc(50% + 6px); background: var(--warn); color: #fff; font-size: .65rem; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 5px; }

#lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center; padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px)); }
#lightbox img { max-height: 100%; max-width: 100%; object-fit: contain; border-radius: 8px; }
#lightbox button { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; }

/* new job features */
.no-hours .timed { display: none !important; }
.no-hours .sum { grid-template-columns: repeat(2, 1fr); }
.no-hours .crew-row { grid-template-columns: 1fr auto; }
.no-hours .crew-row select { grid-column: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.chip.soft { background: var(--sunken); color: var(--fg); font-family: var(--font); }
.chip.warn { background: var(--warn-soft); color: var(--warn); font-family: var(--font); }
.slip.needs-fix { border-color: var(--warn); }
.crew-lines { display: grid; gap: 2px; color: var(--muted); font-size: .86rem; font-family: var(--font-mono); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.quick:empty { display: none; }
.chip-btn { border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 999px; padding: 7px 12px; font: 500 .84rem var(--font); cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 36px; }
.visit-hint { display: grid; gap: 4px; margin-top: 8px; background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; font-size: .88rem; }
.visit-hint .btn { justify-self: start; }
.crew { display: grid; gap: 8px; }
.crew-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) auto auto; gap: 6px; align-items: center; }
.crew-row input, .crew-row select { min-height: 44px; padding: 8px; }
.crew-row .x { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer; font-size: 18px; }
#addHelper { justify-self: start; margin-top: 8px; }
.unsure { border-color: var(--warn) !important; background: var(--warn-soft) !important; }
.unsure-tag { color: var(--warn); font-size: .8rem; font-weight: 700; margin-top: 4px; display: block; }
.fixme { outline: 3px solid var(--warn); outline-offset: 4px; border-radius: 12px; }
.fix-banner { display: grid; gap: 4px; background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 12px 14px; }
.fix-banner span:not(.hint) { color: var(--fg); }
.confirm-box { display: grid; gap: 10px; background: var(--warn-soft); border-radius: 14px; padding: 14px; }
.confirm-box b { color: var(--warn); }
.confirm-box label { display: flex; gap: 10px; align-items: center; font-weight: 600; cursor: pointer; }
.confirm-box input { width: 24px; height: 24px; min-height: 0; flex: none; accent-color: var(--ok); }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.readback { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; display: grid; gap: 6px; margin-top: 8px; }
.readback p { margin: 0; white-space: pre-wrap; }
.readback-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.phone-banner { background: var(--warn-soft); color: var(--warn); border-radius: 14px; padding: 12px 14px; font-weight: 600; font-size: .92rem; }
.fix-head { color: var(--warn); }
.fix-item { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; width: 100%; text-align: left; background: var(--warn-soft); color: var(--fg); border: 1px solid var(--warn); border-radius: 14px; padding: 12px 14px; font: 500 .92rem var(--font); cursor: pointer; }
.fix-item b { color: var(--warn); }
.bill-row, .ticket-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line); }
.bill-row:last-child, .ticket-row:last-child { border-bottom: 0; }
.bill-row .chip { margin-top: 4px; }
.ref-form { display: grid; gap: 8px; width: 100%; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; align-self: end; min-height: 48px; }
.check input { width: 22px; height: 22px; min-height: 0; }
.client-form { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 4px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-weight: 600; font-size: .9rem; z-index: 50; max-width: calc(100% - 32px); box-shadow: var(--shadow); }
.form-head h1 { margin: 0; }

@media (max-width: 420px) {
  .grid2 { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .grid3 .field:first-child { grid-column: 1 / -1; }
  .stat b { font-size: 1.2rem; }
  .crew-row { grid-template-columns: 1fr 1fr auto auto; }
  .crew-row select { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
