/* Kutting Edge: one stylesheet for every screen.
   Big tap targets (a finger on a tablet, not a mouse), high contrast, nothing decorative. */

:root {
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #e3dfd8;
  --bg: #f4f1ec;
  --card: #fff;
  --brand: #8a1538;
  --brand-ink: #fff;
  --ok: #1a7f3c;
  --warn: #b45309;
  --bad: #c62828;
  --radius: 12px;
  --tap: 48px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.hidden { display: none !important; }

main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }

/* ─── Top bar ─── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .5rem 1rem; background: var(--ink); color: #fff;
}
.topbar .brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.1rem; }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.topbar nav a {
  color: #ddd; text-decoration: none; padding: .55rem .8rem; border-radius: 8px;
}
.topbar nav a.active, .topbar nav a:hover { background: #ffffff1f; color: #fff; }
.topbar .who { display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.topbar .ghost { color: #fff; border-color: #ffffff55; }

/* ─── Building blocks ─── */
.card { background: var(--card); border-radius: var(--radius); padding: 1.1rem; box-shadow: 0 1px 3px #0000000f; }
.stack > * + * { margin-top: .85rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-main { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 820px) { .grid-2, .grid-main { grid-template-columns: 1fr; } }

button, .button {
  min-height: var(--tap); padding: 0 1.1rem; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  text-decoration: none;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary, .button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.danger { color: var(--bad); border-color: #f0c4c4; }
button.ghost { background: transparent; }
button.small, .button.small { min-height: 36px; padding: 0 .7rem; font-size: .875rem; }
button.big { min-height: 64px; font-size: 1.15rem; }

label { display: block; font-weight: 600; font-size: .9rem; }
label > input, label > select, label > textarea { margin-top: .3rem; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: .6rem .8rem;
  border: 1px solid #cfc9bf; border-radius: 10px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 80px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid #8a153855; outline-offset: 1px; }
input.search { font-size: 1.25rem; min-height: 60px; }
.check { display: flex; align-items: center; gap: .6rem; font-weight: 500; }
.check input { width: 24px; min-height: 24px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #faf8f5; }

.pill { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .8rem; font-weight: 600; background: #eee; }
.pill.ok { background: #dcf3e3; color: var(--ok); }
.pill.warn { background: #fdecd3; color: var(--warn); }
.pill.bad { background: #fbe0e0; color: var(--bad); }

.empty { text-align: center; color: var(--muted); padding: 1.5rem; }
.notice { padding: .8rem 1rem; border-radius: 10px; background: #fdecd3; color: #7c3d06; }

/* ─── Search results / tappable lists ─── */
.results { list-style: none; margin: 0; padding: 0; }
.results li > button {
  width: 100%; justify-content: space-between; text-align: left; font-weight: 500;
  border-radius: 0; border: 0; border-bottom: 1px solid var(--line); min-height: 60px;
}
.results li > button:hover, .results li > button:focus { background: #faf6f0; }
.results .name { font-weight: 700; }

/* ─── Today screen ─── */
.visits { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .8rem; }
.visit-card {
  display: block; text-align: left; height: auto; min-height: 110px; padding: .9rem;
  font-weight: 400; border-radius: var(--radius); background: #fff; border: 2px solid transparent;
  box-shadow: 0 1px 3px #0000000f;
}
.visit-card:hover { border-color: var(--brand); }
.visit-card .name { font-weight: 700; font-size: 1.1rem; display: block; }

/* ─── Visit screen: service buttons ─── */
.services { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
.services button { min-height: 72px; flex-direction: column; gap: 0; font-weight: 600; line-height: 1.2; padding: .4rem; }
.services button .price { font-weight: 400; color: var(--muted); font-size: .9rem; }
.category { margin: 1rem 0 .4rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.totals td { border: 0; padding: .25rem .5rem; }
.totals .grand td { font-size: 1.35rem; font-weight: 800; border-top: 2px solid var(--ink); padding-top: .6rem; }
.qty { display: inline-flex; align-items: center; gap: .3rem; }
.qty button { min-height: 34px; width: 34px; padding: 0; }
.pay { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }

/* ─── Bars for reports ─── */
.bar { height: 10px; background: var(--brand); border-radius: 5px; min-width: 2px; }
.stat { font-size: 1.6rem; font-weight: 800; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; }

/* ─── Dialogs and messages ─── */
dialog { border: 0; border-radius: var(--radius); padding: 1.4rem; width: min(480px, 94vw); box-shadow: 0 10px 40px #0004; }
dialog::backdrop { background: #0006; }
#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 150%);
  background: var(--ink); color: #fff; padding: .8rem 1.2rem; border-radius: 10px;
  transition: transform .2s; z-index: 100; max-width: 90vw; font-weight: 600;
}
#toast.show { transform: translate(-50%, 0); }
#toast.error { background: var(--bad); }

/* ─── Sign-in screen ─── */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.signin .card { width: min(400px, 100%); padding: 2rem; }
.signin h1 { margin-bottom: .25rem; }

/* ─── Printed bill ─── */
.invoice { max-width: 720px; margin: 0 auto; background: #fff; padding: 2rem; }
.invoice h1 { margin: 0; }
.invoice table { font-size: .95rem; }
@media print {
  body { background: #fff; font-size: 12pt; }
  .no-print, .topbar { display: none !important; }
  main { padding: 0; }
  .invoice { padding: 0; box-shadow: none; }
}
