/* Home Grown — shop + admin styles. Mobile first; one stylesheet, no build step. */

:root {
  --ground: #F3F5F1;
  --surface: #FFFFFF;
  --ink: #15241C;
  --ink-soft: #3D4B43;
  --muted: #56645B;
  --line: #DCE2DA;
  --field: #C9D2C8;
  --primary: #1E5A41;
  --primary-dark: #15402E;
  --primary-soft: #E3EEE7;
  --bar-soft: #A9CDB8;
  --accent: #F0B429;
  --bad: #A8321C;
  --bad-soft: #FBE9E4;
  --warn: #6B4A00;
  --warn-soft: #FDF1D3;
  --info: #1D3F73;
  --info-soft: #E1EAF7;
  --segment: #E4E9E3;
  --radius: 16px;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --nav-h: 68px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 16px/1.5 var(--body); }
img { max-width: 100%; display: block; }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font: 700 26px/1.15 var(--display); letter-spacing: -0.3px; }
h2 { font: 600 19px/1.25 var(--display); }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 18px; height: 18px; }

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.page { padding-top: 16px; padding-bottom: calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 700; }
.price { font-weight: 700; color: var(--primary); }
.center { text-align: center; }
.mt { margin-top: 16px; }
.two-col { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .page { padding-bottom: 48px; }
  .two-col { grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); align-items: start; }
}

