/* Customers app — mobile-first, framework-free.
   Breakpoints: 360 / 420 / 768 / 1024 / 1200 / 1920 / 3000.
   All sizes are rem-based. */

:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --text: #111827;
  --muted: #4b5563;
  --border: #c9d1dc;
  --line: #e3e8ef;
  --field: #6b7280;

  --navy: #0f2a6b;
  --blue: #1d4ed8;
  --blue-dark: #1e40af;
  --blue-soft: #dbeafe;
  --green: #15803d;
  --green-dark: #166534;
  --green-soft: #dcfce7;
  --red: #b91c1c;
  --red-dark: #991b1b;
  --red-soft: #fee2e2;
  --purple: #6d28d9;
  --purple-soft: #ede9fe;
  --amber: #b45309;
  --amber-text: #78350f;
  --amber-soft: #fffbeb;
  --focus: #f59e0b;

  --radius: 0.75rem;
  --radius-sm: 0.5rem;
  --gutter: 1rem;
  --maxw: 100%;
  --nav-h: 4.25rem;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 2px 8px rgba(15, 23, 42, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.5rem, 1.25rem + 0.6vw, 1.75rem); line-height: 1.2; font-weight: 800; }
h2 { font-size: 1.25rem; line-height: 1.25; }
a { color: var(--blue); }
strong { font-weight: 800; }
code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  font-size: 0.95em;
  background: rgba(255, 255, 255, 0.7);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  overflow-wrap: anywhere;
}
.i { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.2em; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 0.5rem; top: -4rem; z-index: 100;
  background: var(--text); color: #fff; padding: 0.75rem 1rem; border-radius: var(--radius-sm);
  font-weight: 700; text-decoration: none;
}
.skip:focus { top: 0.5rem; }

/* Long names / addresses / usernames must never cause sideways scroll */
.nm, .sub, .addr, .q, .who-name, .id-name, .flash p, .alert p, .err-msg, .slip-name { overflow-wrap: anywhere; }

