/* Wine en Route — control panel & farm portal */
:root {
  --bg: #f6f3ef;
  --card: #ffffff;
  --ink: #2b2024;
  --muted: #7c6f73;
  --line: #ece4dc;
  --wine: #7a1f3d;
  --wine-2: #5e1530;
  --wine-soft: #f6e8ed;
  --gold: #b8892b;
  --ok: #2f7a4f;
  --ok-bg: #e8f4ec;
  --warn: #8a6100;
  --warn-bg: #fff4d6;
  --err: #b0302f;
  --err-bg: #fbe9e8;
  --side: 236px;
  --radius: 12px;
  --serif: Fraunces, Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14.5px/1.5 var(--sans); }
a { color: var(--wine); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h1 { font-family: var(--serif); font-weight: 600; font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.02rem; font-weight: 600; }
h3 { font-size: .95rem; font-weight: 600; margin-top: 1.2em; }
code { font-size: .82em; background: #f3eee9; padding: 1px 5px; border-radius: 4px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.nowrap { white-space: nowrap; }
.r { text-align: right; }
.lead { margin: 0 0 18px; max-width: 760px; }
.warn { color: var(--warn); }

/* ---------- shell ---------- */
.side { position: fixed; inset: 0 auto 0 0; width: var(--side); background: #2b2024; color: #e8dfe2; display: flex; flex-direction: column; z-index: 50; transition: transform .2s; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; color: #fff; font-family: var(--serif); font-size: 1.15rem; font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand small { display: block; font: 500 .7rem var(--sans); letter-spacing: .12em; text-transform: uppercase; color: #b9a6ad; margin-top: 2px; }
.brand .mark, .authbrand .mark { color: #e2a3b8; }
.side nav { display: flex; flex-direction: column; padding: 6px 10px; gap: 2px; flex: 1; overflow-y: auto; }
.side nav a { display: flex; align-items: center; gap: 11px; color: #d9cdd1; padding: 9px 10px; border-radius: 8px; font-weight: 500; }
.side nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.side nav a.on { background: rgba(226,163,184,.16); color: #fff; }
.side nav svg { width: 18px; height: 18px; fill: currentColor; opacity: .8; flex-shrink: 0; }
.pill { background: var(--gold); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 7px; margin-left: 4px; font-weight: 600; }
.side-foot { padding: 14px 18px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: .84rem; }
.side-foot a { color: #e2a3b8; }
.side-foot .who { margin-top: 10px; color: #b9a6ad; }

.main { margin-left: var(--side); padding: 0 28px 60px; min-height: 100vh; }
.top { display: flex; align-items: center; gap: 12px; padding: 22px 0 18px; flex-wrap: wrap; }
.top h1 { flex: 1; min-width: 0; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.burger { display: none; font-size: 1.4rem; cursor: pointer; padding: 2px 8px; border-radius: 8px; user-select: none; }
.scrim { display: none; }

@media (max-width: 860px) {
  .side { transform: translateX(-100%); }
  #navtoggle:checked ~ .side { transform: none; }
  #navtoggle:checked ~ .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
  .main { margin-left: 0; padding: 0 14px 50px; }
  .burger { display: inline-block; }
  h1 { font-size: 1.3rem; }
}

/* ---------- cards & grids ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; border: 1px solid var(--line); }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 620px; }
.card.danger { border-color: #f1d0cf; }
.cardhead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.cardhead h2 { margin: 0; }
.cardhead.pad { padding: 16px 20px 6px; margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid2 > .card, .grid3 > .card { margin-bottom: 0; }
.grid2, .grid3 { margin-bottom: 18px; }
.grid2.tight { gap: 10px 14px; margin-bottom: 0; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.farmform > .grid2 > * > .card, .farmform > .grid2 > .card { margin-bottom: 18px; }
.farmform > .grid2 { align-items: start; margin-bottom: 0; }
@media (max-width: 1100px) { .grid3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tl { font-size: .78rem; color: var(--muted); font-weight: 500; }
.tv { font-family: var(--serif); font-size: 1.75rem; font-weight: 600; margin: 2px 0; font-variant-numeric: tabular-nums; }
.ts { font-size: .78rem; color: var(--muted); }
.up { color: var(--ok); font-weight: 600; }
.down { color: var(--err); font-weight: 600; }
.bignum { font-family: var(--serif); font-size: 2rem; font-weight: 600; margin-bottom: 10px; }

.chartbox { position: relative; height: 290px; }
.chartbox.sm { height: 210px; }

.empty { color: var(--muted); padding: 18px 20px; margin: 0; }

/* ---------- tables ---------- */
.tblwrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fbf9f7; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th.r, .tbl td.r { text-align: right; }
.card:not(.flush) .tbl td:first-child, .card:not(.flush) .tbl th:first-child { padding-left: 0; }
.card:not(.flush) .tbl td:last-child, .card:not(.flush) .tbl th:last-child { padding-right: 0; }
.tbl tr.dim td { opacity: .55; }
.thumbcell { width: 56px; }
.thumbcell img, .noimg { width: 48px; height: 36px; object-fit: cover; border-radius: 6px; display: grid; place-items: center; background: var(--wine-soft); color: var(--wine); }
.actions .btn { margin-left: 4px; }

.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #eee8e3; color: #5f5357; white-space: nowrap; }
.b-active { background: var(--ok-bg); color: var(--ok); }
.b-pending, .b-trial { background: var(--warn-bg); color: var(--warn); }
.b-suspended, .b-past_due, .b-cancelled { background: var(--err-bg); color: var(--err); }
.tag { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); margin-left: 6px; }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-weight: 500; font-size: .86rem; margin-bottom: 4px; }
.field small, small.muted { display: block; color: var(--muted); font-size: .8rem; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=url], input[type=number], input[type=date], input[type=search],
input:not([type]), select, textarea {
  width: 100%; font: inherit; padding: 9px 11px; border: 1px solid #ddd2c8; border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--wine); box-shadow: 0 0 0 3px rgba(122,31,61,.12); }
input:disabled { background: #f5f1ed; color: var(--muted); }
textarea { resize: vertical; }
input.num { width: 64px; padding: 4px 6px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-bottom: 14px; }
.checks label, .check { display: flex; gap: 8px; align-items: center; font-size: .92rem; }
.check { margin: 4px 0 10px; align-items: flex-start; }
.check input { margin-top: 3px; }
.stack > * + * { margin-top: 0; }
.stack .btn { margin-top: 4px; }
form.inline { display: inline; }
.savebar { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(180deg, rgba(246,243,239,0), var(--bg) 35%); z-index: 5; }
.adminonly { border-color: #ecdcb8; background: #fffcf4; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 .9rem var(--sans); padding: 8px 14px; border-radius: 8px;
  border: 1px solid #ddd2c8; background: #fff; color: var(--ink); cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { text-decoration: none; border-color: #c9bbaf; }
.btn.primary { background: var(--wine); border-color: var(--wine); color: #fff; }
.btn.primary:hover { background: var(--wine-2); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.ghost.danger { background: transparent; color: var(--err); border-color: transparent; }
.btn.sm { padding: 5px 10px; font-size: .82rem; }
.btn.block { width: 100%; }
.btn.disabled { opacity: .6; pointer-events: none; }

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; background: var(--ok-bg); color: #1f5a37; border: 1px solid #cfe7d7; }
.flash.err { background: var(--err-bg); color: #8a2322; border-color: #f2cfcd; }
.flash.warn { background: var(--warn-bg); color: #6b4c00; border-color: #f1e0ad; }
.flash a { color: inherit; text-decoration: underline; }

/* filters & ranges */
.filterbar, .rangebar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.segs { display: inline-flex; flex-wrap: wrap; background: #ebe4dd; padding: 3px; border-radius: 9px; gap: 2px; }
.seg { padding: 5px 11px; border-radius: 7px; color: var(--muted); font-weight: 500; font-size: .86rem; }
.seg:hover { text-decoration: none; color: var(--ink); }
.seg.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.rangebar .custom { display: flex; align-items: center; gap: 6px; }
.rangebar .custom input { width: auto; padding: 5px 8px; }
.filterbar .search input, .filterbar .search select { min-width: 240px; padding: 7px 10px; }
.filterbar .rangebar { margin: 0; flex: 1; }

/* popover menus */
details.pop { display: inline-block; position: relative; }
details.pop summary { list-style: none; }
details.pop summary::-webkit-details-marker { display: none; }
.popbody { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.12); z-index: 20; min-width: 230px; text-align: left; white-space: normal; display: grid; gap: 8px; }

/* maps */
.pickmap { height: 280px; border-radius: 10px; border: 1px solid var(--line); margin: 6px 0; z-index: 0; }
.geosearch { display: flex; gap: 6px; margin-top: 4px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; }
.dot.red { background: #c0392b; opacity: .7; }

/* images */
.imgrow { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.imgpick { display: grid; gap: 6px; align-content: start; }
.imgpick .lbl { font-weight: 500; font-size: .86rem; }
.imgpick img { width: 100%; max-height: 150px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.imgpick input[type=file], .uploadrow input[type=file] { font-size: .84rem; max-width: 100%; }
.uploadrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.gitem { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fcfaf8; }
.gitem img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.gitem input[type=text] { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.gbar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; flex-wrap: wrap; }
.gbar label { margin-right: auto; display: flex; align-items: center; gap: 4px; }

/* qr */
.qrthumb { width: 64px; height: 64px; }
.qrthumb img, .qrthumb canvas { width: 64px !important; height: 64px !important; }

/* analytics */
.funnel { display: grid; gap: 10px; }
.frow { display: grid; grid-template-columns: 170px 1fr 120px; gap: 12px; align-items: center; }
.fbar, .bb { background: #f1ebe5; border-radius: 6px; height: 22px; overflow: hidden; display: block; }
.fbar span { display: block; height: 100%; background: linear-gradient(90deg, var(--wine), #a6587a); border-radius: 6px; }
.fn { font-variant-numeric: tabular-nums; font-weight: 600; }
.blist { display: grid; gap: 7px; }
.bl { display: grid; grid-template-columns: minmax(80px, 1.2fr) 1fr 44px; gap: 8px; align-items: center; font-size: .88rem; }
.bl > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bb { height: 8px; }
.bb span { display: block; height: 100%; background: var(--gold); border-radius: 6px; }
.bn { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .frow { grid-template-columns: 1fr 70px; } .frow .fbar { grid-column: 1 / -1; grid-row: 2; } }
.tips ul { margin: 0; padding-left: 18px; } .tips li { margin-bottom: 6px; }

/* packages / plan */
.pkgcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin-bottom: 18px; }
.pkgcard { margin: 0; display: flex; flex-direction: column; }
.pkgcard.current { border: 2px solid var(--wine); }
.pkgcard h3 { font-family: var(--serif); font-size: 1.3rem; margin: 6px 0 2px; }
.pkgcard .price { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; }
.pkgcard .price small { font: 400 .85rem var(--sans); color: var(--muted); }
.pkgcard p { flex: 1; }
.feat { padding-left: 18px; margin: 0 0 14px; color: var(--muted); font-size: .9rem; }
.planrow { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.planrow span.muted { display: block; margin-bottom: 2px; }
.planrow strong { font-size: 1.05rem; }
.pkgpick { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 4px 0 12px; }
.pkgpick legend { font-weight: 500; font-size: .86rem; padding: 0 4px; }
.pkgopt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.pkgopt:last-child { border-bottom: 0; }
.pkgopt input { margin-top: 4px; }
.pkgopt small { display: block; color: var(--muted); }

/* ---------- auth pages ---------- */
.authpage { background: linear-gradient(160deg, #2b2024 0%, #4a1a2c 100%); min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; }
.authwrap { width: 100%; max-width: 460px; }
.authbrand { display: block; text-align: center; color: #fff; font-family: var(--serif); font-size: 1.4rem; font-weight: 600; margin-bottom: 18px; }
.authbrand:hover { text-decoration: none; }
.authcard { background: #fff; border-radius: 16px; padding: 26px 26px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.authcard h1 { font-size: 1.5rem; margin-bottom: 14px; }
.authalt { text-align: center; margin: 14px 0 0; }
