:root {
  --bg: #f6f6f4;
  --card: #fff;
  --text: #1f2328;
  --muted: #6a6f76;
  --line: #e3e3df;
  --accent: #2f5d8a;      /* the shop's brand color, set by applyTheme() */
  --on-accent: #fff;
  --danger: #b42318;
  --ok: #2e7d4f;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, system-ui, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 10px; }
input, select, textarea, button { font: inherit; }
input, select, textarea { padding: 6px 8px; border: 1px solid #c9c9c4; border-radius: 6px; background: #fff; min-width: 0; }
textarea { width: 100%; min-height: 70px; }
button { padding: 6px 12px; border: 1px solid #c9c9c4; border-radius: 6px; background: #fff; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
label.button.busy, button.busy, .thumb.busy { opacity: .6; pointer-events: none; }
label.button { display: inline-block; padding: 6px 12px; border: 1px solid #c9c9c4; border-radius: 6px; background: #fff; cursor: pointer; }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; color: var(--muted); text-decoration: underline; padding: 4px; }
button:disabled { opacity: .5; cursor: default; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---- shell ---- */
.shell { display: flex; min-height: 100vh; }
.side { width: 190px; flex: none; background: #1f2328; color: #d6d8db; padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; }
.side .brand { color: #fff; font-size: 20px; font-weight: 700; padding: 0 10px 14px; }
.side .brand img { display: block; height: var(--logo-h, 64px); max-width: 100%; object-fit: contain; object-position: left; margin-bottom: 8px; }
.side .brand img + .name { font-size: 16px; }
.side .brand .name { display: block; }
input[type=range] { padding: 0; accent-color: var(--accent); }
.side a { color: #d6d8db; padding: 8px 10px; border-radius: 6px; }
.side a:hover { background: #2c3238; text-decoration: none; }
.side a.on { background: #3a424a; color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.side.light { background: #fff; color: var(--text); border-right: 1px solid var(--line); }
.side.light .brand { color: var(--text); }
.side.light a { color: var(--text); }
.side.light a:hover { background: #f1f1ee; }
.side.light a.on { background: #eceeef; color: var(--text); }
.side.light .who, .side.light .who button { color: var(--muted); }
.logo-preview { width: 160px; height: 64px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--line); border-radius: 8px; padding: 6px; }
.logo-preview img { max-width: 100%; max-height: 100%; }
input[type=color] { height: 34px; padding: 2px; }
.side .who { margin-top: auto; padding: 10px; font-size: 13px; color: #9aa0a6; word-break: break-all; }
.side .who button { color: #9aa0a6; padding: 4px 0; }
main { flex: 1; min-width: 0; }
#view { max-width: 1180px; padding: 22px 28px 60px; }

/* ---- running timers ---- */
.timers { background: #fff6e0; border-bottom: 1px solid #f0dca8; padding: 8px 28px; display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; }
.timers .dot { color: #d97706; }

/* ---- cards and tables ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; font-size: 13px; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f8f8f6; }
tr.archived td { color: var(--muted); }
td input[type=number] { width: 90px; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eceeef; color: #3c4146; }
.pill.quote { background: #eef2f7; color: var(--accent); }
.pill.approved, .pill.in_progress { background: #e6f2ea; color: var(--ok); }
.pill.waiting { background: #fff1d6; color: #9a6400; }
.pill.done, .pill.paid { background: #eceeef; color: #3c4146; }
.pill.cancelled { background: #f6e3e1; color: var(--danger); }
.flag { color: var(--danger); font-weight: 600; font-size: 13px; }
.notice { background: #fff6e0; border: 1px solid #f0dca8; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.tabs button.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* ---- forms ---- */
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 12px; align-items: end; }
.form label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.form label.check { flex-direction: row; align-items: center; gap: 6px; }
.form input:not([type=checkbox]), .form select { width: 100%; }
.form label.wide { grid-column: 1 / -1; }
.form .actions { grid-column: 1 / -1; display: flex; gap: 8px; }

/* ---- job page ---- */
.job { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.job-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.job-head h1 { margin: 0; }
.part-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.part-head input.name { font-weight: 600; flex: 1; }
.part-head input.qty { width: 70px; }
.add-line { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.add-line select { max-width: 260px; }
.totals td { border: 0; padding: 3px 0; }
.totals tr.sum td { border-top: 1px solid var(--line); font-weight: 700; padding-top: 6px; }
.running { color: #d97706; font-weight: 600; }

/* ---- sign-in (as Cookie's) ---- */
.signin { max-width: 360px; margin: 15vh auto; padding: 0 16px; text-align: center; }
.signin form, .signin #emailRow { display: flex; flex-direction: column; gap: 10px; }
.signin input { padding: 10px; border-radius: 10px; }
.signin .btn { font-weight: 600; padding: 10px; border: 0; border-radius: 10px; background: #222; color: #fff; }
.btn-apple, .btn-google { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; max-width: 260px; align-self: center; height: 40px; padding: 0 12px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-apple { border: 0; background: #000; color: #fff; }
.btn-google { border: 1px solid #dadce0; background: #fff; color: #1f1f1f; }
.btn-apple svg, .btn-google svg { width: 16px; height: 16px; }
.signin .link { font-size: 13px; padding: 8px; }
.err { color: var(--danger); font-size: 14px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1f2328; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 10; }

/* ---- photos and gallery ---- */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.thumb { position: relative; width: 84px; height: 84px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.thumb button { position: absolute; top: 0; right: 0; background: rgba(255,255,255,.85); border-radius: 0 6px 0 6px; text-decoration: none; }
.check-line { display: flex; gap: 6px; align-items: center; margin: 4px 0; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile { position: relative; padding: 0; border: 0; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4 / 3; background: #e8e8e4; cursor: pointer; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .no-photo { display: flex; height: 100%; align-items: center; justify-content: center; color: var(--muted); }
.tile .caption { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 8px; text-align: left; color: #fff; font-weight: 600; background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 24px; }
.viewer-card { position: relative; background: #fff; border-radius: var(--radius); max-width: 1000px; width: 100%; max-height: 100%; overflow: auto; display: grid; grid-template-columns: 1fr 260px; }
.viewer-photos { display: flex; flex-direction: column; gap: 8px; padding: 12px; }
.viewer-photos img { width: 100%; border-radius: 6px; }
.viewer-info { padding: 20px; border-left: 1px solid var(--line); }
.viewer-info .price { font-size: 20px; font-weight: 700; color: var(--accent); }
.viewer-close { position: absolute; top: 8px; right: 8px; z-index: 1; }

/* ---- the public gallery page ---- */
body.public { background: var(--bg); }
.public-head { max-width: 1180px; margin: 0 auto; padding: 28px 24px 8px; font-size: 26px; font-weight: 700; color: var(--accent); display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.public-head img { max-width: 100%; object-fit: contain; display: block; }
.public-main { max-width: 1180px; margin: 0 auto; padding: 12px 24px 60px; }
@media (max-width: 700px) { .viewer-card { grid-template-columns: 1fr; } .viewer-info { border-left: 0; border-top: 1px solid var(--line); } }