/* ---------- Layout ---------- */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1rem max(var(--gutter), env(safe-area-inset-left)) 2rem max(var(--gutter), env(safe-area-inset-right));
}
body.has-nav { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
.narrow { max-width: 36rem; margin: 0 auto; }

.page-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.5rem 1rem; margin: 0.25rem 0 1rem;
}
.page-head h1 { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; min-width: 0; }
.count { font-size: 1rem; font-weight: 700; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0.125rem 0.75rem; }
.today { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 1.0625rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.sec-h { display: flex; align-items: center; gap: 0.5rem; margin: 1.75rem 0 0.75rem; font-weight: 800; }
.sec-h .i { color: var(--muted); }

/* ---------- Top bar & navigation ---------- */
.topbar { background: var(--navy); color: #fff; padding-top: env(safe-area-inset-top); }
.topbar-in {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 0.5rem;
  min-height: 3.75rem;
  padding: 0.375rem max(var(--gutter), env(safe-area-inset-right)) 0.375rem max(var(--gutter), env(safe-area-inset-left));
}
.brand {
  display: inline-flex; align-items: center; gap: 0.5rem; min-height: 3rem; min-width: 3rem;
  color: #fff; text-decoration: none; font-weight: 800; font-size: 1.25rem; white-space: nowrap;
}
.brand .i { width: 1.75rem; height: 1.75rem; }
.brand-txt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.account { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.who { display: inline-flex; align-items: center; gap: 0.375rem; min-width: 0; font-weight: 700; font-size: 1rem; }
.who .i { opacity: 0.85; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 6.5rem; }
.logout { margin: 0; flex: none; }

/* Phones: bottom tab bar */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.12);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.125rem;
  min-height: var(--nav-h); padding: 0.25rem;
  color: #374151; text-decoration: none; font-size: 0.875rem; font-weight: 700; line-height: 1.2;
  border-top: 4px solid transparent; text-align: center;
}
.tab .i { width: 1.625rem; height: 1.625rem; }
.tab.is-active { color: var(--blue); border-top-color: var(--blue); background: var(--blue-soft); }
.tab:focus-visible { outline-offset: -4px; }
.lbl-long { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 3rem; padding: 0.625rem 1.125rem;
  border: 2px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-size: 1.0625rem; font-weight: 700; line-height: 1.2;
  text-decoration: none; text-align: center; cursor: pointer;
  background: var(--surface); color: var(--text);
  transition: background-color 0.15s, border-color 0.15s, transform 0.05s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn .i { width: 1.3em; height: 1.3em; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-print { background: var(--green); color: #fff; }
.btn-print:hover { background: var(--green-dark); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-dark); }
.btn-danger-outline { background: var(--surface); color: var(--red); border-color: var(--red); }
.btn-danger-outline:hover { background: var(--red-soft); }
.btn-plain { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-plain:hover { background: var(--surface-2); border-color: var(--field); }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.65); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.14); }
.btn-sm { min-height: 3rem; padding: 0.5rem 0.75rem; font-size: 1rem; }
.btn-lg { min-height: 3.5rem; padding: 0.75rem 1.5rem; font-size: 1.1875rem; }
.btn-xl { min-height: 3.25rem; padding: 0.75rem 1.5rem; font-size: 1.125rem; border-radius: var(--radius); }
.btn-huge { min-height: 3.5rem; padding: 0.75rem 1.5rem; font-size: 1.25rem; border-radius: var(--radius); }
.btn-huge .i { width: 1.5em; height: 1.5em; }
.btn-block { display: flex; width: 100%; }
.btn:disabled, .btn.is-busy { opacity: 0.6; cursor: progress; }
.btn.is-disabled { opacity: 0.45; cursor: default; pointer-events: none; }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }
.btn-row form { margin: 0; }
.btn-row-split { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
.btn-row-split .btn { width: 100%; }
.cta { margin: 1.5rem 0 0.5rem; }
.more { margin-top: 0.75rem; text-align: center; }

/* ---------- Flash & alerts ---------- */
.flash, .alert {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.875rem 1rem; margin: 0 0 1rem;
  border: 2px solid var(--blue); border-radius: var(--radius);
  background: var(--blue-soft); color: #1e3a8a; font-weight: 600;
}
.flash .i, .alert > .i { width: 1.75rem; height: 1.75rem; margin-top: -0.0625rem; }
.flash p, .alert p { min-width: 0; }
.flash-success { background: var(--green-soft); border-color: var(--green); color: #14532d; }
.flash-error, .alert-error { background: var(--red-soft); border-color: var(--red); color: #7f1d1d; }
.alert-info { background: var(--blue-soft); border-color: var(--blue); color: #1e3a8a; }
.alert-info p + p { margin-top: 0.5rem; }
.alert-warn { background: var(--amber-soft); border-color: var(--amber); color: var(--amber-text); }
.alert-body { min-width: 0; flex: 1; }
.alert-title { font-size: 1.1875rem; font-weight: 700; }
.alert-body p + p { margin-top: 0.375rem; }
.alert-body .nm { color: var(--text); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; white-space: nowrap;
  background: var(--navy); color: #fff;
  font-weight: 800; font-size: 1.0625rem; line-height: 1.2; font-variant-numeric: tabular-nums;
  padding: 0.3rem 0.6rem; border-radius: var(--radius-sm);
}
.badge-lg { font-size: 0.85em; padding: 0.25rem 0.625rem; }
.badge-red { background: var(--red); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 1.25rem; }
.field { display: grid; gap: 0.375rem; min-width: 0; }
.field label { font-weight: 800; font-size: 1.125rem; }
.opt { font-weight: 600; color: var(--muted); }
input[type="text"], input[type="search"], input[type="password"], input[type="tel"], textarea {
  width: 100%; min-width: 0;
  font: inherit; font-size: max(16px, 1.1875rem); line-height: 1.35;
  min-height: 3.5rem; padding: 0.75rem 1rem;
  color: var(--text); background: var(--surface);
  border: 2px solid var(--field); border-radius: var(--radius-sm);
  -webkit-appearance: none; appearance: none;
}
textarea { min-height: 6.5rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: #6b7280; opacity: 1; }
input:focus, textarea:focus { border-color: var(--blue); outline: 3px solid var(--focus); outline-offset: 1px; }
.hint { color: var(--muted); font-size: 1rem; }
.err { display: flex; align-items: flex-start; gap: 0.375rem; color: var(--red); font-weight: 700; font-size: 1.0625rem; }
.err .i { margin-top: 0.125rem; }
.has-error input, .has-error textarea { border-color: var(--red); background: #fff7f7; }
.has-error label { color: var(--red-dark); }
.form-actions { display: grid; grid-template-columns: 1fr; gap: 0.75rem; margin-top: 0.25rem; }
.danger-link { margin-top: 1.5rem; text-align: center; }

/* ---------- Dashboard: stats ---------- */
.stats { display: grid; grid-template-columns: 1fr; gap: 0.625rem; margin: 0 0 1.25rem; }
.stat {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--surface); border: 1px solid var(--border); border-left: 6px solid var(--blue);
  border-radius: var(--radius); padding: 0.625rem 1rem; box-shadow: var(--shadow); min-width: 0;
}
.stat-ico { display: grid; place-items: center; flex: none; width: 2.75rem; height: 2.75rem; border-radius: 50%; background: var(--blue-soft); color: var(--blue); }
.stat-ico .i { width: 1.5rem; height: 1.5rem; }
.stat-label { font-weight: 700; color: var(--muted); font-size: 1rem; line-height: 1.25; min-width: 0; }
.stat-num { margin-left: auto; font-size: 2rem; font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-purple { border-left-color: var(--purple); }
.stat-purple .stat-ico { background: var(--purple-soft); color: var(--purple); }
.stat-green { border-left-color: var(--green); }
.stat-green .stat-ico { background: var(--green-soft); color: var(--green); }

/* ---------- Search ---------- */
.search-card {
  background: var(--surface); border: 3px solid var(--blue); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow);
}
.search-card-sm { border-width: 2px; border-color: var(--border); margin-bottom: 1rem; }
.search { margin: 0; }
.search-label { display: flex; align-items: center; gap: 0.5rem; font-weight: 800; font-size: 1.125rem; margin-bottom: 0.625rem; }
.search-label .i { color: var(--blue); }
.search-row { display: grid; grid-template-columns: 1fr; gap: 0.625rem; }
.search-row input { min-height: 3rem; font-size: max(16px, 1.125rem); font-weight: 600; }
.search-card-sm .search-row input { min-height: 3.25rem; font-size: max(16px, 1.1875rem); }
.search-note { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-top: 0.75rem; color: var(--muted); }

/* ---------- Empty states ---------- */
.empty {
  display: grid; justify-items: center; gap: 0.5rem; text-align: center;
  background: var(--surface); border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 1.75rem 1rem; margin-top: 1rem;
}
.empty-ico { display: grid; place-items: center; width: 4rem; height: 4rem; border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.empty-ico .i { width: 2rem; height: 2rem; }
.empty-title { font-size: 1.5rem; font-weight: 800; }
.empty-text { color: var(--muted); max-width: 100%; }
.empty .btn { margin-top: 0.5rem; }
.empty-sm { padding: 1.25rem 1rem; }

/* ---------- Customer list: cards on phones, table from 768px ---------- */
.tablewrap { min-width: 0; }
.clist { width: 100%; border-collapse: separate; border-spacing: 0; }
.clist .nm { display: block; font-weight: 700; font-size: 1.0625rem; line-height: 1.3; }
.clist .sub {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; overflow: hidden;
  color: var(--muted); font-size: 0.9375rem; line-height: 1.4; margin-top: 0.125rem;
}
.c-phone { font-variant-numeric: tabular-nums; }
.addr { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.none { color: var(--muted); }
.acts form { margin: 0; }

@media (max-width: 767.98px) {
  html { scroll-padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 1rem); }
  .clist, .clist tbody, .clist td { display: block; }
  .clist thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .clist tr {
    display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0.5rem 0.75rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 0.875rem; margin-bottom: 0.75rem; box-shadow: var(--shadow);
  }
  .clist td { padding: 0; min-width: 0; }
  .clist .c-id { grid-column: 1; align-self: start; }
  .clist .c-name { grid-column: 2; }
  .clist .c-phone, .clist .c-addr, .clist .c-date, .clist .c-act { grid-column: 1 / -1; }
  .clist .c-phone { display: flex; align-items: center; gap: 0.5rem; font-size: 1.25rem; font-weight: 700; }
  .clist .c-phone .i, .clist .c-addr .i { color: var(--muted); }
  .clist .c-addr { display: flex; align-items: flex-start; gap: 0.5rem; color: var(--muted); font-size: 1rem; }
  .clist .c-addr .i { margin-top: 0.15rem; }
  .clist .c-addr .addr { -webkit-line-clamp: 3; }
  .clist .c-addr.is-empty { display: none; }
  .clist .c-date { color: var(--muted); font-size: 0.9375rem; }
  .clist .sub-mid { display: none; }
  .clist .c-act { margin-top: 0.25rem; }
  .acts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .acts-3 > :first-child { grid-column: 1 / -1; }
  .acts .btn { width: 100%; }
}

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 1.25rem; }
.pager-info { text-align: center; color: var(--muted); font-size: 1rem; }

/* ---------- Saved / done ---------- */
.done { text-align: center; }
.done-ico { display: block; color: var(--green); margin: 0.25rem auto 0.5rem; }
.done-ico .i { width: 5rem; height: 5rem; }
.done h1 { color: var(--green-dark); }
.id-card { margin: 1.25rem 0; padding: 1.5rem 1.25rem; border-width: 2px; }
.id-label { font-size: 1rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.id-big { font-size: clamp(2.5rem, 1.5rem + 4vw, 4rem); font-weight: 900; line-height: 1.05; font-variant-numeric: tabular-nums; color: var(--navy); }
.id-name { font-size: 1.5rem; font-weight: 800; margin-top: 0.5rem; }
.id-phone { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 1.3125rem; color: var(--muted); font-weight: 700; margin-top: 0.25rem; }
.print-form { margin: 0 0 1rem; }

/* ---------- Delete ---------- */
.danger-card { border: 3px solid var(--red); background: #fff8f8; text-align: center; }
.danger-ico { display: block; color: var(--red); }
.danger-ico .i { width: 4rem; height: 4rem; }
.danger-card h1 { margin-top: 0.5rem; font-size: clamp(1.5rem, 1.25rem + 1.2vw, 2rem); }
.danger-card .badge { font-size: 0.8em; vertical-align: 0.1em; }
.danger-phone { display: inline-flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; color: var(--muted); font-weight: 700; font-size: 1.1875rem; }
.danger-text { margin-top: 0.75rem; font-size: 1.25rem; font-weight: 800; color: var(--red-dark); }

/* ---------- Error page ---------- */
.errpage .card { text-align: center; display: grid; justify-items: center; gap: 0.75rem; padding: 2rem 1.25rem; margin-top: 1rem; }
.err-ico { color: var(--red); }
.err-ico .i { width: 4rem; height: 4rem; }
.err-code { font-weight: 800; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; }

/* ---------- Login ---------- */
body.no-nav .wrap { padding-top: max(1.5rem, env(safe-area-inset-top)); }
.login { min-height: calc(100vh - 4rem); display: grid; place-items: center; }
.login-card { width: 100%; max-width: 28rem; padding: 1.5rem 1.25rem; }
.login-logo { display: flex; align-items: center; justify-content: center; gap: 0.5rem; color: var(--navy); font-weight: 900; font-size: 1.5rem; }
.login-logo .i { width: 2.25rem; height: 2.25rem; }
.login-title { text-align: center; margin: 0.5rem 0 1.25rem; }
.login .form { gap: 1rem; }
.login .btn { margin-top: 0.5rem; }

/* ========== Breakpoints ========== */

/* Small phones (< 420px): keep the main action above the fold */
@media (max-width: 419.98px) {
  /* Dashboard: search first, numbers after the Add button */
  .dash { display: flex; flex-direction: column; }
  .dash > .stats { order: 1; margin: 1.25rem 0 0; }
  .dash > .recent { order: 2; }
  .dash > .page-head { margin-bottom: 0.75rem; }
  .dash .page-head h1 { font-size: 1.5rem; }
  .dash .today { font-size: 1rem; }
  .search-label { font-size: 1.1875rem; margin-bottom: 0.5rem; }
  .search-card { padding: 0.875rem; }
  .search-row input { padding-left: 0.75rem; padding-right: 0.5rem; }
  .search-row input::placeholder { font-size: 1rem; }

  /* Saved */
  .done-ico { margin: 0 auto 0.25rem; }
  .done-ico .i { width: 3rem; height: 3rem; }
  .done h1 { font-size: 1.375rem; }
  .card.id-card { margin: 0.75rem 0; padding: 1rem; }
  .id-label { font-size: 0.875rem; }
  .id-name { font-size: 1.1875rem; margin-top: 0.25rem; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
  .id-phone { font-size: 1.125rem; }
  .print-form { margin-bottom: 0.75rem; }
  .btn-huge { min-height: 4.5rem; padding: 1rem 1.25rem; }

  /* Delete */
  .card.danger-card { padding: 1rem; }
  .danger-ico .i { width: 3rem; height: 3rem; }
  .danger-card h1 { font-size: 1.25rem; margin-top: 0.25rem; }
  .danger-phone { font-size: 1.0625rem; margin-top: 0.25rem; }
  .danger-text { font-size: 1.125rem; margin-top: 0.5rem; }

  /* Duplicate warning: no icon column, full-width stacked buttons */
  .alert-warn > .i { display: none; }
  .alert-warn .btn-row { display: grid; grid-template-columns: 1fr; gap: 0.5rem; }
  .alert-warn .btn-row .btn { width: 100%; }
}

/* Small phones and up */
@media (min-width: 360px) {
  .card { padding: 1.5rem; }
}

/* Large phones: room for the brand word and 3 compact stat cards */
@media (min-width: 420px) {
  .brand-txt { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  .who-name { max-width: 9rem; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat { flex-direction: column; align-items: flex-start; gap: 0.25rem; padding: 0.75rem; border-left-width: 1px; border-top: 6px solid var(--blue); }
  .stat-purple { border-top-color: var(--purple); }
  .stat-green { border-top-color: var(--green); }
  .stat-ico { width: 2.25rem; height: 2.25rem; }
  .stat-ico .i { width: 1.25rem; height: 1.25rem; }
  .stat-label { font-size: 0.875rem; }
  .stat-num { margin-left: 0; font-size: clamp(1.75rem, 1.25rem + 1vw, 2.25rem); }
  .search-row { grid-template-columns: minmax(0, 1fr) auto; }
  .btn-row-split, .form-actions { grid-template-columns: 1fr 1fr; }
}

/* Top navigation bar: tablets and up, and short landscape phones (no fixed bottom bar there) */
@media (min-width: 768px), (max-height: 500px) {
  body.has-nav { padding-bottom: 0; }
  html { scroll-padding-bottom: 0; }
  .brand-txt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .tabs {
    position: static; display: flex; gap: 0.25rem;
    background: none; border: 0; box-shadow: none; padding: 0;
  }
  .tab {
    flex-direction: row; gap: 0.5rem; min-height: 3rem; padding: 0.5rem 0.875rem;
    color: #fff; font-size: 1.0625rem; border: 0; border-radius: var(--radius-sm);
  }
  .tab .i { width: 1.375rem; height: 1.375rem; }
  .tab:hover { background: rgba(255, 255, 255, 0.14); }
  .tab.is-active { background: #fff; color: var(--navy); }
  .tab:focus-visible { outline-offset: 2px; }
}
/* Very narrow short landscape (e.g. 568x320): drop the username to fit the tabs */
@media (max-width: 639.98px) and (max-height: 500px) {
  .who { display: none; }
  .tab { padding: 0.5rem 0.625rem; }
}

/* Tablets and up: real table */
@media (min-width: 768px) {
  :root { --gutter: 1.5rem; }
  .wrap { padding-top: 1.5rem; padding-bottom: 3rem; }
  .topbar-in { gap: 1rem; min-height: 4rem; }

  .stats { gap: 1rem; }
  .stat { padding: 1rem 1.25rem; gap: 0.5rem; }
  .stat-ico { width: 3rem; height: 3rem; }
  .stat-ico .i { width: 1.625rem; height: 1.625rem; }
  .stat-label { font-size: 1.0625rem; }
  .search-card { padding: 1.25rem; }
  .search-row input { min-height: 3.25rem; }
  .search-row .btn { min-width: 10rem; }

  .tablewrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
  .clist th {
    text-align: left; font-size: 0.9375rem; font-weight: 800; color: var(--muted);
    background: var(--surface-2); padding: 0.75rem 0.875rem; border-bottom: 2px solid var(--border);
    white-space: nowrap;
  }
  .clist td { padding: 0.75rem 0.875rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
  .clist tbody tr:last-child td { border-bottom: 0; }
  .clist tbody tr:hover td { background: #f9fbfd; }
  .clist .c-id { width: 1%; white-space: nowrap; }
  .clist .c-phone { white-space: nowrap; font-weight: 600; }
  .clist .c-phone .i, .clist .c-addr .i { display: none; }
  .clist .c-act { width: 1%; white-space: nowrap; }
  .clist .date-lbl { display: none; }
  .clist .c-date { white-space: nowrap; color: var(--muted); }
  .acts { display: flex; gap: 0.5rem; justify-content: flex-end; }
  .acts .btn { min-height: 3rem; padding: 0.5rem 0.875rem; }
  /* Tablet: hide Address & Added columns; address shows under the name */
  .clist-full .c-addr, .clist-full .c-date { display: none; }
  .clist-full .c-name { min-width: 11rem; }
  .clist-full .acts { display: grid; grid-template-columns: 1fr 1fr; }
  .clist-full .acts > :first-child { grid-column: 1 / -1; }
  .clist-full .acts .btn { width: 100%; }

  .narrow { max-width: 38rem; }
  .card { padding: 1.75rem; }
  .login-card { padding: 2rem; }
}

/* Laptops: full nav labels, brand word back */
@media (min-width: 1024px) {
  .brand-txt { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  .lbl-short { display: none; }
  .lbl-long { display: inline; }
  .who-name { max-width: 12rem; }
}

/* Desktops: show every column */
@media (min-width: 1200px) {
  :root { --gutter: 2rem; }
  .clist-full .c-addr, .clist-full .c-date { display: table-cell; }
  .clist-full .sub-mid { display: none; }
  .clist .addr { max-width: 22rem; }
  .clist-full .c-addr { min-width: 12rem; }
  .clist-full .c-name { min-width: 14rem; }
  .clist-full .acts { display: flex; }
  .clist-full .acts .btn { width: auto; }
  .stat { flex-direction: row; align-items: center; gap: 1rem; padding: 1rem 1.25rem; }
  .stat-label { font-size: 1.125rem; }
  .stat-num { margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  .topbar, .tabs, .skip, .btn, form .btn { display: none !important; }
  body { background: #fff; padding: 0 !important; }
}

/* Logout stands out in red. */
.logout .btn { background: var(--red); border-color: var(--red); color: #fff; }
.logout .btn:hover { background: var(--red-dark); border-color: var(--red-dark); color: #fff; }

/* Dashboard: heading, stats, search and "Add Customer" sit in a centred column;
   the customer tables below still use the full width. */
.dash > .page-head, .dash > .stats, .dash > .search-card, .dash > .cta {
  width: 100%;
  max-width: 64rem;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Flat look: no outlines, tinted backgrounds ---------- */
/* Stat cards: soft colour per card, no borders or stripes. */
.stat, .stat-purple, .stat-green {
  border: 0; box-shadow: none;
}
.stat        { background: var(--blue-soft); }
.stat-purple { background: var(--purple-soft); }
.stat-green  { background: var(--green-soft); }
.stat .stat-ico { background: rgba(255, 255, 255, 0.75); }
.stat-label { color: #374151; }

/* Search box: plain white card; the input has no border until hovered or focused. */
.search-card, .search-card-sm { border: 0; box-shadow: var(--shadow); }
.search-row input {
  background: var(--bg); border: 2px solid transparent;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.search-row input:hover { border-color: var(--blue); background: var(--surface); }
.search-row input:focus { border-color: var(--blue); background: var(--surface); outline: none; }

/* "No customer found": soft card, no dashed border. */
.empty { border: 0; background: var(--surface); box-shadow: var(--shadow); }

/* Search results sit in the same centred column as the search box. */
.dash > .results { width: 100%; max-width: 64rem; margin-left: auto; margin-right: auto; }
/* When nothing is found, the empty card already offers "Add new customer". */
.dash > .results:has(.empty) ~ .cta { display: none; }

/* All form fields (add/edit customer, login): same flat style as the search box.
   No border at rest; one blue outline on hover or while typing. Errors stay red. */
input[type="text"], input[type="search"], input[type="password"], input[type="tel"], textarea {
  background: var(--bg); border: 2px solid transparent;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
input[type="text"]:hover, input[type="search"]:hover, input[type="password"]:hover, input[type="tel"]:hover, textarea:hover,
input:focus, textarea:focus {
  border-color: var(--blue); background: var(--surface); outline: none;
}
.has-error input, .has-error textarea { border-color: var(--red); background: #fff7f7; }
.card { border: 0; }

/* Phones: search and "Add Customer" are the focus; the numbers become one
   small row of three tiles underneath instead of three big cards. */
@media (max-width: 767.98px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
  .stat { flex-direction: column; align-items: center; text-align: center; gap: 0.125rem; padding: 0.5rem 0.25rem; }
  .stat .stat-ico { display: none; }
  .stat-label { font-size: 0.75rem; line-height: 1.2; font-weight: 700; order: 2; }
  .stat-num { margin: 0; font-size: 1.375rem; order: 1; }
  /* Order on every phone: search, Add Customer, numbers, recent list. */
  .dash { display: flex; flex-direction: column; }
  .dash > .stats { order: 1; margin: 1.25rem 0 0; }
  .dash > .recent { order: 2; }
}

/* Wide screens: breathing room at the sides (grows with the screen) and
   roomier table rows, so wide pages don't look stretched edge to edge. */
@media (min-width: 1200px) {
  :root { --gutter: clamp(2rem, 4vw, 6rem); }
  .clist th { padding: 0.875rem 1.25rem; }
  .clist td { padding: 1rem 1.25rem; }
}

/* ---------- Phones: calmer screen, one main button ----------
   Only "Add Customer" is a solid colour button. Search becomes a plain field
   with a small icon button, numbers are quiet, row buttons are smaller and lighter. */
@media (max-width: 767.98px) {
  .wrap { padding-top: 0.75rem; }
  .dash > .page-head { margin-bottom: 0.75rem; }
  .dash .page-head h1 { font-size: 1.375rem; }
  .dash .today { font-size: 0.875rem; }

  /* Search: no card, label hidden (placeholder says it), icon-only button beside the field */
  .dash > .search-card { background: none; box-shadow: none; padding: 0; }
  .dash .search-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .search-row { grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem; }
  .search-row input { min-height: 3rem; font-size: 1rem; background: var(--surface); border-color: var(--line); }
  .search-row .btn { min-height: 3rem; min-width: 3rem; padding: 0 0.875rem; background: var(--surface); color: var(--blue); border: 2px solid var(--line); }
  .search-row .btn:hover { background: var(--blue-soft); }
  .search-row .btn > span:not(.sr-only) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

  /* The one main button */
  .cta { margin: 1rem 0 0; }
  .btn-xl { min-height: 3rem; font-size: 1.0625rem; border-radius: var(--radius-sm); }

  /* Numbers: plain white tiles, coloured number only */
  .stat, .stat-purple, .stat-green { background: var(--surface); }
  .stat { padding: 0.625rem 0.25rem; }
  .stat-num { font-size: 1.25rem; color: var(--blue); }
  .stat-purple .stat-num { color: var(--purple); }
  .stat-green .stat-num { color: var(--green); }
  .stat-label { font-size: 0.6875rem; font-weight: 600; color: var(--muted); }

  /* Section heading and customer cards */
  .sec-h { font-size: 1.0625rem; margin: 1.5rem 0 0.5rem; }
  .clist tr { border-color: var(--line); box-shadow: none; }
  .clist .c-phone { font-size: 1.0625rem; }
  .acts .btn { min-height: 2.5rem; padding: 0.375rem 0.75rem; font-size: 0.9375rem; border-radius: var(--radius-sm); }
  .acts .btn .i { width: 1.125rem; height: 1.125rem; }
  /* Print: light green instead of solid */
  .btn-print { background: var(--green-soft); color: var(--green-dark); }
  .btn-print:hover { background: #bbf7d0; }
  .btn-plain { border-color: var(--line); }

  /* "See all customers": simple link-style button */
  .more .btn { background: none; border: 0; color: var(--blue); min-height: 2.75rem; font-size: 1rem; }

  /* Bottom bar: active tab shown by colour only, no filled block */
  .tab.is-active { background: none; }
  /* Softer ID badge and a smaller (still red) Logout */
  .clist .badge { background: var(--blue-soft); color: var(--navy); }
  .logout .btn { min-height: 2.5rem; padding: 0.25rem 0.75rem; font-size: 0.9375rem; }
}
