/* Design tokens lifted verbatim from Justin's wholesale portal prototype
   (frutiva-portal.pages.dev) so this interim tool and the real portal read as
   one product. If he changes these, change them here too. */

:root {
  --color-primary: #2d6a4f;
  --frutiva-green: #2d6a4f;
  --dark-green: #0a4635;
  --brand-green: #638a47;
  --brand-2: #3a8163;
  --color-gold: #d4b06a;
  --color-gold-light: #e8c87a;

  --color-bg: #ffffff;
  --color-surface: #f9f9f9;
  --color-border: #e0e0e0;
  --color-text: #1a1a1a;
  --color-text-light: #555;

  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-sans: 'Lato', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);

  --duration-fast: 0.15s;
  --transition-smooth: 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);

  --danger: #a4262c;
  --danger-bg: #fdf3f4;
  --warn: #8a6100;
  --warn-bg: #fff8e6;
  --ok-bg: #eef5f0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { font-family: var(--font-serif); font-weight: 700; margin: 0; }
h1 { font-size: 2rem; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }

a { color: var(--dark-green); }

/* ---------- App shell ---------- */

.topbar {
  background: var(--dark-green);
  color: #fff;
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.topbar .wordmark {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.topbar .tag {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  background: rgba(255, 255, 255, 0.16);
  padding: 0.18rem 0.5rem;
  border-radius: var(--radius-sm);
}
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 0.85rem; opacity: 0.9; }
.topbar button.link {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
}
.topbar button.link:hover { background: rgba(255, 255, 255, 0.12); }

.nav {
  border-bottom: 1px solid var(--color-border);
  padding: 0 2rem;
  display: flex;
  gap: 1.6rem;
}
.nav a {
  padding: 0.85rem 0.1rem;
  text-decoration: none;
  color: var(--color-text-light);
  font-size: 0.92rem;
  border-bottom: 2px solid transparent;
}
.nav a.active { color: var(--dark-green); font-weight: 700; border-bottom-color: var(--color-primary); }

main { max-width: 1180px; margin: 0 auto; padding: 1.75rem 2rem 5rem; }
.lede { color: var(--color-text-light); margin: 0.4rem 0 1.5rem; max-width: 46ch; }

/* ---------- Steps ---------- */

.steps { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; }
.step {
  font-size: 0.8rem;
  color: var(--color-text-light);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.step .dot {
  width: 1.35rem; height: 1.35rem; border-radius: 50%;
  background: var(--color-surface); border: 1px solid var(--color-border);
  display: grid; place-items: center; font-size: 0.72rem; font-weight: 700;
}
.step.done .dot { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.step.current { color: var(--dark-green); font-weight: 700; }
.step.current .dot { border-color: var(--color-primary); color: var(--dark-green); }
.step .sep { color: var(--color-border); }

/* ---------- Layout ---------- */

.split { display: grid; grid-template-columns: 1fr 275px; gap: 1.4rem; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

.card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
}
.card + .card { margin-top: 0.85rem; }
.card.tinted { background: var(--color-surface); }

/* ---------- Form controls ---------- */

label.field { display: block; margin-bottom: 0.85rem; }
label.field > span { display: block; font-size: 0.8rem; font-weight: 700; margin-bottom: 0.28rem; }
label.field > span .req { color: var(--danger); font-weight: 400; }

input[type='text'], input[type='email'], input[type='tel'], input[type='password'],
input[type='number'], select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
  color: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand-2);
  outline-offset: -1px;
  border-color: var(--brand-2);
}
input[aria-invalid='true'] { border-color: var(--danger); background: var(--danger-bg); }
textarea { min-height: 4.5rem; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.8rem; }
.grid3 { display: grid; grid-template-columns: 2fr 0.8fr 1fr; gap: 0 0.8rem; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

button {
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: #fff;
  padding: 0.55rem 0.9rem;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
button:hover:not(:disabled) { background: var(--color-surface); }
button.primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  font-weight: 700;
}
button.primary:hover:not(:disabled) { background: var(--dark-green); border-color: var(--dark-green); }
button.ghost { border-color: transparent; color: var(--dark-green); font-weight: 700; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.block { width: 100%; }
.actions { display: flex; gap: 0.6rem; align-items: center; margin-top: 1rem; }

/* ---------- Chips / pills ---------- */

.chips { display: flex; gap: 0.45rem; flex-wrap: wrap; margin: 0.85rem 0; }
.chip {
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: #fff;
  padding: 0.32rem 0.85rem;
  font-size: 0.85rem;
}
.chip.on { background: var(--color-primary); border-color: var(--color-primary); color: #fff; font-weight: 700; }

.tierpills { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 0.6rem 0 1.1rem; }
.tierpills .caption {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--color-text-light); font-weight: 700;
}
.tierpill {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.3rem 0.7rem;
  text-align: center;
  line-height: 1.15;
}
.tierpill b { display: block; font-size: 0.95rem; }
.tierpill small { font-size: 0.68rem; color: var(--color-text-light); }
.tierpill.on { background: var(--ok-bg); border-color: var(--color-primary); }
.tierpills .status { font-size: 0.78rem; font-weight: 700; color: var(--dark-green); }

/* ---------- Product rows ---------- */

.grouphead {
  display: flex; align-items: baseline; gap: 0.5rem;
  margin: 1.5rem 0 0.7rem;
}
.grouphead h3 { font-size: 1.15rem; }
.grouphead .count {
  font-size: 0.75rem; color: var(--color-text-light);
  background: var(--color-surface); border-radius: 999px; padding: 0.1rem 0.5rem;
}

.row {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.7rem 0.9rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 1rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.row.active { border-color: var(--color-primary); box-shadow: var(--shadow-sm); }

/* Bottle shot beside the name. Reps recognise the label faster than the words,
   which matters most across the bilingual tradicional line. */
.row .ident { display: flex; align-items: center; gap: 0.8rem; min-width: 0; }
.row .shot {
  flex: 0 0 auto;
  width: 30px;
  height: 92px;
  object-fit: contain;
  object-position: center;
}
.row .shot.placeholder {
  display: block;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
}
@media (max-width: 640px) {
  .row .shot { width: 22px; height: 68px; }
}

.row .name { font-weight: 700; }
.row .meta { font-size: 0.74rem; color: var(--color-text-light); letter-spacing: 0.03em; }
.row .price { font-size: 0.88rem; margin-top: 0.15rem; }
.row .price b { color: var(--dark-green); }
.row .price .ext { color: var(--color-text-light); margin-left: 0.4rem; }
.row .quick { grid-column: 1 / -1; display: flex; gap: 0.35rem; }
.row .quick button { padding: 0.15rem 0.6rem; font-size: 0.78rem; border-radius: 999px; }

.stepper { display: flex; align-items: center; border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; }
.stepper button {
  border: none; border-radius: 0; width: 2.1rem; height: 2.1rem;
  font-size: 1.1rem; line-height: 1; display: grid; place-items: center;
}
.stepper input {
  width: 3.1rem; text-align: center; border: none; border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border); border-radius: 0; padding: 0.4rem 0; font-weight: 700;
}
.stepper input:focus { outline-offset: -2px; }

/* ---------- Right rail ---------- */

.rail { position: sticky; top: 1rem; }
.rail .top { display: flex; justify-content: space-between; font-size: 0.78rem; margin-bottom: 0.35rem; }
.rail .top .met { color: var(--dark-green); font-weight: 700; }
.bar { height: 5px; border-radius: 999px; background: var(--color-border); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--color-primary); transition: width var(--transition-smooth); }
.nudge {
  background: var(--ok-bg); border-radius: var(--radius-md);
  padding: 0.55rem 0.7rem; font-size: 0.8rem; margin: 0.8rem 0;
}
.rail .total { font-family: var(--font-serif); font-size: 1.7rem; font-weight: 700; color: var(--dark-green); }
.rail .totalsub { font-size: 0.78rem; color: var(--color-text-light); margin-bottom: 0.85rem; }
.rail .breakdown { font-size: 0.78rem; color: var(--color-text-light); margin: 0.5rem 0 0; }
.rail .breakdown div { display: flex; justify-content: space-between; }

/* ---------- Messages ---------- */

.msg { border-radius: var(--radius-md); padding: 0.6rem 0.8rem; font-size: 0.85rem; margin-bottom: 0.7rem; }
.msg.error { background: var(--danger-bg); color: var(--danger); border: 1px solid #f0c9cb; }
.msg.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #f0e0b0; }
.msg.ok { background: var(--ok-bg); color: var(--dark-green); border: 1px solid #cfe3d6; }
.msg ul { margin: 0.3rem 0 0; padding-left: 1.1rem; }

/* ---------- Customer picker ---------- */

.results { border: 1px solid var(--color-border); border-radius: var(--radius-lg); max-height: 22rem; overflow: auto; }
.result {
  display: flex; justify-content: space-between; gap: 1rem; align-items: center;
  padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--color-border); cursor: pointer;
  background: none; width: 100%; text-align: left; border-radius: 0;
}
.result:last-child { border-bottom: none; }
.result:hover { background: var(--color-surface); }
.result .nm { font-weight: 700; }
.result .ad { font-size: 0.78rem; color: var(--color-text-light); }
.badge {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0.13rem 0.45rem; border-radius: var(--radius-sm); white-space: nowrap;
}
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.new { background: var(--ok-bg); color: var(--dark-green); }
.empty { padding: 1.6rem; text-align: center; color: var(--color-text-light); font-size: 0.9rem; }

/* ---------- Mixed cases ---------- */

.mixedbox { border: 1px dashed var(--color-border); border-radius: var(--radius-lg); padding: 0.9rem 1rem; margin-bottom: 0.9rem; }
.mixedbox.invalid { border-color: var(--danger); background: var(--danger-bg); }
.mixedbox header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; }
.mixedbox .slot { display: grid; grid-template-columns: 1fr 6.5rem auto; gap: 0.5rem; align-items: center; margin-bottom: 0.45rem; }
.bottlecount { font-size: 0.8rem; color: var(--color-text-light); }

/* ---------- Review sheet ---------- */

.sheet { max-width: 700px; }
.sumline { display: flex; justify-content: space-between; padding: 0.32rem 0; font-size: 0.92rem; }
.sumline.grand { border-top: 1px solid var(--color-border); margin-top: 0.4rem; padding-top: 0.6rem; font-weight: 700; font-size: 1.05rem; }
.sumline .lbl { color: var(--color-text-light); }
pre.preview {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 0.85rem; overflow: auto;
  font-size: 0.74rem; line-height: 1.45; max-height: 24rem;
}

/* ---------- Orders table ---------- */

table.orders { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.orders th {
  text-align: left; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--color-text-light); border-bottom: 1px solid var(--color-border); padding: 0.5rem 0.6rem;
}
table.orders td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--color-border); }
table.orders tr:hover td { background: var(--color-surface); }
.pill { font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 999px; }
.pill.sent { background: var(--ok-bg); color: var(--dark-green); }
.pill.unsent { background: var(--warn-bg); color: var(--warn); }

/* ---------- Login ---------- */

.loginwrap { min-height: 78vh; display: grid; place-items: center; }
.loginwrap .card { width: 100%; max-width: 22rem; }
.loginwrap h1 { font-size: 1.5rem; margin-bottom: 0.2rem; }
.loginwrap .sub { font-size: 0.85rem; color: var(--color-text-light); margin-bottom: 1.1rem; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
