/* ─────────────────────────────────────────────────────────────────────
   Rutha's Covering — Design system (mobile-first, responsive PWA)
   Gold-covering shop billing. Adapted from the MedConnect core structure.
   ─────────────────────────────────────────────────────────────────────*/
:root {
    --gold: #b8860b; --gold-2: #d4af37; --gold-dark: #8a6508; --gold-soft: #fdf6e3; --gold-line: #f0e2b8;
    --green: #10b981; --green-soft: #d1fae5;
    --amber: #f59e0b; --amber-soft: #fef3c7;
    --red: #dc2626; --red-soft: #fee2e2;
    --blue: #2563eb; --blue-soft: #dbeafe;
    --ink: #2a210f; --ink-2: #5b4a26; --muted: #8a7a52; --muted-2: #b3a576;
    --line: #ece3cf; --line-2: #ddd0ad; --bg: #fffdf7; --bg-2: #fbf6e9;
    --radius: 14px; --radius-lg: 18px; --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(80,60,10,.06);
    --shadow: 0 4px 14px -6px rgba(120,90,20,.18);
    --shadow-lg: 0 14px 36px -18px rgba(120,90,20,.30);
    --nav-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%; text-size-adjust: 100%;  /* no auto font inflation */
    touch-action: manipulation;                              /* kill double-tap zoom */
}
body {
    font-family: 'Inter', 'Noto Sans Tamil', system-ui, -apple-system, "Segoe UI", "Nirmala UI", Roboto, sans-serif;
    background: var(--bg); color: var(--ink); min-height: 100dvh; line-height: 1.5;
    overflow-x: hidden;
}
a { color: var(--gold-dark); text-decoration: none; }
img, svg { max-width: 100%; height: auto; display: block; }
i[class^="ri-"], i[class*=" ri-"] { font-style: normal; line-height: 1; display: inline-flex; vertical-align: middle; }

/* ═══════════════════════ App shell ═══════════════════════ */
.app-shell {
    width: 100%; max-width: 640px; margin: 0 auto;
    min-height: 100dvh; position: relative; background: var(--bg);
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
}

.topbar {
    background: #fff; border-bottom: 1px solid var(--line);
    padding: 14px 18px; padding-top: calc(14px + env(safe-area-inset-top));
    position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 12px;
}
.topbar h1 { font-size: 18px; font-weight: 800; flex: 1; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .brand-mini { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--gold-2), var(--gold-dark)); color: #fff; display: grid; place-items: center; font-size: 18px; flex-shrink: 0; }
.icon-btn {
    width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--line);
    background: #fff; color: var(--ink-2); display: grid; place-items: center;
    font-size: 19px; cursor: pointer; flex-shrink: 0;
}
.icon-btn:active { transform: scale(.94); }

.content { padding: 16px 16px 24px; }

/* ── Bottom nav (mobile) ── */
.app-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    display: flex; align-items: stretch; justify-content: space-around;
    max-width: 640px; margin: 0 auto;
}
.app-nav .brand-block { display: none; }
.nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer; position: relative;
}
.nav-item .icon { font-size: 22px; }
.nav-item.active { color: var(--gold-dark); }
.nav-item.fab {
    flex: 0 0 84px; margin-top: -22px; align-self: flex-start;
}
.nav-item.fab .icon {
    width: 56px; height: 56px; border-radius: 50%; font-size: 28px; color: #fff;
    background: linear-gradient(135deg, var(--gold-2), var(--gold-dark));
    display: grid; place-items: center; box-shadow: 0 8px 20px -6px rgba(138,101,8,.55);
    border: 4px solid var(--bg);
}
.nav-item.fab { color: var(--gold-dark); font-weight: 700; }

