:root {
    --red: #b3121f;
    --red-dark: #8c0d17;
    --red-soft: #fbe9ea;
    --paper: #f7f3ee;
    --card: #ffffff;
    --ink: #1f1a17;
    --muted: #7a706a;
    --line: #ece4dc;
    --pant: #b3121f;
    --shirt: #1d5fa8;
    --coat: #2f6b3a;
    --radius: 14px;
    --font: "Inter", "Noto Sans Gurmukhi", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: var(--font);
    background: var(--paper);
    color: var(--ink);
    font-size: 16px;
    line-height: 1.4;
    -webkit-tap-highlight-color: transparent;
}
a { color: var(--red); text-decoration: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
    background: var(--red); color: #fff;
    box-shadow: 0 2px 10px rgba(140, 13, 23, .25);
}
.topbar h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { color: #fff; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; }
.icon-btn:active { background: rgba(255,255,255,.15); }
.brand-dot { width: 36px; height: 36px; display: grid; place-items: center; background: rgba(255,255,255,.18); border-radius: 10px; font-size: 18px; }

.wrap { max-width: 560px; margin: 0 auto; padding: 16px 16px 110px; }

/* ---------- Bottom nav ---------- */
.bottomnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    background: #fff; border-top: 1px solid var(--line);
    padding: 6px 8px; padding-bottom: max(6px, env(safe-area-inset-bottom));
    max-width: 560px; margin: 0 auto;
}
.bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11px; padding: 4px 0; }
.bottomnav a.on { color: var(--red); font-weight: 600; }
.bottomnav .fab {
    justify-self: center; width: 58px; height: 58px; border-radius: 50%;
    background: var(--red); color: #fff; justify-content: center;
    transform: translateY(-18px);
    box-shadow: 0 6px 16px rgba(179, 18, 31, .4), 0 0 0 5px var(--paper);
}
.bottomnav .fab svg { width: 28px; height: 28px; stroke-width: 2.6; }
.bottomnav .fab:active { background: var(--red-dark); }

/* ---------- Flash ---------- */
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-size: 14px; }
.flash-ok { background: #e7f4ea; color: #1f5a2b; }
.flash-err { background: var(--red-soft); color: var(--red-dark); }

/* ---------- Search ---------- */
.search { position: relative; margin-bottom: 14px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 20px; height: 20px; }
.search input {
    width: 100%; padding: 14px 40px 14px 44px; font: inherit;
    border: 1px solid var(--line); border-radius: 30px; background: #fff; outline: none;
}
.search input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.search .clear { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 22px; }

/* ---------- Stats ---------- */
.stat {
    display: flex; flex-direction: column; gap: 2px;
    background: var(--card); border-radius: var(--radius); padding: 14px; color: var(--ink);
    border: 1px solid var(--line); position: relative; overflow: hidden;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--red)); }
