/* ==========================================================================
   App styles — hand written, mobile-first, no framework, no CDN.
   ========================================================================== */

@font-face {
  font-family: "Hind Siliguri";
  src: local("Hind Siliguri"), url("../fonts/HindSiliguri-Regular.ttf") format("truetype");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Hind Siliguri";
  src: local("Hind Siliguri SemiBold"), url("../fonts/HindSiliguri-SemiBold.ttf") format("truetype");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Hind Siliguri";
  src: local("Hind Siliguri Bold"), url("../fonts/HindSiliguri-Bold.ttf") format("truetype");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-soft: #ccfbf1;
  --accent: #f59e0b;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warn-soft: #fef3c7;
  --info-soft: #e0f2fe;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  --font: "Hind Siliguri", "Noto Sans Bengali", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.6;
  color: var(--text); background: var(--bg);
}
img { max-width: 100%; height: auto; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; margin-top: 1.25em; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75em; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; background: #f3f4f6; padding: 1px 6px; border-radius: 4px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.center { text-align: center; }
.right { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hide-sm { display: none; }
@media (min-width: 640px) { .hide-sm { display: inline; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 18px; border: 1px solid var(--brand); border-radius: 10px;
  background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: background .15s;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-ghost:hover { background: var(--brand-soft); }
.btn-sm { min-height: 36px; padding: 4px 12px; font-size: .9rem; }
.btn-lg { min-height: 52px; padding: 10px 26px; font-size: 1.1rem; }
.btn-block { width: 100%; }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }

/* ---------- Cards / alerts ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.center-card { text-align: center; }
.big-icon { font-size: 3rem; line-height: 1; margin-bottom: 8px; }
.alert { padding: 12px 14px; border-radius: 10px; margin: 0 0 16px; }
.alert-success { background: var(--success-soft); color: #14532d; }
.alert-error { background: var(--danger-soft); color: #7f1d1d; }
.alert-info { background: var(--info-soft); color: #0c4a6e; }
.pill { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: #f3f4f6; }
.pill-pending { background: var(--warn-soft); color: #92400e; }
.pill-approved { background: var(--success-soft); color: #14532d; }
.pill-rejected { background: var(--danger-soft); color: #7f1d1d; }
.badge { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: .75rem; background: var(--accent); color: #fff; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label, .field .label { display: block; font-weight: 600; margin-bottom: 4px; }
.req { color: var(--danger); }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number],
input[type=url], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; font: inherit; color: inherit;
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.has-error input, .has-error textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: .875rem; margin: 4px 0 0; }
.hint { color: var(--muted); font-size: .85rem; margin: 4px 0 0; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 70px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--brand); font: inherit; font-size: .85rem; cursor: pointer; padding: 6px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 400; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 16px; align-items: center; }
.actions.center { justify-content: center; }
.radio-row { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-pill { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-weight: 600; }
.radio-pill:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.radio-pill input { accent-color: var(--brand); }
.logo-preview { display: block; border-radius: 8px; margin-bottom: 8px; object-fit: cover; }
.checklist { list-style: none; padding: 0; margin: 0 0 12px; }
.checklist .ok { color: var(--success); }
.checklist .bad { color: var(--danger); font-weight: 600; }

/* ---------- Public site ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.site-header .container { min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.site-nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.site-nav a:not(.btn) { color: var(--text); }
.site-nav a[href^="/#"] { display: none; }
@media (min-width: 640px) { .site-nav a[href^="/#"] { display: inline; } }
.site-footer { padding: 24px 0; border-top: 1px solid var(--border); margin-top: 40px; font-size: .9rem; }
.public main > .alert { max-width: 1100px; margin: 16px auto; }

.hero { background: linear-gradient(135deg, var(--brand) 0%, #134e4a 100%); color: #fff; padding: 48px 0; }
.hero-inner { display: grid; gap: 32px; align-items: center; }
.hero h1 { font-size: 2rem; }
.hero .lead { font-size: 1.15rem; opacity: .92; }
.hero .btn { background: #fff; color: var(--brand); border-color: #fff; }
.hero .btn-ghost { background: transparent; color: #fff; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }
.mock-receipt { background: #fff; color: var(--text); border-radius: 12px; padding: 18px; max-width: 300px; margin: 0 auto; box-shadow: 0 20px 40px rgba(0,0,0,.25); font-size: .95rem; }
.mock-receipt p { display: flex; justify-content: space-between; margin: 0 0 6px; }
.mock-title { font-weight: 700; justify-content: center !important; border-bottom: 1px dashed var(--border); padding-bottom: 8px; }
.mock-total { border-top: 1px dashed var(--border); padding-top: 8px; font-weight: 700; }
@media (min-width: 800px) { .hero-inner { grid-template-columns: 1.3fr 1fr; } .hero h1 { font-size: 2.6rem; } }

.section { padding: 40px 16px 0; }
.feature-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.feature { background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.steps-3 { list-style: none; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.steps-3 li { background: var(--surface); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); }

/* ---------- Auth ---------- */
.auth-shell { max-width: 440px; margin: 0 auto; padding: 32px 16px; }
.auth-shell.wide { max-width: 560px; }
.brand-center { display: flex; justify-content: center; margin-bottom: 18px; font-size: 1.3rem; }
.auth-card h1 { font-size: 1.4rem; }

/* ---------- Wizard ---------- */
.wizard { padding-top: 20px; padding-bottom: 40px; max-width: 900px; }
.stepper { display: flex; list-style: none; padding: 0; margin: 0 0 18px; gap: 4px; counter-reset: s; }
.stepper li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .8rem; color: var(--muted); position: relative; }
.stepper li::before { content: ""; position: absolute; top: 15px; left: -50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.stepper li:first-child::before { display: none; }
.stepper .dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: #fff; border: 2px solid var(--border); font-weight: 700; z-index: 1; }
.stepper li.done .dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.stepper li.done::before, .stepper li.current::before { background: var(--brand); }
.stepper li.current .dot { border-color: var(--brand); color: var(--brand); }
.stepper li.current { color: var(--text); font-weight: 600; }

.type-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .type-grid { grid-template-columns: repeat(4, 1fr); } }
.type-card { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 18px 10px; border: 2px solid var(--border); border-radius: 14px; background: #fff; cursor: pointer; transition: border-color .15s, background .15s; }
.type-card input { position: absolute; top: 10px; right: 10px; width: 20px; height: 20px; accent-color: var(--brand); }
.type-card:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.type-card.static { cursor: default; }
.type-icon { font-size: 2.6rem; line-height: 1.1; }
.type-name { font-weight: 700; }
.type-desc { font-size: .8rem; color: var(--muted); }

.menu-toolbar { position: sticky; top: 60px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--surface); padding: 10px 0; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.menu-count { margin-left: auto; font-size: .9rem; color: var(--muted); }
.tpl { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; overflow: hidden; }
.tpl > summary { cursor: pointer; padding: 12px 14px; font-weight: 700; background: #f9fafb; list-style: none; }
.tpl > summary::-webkit-details-marker { display: none; }
.tpl > summary::after { content: "▾"; float: right; color: var(--muted); }
.tpl:not([open]) > summary::after { content: "▸"; }
.tpl-cat { border: 0; border-top: 1px solid var(--border); margin: 0; padding: 8px 14px 4px; }
.tpl-cat legend { font-weight: 700; padding: 6px 0 2px; float: left; width: 100%; }
.tpl-item { clear: both; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.tpl-item:last-child { border-bottom: 0; }
.tpl-item.off { opacity: .45; }
.tpl-name { flex: 1 1 180px; }
.tpl-variants { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; padding-left: 28px; }
.variant { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; background: #f9fafb; padding: 2px 8px; border-radius: 8px; }
.money-input { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); }
.money-input input { width: 84px; min-height: 36px; padding: 4px 8px; text-align: right; }
.tpl-addons { width: 100%; padding-left: 28px; margin: 0; }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); padding: 12px 0; border-top: 1px solid var(--border); }

.cycle-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 4px; margin-bottom: 16px; gap: 4px; flex-wrap: wrap; }
.cycle-toggle label { padding: 6px 16px; border-radius: 999px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.cycle-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.cycle-toggle label:has(input:checked) { background: var(--brand); color: #fff; }
.plan-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.plan-card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 20px; border: 2px solid var(--border); border-radius: 14px; background: #fff; cursor: pointer; }
.plan-card input { position: absolute; top: 14px; right: 14px; width: 22px; height: 22px; accent-color: var(--brand); }
.plan-card:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.plan-card.static { cursor: default; }
.plan-name { font-weight: 700; font-size: 1.2rem; }
.plan-price strong { font-size: 1.8rem; color: var(--brand); }
.plan-features { padding-left: 18px; margin: 6px 0 12px; color: var(--muted); }

/* ---------- Billing ---------- */
.summary-box { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; background: #f9fafb; border-radius: 10px; padding: 14px; }
.summary-box div { display: flex; flex-direction: column; }
.summary-box .full { grid-column: 1 / -1; }
.summary-box .amount { font-size: 1.5rem; color: var(--brand); }
.merchant-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 8px; }
.merchant { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); }
.merchant.bkash { border-left: 5px solid #e2136e; }
.merchant.nagad { border-left: 5px solid #f6921e; }
.merchant-name { font-weight: 600; }
.merchant-no { font-size: 1.2rem; letter-spacing: .5px; flex: 1; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: .85rem; color: var(--muted); font-weight: 600; white-space: nowrap; }

/* ---------- App shell ---------- */
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--border); min-height: 56px; }
.app-user { display: flex; align-items: center; gap: 10px; }
.logo-img { border-radius: 6px; object-fit: cover; }
.app-tabs { display: flex; gap: 2px; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 8px; scrollbar-width: none; }
.app-tabs::-webkit-scrollbar { display: none; }
.app-tabs a, .app-tabs .tab-soon { padding: 12px 14px; white-space: nowrap; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 600; }
.app-tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.app-tabs a:hover { text-decoration: none; color: var(--text); }
.app-tabs .tab-soon { opacity: .5; cursor: not-allowed; }
.app-main { padding-top: 16px; padding-bottom: 32px; }
.admin-header { background: #1f2937; color: #fff; }
.admin-header .brand { color: #fff; }
.admin-header .btn-ghost { color: #fff; border-color: #fff; }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 16px; font-weight: 600; }
.banner-expiring { background: var(--warn-soft); color: #92400e; }
.banner-grace, .banner-readonly { background: var(--danger-soft); color: #7f1d1d; }

.grid-3, .grid-4 { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); margin-bottom: 16px; }
@media (min-width: 700px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(4, 1fr); } }
.stat { display: flex; flex-direction: column; gap: 2px; background: var(--surface); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); color: var(--text); }
.stat strong { font-size: 1.5rem; }
.stat-link:hover { text-decoration: none; box-shadow: 0 0 0 2px var(--brand-soft); }
.stat-alert strong { color: var(--danger); }

/* ---------- Admin payments ---------- */
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-row select { width: auto; }
.filter-row input { flex: 1 1 200px; width: auto; }
.pay-list { display: grid; gap: 12px; }
.pay-item { border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: grid; gap: 12px; }
@media (min-width: 900px) { .pay-item { grid-template-columns: 1fr 320px; } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 8px 0 0; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.trx { font-size: 1rem; font-weight: 700; }
.pay-actions { display: grid; gap: 8px; align-content: start; }
.pay-actions form { display: flex; gap: 6px; }
.pay-actions input { min-height: 36px; }

/* ---------- Error ---------- */
.error-page { text-align: center; }
.error-code { font-size: 3rem; font-weight: 700; color: var(--brand); margin: 0; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #111827; color: #fff; padding: 8px 16px; border-radius: 999px; z-index: 100; font-size: .9rem; }