/* ── Desktop: sidebar layout ── */
@media (min-width: 1024px) {
    body { background: var(--bg-2); }
    .app-shell {
        max-width: none; width: 100%; margin: 0; padding-bottom: 0;
        display: grid; grid-template-columns: 264px minmax(0,1fr);
        grid-template-rows: auto 1fr; grid-template-areas: "nav topbar" "nav content";
        background: linear-gradient(90deg,#fff 0,#fff 264px,var(--bg-2) 264px);
    }
    .topbar { grid-area: topbar; padding: 20px 36px; background: rgba(255,253,247,.85); backdrop-filter: blur(8px); }
    .topbar h1 { font-size: 24px; }
    .topbar .brand-mini { display: none; }
    .content { grid-area: content; padding: 28px 36px 56px; max-width: 1080px; width: 100%; margin: 0 auto; }
    .app-nav {
        grid-area: nav; position: sticky; top: 0; align-self: start; height: 100dvh;
        flex-direction: column; justify-content: flex-start; align-items: stretch; gap: 4px;
        background: #fff; border-top: none; border-right: 1px solid var(--line);
        max-width: none; margin: 0; padding: 22px 14px;
    }
    .app-nav .brand-block {
        display: flex; align-items: center; gap: 11px; padding: 4px 10px 18px; margin-bottom: 10px;
        border-bottom: 1px solid var(--line);
    }
    .app-nav .brand-block .logo { width: 40px; height: 40px; border-radius: 11px; background: linear-gradient(135deg,var(--gold-2),var(--gold-dark)); color:#fff; display:grid; place-items:center; font-size:21px; flex-shrink:0; }
    .app-nav .brand-block .name { font-size: 15px; font-weight: 800; line-height: 1.2; }
    .app-nav .brand-block .name small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); }
    .nav-item {
        flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 12px;
        font-size: 14.5px; padding: 11px 14px; border-radius: 11px;
    }
    .nav-item .icon { font-size: 20px; }
    .nav-item:hover { background: var(--bg-2); color: var(--ink); }
    .nav-item.active { background: var(--gold-soft); color: var(--gold-dark); }
    .nav-item.fab { flex: 0 0 auto; margin-top: 6px; align-self: stretch; }
    .nav-item.fab .icon {
        width: 30px; height: 30px; font-size: 20px; border: none; box-shadow: none; border-radius: 9px;
    }
}

/* ═══════════════════════ Cards ═══════════════════════ */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.card.lg { padding: 22px; border-radius: var(--radius-lg); }
.card + .card { margin-top: 12px; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(4,1fr); } }

.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 24px; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.gold { background: linear-gradient(135deg, var(--gold-soft), #fff); border-color: var(--gold-line); }

.section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 18px 4px 10px; }

/* ═══════════════════════ Buttons ═══════════════════════ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-family: inherit; font-size: 15px; font-weight: 600; line-height: 1;
    padding: 12px 18px; border-radius: 12px; border: 1px solid transparent; cursor: pointer;
    transition: transform .05s, filter .15s; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--gold-2), var(--gold-dark)); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { filter: brightness(1.04); }
.btn-secondary { background: #fff; color: var(--ink-2); border-color: var(--line-2); }
.btn-secondary:hover { background: var(--bg-2); }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--gold-dark); }
.btn-full { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn.lg { padding: 15px 22px; font-size: 16px; }

/* ═══════════════════════ Forms ═══════════════════════ */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }
input, select, textarea {
    width: 100%; font-family: inherit; font-size: 15px; color: var(--ink);
    padding: 12px 13px; border: 1px solid var(--line-2); border-radius: 11px; background: #fff;
    -webkit-appearance: none; appearance: none;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold-2); box-shadow: 0 0 0 3px rgba(212,175,55,.18); }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238a7a52' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px; }
textarea { resize: vertical; min-height: 80px; }
/* Checkboxes/radios must keep their native rendering (the reset above hides the tick). */
input[type="checkbox"], input[type="radio"] {
    -webkit-appearance: auto; appearance: auto;
    width: 18px; height: 18px; min-width: 18px; padding: 0; box-shadow: none;
    accent-color: var(--gold-dark); cursor: pointer; vertical-align: middle;
}
input[type="checkbox"]:focus, input[type="radio"]:focus { box-shadow: none; }

