/* RefinishAI ShopSafe — one stylesheet for the shop app and the distributor console. */
:root {
  --navy: #1e3a8a;
  --navy-2: #1e40af;
  --navy-tint: #eef2ff;
  --ink: #111827;
  --ink-2: #4b5563;
  --line: #e5e7eb;
  --bg: #f6f7f9;
  --card: #ffffff;
  --red: #b91c1c;
  --red-tint: #fef2f2;
  --amber: #b45309;
  --amber-tint: #fffbeb;
  --green: #15803d;
  --green-tint: #f0fdf4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .06), 0 1px 3px rgba(17, 24, 39, .08);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px; line-height: 1.45; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy-2); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--navy); color: #fff;
  display: flex; align-items: center; gap: .75rem; padding: .7rem 1rem;
  padding-top: calc(.7rem + env(safe-area-inset-top));
}
.topbar .brand { font-weight: 700; letter-spacing: .2px; }
.topbar .brand span { opacity: .75; font-weight: 500; }
.topbar .shopname { margin-left: auto; font-size: .85rem; opacity: .9; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { max-width: 880px; margin: 0 auto; padding: 1rem 1rem 6rem; }
.wide main, main.wide { max-width: 1180px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: #fff;
  border-top: 1px solid var(--line); display: flex; justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; text-align: center; padding: .55rem .25rem .6rem; color: var(--ink-2);
  text-decoration: none; font-size: .75rem; font-weight: 600;
}
.tabbar a .ico { display: block; font-size: 1.25rem; line-height: 1.2; }
.tabbar a.active { color: var(--navy-2); }
@media (min-width: 900px) {
  .tabbar { top: 52px; bottom: auto; left: 0; right: auto; width: 180px; flex-direction: column; border-top: 0; border-right: 1px solid var(--line); height: calc(100vh - 52px); justify-content: flex-start; padding-top: 1rem; }
  .tabbar a { flex: 0; text-align: left; padding: .7rem 1.25rem; font-size: .95rem; display: flex; gap: .6rem; align-items: center; }
  .tabbar a .ico { display: inline; font-size: 1.1rem; }
  body.has-tabs main { margin-left: 180px; margin-right: auto; padding-left: 2rem; }
}

/* ---------- Cards & lists ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }
.card.flush { padding: 0; overflow: hidden; }
.grid { display: grid; gap: .75rem; }
.grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .8rem; text-decoration: none; color: inherit; display: block; }
.stat .n { font-size: 1.6rem; font-weight: 700; }
.stat .l { font-size: .8rem; color: var(--ink-2); font-weight: 600; }
.stat.red .n { color: var(--red); }
.stat.amber .n { color: var(--amber); }
.stat.green .n { color: var(--green); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.row { display: flex; align-items: center; gap: .75rem; padding: .8rem 1rem; text-decoration: none; color: inherit; }
.row:hover { background: #fafafa; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .sub { font-size: .85rem; color: var(--ink-2); }
.row .chev { color: #9ca3af; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 1.25rem 0 .5rem; }
.section-title h2 { margin: 0; }

/* ---------- Score ---------- */
.score { display: flex; align-items: center; gap: 1rem; }
.ring { --p: 0; width: 92px; height: 92px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--ring-color, var(--green)) calc(var(--p) * 1%), #e5e7eb 0);
  display: grid; place-items: center; }
.ring::after { content: attr(data-label); width: 70px; height: 70px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 800; font-size: 1.35rem; }

/* ---------- Badges ---------- */
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: .12rem .45rem; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.badge.red { background: var(--red-tint); color: var(--red); }
.badge.amber { background: var(--amber-tint); color: var(--amber); }
.badge.green { background: var(--green-tint); color: var(--green); }
.badge.grey { background: #f3f4f6; color: var(--ink-2); }
.badge.navy { background: var(--navy-tint); color: var(--navy-2); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin: .75rem 0 .3rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; padding: .65rem .75rem; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy-2); outline-offset: 1px; border-color: transparent; }
textarea { min-height: 84px; resize: vertical; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; margin: .6rem 0; }
.check input { width: 1.2rem; height: 1.2rem; }
.help { font-size: .82rem; color: var(--ink-2); margin-top: .25rem; }
.error-box { background: var(--red-tint); color: var(--red); border-radius: 8px; padding: .65rem .8rem; margin: .75rem 0; font-weight: 600; }
.ok-box { background: var(--green-tint); color: var(--green); border-radius: 8px; padding: .65rem .8rem; margin: .75rem 0; font-weight: 600; }
.note-box { background: var(--amber-tint); color: #78350f; border-radius: 8px; padding: .65rem .8rem; margin: .75rem 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 700;
  border: 1px solid transparent; border-radius: 8px; padding: .65rem 1rem; cursor: pointer; text-decoration: none;
  background: var(--navy-2); color: #fff; min-height: 44px;
}
.btn:hover { background: var(--navy); }
.btn.secondary { background: #fff; color: var(--navy-2); border-color: #c7d2fe; }
.btn.secondary:hover { background: var(--navy-tint); }
.btn.danger { background: var(--red); }
.btn.block { width: 100%; }
.btn.small { padding: .35rem .7rem; min-height: 34px; font-size: .85rem; }
.btn[disabled] { opacity: .55; cursor: wait; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }

/* Yes / No / N/A segmented answers — big targets for gloved hands. */
.seg { display: flex; gap: .4rem; }
.seg button { flex: 1; font: inherit; font-weight: 700; padding: .6rem; border-radius: 8px; border: 1px solid #d1d5db; background: #fff; cursor: pointer; min-height: 44px; }
.seg button[aria-pressed=true][data-v=yes] { background: var(--green); color: #fff; border-color: var(--green); }
.seg button[aria-pressed=true][data-v=no] { background: var(--red); color: #fff; border-color: var(--red); }
.seg button[aria-pressed=true][data-v=na] { background: #6b7280; color: #fff; border-color: #6b7280; }
.q { padding: .75rem 0; border-top: 1px solid var(--line); }
.q:first-child { border-top: 0; }
.q .qlabel { font-weight: 600; margin-bottom: .45rem; }
.q .req { color: var(--red); }

.sigpad { width: 100%; height: 150px; border: 1px dashed #9ca3af; border-radius: 8px; background: #fff; touch-action: none; display: block; }
.thumbs { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }

/* ---------- Tables (console) ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-2); background: #fafafa; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: #fafafa; }
.bar { height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--green); }
.scroll-x { overflow-x: auto; }

/* ---------- Auth screens ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, #1e3a8a 0%, #1e40af 55%, #312e81 100%); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 1.6rem; box-shadow: 0 20px 40px rgba(0,0,0,.25); }
.auth-card .logo { font-weight: 800; color: var(--navy); font-size: 1.3rem; }
.auth-card .logo span { color: var(--ink-2); font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: #111827; color: #fff; padding: .7rem 1rem; border-radius: 8px; z-index: 50; font-weight: 600; max-width: 90vw; }
dialog { border: 0; border-radius: 12px; padding: 1.25rem; width: min(520px, 94vw); box-shadow: 0 20px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(17,24,39,.5); }
.empty { text-align: center; padding: 2rem 1rem; color: var(--ink-2); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; font-size: .92rem; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; }
.spinner { padding: 2rem; text-align: center; color: var(--ink-2); }
.btn-reset { background: none; border: 0; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.row.stack { flex-wrap: wrap; }
.row.stack > .actions { margin-top: 0; width: 100%; }
@media (min-width: 640px) { .row.stack { flex-wrap: nowrap; } .row.stack > .actions { width: auto; } }
