/* ===== Base tokens (a business theme.css overrides --brand*) ===== */
:root {
  --brand: #1976d2;
  --brand-dark: #135ba8;
  --brand-mid: #b5d3f0;
  --brand-soft: #e8f1fb;
  --on-brand: #ffffff;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --text: #18202c;
  --muted: #667085;
  --border: #e1e6ee;
  --danger: #c62828;
  --danger-soft: #fdecec;
  --success: #1f7a3d;
  --success-soft: #e8f6ed;
  --whatsapp: #1fa855;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .06);
  --font: "Inter", "Noto Sans Gujarati", system-ui, -apple-system, "Segoe UI", Roboto, "Nirmala UI", sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 16px/1.5 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
img { max-width: 100%; }
a { color: var(--brand-dark); }
.is-hidden { display: none !important; }
.muted { color: var(--muted); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ===== Buttons & inputs ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: 0 1.1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: 600 .95rem/1 var(--font); cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #f7f9fc; border-color: #cfd6e2; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .qty-btn:focus-visible, .tab:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid var(--brand-mid); outline-offset: 1px;
}
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-primary[aria-disabled="true"] { opacity: .55; }
.btn-whatsapp { background: var(--whatsapp); border-color: var(--whatsapp); color: #fff; }
.btn-whatsapp:hover { background: #178f48; border-color: #178f48; }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #a61f1f; border-color: #a61f1f; }
.btn-sm { min-height: 36px; padding: 0 .8rem; font-size: .85rem; }
.btn-link { background: none; border: 0; padding: .25rem 0; color: var(--brand-dark); font: 600 .9rem var(--font); cursor: pointer; }

input[type="text"], input[type="tel"], input[type="date"], input[type="time"], input[type="search"],
input[type="email"], input[type="url"], input[type="number"], input[type="password"], select, textarea {
  width: 100%; min-height: 44px; padding: .55rem .75rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: #fff; color: var(--text); font: 16px/1.4 var(--font);
}
textarea { resize: vertical; min-height: 74px; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field > span { font-size: .82rem; font-weight: 600; color: var(--muted); }
.field-wide { grid-column: 1 / -1; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: .85rem; padding: .25rem 0 .5rem; }
@media (min-width: 600px) { .form-grid { grid-template-columns: 1fr 1fr; } }

.alert { padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-weight: 500; }
.alert-error { background: var(--danger-soft); color: #8e1b1b; border: 1px solid #f3c1c1; }
.alert-success { background: var(--success-soft); color: #14532d; border: 1px solid #b7e1c4; }
.alert-info { background: var(--brand-soft); color: #123a63; border: 1px solid var(--brand-mid); }

/* ===== Public order page ===== */
.topbar {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: var(--on-brand);
  padding: calc(env(safe-area-inset-top, 0px) + .9rem) 1rem .9rem; box-shadow: var(--shadow);
}
.topbar-inner { max-width: 860px; margin: 0 auto; display: flex; align-items: center; gap: .85rem; }
.brand-logo { height: 48px; width: auto; max-width: 120px; object-fit: contain; background: #fff; border-radius: 10px; padding: 4px; }
.brand-badge {
  width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center;
  background: rgba(255,255,255,.2); font-weight: 700; font-size: 1.25rem;
}
.brand-text h1 { font-size: 1.2rem; line-height: 1.25; }
.brand-text span { font-size: .85rem; opacity: .9; }

.wrap { max-width: 860px; margin: 0 auto; padding: 1rem 1rem 7.5rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }
.card-title { font-size: 1.05rem; font-weight: 700; }
details.card > summary { cursor: pointer; list-style: none; display: flex; flex-direction: column; gap: .1rem; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary small { color: var(--muted); }
details.card[open] > summary { margin-bottom: .75rem; }

.items-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.search-row { margin-bottom: .6rem; }
.tabs {
  display: flex; gap: .45rem; overflow-x: auto; padding: .2rem 0 .7rem; margin: 0 -.25rem;
  scrollbar-width: thin; position: sticky; top: 0; background: var(--surface); z-index: 5;
}
.tab {
  flex: 0 0 auto; border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 999px; padding: .5rem .95rem; font: 600 .9rem var(--font); cursor: pointer; min-height: 40px;
}
.tab.is-active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.tab .dot {
  display: inline-block; min-width: 1.35rem; padding: 0 .3rem; margin-left: .35rem; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-dark); font-size: .75rem; line-height: 1.35rem; text-align: center;
}
.tab.is-active .dot { background: rgba(255,255,255,.25); color: inherit; }

.group-title { margin: 1rem 0 .4rem; font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--brand-dark); }
.sub-title { margin: .9rem 0 .3rem; padding: .35rem .7rem; background: var(--brand-soft); color: var(--brand-dark); border-radius: 8px; font-weight: 700; font-size: .9rem; }

.item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem .75rem; align-items: center;
  padding: .75rem .25rem; border-bottom: 1px solid var(--border);
}
.item:last-child { border-bottom: 0; }
.item.has-qty { background: linear-gradient(90deg, var(--brand-soft), transparent 70%); border-radius: 10px; padding-left: .6rem; }
.i-main { min-width: 0; }
.i-title { font-weight: 600; overflow-wrap: break-word; word-break: normal; }
.i-sub { font-size: .85rem; color: var(--muted); overflow-wrap: break-word; }
.i-price { font-size: .85rem; color: var(--brand-dark); font-weight: 600; }
.i-line { font-size: .85rem; font-weight: 700; color: var(--text); text-align: right; min-height: 1.2em; }

.stepper { display: inline-flex; align-items: center; gap: .3rem; }
.qty-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border); background: #fff;
  font: 700 1.3rem/1 var(--font); color: var(--brand-dark); cursor: pointer; display: grid; place-items: center; padding: 0;
}
.qty-btn:active { background: var(--brand-soft); }
.qty-input { width: 72px; text-align: center; font-weight: 700; padding: .5rem .25rem; }
.unit-label { font-size: .8rem; color: var(--muted); min-width: 2.2rem; white-space: nowrap; }

/* Phones: name on its own line, stepper full width underneath (no cramped columns) */
@media (max-width: 560px) {
  .item { grid-template-columns: minmax(0, 1fr); gap: .55rem; padding: .85rem .35rem; }
  .item.has-qty { padding-left: .6rem; }
  .stepper { width: 100%; }
  .qty-input { flex: 1 1 auto; width: auto; min-width: 0; font-size: 1.05rem; }
  .unit-label { min-width: 3.2rem; text-align: left; }
  .card { padding: .9rem; }
}

.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1rem calc(env(safe-area-inset-bottom, 0px) + .75rem); background: #fff; border-top: 1px solid var(--border);
  box-shadow: 0 -6px 18px rgba(16,24,40,.08);
}
.bar-summary { display: flex; flex-wrap: wrap; gap: .25rem .5rem; align-items: baseline; max-width: 860px; }
.bar-summary strong { font-size: 1.15rem; }
.bar-total { font-weight: 700; color: var(--brand-dark); }
.bottom-bar .btn { min-width: 150px; }

.center-page { display: grid; place-items: center; min-height: 100vh; }
.empty-state { text-align: center; padding: 2rem; }
.empty-code { font-size: 3.5rem; font-weight: 800; color: var(--brand); }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 5.5rem); z-index: 50;
  background: #111827; color: #fff; padding: .7rem 1.1rem; border-radius: 999px; max-width: 92vw; font-size: .92rem; box-shadow: var(--shadow);
}

.hint { font-size: .8rem; color: var(--muted); }

/* ===== "Send to" popup ===== */
body.modal-open { overflow: hidden; }
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(17, 24, 39, .55); }
.modal-card {
  position: relative; background: #fff; width: 100%; max-width: 480px; max-height: 92vh; overflow: auto;
  border-radius: 20px 20px 0 0; padding: 1.1rem 1.1rem calc(env(safe-area-inset-bottom, 0px) + 1rem);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .25);
}
@media (min-width: 560px) { .modal { align-items: center; } .modal-card { border-radius: 20px; } }
.modal-card h2 { font-size: 1.15rem; margin-bottom: .8rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.chips:empty { display: none; }
.chip {
  border: 1px solid var(--brand-mid); background: var(--brand-soft); color: var(--brand-dark); border-radius: 999px;
  padding: .45rem .9rem; font: 600 .88rem var(--font); cursor: pointer; min-height: 38px;
}
.saved-wrap { margin: .4rem 0 .6rem; }
.saved-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .3rem; }
.saved { display: flex; flex-direction: column; gap: .3rem; max-height: 150px; overflow: auto; }
.saved-row { display: flex; gap: .3rem; }
.saved-pick { flex: 1; text-align: left; border: 1px solid var(--border); background: #fff; border-radius: 10px; padding: .5rem .7rem; font: 500 .9rem var(--font); cursor: pointer; min-height: 40px; }
.saved-del { width: 40px; border: 1px solid var(--border); background: #fff; border-radius: 10px; color: var(--danger); cursor: pointer; }
.check { display: flex; align-items: center; gap: .55rem; min-height: 44px; font-weight: 500; }
.check input { width: 20px; height: 20px; flex: 0 0 auto; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .6rem; }
.modal-actions .btn { flex: 1; }