/* Toggle pill (GST / Non-GST) */
.toggle-pill { display: flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.toggle-pill button {
    flex: 1; border: none; background: transparent; font-family: inherit; font-size: 14px; font-weight: 700;
    color: var(--muted); padding: 10px; border-radius: 9px; cursor: pointer;
}
.toggle-pill button.active { background: #fff; color: var(--gold-dark); box-shadow: var(--shadow-sm); }
.toggle-pill button.active.gst { color: var(--green); }

/* ═══════════════════════ Badges ═══════════════════════ */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.badge.gold { background: var(--gold-soft); color: var(--gold-dark); }
.badge.green { background: var(--green-soft); color: #047857; }
.badge.blue { background: var(--blue-soft); color: #1d4ed8; }
.badge.gray { background: var(--bg-2); color: var(--muted); }
.badge.amber { background: var(--amber-soft); color: #b45309; }

/* ═══════════════════════ Lists / rows ═══════════════════════ */
.list { display: flex; flex-direction: column; gap: 8px; }
.row-item {
    display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line);
    border-radius: var(--radius); padding: 13px 14px; cursor: pointer;
}
.row-item:active { background: var(--bg-2); }
.row-item.kbd-active { border-color: var(--gold-2); background: var(--gold-soft); box-shadow: 0 0 0 2px rgba(212,175,55,.30); }
.row-item .ri-avatar { width: 42px; height: 42px; border-radius: 11px; background: var(--gold-soft); color: var(--gold-dark); display: grid; place-items: center; font-size: 19px; flex-shrink: 0; }
.row-item .row-main { flex: 1; min-width: 0; }
.row-item .row-title { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .row-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.row-item .row-end { text-align: right; flex-shrink: 0; }
.row-item .row-amt { font-weight: 800; font-size: 15px; }

/* ═══════════════════════ Tables ═══════════════════════ */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); text-transform: uppercase; letter-spacing: .03em; }
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--line); }
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ═══════════════════════ Cart line (billing) ═══════════════════════ */
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; background:#fff; border:1px solid var(--line); border-radius: var(--radius); padding: 12px 13px; align-items: center; }
.cart-line .cl-name { font-weight: 700; font-size: 14.5px; }
.cart-line .cl-controls { display: flex; align-items: center; gap: 6px; }
.cart-line .qty-btn { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line-2); background: #fff; font-size: 17px; font-weight: 700; color: var(--gold-dark); cursor: pointer; display: grid; place-items: center; }
.cart-line .qty-val { min-width: 26px; text-align: center; font-weight: 700; }
.cart-line .cl-qty-input { width: 64px; padding: 8px 8px; font-size: 14px; text-align: center; }
.cart-line .cl-price { width: 96px; }
.cart-line .cl-price input { padding: 8px 10px; font-size: 14px; text-align: right; }
.cart-line .cl-total { font-weight: 800; min-width: 84px; text-align: right; }
.cart-line .cl-remove { color: var(--red); cursor: pointer; font-size: 18px; }

.totals { background: var(--gold-soft); border: 1px solid var(--gold-line); border-radius: var(--radius); padding: 14px 16px; }
.totals .t-row { display: flex; justify-content: space-between; font-size: 14px; padding: 4px 0; color: var(--ink-2); }
.totals .t-row.grand { font-size: 19px; font-weight: 800; color: var(--ink); border-top: 1px dashed var(--line-2); margin-top: 6px; padding-top: 10px; }

/* ═══════════════════════ Empty / skeleton ═══════════════════════ */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ic { font-size: 52px; color: var(--line-2); margin-bottom: 10px; }
.empty h3 { font-size: 16px; color: var(--ink-2); margin-bottom: 4px; }
.skeleton { background: linear-gradient(90deg, var(--bg-2) 25%, #fff 50%, var(--bg-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 10px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ═══════════════════════ Messages / spinner ═══════════════════════ */
.msg { font-size: 14px; padding: 11px 14px; border-radius: 11px; margin-bottom: 12px; }
.msg.err { background: var(--red-soft); color: #b91c1c; }
.msg.ok { background: var(--green-soft); color: #047857; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
.spinner.dark { border-color: rgba(138,101,8,.25); border-top-color: var(--gold-dark); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════ Bottom sheet / modal ═══════════════════════ */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(42,33,15,.5); z-index: 100; display: none; align-items: flex-end; justify-content: center; }
.sheet-backdrop.show { display: flex; animation: fade .2s; }
@media (min-width: 720px) { .sheet-backdrop { align-items: center; } }
.sheet {
    background: #fff; width: 100%; max-width: 520px; border-radius: 22px 22px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
    max-height: 92dvh; overflow-y: auto; animation: slideUp .25s;
}
@media (min-width: 720px) { .sheet { border-radius: 18px; } }
.sheet-handle { width: 40px; height: 4px; border-radius: 99px; background: var(--line-2); margin: 0 auto 14px; }
.sheet h2 { font-size: 18px; font-weight: 800; margin-bottom: 14px; }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Search input */
.search-bar { position: relative; margin-bottom: 14px; }
.search-bar i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 18px; }
.search-bar input { padding-left: 40px; }

.fab-add { position: fixed; right: 18px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px); z-index: 45; width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg,var(--gold-2),var(--gold-dark)); color: #fff; border: none; font-size: 27px; box-shadow: var(--shadow-lg); cursor: pointer; display: grid; place-items: center; }
@media (min-width: 1024px) { .fab-add { right: 36px; bottom: 28px; } }

.mt-1{margin-top:4px}.mt-2{margin-top:8px}.mt-3{margin-top:12px}.mt-4{margin-top:16px}
.mb-2{margin-bottom:8px}.mb-3{margin-bottom:12px}
.flex{display:flex}.items-center{align-items:center}.justify-between{justify-content:space-between}.gap-2{gap:8px}.gap-3{gap:12px}
.text-muted{color:var(--muted)}.text-sm{font-size:13px}.text-right{text-align:right}.fw-700{font-weight:700}
