/* El Rural Spices - warm spice theme, mobile first */
:root {
  --paprika: #B7312C; --paprika-d: #8E2420; --turmeric: #E3A018; --turmeric-l: #FCEFCF; --brown: #5A3A22; --brown-l: #8A6A52;
  --cream: #FBF5EC; --card: #FFFFFF; --line: #EADFCF; --green: #3E7B3A; --green-l: #E3F1E1; --red-l: #FBE3E1;
  --r: 14px; --shadow: 0 1px 2px rgba(90, 58, 34, .08), 0 4px 14px rgba(90, 58, 34, .06);
  --nav-h: 66px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--brown); background: var(--cream); }
body.noscroll { overflow: hidden; }
a { color: var(--paprika); text-decoration: none; }
h1 { font-size: 1.55rem; margin: .2rem 0 .6rem; color: var(--brown); }
h2 { font-size: 1.08rem; margin: 0; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; color: var(--brown-l); text-transform: uppercase; letter-spacing: .03em; }
[hidden] { display: none !important; }
.boot { display: grid; place-items: center; height: 100vh; font-size: 3rem; }

/* header + nav */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .6rem; padding: .55rem 1rem; padding-top: max(.55rem, env(safe-area-inset-top));
  background: var(--paprika); color: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.brand { display: flex; align-items: baseline; gap: .35rem; color: #fff; font-size: 1.15rem; margin-right: auto; }
.brand span:last-child { color: var(--turmeric); font-weight: 600; }
.logo-s { font-size: 1.2rem; }
.me { font-size: .85rem; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.live { width: 9px; height: 9px; border-radius: 50%; background: #f3b0a8; }
.live.on { background: #8fe08a; box-shadow: 0 0 0 3px rgba(143, 224, 138, .25); }
.chip.lang { background: rgba(255, 255, 255, .18); color: #fff; border-color: transparent; font-weight: 700; }
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; background: #fff; border-top: 1px solid var(--line);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
.nav a { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--brown-l); font-size: .75rem; font-weight: 600; }
.nav a .ic { font-size: 1.4rem; filter: grayscale(.7); opacity: .8; }
.nav a.on, .nav a.on-m { color: var(--paprika); }
.nav a.on .ic, .nav a.on-m .ic { filter: none; opacity: 1; }
.nav a.on::before, .nav a.on-m::before { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; border-radius: 0 0 3px 3px; background: var(--paprika); }
.nb { position: absolute; top: 6px; left: 54%; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--turmeric); color: var(--brown);
  font: 700 .7rem/18px system-ui; text-align: center; font-style: normal; }
.menu .nb { position: static; display: inline-block; margin-left: .3rem; }
.d-only { display: none !important; }
main { overflow-x: hidden; padding: 1rem 1rem calc(var(--nav-h) + 1.5rem + env(safe-area-inset-bottom)); max-width: 1080px; margin: 0 auto; }

/* layout bits */
.page-h { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: .4rem 0 .8rem; flex-wrap: wrap; }
.page-h h1, .page-h h2 { margin: 0; }
.hello h1 { margin-bottom: 0; }
.sub { color: var(--brown-l); margin: .1rem 0 1rem; }
.back { display: inline-block; margin-bottom: .4rem; font-weight: 600; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: 1rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.stat { background: var(--card); border-radius: var(--r); padding: .8rem .9rem; box-shadow: var(--shadow); border-top: 4px solid var(--turmeric); }
.stat .l { font-size: .8rem; color: var(--brown-l); font-weight: 600; }
.stat .v { font-size: 1.45rem; font-weight: 800; color: var(--brown); margin-top: .1rem; }
.stat .s { font-size: .8rem; color: var(--brown-l); }
.stat.warn { border-top-color: var(--paprika); }
.stat.warn .v { color: var(--paprika); }
.card { background: var(--card); border-radius: var(--r); padding: .9rem 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.card.alert { border-left: 5px solid var(--paprika); }
.see { font-size: .9rem; font-weight: 600; white-space: nowrap; }
details.card summary { cursor: pointer; list-style: none; }
details.card summary h2 { display: inline; }
details.card summary::before { content: "▸ "; }
details[open].card summary::before { content: "▾ "; }
.cols { display: grid; gap: 0 1rem; grid-template-columns: minmax(0, 1fr); }
.empty { color: var(--brown-l); margin: .4rem 0 .7rem; }
.meta { font-size: .85rem; color: var(--brown-l); }
.meta span + span::before, .meta a::before { content: ""; }
.meta > * { margin-right: .5rem; }
.notes { background: var(--turmeric-l); border-radius: 10px; padding: .5rem .7rem; margin: .5rem 0; font-size: .92rem; white-space: pre-wrap; }
.center { text-align: center; }
.red { color: var(--paprika); }
.green { color: var(--green); }
.wide { width: 100%; }
.line-i { padding: .2rem 0; }

/* rows */
.row { display: flex; align-items: center; gap: .7rem; padding: .7rem 0; border-bottom: 1px solid var(--line); color: inherit; }
.row:last-child { border-bottom: 0; }
.row.link:active, .tap:active { background: #faf3e8; }
.tap { cursor: pointer; }
.grow { flex: 1; min-width: 0; }
.row b { overflow-wrap: anywhere; }
.right { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; }
.avatar { width: 42px; height: 42px; flex: none; border-radius: 12px; background: var(--turmeric-l); display: grid; place-items: center; font-size: 1.3rem; }
.chev { color: var(--brown-l); font-size: 1.4rem; }
.num { width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--brown); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
.pill { background: var(--turmeric-l); border-radius: 20px; padding: .25rem .6rem; font-weight: 700; font-size: .9rem; }
.progress { height: 6px; background: #f1e7d8; border-radius: 3px; overflow: hidden; margin: .35rem 0 .15rem; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--turmeric), var(--paprika)); border-radius: 3px; }
.stops-mini { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 20px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.badge.red { background: var(--red-l); color: var(--paprika-d); }
.badge.green { background: var(--green-l); color: var(--green); }
.badge.yellow { background: var(--turmeric-l); color: #8a5d00; }
.badge.big { font-size: 1rem; padding: .45rem .9rem; }

/* tasks */
.task .check { width: 34px; height: 34px; flex: none; border-radius: 50%; border: 2.5px solid var(--brown-l); background: #fff; color: #fff; font-weight: 800; font-size: 1.1rem; cursor: pointer; }
.task .check.on { background: var(--green); border-color: var(--green); }
.task.done .title { text-decoration: line-through; opacity: .6; }
.task .title { font-weight: 600; overflow-wrap: anywhere; }
.task .over { color: var(--paprika); font-weight: 700; }
.rep { font-size: .75rem; color: #8a5d00; background: var(--turmeric-l); padding: .05rem .4rem; border-radius: 8px; font-weight: 600; white-space: nowrap; }
.prio { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: .15rem; }
.prio.p1 { background: var(--paprika); } .prio.p2 { background: var(--turmeric); } .prio.p3 { background: #c9bba8; }
.tabs { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .3rem; margin-bottom: .6rem; scrollbar-width: none; }
.tab { flex: none; border: 1.5px solid var(--line); background: #fff; border-radius: 22px; padding: .55rem .9rem; font: 600 .95rem system-ui; color: var(--brown); cursor: pointer; }
.tab span { background: var(--turmeric-l); border-radius: 10px; padding: 0 .4rem; margin-left: .2rem; font-size: .8rem; }
.tab.on { background: var(--brown); color: #fff; border-color: var(--brown); }
.tab.on span { background: rgba(255, 255, 255, .2); }
.tab.red:not(.on) { border-color: var(--paprika); color: var(--paprika); }

/* buttons + inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 46px; padding: .55rem 1rem; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff; color: var(--brown); font: 700 1rem system-ui; cursor: pointer; text-align: center; -webkit-tap-highlight-color: transparent; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--paprika); border-color: var(--paprika); color: #fff; }
.btn.primary:active { background: var(--paprika-d); }
.btn.big { min-height: 56px; font-size: 1.05rem; }
.btn.sm { min-height: 38px; padding: .35rem .7rem; font-size: .9rem; border-radius: 10px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--paprika); border-color: #f0c5c1; background: #fff; margin-top: 1rem; }
.btn.on { background: var(--brown); color: #fff; border-color: var(--brown); }
.btns { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .5rem; margin-top: .8rem; }
.chip { border: 1.5px solid var(--line); background: #fff; color: var(--brown); border-radius: 20px; padding: .4rem .8rem; font: 600 .9rem system-ui; cursor: pointer; }
.chip.on { background: var(--turmeric); border-color: var(--turmeric); }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: .3rem 0 .9rem; }
.seg { display: flex; background: #f1e7d8; border-radius: 12px; padding: 4px; gap: 4px; margin: .5rem 0; }
.seg > * { flex: 1; }
.seg button, .seg label span { display: block; width: 100%; border: 0; background: transparent; padding: .65rem .5rem; border-radius: 9px; font: 700 .95rem system-ui; color: var(--brown); cursor: pointer; text-align: center; }
.seg label input { position: absolute; opacity: 0; pointer-events: none; }
.seg button.on, .seg label input:checked + span { background: #fff; box-shadow: var(--shadow); color: var(--paprika); }
.seg.small { max-width: 260px; }
.seg.small button { padding: .45rem; font-size: .88rem; }
.field { display: block; margin-bottom: .8rem; }
.field > span { display: block; font-size: .85rem; font-weight: 700; color: var(--brown-l); margin-bottom: .25rem; }
input, select, textarea { width: 100%; font: 16px system-ui; color: var(--brown); padding: .7rem .8rem; border: 1.5px solid var(--line); border-radius: 11px; background: #fff; min-height: 48px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--turmeric); box-shadow: 0 0 0 3px rgba(227, 160, 24, .2); }
input[type=file] { min-height: 0; padding: .4rem; border-style: dashed; margin-bottom: .4rem; }
textarea { resize: vertical; }
.search { margin-bottom: .6rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.two:empty { display: none; }

/* inventory */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.pcard { display: flex; gap: .8rem; background: var(--card); border-radius: var(--r); padding: .8rem; box-shadow: var(--shadow); border-left: 5px solid var(--turmeric); }
.pcard.low { border-left-color: var(--paprika); }
.pimg { width: 84px; height: 84px; flex: none; border-radius: 12px; background: var(--turmeric-l); display: grid; place-items: center; overflow: hidden; font-size: 2.2rem; }
.pimg img { width: 100%; height: 100%; object-fit: cover; }
.pbody { flex: 1; min-width: 0; }
.pbody .title { font-weight: 800; }
.stock { margin-top: .25rem; }
.stock b { font-size: 1.3rem; }
.photo-pick { display: flex; gap: .8rem; align-items: center; }

/* routes */
.map { height: 300px; border-radius: var(--r); overflow: hidden; margin: .8rem 0 1rem; box-shadow: var(--shadow); background: #efe6d8; z-index: 0; }
.map.nomap { height: auto; padding: .6rem 1rem; }
.pin span { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--paprika); color: #fff; font-weight: 800; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); }
.pin.st-visited span, .pin.st-sale span { background: var(--green); }
.pin.st-no_sale span { background: #7d6b5d; }
.pin.st-rescheduled span { background: var(--turmeric); color: var(--brown); }
.stop { border-left: 5px solid var(--line); }
.stop.st-sale, .stop.st-visited { border-left-color: var(--green); }
.stop.st-no_sale { border-left-color: #7d6b5d; }
.stop.st-rescheduled { border-left-color: var(--turmeric); }
.stop-h { display: flex; gap: .7rem; align-items: flex-start; }
.stop-h .mini { display: flex; gap: .3rem; }
.st-line { margin-top: .3rem; font-size: .9rem; }
.st-btns { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; margin-top: .7rem; }
.st-btns .btn { min-height: 50px; font-size: .95rem; }
.big-status { font-size: 1.3rem; font-weight: 800; margin: 0 0 .8rem; }
.sel-row .btn { min-width: 40px; }
.add-row { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; font: inherit; color: inherit; cursor: pointer; }
.add-row .plus { width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--turmeric-l); display: grid; place-items: center; font-weight: 800; color: var(--paprika); }

/* recommendations */
.rec { padding: .2rem 0 .6rem; }
.rec + .rec { border-top: 1px dashed var(--line); padding-top: .8rem; }
.rec-h { display: flex; gap: .7rem; align-items: flex-start; }
.rec-ic { font-size: 1.5rem; width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--turmeric-l); }
.why { margin: .15rem 0 .4rem; font-size: .9rem; color: var(--brown-l); }
.rec-i { margin: .45rem 0 0 3.2rem; padding: .55rem .7rem; border-radius: 10px; background: #fcf8f1; }
.rec-i .txt { font-size: .95rem; }
.rec-i .btns { margin-top: .4rem; }
.more-l { display: block; margin: .4rem 0 0 3.2rem; font-weight: 600; font-size: .9rem; }
.rec > .btn.primary { margin: .7rem 0 0 3.2rem; }

/* sale form */
.line { display: grid; grid-template-columns: 1fr 1fr auto; gap: .45rem; padding: .7rem; background: #fcf8f1; border-radius: 12px; margin-bottom: .5rem; }
.line select { grid-column: 1 / -1; }
.line .rm { align-self: end; min-height: 48px; }
.mini-f span { display: block; font-size: .75rem; font-weight: 700; color: var(--brown-l); }
.warn-line { grid-column: 1 / -1; color: var(--paprika); font-size: .85rem; font-weight: 700; }
.warn-line:empty { display: none; }
.total-line { font-size: 1.3rem; text-align: right; margin: .8rem 0 .3rem; }
.tbl { width: 100%; border-collapse: collapse; margin: .5rem 0; }
.tbl td { padding: .45rem .2rem; border-bottom: 1px solid var(--line); }
.tbl .r { text-align: right; white-space: nowrap; }
.tbl .tot td { font-weight: 800; font-size: 1.1rem; border-bottom: 0; }

/* modal + toast */
#modal { position: fixed; inset: 0; z-index: 50; background: rgba(40, 25, 15, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--cream); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 0 1rem calc(1rem + env(safe-area-inset-bottom)); animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
.sheet-h { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: 1rem 0 .6rem; background: var(--cream); }
.sheet-h h2 { font-size: 1.2rem; }
.x { width: 44px; height: 44px; border: 0; border-radius: 50%; background: #efe4d3; font-size: 1.1rem; cursor: pointer; color: var(--brown); flex: none; }
.sheet-f { position: sticky; bottom: calc(-1rem - env(safe-area-inset-bottom)); padding: .8rem 0 1rem; background: var(--cream); margin-top: .5rem; }
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px); z-index: 60; max-width: 90vw;
  background: var(--brown); color: #fff; padding: .75rem 1.1rem; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--paprika); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; background: radial-gradient(circle at 20% 0%, var(--turmeric) 0, transparent 45%), radial-gradient(circle at 100% 100%, var(--paprika) 0, transparent 50%), var(--cream); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 22px; padding: 1.6rem 1.4rem; box-shadow: 0 10px 40px rgba(90, 58, 34, .18); text-align: center; }
.login-card form { text-align: left; margin: 1rem 0; }
.login-card .logo { font-size: 3rem; }
.login-card h1 { margin: .2rem 0; }
.login-card .seg { margin: 0 auto; }
.err { color: var(--paprika); font-weight: 700; min-height: 1.2em; }

.menu { display: grid; gap: .6rem; margin-bottom: 1rem; }
.menu .btn { justify-content: flex-start; }
#nameForm { display: flex; gap: .5rem; align-items: flex-end; }
#nameForm .field { flex: 1; margin: 0; }

/* desktop */
@media (min-width: 900px) {
  .nav { top: 0; bottom: 0; right: auto; width: 210px; height: auto; flex-direction: column; justify-content: flex-start; padding: 70px .6rem 1rem; border-top: 0; border-right: 1px solid var(--line); z-index: 10; }
  .nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: .7rem; padding: .7rem .8rem; border-radius: 10px; font-size: .98rem; }
  .nav a.on { background: var(--turmeric-l); }
  .nav a.on::before, .nav a.on-m::before { display: none; }
  .nav a.on-m:not(.on) { color: var(--brown-l); }
  .nav a.on-m:not(.on) .ic { filter: grayscale(.7); opacity: .8; }
  .nb { position: static; margin-left: auto; }
  .d-only { display: flex !important; }
  .m-more { order: 9; }
  .m-only { display: none; }
  main { margin-left: 210px; padding: 1.4rem 2rem 2rem; max-width: 1180px; }
  .cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  #modal { align-items: center; }
  .sheet { border-radius: 20px; max-height: 88vh; }
  #toast { bottom: 24px; }
  .map { height: 380px; }
  .st-btns { grid-template-columns: repeat(4, 1fr); }
}