.stat-label { font-size: 14px; font-weight: 600; color: var(--c, var(--red)); }
.stat-num { font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--muted); }
.stat-total { background: var(--red); color: #fff; border: 0; margin-bottom: 10px; padding: 18px; }
.stat-total::before { display: none; }
.stat-total .stat-label, .stat-total .stat-sub { color: rgba(255,255,255,.85); }
.stat-total .stat-num { font-size: 40px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px; }
.stat-pant { --c: var(--pant); } .stat-shirt { --c: var(--shirt); } .stat-coat { --c: var(--coat); }
.stat:active { transform: scale(.98); }

/* ---------- Lists ---------- */
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0 8px; }
.section-head h3, .h-sub { margin: 0; font-size: 15px; }
.h-sub { margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.list { list-style: none; margin: 0; padding: 0; background: #fff; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.list a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: var(--ink); }
.list a:active { background: var(--paper); }
.li-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.li-main b { font-weight: 600; }
.li-main small { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--red-soft); color: var(--red); font-weight: 700; }
.avatar-lg { width: 54px; height: 54px; font-size: 22px; }
.pill { min-width: 26px; padding: 2px 8px; border-radius: 20px; background: var(--paper); color: var(--muted); font-size: 12px; font-weight: 600; text-align: center; }
.chev { color: var(--muted); font-size: 22px; }
.count-line { font-size: 13px; margin: -4px 4px 10px; }
.empty { text-align: center; padding: 28px 16px; background: #fff; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }

/* ---------- Tags / chips ---------- */
.tag { flex: none; padding: 4px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; color: #fff; background: var(--red); }
.tag-pant { background: var(--pant); } .tag-shirt { background: var(--shirt); } .tag-coat { background: var(--coat); }
.chips { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; }
.chips a { padding: 7px 16px; border-radius: 20px; background: #fff; border: 1px solid var(--line); color: var(--ink); font-size: 14px; white-space: nowrap; }
.chips a.on { background: var(--red); border-color: var(--red); color: #fff; }

/* ---------- Cards, forms, buttons ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.form label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 14px; }
.form input, .form textarea {
    display: block; width: 100%; margin-top: 6px; padding: 12px 14px; font: inherit; font-weight: 400;
    border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none;
}
.form input:focus, .form textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.req { color: var(--red); }
.err { display: block; margin-top: 6px; color: var(--red-dark); font-weight: 400; font-size: 13px; }

.btn {
    display: inline-flex; justify-content: center; align-items: center; gap: 6px;
    padding: 13px 20px; border: 0; border-radius: 12px; font: inherit; font-weight: 600;
    background: var(--red); color: #fff; cursor: pointer;
}
.btn:active { background: var(--red-dark); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.btn-ghost { background: var(--paper); color: var(--ink); }
.btn-ghost:active { background: var(--line); }
.btn-danger-ghost { background: transparent; color: var(--red); border: 1px solid var(--red-soft); }
.row-actions { display: flex; gap: 8px; margin-top: 12px; }
.row-actions form { margin: 0; }

/* ---------- Steps ---------- */
.steps { display: flex; list-style: none; margin: 0 0 14px; padding: 0; gap: 6px; font-size: 12px; counter-reset: s; }
.steps li { flex: 1; text-align: center; padding: 6px 4px; border-radius: 8px; background: #fff; color: var(--muted); border: 1px solid var(--line); }
.steps li.on { background: var(--red); color: #fff; border-color: var(--red); font-weight: 600; }
.steps li.done { color: var(--red); border-color: var(--red-soft); background: var(--red-soft); }

/* ---------- Customer profile ---------- */
.profile-top { display: flex; gap: 14px; align-items: center; }
.profile .li-main b { font-size: 18px; }
.phone { font-weight: 600; font-size: 15px; }
.type-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.type-btn {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 18px 8px; border-radius: var(--radius); color: #fff; background: var(--c);
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.type-btn:active { transform: scale(.97); }
.type-pant { --c: var(--pant); } .type-shirt { --c: var(--shirt); } .type-coat { --c: var(--coat); }
.type-pa { font-size: 22px; font-weight: 700; }
.type-en { font-size: 12px; opacity: .85; }
.type-plus { position: absolute; top: 6px; right: 10px; font-size: 18px; font-weight: 700; opacity: .8; }

.mcard { border-left: 4px solid var(--c, var(--red)); }
.mcard-pant { --c: var(--pant); } .mcard-shirt { --c: var(--shirt); } .mcard-coat { --c: var(--coat); }
.mcard-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.mcard-head small { color: var(--muted); }
.mgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.mgrid div { background: var(--paper); border-radius: 10px; padding: 8px 10px; }
.mgrid dt { font-size: 13px; color: var(--muted); }
.mgrid dd { margin: 0; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.notes { margin: 10px 0 0; font-size: 14px; }

/* ---------- Measurement form ---------- */
.who { margin: 0 2px 10px; color: var(--muted); font-size: 14px; }
.who b { color: var(--ink); }
.mform { --c: var(--red); padding: 8px 16px 16px; }
.mform-shirt { --c: var(--shirt); } .mform-coat { --c: var(--coat); }
.mrow { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.mlabel { flex: 1; font-size: 18px; font-weight: 600; color: var(--c); }
.form .mval {
    width: 110px; flex: none; margin: 0; text-align: center; font-size: 18px; font-weight: 700;
    padding: 10px; font-variant-numeric: tabular-nums;
}
.form .mlabel-in { flex: 1; margin: 0; font-size: 16px; padding: 10px 12px; color: var(--c); font-weight: 600; min-width: 0; }
.mrow-custom .mval { width: 90px; }
.rm { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--red-soft); color: var(--red); font-size: 20px; line-height: 1; cursor: pointer; }
.add-field {
    width: 100%; margin: 14px 0 16px; padding: 12px; border-radius: 12px; cursor: pointer;
    border: 2px dashed var(--c); background: transparent; color: var(--c);
    font: inherit; font-weight: 600; display: flex; justify-content: center; align-items: center; gap: 8px;
}
.add-field span { width: 26px; height: 26px; border-radius: 50%; background: var(--c); color: #fff; display: grid; place-items: center; font-size: 18px; }
.add-field small { font-weight: 400; opacity: .8; }
.notes-label { color: var(--c); }
.mform .btn { background: var(--c); }
.sticky-save { position: sticky; bottom: 84px; padding-top: 8px; }

/* ---------- Auth ---------- */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--red) 0 38%, var(--paper) 38%); }
.auth-card { width: 100%; max-width: 380px; background: #fff; border-radius: 20px; padding: 28px 22px; box-shadow: 0 20px 50px rgba(0,0,0,.12); text-align: center; }
.auth-card h2 { margin: 8px 0 4px; }
.auth-card form { text-align: left; margin-top: 18px; }
.auth-card label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 14px; }
.auth-card input { display: block; width: 100%; margin-top: 6px; padding: 12px 14px; font: inherit; border: 1px solid var(--line); border-radius: 10px; }
.auth-card input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.auth-logo { width: 64px; height: 64px; margin: 0 auto; border-radius: 18px; background: var(--red); color: #fff; display: grid; place-items: center; font-size: 30px; }

@media (max-width: 360px) {
    .mgrid { grid-template-columns: repeat(2, 1fr); }
    .stat-num { font-size: 24px; }
}

/* ---------- PWA install ---------- */
.auth-icon { width: 72px; height: 72px; display: block; margin: 0 auto; border-radius: 18px; box-shadow: 0 6px 16px rgba(179, 18, 31, .3); }
.btn-outline { background: #fff; color: var(--red); border: 2px solid var(--red); }
.btn-outline:active { background: var(--red-soft); }
.btn-outline svg { width: 20px; height: 20px; }
.install-box { margin-top: 6px; }
.install-or { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--muted); font-size: 13px; }
.install-or::before, .install-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.install-help { margin-top: 12px; padding: 14px; border-radius: 12px; background: var(--paper); text-align: left; font-size: 14px; }
.install-help p { margin: 0 0 10px; }
.ios-share { display: inline-block; padding: 0 6px; border: 1px solid var(--muted); border-radius: 6px; font-size: 12px; }
[hidden] { display: none !important; }
