/* ==========================================================================
   Franchisee portal + Admin panel — shared UI layer.
   Uses the same palette/typography tokens as the public website's style.css
   (logo teal, ribbon red, gold lettering, parchment cream, brown outlines).
   ========================================================================== */
:root {
    --primary: #b81c1f; --primary-deep: #7a1215; --primary-dark: #4d0c0d;
    --secondary: #004f56; --secondary-deep: #00393e;
    --accent: #f2a33a; --accent-deep: #de7b1e; --gold: #d9a441; --gold-light: #f3dc8f; --gold-deep: #8a5d14;
    --dark: #2b1410; --dark-deep: #1c0c08; --cream: #fbf3dc; --ivory: #fffaf0; --beige: #f3e4c4; --ink: #3a2418; --muted: #6b5242;
    --line: rgba(138, 93, 20, 0.22);
    --font-body: "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-display: "Noto Serif Devanagari", "Noto Sans Devanagari", serif;
    --radius: 14px; --sidebar-w: 256px;
    --shadow-soft: 0 14px 30px -22px rgba(77, 12, 13, 0.45);
    --ok: #1f7a3d; --warn: #b26a00; --bad: #b81c1f; --info: #00606a;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body.app { font-family: var(--font-body); font-size: 0.97rem; line-height: 1.55; color: var(--ink); background: var(--cream); min-height: 100vh; margin: 0; -webkit-font-smoothing: antialiased; }
body.app h1, body.app h2, body.app h3 { font-family: var(--font-display); color: var(--dark); }
a { color: var(--primary); }
a:hover { color: var(--primary-deep); }
:focus-visible { outline: 3px solid var(--secondary); outline-offset: 2px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--dark); color: #fff; padding: .5rem 1rem; z-index: 3000; }
.skip-link:focus { left: 0; }

/* ---------- layout ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: linear-gradient(180deg, #3d130e 0%, var(--dark) 55%, var(--dark-deep) 100%); color: var(--cream); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 1040; }
.sidebar .brand { display: flex; align-items: center; gap: .65rem; padding: 1rem 1.1rem; text-decoration: none; border-bottom: 1px solid rgba(243, 220, 143, .18); }
.sidebar .brand img { width: 46px; height: auto; filter: drop-shadow(0 3px 8px rgba(0,0,0,.4)); }
.sidebar .brand span { display: flex; flex-direction: column; font-family: var(--font-display); font-weight: 700; line-height: 1.2; color: var(--gold-light); font-size: .88rem; }
.sidebar .brand span b { color: var(--cream); font-size: 1.1rem; }
.side-nav { list-style: none; margin: 0; padding: .6rem .6rem 1rem; flex: 1; }
.side-nav li a { display: flex; align-items: center; gap: .7rem; padding: .62rem .85rem; margin: 2px 0; border-radius: 10px; color: rgba(251, 243, 220, .85); text-decoration: none; font-weight: 500; transition: background .2s, color .2s; position: relative; }
.side-nav li a:hover { background: rgba(243, 220, 143, .1); color: var(--gold-light); }
.side-nav li a.active { background: rgba(217, 164, 65, .18); color: var(--gold-light); box-shadow: inset 3px 0 0 var(--gold); }
.side-nav .ico { width: 1.25rem; text-align: center; opacity: .9; flex: none; }
.side-nav .badge-count { margin-left: auto; background: var(--accent); color: var(--dark); font-size: .72rem; font-weight: 700; border-radius: 99px; padding: .05rem .5rem; }
.side-nav .group { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: rgba(243, 220, 143, .5); padding: .9rem .9rem .3rem; }
.side-foot { padding: .8rem 1rem; border-top: 1px solid rgba(243, 220, 143, .18); font-size: .82rem; color: rgba(251, 243, 220, .7); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.4rem; background: var(--ivory); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1030; }
.topbar .menu-btn { display: none; border: 1px solid var(--line); background: #fff; border-radius: 10px; width: 42px; height: 42px; font-size: 1.2rem; }
.topbar .title { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--dark); margin: 0; flex: 1; }
.topbar .who { font-size: .88rem; color: var(--muted); text-align: right; line-height: 1.25; }
.topbar .who b { color: var(--dark); display: block; }
.content { padding: 1.4rem; max-width: 1400px; width: 100%; margin: 0 auto; }
.scrim { display: none; }

@media (max-width: 991.98px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .3s cubic-bezier(.22, 1, .36, 1); box-shadow: 0 0 40px rgba(0,0,0,.5); }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(28, 12, 8, .55); z-index: 1035; }
    .topbar .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
    .content { padding: 1rem; }
    .topbar { padding: .6rem 1rem; }
}

/* ---------- cards, stats ---------- */
.cardx { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-soft); }
.cardx > .hd { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .85rem 1.1rem; border-bottom: 1px solid var(--line); font-weight: 700; color: var(--dark); }
.cardx > .hd .sp { flex: 1; }
.cardx > .bd { padding: 1.1rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .9rem; margin-bottom: 1.2rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .95rem 1.05rem; position: relative; overflow: hidden; box-shadow: var(--shadow-soft); }
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--gold); }
.stat.red::before { background: var(--primary); } .stat.teal::before { background: var(--secondary); } .stat.green::before { background: var(--ok); } .stat.orange::before { background: var(--accent-deep); }
.stat .k { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat .v { font-family: var(--font-display); font-weight: 700; font-size: 1.55rem; color: var(--dark); line-height: 1.25; }
.stat .s { font-size: .78rem; color: var(--muted); }
.welcome { background: linear-gradient(135deg, var(--primary-deep), var(--dark)); color: var(--cream); border-radius: var(--radius); padding: 1.3rem 1.5rem; margin-bottom: 1.2rem; display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; position: relative; overflow: hidden; }
body.app .welcome h2 { color: var(--gold-light); font-size: 1.35rem; margin: 0 0 .25rem; }
.welcome p { margin: 0; opacity: .9; }
.welcome .chip { background: rgba(243, 220, 143, .16); border: 1px solid rgba(243, 220, 143, .35); border-radius: 99px; padding: .15rem .8rem; font-size: .85rem; display: inline-block; margin: .15rem .3rem .15rem 0; }

/* ---------- buttons / forms ---------- */
.btn-brand { background: linear-gradient(180deg, #cf2a2d, var(--primary)); color: #fff; border: 0; font-weight: 600; border-radius: 10px; padding: .5rem 1.1rem; box-shadow: 0 8px 18px -10px rgba(184, 28, 31, .8); }
.btn-brand:hover, .btn-brand:focus { background: var(--primary-deep); color: #fff; }
.btn-brand:disabled { opacity: .6; }
.btn-teal { background: var(--secondary); color: #fff; border: 0; border-radius: 10px; font-weight: 600; } .btn-teal:hover { background: var(--secondary-deep); color: #fff; }
.btn-ghost { background: #fff; border: 1px solid var(--gold); color: var(--gold-deep); border-radius: 10px; font-weight: 600; } .btn-ghost:hover { background: var(--beige); color: var(--dark); }
.btn-sm { padding: .25rem .7rem; font-size: .85rem; }
.form-control, .form-select { border-radius: 10px; border-color: rgba(138, 93, 20, .35); background-color: #fff; }
.form-control:focus, .form-select:focus { border-color: var(--secondary); box-shadow: 0 0 0 .2rem rgba(0, 79, 86, .15); }
.form-label { font-weight: 600; font-size: .86rem; color: var(--ink); margin-bottom: .2rem; }
.form-text.err, .invalid-msg { color: var(--bad); font-size: .8rem; }
.req::after { content: " *"; color: var(--bad); }
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; align-items: center; }
.toolbar .form-control, .toolbar .form-select { width: auto; min-width: 160px; }
.toolbar .grow { flex: 1; min-width: 200px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.tbl th { background: var(--beige); color: var(--dark); text-align: left; font-weight: 700; padding: .6rem .75rem; white-space: nowrap; border-bottom: 2px solid var(--gold); position: sticky; top: 0; }
table.tbl td { padding: .6rem .75rem; border-bottom: 1px solid rgba(138, 93, 20, .13); vertical-align: middle; }
table.tbl tbody tr:hover { background: rgba(243, 228, 196, .35); }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tbl tfoot td { font-weight: 700; background: var(--ivory); }
.empty { text-align: center; padding: 2.2rem 1rem; color: var(--muted); }
.empty .big { font-size: 2.2rem; opacity: .5; }
.pager { display: flex; gap: .4rem; align-items: center; justify-content: flex-end; padding: .7rem 1rem; font-size: .88rem; color: var(--muted); }

/* ---------- status badges ---------- */
.sb { display: inline-block; padding: .12rem .6rem; border-radius: 99px; font-size: .76rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; border: 1px solid transparent; }
.sb-gray { background: #eee7d6; color: #5c4a35; border-color: #d9cdb0; } .sb-blue { background: #dff0f2; color: #00606a; border-color: #b5d9de; }
.sb-orange { background: #fff0d6; color: #99590a; border-color: #f3d29a; } .sb-green { background: #def3e4; color: #1f6b38; border-color: #b4dcbf; }
.sb-red { background: #fbe0e0; color: #9a1519; border-color: #efb3b4; } .sb-purple { background: #ece4f7; color: #5a3a8c; border-color: #d4c3ec; }

/* ---------- order timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--gold); }
.timeline li { position: relative; padding: 0 0 .95rem 1rem; }
.timeline li::before { content: ""; position: absolute; left: -1.6rem; top: .3rem; width: .85rem; height: .85rem; background: var(--gold); border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px var(--gold); }
.timeline li.done::before { background: var(--ok); box-shadow: 0 0 0 1px var(--ok); }
.timeline li.bad::before { background: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.timeline .t { font-weight: 700; color: var(--dark); } .timeline .m { font-size: .82rem; color: var(--muted); }
.progress-steps { display: flex; gap: 0; margin: .4rem 0 1.3rem; overflow-x: auto; padding-bottom: .4rem; }
.progress-steps .step { flex: 1; min-width: 92px; text-align: center; position: relative; font-size: .78rem; color: var(--muted); }
.progress-steps .step::before { content: ""; display: block; width: 26px; height: 26px; border-radius: 50%; margin: 0 auto .3rem; background: #fff; border: 3px solid var(--beige); position: relative; z-index: 1; }
.progress-steps .step::after { content: ""; position: absolute; top: 12px; left: -50%; width: 100%; height: 3px; background: var(--beige); }
.progress-steps .step:first-child::after { display: none; }
.progress-steps .step.done { color: var(--ok); font-weight: 700; } .progress-steps .step.done::before { background: var(--ok); border-color: var(--ok); } .progress-steps .step.done::after { background: var(--ok); }
.progress-steps .step.now::before { border-color: var(--primary); background: var(--accent); }

/* ---------- shop ---------- */
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 1rem; }
.prod { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-soft); transition: transform .25s, box-shadow .25s; }
.prod:hover { transform: translateY(-3px); box-shadow: 0 22px 34px -22px rgba(77, 12, 13, .55); }
.prod .img { aspect-ratio: 4/3; background: var(--beige) center/cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 2.6rem; color: var(--gold-deep); position: relative; }
.prod .img .tag { position: absolute; top: .5rem; left: .5rem; background: var(--primary); color: #fff; font-size: .7rem; font-weight: 700; padding: .1rem .55rem; border-radius: 99px; }
.prod .bd { padding: .8rem .9rem; flex: 1; display: flex; flex-direction: column; gap: .15rem; }
.prod .nm { font-weight: 700; color: var(--dark); line-height: 1.3; }
.prod .cat { font-size: .76rem; color: var(--gold-deep); text-transform: uppercase; letter-spacing: .05em; }
.prod .pr { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; color: var(--primary-deep); }
.prod .pr small { font-size: .75rem; color: var(--muted); font-weight: 500; font-family: var(--font-body); }
.prod .meta { font-size: .78rem; color: var(--muted); }
.prod .ft { padding: 0 .9rem .9rem; }
.stock-ok { color: var(--ok); font-weight: 600; } .stock-low { color: var(--warn); font-weight: 600; } .stock-out { color: var(--bad); font-weight: 700; }
.qty { display: inline-flex; align-items: stretch; border: 1px solid var(--gold); border-radius: 10px; overflow: hidden; background: #fff; }
.qty button { width: 34px; border: 0; background: var(--beige); font-weight: 700; color: var(--dark); } .qty button:hover { background: var(--gold-light); }
.qty input { width: 58px; text-align: center; border: 0; border-inline: 1px solid var(--line); padding: .3rem 0; font-weight: 600; -moz-appearance: textfield; }
.qty input::-webkit-inner-spin-button { display: none; }
.cart-line { display: grid; grid-template-columns: 64px 1fr auto; gap: .8rem; padding: .85rem 0; border-bottom: 1px solid var(--line); align-items: center; }
.cart-line .thumb { width: 64px; height: 64px; border-radius: 10px; background: var(--beige) center/cover; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.sum-row { display: flex; justify-content: space-between; padding: .3rem 0; }
.sum-row.total { border-top: 2px solid var(--gold); margin-top: .4rem; padding-top: .6rem; font-size: 1.15rem; font-weight: 700; color: var(--primary-deep); }
.addr-card { border: 2px solid var(--line); border-radius: 12px; padding: .8rem .95rem; cursor: pointer; background: #fff; display: block; position: relative; }
.addr-card:has(input:checked) { border-color: var(--secondary); background: #f1fafb; }
.addr-card input { position: absolute; right: .8rem; top: .8rem; }
.alert-soft { border-radius: 10px; padding: .7rem 1rem; font-size: .9rem; border: 1px solid; margin-bottom: .8rem; }
.alert-soft.warn { background: #fff6e3; border-color: #f0d08a; color: #6f4400; } .alert-soft.bad { background: #fdecec; border-color: #efb3b4; color: #8a1215; } .alert-soft.ok { background: #e7f6ec; border-color: #b4dcbf; color: #1a5f31; } .alert-soft.info { background: #e6f4f6; border-color: #b5d9de; color: #00494f; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: .25rem .8rem; font-size: .9rem; } .kv dt { color: var(--muted); font-weight: 600; } .kv dd { margin: 0; word-break: break-word; }
@media (max-width: 575.98px) { .kv { grid-template-columns: 110px 1fr; } .cart-line { grid-template-columns: 52px 1fr; } .cart-line > :last-child { grid-column: 1 / -1; justify-self: end; } }

/* ---------- toasts, spinner ---------- */
#toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 4000; display: flex; flex-direction: column; gap: .5rem; max-width: min(92vw, 380px); }
.toastx { background: var(--dark); color: #fff; border-left: 5px solid var(--gold); border-radius: 10px; padding: .7rem 1rem; box-shadow: 0 14px 30px -10px rgba(0, 0, 0, .5); animation: tin .3s ease; }
.toastx.ok { border-color: #3fbf6b; } .toastx.err { border-color: #ff6b6b; } @keyframes tin { from { transform: translateY(14px); opacity: 0; } }
.spin { display: inline-block; width: 1.1rem; height: 1.1rem; border: 3px solid rgba(138, 93, 20, .25); border-top-color: var(--primary); border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -3px; } @keyframes sp { to { transform: rotate(360deg); } }
.loading { text-align: center; padding: 3rem; color: var(--muted); }
.lang-switch { border: 1px solid var(--gold); border-radius: 99px; background: #fff; font-size: .8rem; padding: .15rem .7rem; font-weight: 700; color: var(--gold-deep); }

/* ---------- auth pages ---------- */
body.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; font-family: var(--font-body); color: var(--ink); background: radial-gradient(circle at 15% 10%, rgba(0, 79, 86, .35), transparent 40%), radial-gradient(circle at 90% 90%, rgba(184, 28, 31, .35), transparent 45%), linear-gradient(160deg, #3d130e, var(--dark) 55%, var(--dark-deep)); }
.auth-card { width: 100%; max-width: 460px; background: var(--ivory); border-radius: 22px; box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .7); border: 1px solid rgba(243, 220, 143, .4); overflow: hidden; }
.auth-card.wide { max-width: 860px; }
.auth-card .head { text-align: center; padding: 1.4rem 1.5rem 1rem; background: linear-gradient(180deg, #fff, var(--cream)); border-bottom: 1px solid var(--line); }
.auth-card .head img { width: 82px; margin: 0 auto .4rem; }
.auth-card .head h1 { font-size: 1.12rem; margin: 0; color: var(--primary-deep); }
.auth-card .head p { margin: .2rem 0 0; color: var(--muted); font-size: .9rem; }
.auth-card .body { padding: 1.4rem 1.6rem 1.6rem; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; font-size: .88rem; margin-top: 1rem; }

@media print { .sidebar, .topbar, #toasts, .no-print { display: none !important; } .content { padding: 0; } .cardx { box-shadow: none; } }