/* ---------- Top bar & navigation ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(243, 245, 241, 0.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; gap: 16px; min-height: 64px; padding-top: env(safe-area-inset-top); }
.brand { font: 700 22px var(--display); color: var(--primary); text-decoration: none; letter-spacing: -0.3px; display: flex; align-items: center; gap: 8px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.topnav { display: none; gap: 4px; margin-left: auto; }
.topnav a { padding: 10px 14px; border-radius: 12px; color: var(--ink-soft); text-decoration: none; font-weight: 500; }
.topnav a:hover { background: var(--surface); color: var(--ink); }
.topnav a[aria-current="page"] { color: var(--primary); font-weight: 700; background: var(--primary-soft); }
.iconbtn { position: relative; width: 44px; height: 44px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; color: var(--ink); text-decoration: none; cursor: pointer; flex: none; }
.topbar .iconbtn { margin-left: auto; }
.badge { position: absolute; top: -3px; right: -3px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: var(--ink); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.bottomnav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); }
.bottomnav a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--muted); text-decoration: none; }
.bottomnav a[aria-current="page"] { color: var(--primary); font-weight: 700; }
.bottomnav .badge { top: 6px; right: calc(50% - 22px); }
@media (min-width: 900px) {
  .topnav { display: flex; }
  .topbar .iconbtn { margin-left: 0; }
  .bottomnav { display: none; }
}

/* ---------- Surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel-tight { padding: 12px; }
.panel h2 + * { margin-top: 12px; }
.divider { height: 1px; background: var(--line); border: 0; margin: 8px 0; }
.section-label { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 8px; }
.sum-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; }
.sum-row span:first-child { color: var(--muted); }
.sum-row.total { font-size: 18px; font-weight: 700; }
.sum-row.total span:first-child { color: var(--ink); }

/* ---------- Alerts ---------- */
.alert { padding: 12px 14px; border-radius: 14px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.alert-ok { background: var(--primary-soft); border-color: #C3DDCD; color: var(--primary-dark); }
.alert-err { background: var(--bad-soft); border-color: #F1C6BA; color: #7A2615; }
.alert-warn { background: var(--warn-soft); border-color: #F1D9A0; color: var(--warn); }

/* ---------- Pills ---------- */
.pill { display: inline-block; padding: 3px 9px; border-radius: 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill-ok { background: var(--primary-soft); color: var(--primary); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-muted { background: var(--segment); color: var(--ink-soft); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 14px; border: 1px solid transparent; font: 700 15px var(--body); text-decoration: none; cursor: pointer; transition: background 0.15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-outline { background: var(--surface); color: var(--primary); border-color: var(--line); }
.btn-outline:hover { border-color: var(--primary); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-danger { background: transparent; color: var(--bad); border-color: transparent; }
.btn-danger:hover { background: var(--bad-soft); color: var(--bad); }
.btn-block { display: flex; width: 100%; }
.btn-lg { min-height: 54px; font-size: 16px; border-radius: 16px; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; text-decoration: underline; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 14px; font-weight: 700; color: var(--ink-soft); }
.input, .field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 12px 14px; border: 1px solid var(--field); border-radius: 12px; background: var(--surface); color: var(--ink); font: 16px var(--body);
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field .hint { font-size: 13px; color: var(--muted); }
.field .error, .error { font-size: 13px; color: var(--bad); font-weight: 500; }
.field.has-error input, .field.has-error textarea, .field.has-error select { border-color: var(--bad); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 84px !important; }
.password-wrap button { position: absolute; right: 6px; top: 6px; height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: var(--ground); color: var(--primary); font: 700 13px var(--body); cursor: pointer; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--primary); }

.search { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; color: var(--muted); }
.search input { flex: 1; border: 0; outline: none; background: transparent; font: 16px var(--body); color: var(--ink); min-width: 0; }
.search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* Choice cards (payment method) */
.choice { display: flex; align-items: center; gap: 12px; padding: 13px 15px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.choice:has(input:checked) { border: 2px solid var(--primary); padding: 12px 14px; }
.choice input { width: 20px; height: 20px; margin: 0; accent-color: var(--primary); }
.method-badge { width: 40px; height: 40px; border-radius: 10px; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none; }

/* Chips & segmented filters */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-size: 14px; }
.chip[aria-current="true"] { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.segment { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--segment); border-radius: 14px; }
.segment a { display: flex; align-items: center; justify-content: center; min-height: 40px; border-radius: 10px; color: var(--ink-soft); text-decoration: none; font-size: 14px; }
.segment a[aria-current="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgba(21, 36, 28, 0.12); }

/* Quantity stepper */
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper button, .stepper .step { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--ground); color: var(--ink); font: 400 20px var(--body); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.stepper button:disabled { opacity: 0.4; cursor: not-allowed; }
.stepper input, .stepper output { width: 52px; min-height: 44px; text-align: center; font-size: 17px; font-weight: 700; border: 0; background: transparent; color: var(--ink); -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-sm button { width: 36px; height: 36px; font-size: 18px; border-radius: 10px; }
.stepper-sm output { width: 30px; min-height: 36px; font-size: 15px; }

/* ---------- Products ---------- */
.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 960px) { .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }
.pcard { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--ink); transition: transform 0.15s, box-shadow 0.15s; }
.pcard:hover { color: var(--ink); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(21, 36, 28, 0.08); }
.pcard-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.pcard-name { font-size: 14px; font-weight: 700; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pimg { position: relative; aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; color: var(--primary); overflow: hidden; }
.pimg img { width: 100%; height: 100%; object-fit: cover; }
.pimg .pill { position: absolute; left: 8px; top: 8px; }
.thumb { width: 64px; height: 64px; border-radius: 12px; flex: none; }
.thumb-sm { width: 48px; height: 48px; border-radius: 10px; }
.product-hero { border-radius: var(--radius); }
@media (min-width: 900px) {
  .product-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
  .product-hero { aspect-ratio: 1 / 1; }
}
.stock-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--primary); }
.stock-dot::before { content: ''; width: 8px; height: 8px; border-radius: 4px; background: #2E8B57; }
.stock-dot.out { color: var(--bad); }
.stock-dot.out::before { background: var(--bad); }

/* Sticky action bar (product, cart, checkout) on phones */
.actionbar { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 10; margin: 0 -16px; padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--line); }
@media (min-width: 900px) { .actionbar { position: static; margin: 0; padding: 0; border: 0; background: none; } }

/* Lists of lines (cart, orders) */
.line { display: flex; gap: 12px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); }
a.line:hover { border-color: var(--primary); color: var(--ink); }

/* Order timeline */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.timeline li { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.timeline li::before { content: ''; width: 12px; height: 12px; border-radius: 6px; border: 2px solid #A9B4AC; }
.timeline li.done { color: var(--ink); font-weight: 700; }
.timeline li.done::before { background: var(--primary); border-color: var(--primary); }

.status-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0 4px; }
.status-icon { width: 88px; height: 88px; border-radius: 44px; display: flex; align-items: center; justify-content: center; }
.status-icon .i { width: 44px; height: 44px; stroke-width: 2.2; }
.status-icon.ok { background: var(--primary-soft); color: var(--primary); }
.status-icon.wait { background: var(--warn-soft); color: var(--warn); }
.status-icon.bad { background: var(--bad-soft); color: var(--bad); }

.empty { text-align: center; padding: 48px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-icon { width: 72px; height: 72px; border-radius: 36px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.empty-icon .i { width: 34px; height: 34px; }

.install-card { display: flex; align-items: center; gap: 12px; }
.install-card img { width: 44px; height: 44px; border-radius: 12px; }

/* ---------- Admin ---------- */
.admin-head { background: var(--primary); color: #fff; padding-top: env(safe-area-inset-top); }
.admin-head .topbar-in { min-height: 60px; }
.admin-head .brand { color: #fff; font-size: 19px; }
.admin-head .brand small { font: 500 13px var(--body); color: #CFE3D7; }
.admin-head a.headlink { color: #fff; text-decoration: none; font-size: 14px; font-weight: 500; padding: 8px 12px; border-radius: 10px; }
.admin-head a.headlink:hover { background: #2B6E52; }
.admin-shell { display: block; }
.sidenav { display: none; }
@media (min-width: 900px) {
  .admin-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; }
  .sidenav { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 16px; align-self: start; padding-top: 16px; }
  .sidenav a { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px; color: var(--ink-soft); text-decoration: none; font-weight: 500; }
  .sidenav a:hover { background: var(--surface); color: var(--ink); }
  .sidenav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
}
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); }
.kpi .value { font: 700 24px var(--display); }
.kpi.alarm { background: var(--bad-soft); border-color: #F1C6BA; }
.kpi.alarm .value, .kpi.alarm .tiny { color: var(--bad); }
a.kpi:hover { color: var(--ink); border-color: var(--bad); }
.up { color: var(--primary); font-weight: 700; }
.down { color: var(--bad); font-weight: 700; }

/* Bar chart (server-drawn) */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 150px; }
.bar { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; }
.bar .fill { width: 100%; border-radius: 6px 6px 2px 2px; background: var(--bar-soft); min-height: 2px; }
.bar:last-child .fill { background: var(--primary); }
.bar .val { font-size: 10px; color: var(--muted); white-space: nowrap; }
.bar .lbl { font-size: 11px; color: var(--muted); white-space: nowrap; }
.meter { height: 8px; border-radius: 4px; background: var(--segment); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--primary); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); padding: 0 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 8px; border-bottom: 1px solid #EEF1EC; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table a.rowlink { color: var(--ink); text-decoration: none; font-weight: 700; }

.pagination { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.photo-pick { display: flex; align-items: center; gap: 14px; }
.photo-pick .thumb { width: 84px; height: 84px; }

/* Fixes from the visual check */
.stepper output { display: inline-flex; align-items: center; justify-content: center; }
.admin-head .brand { flex: 1; min-width: 0; font-size: 17px; }
.admin-head .brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-head .headlink { white-space: nowrap; }
@media (min-width: 900px) { .admin-head .brand { font-size: 19px; } }
