/* Entirely Sales.
   Built on the estate's design tokens (web/tokens/, the same copies every staff app carries):
   Sand page, Moss header, white panels, Neon accent, Bagoss Standard headings, Outfit for everything else.
   The header, panel and capsule buttons match Entirely Procurement, so the staff apps read as one product. */

@import url('tokens/colors.css');
@import url('tokens/fonts.css');
@import url('tokens/spacing.css');
@import url('tokens/typography.css');

/* [hidden] must outrank any later display rule, or the fixed full-screen gate stays on top
   of a rendered app with nothing in the console to say why. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

:root {
  --field-border: rgba(0, 0, 0, 0.2);
  --field-height: 44px;
  --danger: #b3261e;
  --ok-ink: #1f5c36;
  --wait-ink: #6b5a00;
}

body {
  margin: 0;
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  letter-spacing: var(--tracking-body);
  -webkit-text-size-adjust: 100%;
}

/* Form controls take the page font; browsers otherwise use their own. */
button, input, select, textarea { font-family: inherit; letter-spacing: inherit; }

/* ------------------------------------------------------------------ header */
.bar {
  background: var(--surface-moss);
  color: var(--text-on-dark);
  position: sticky;
  top: 0;
  z-index: 2;
  padding-top: env(safe-area-inset-top);
}
.bar-in {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  min-height: 60px;
}
.brand { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.mark { width: var(--stroke-heavy); height: 34px; background: var(--accent); display: block; flex: none; }
.bar h1 {
  font-family: var(--font-display);
  font-weight: var(--weight-medium);
  font-size: var(--fs-h3);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-h3);
  margin: 0;
}
.bar p { margin: 0; font-size: var(--fs-caption); color: rgba(255, 255, 255, 0.72); }
.who { display: flex; align-items: center; gap: var(--space-3); font-size: var(--fs-caption); color: rgba(255, 255, 255, 0.85); flex-wrap: wrap; }
#whoami { word-break: break-all; }
.tier {
  border: var(--stroke-thin) solid var(--border-on-dark);
  border-radius: var(--radius-capsule);
  padding: 2px var(--space-3);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caption);
  color: var(--accent);
}

.banner {
  background: var(--color-cream);
  color: var(--text-primary);
  font-size: var(--fs-small);
  padding: var(--space-3) var(--space-4);
  text-align: center;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom));
}

/* -------------------------------------------------------------------- tabs */
.tabs { display: flex; gap: var(--space-2); margin: 0 0 var(--space-4); overflow-x: auto; }
.tab {
  font-size: var(--fs-small);
  font-weight: var(--weight-medium);
  padding: var(--space-2) var(--space-4);
  min-height: 40px;
  border-radius: var(--radius-capsule);
  border: var(--stroke-thin) solid var(--border-subtle);
  background: var(--surface-card);
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { border-color: var(--field-border); }
.tab[aria-selected="true"] { background: var(--surface-moss); color: var(--text-on-dark); border-color: var(--surface-moss); }

/* ------------------------------------------------------------------ panels */
.panel {
  background: var(--surface-card);
  border: var(--stroke-thin) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.panel h2 {
  font-family: var(--font-display);
  font-weight: var(--weight-medium);
  font-size: var(--fs-h4);
  line-height: var(--lh-heading);
  letter-spacing: var(--tracking-tight);
  margin: 0 0 var(--space-4);
}
/* A section inside a panel: small, tracked capitals. */
.subhead {
  font-size: var(--fs-caption);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caption);
  color: var(--text-secondary);
  margin: 0 0 var(--space-3);
}
.divider { border: 0; border-top: var(--stroke-thin) solid var(--border-subtle); margin: var(--space-5) 0; }
p.lede { margin: -8px 0 var(--space-5); color: var(--text-secondary); font-size: var(--fs-small); max-width: 60ch; }
.row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.between .subhead { margin: 0; }
.gap-top { margin-top: var(--space-5); }
.status { font-size: var(--fs-small); color: var(--text-secondary); margin: var(--space-2) 0; }
.status:empty { display: none; }

/* A panel title with its one action on the right. */
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin: 0 0 var(--space-4); }
.panel-head h2, .panel-head .subhead { margin: 0; }
.panel-head + .status, h3 + .status { margin-top: 0; }
#customerPanel .panel-head { margin-top: var(--space-5); padding-top: var(--space-5); border-top: var(--stroke-thin) solid var(--border-subtle); }
button.btn.back { margin: 0 0 var(--space-4); padding-left: var(--space-3); }
button.btn.back::before { content: '\2190'; margin-right: var(--space-2); }

/* ------------------------------------------------------------------ fields */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4) var(--space-4); }
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  font-size: var(--fs-small);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}
.field.wide { grid-column: 1 / -1; }
@media (max-width: 560px) { .fields { grid-template-columns: 1fr; } }

.field .label { color: var(--text-primary); }
.field .opt { margin-left: var(--space-1); font-weight: var(--weight-regular); color: var(--text-muted); }
.field .hint { font-size: var(--fs-caption); font-weight: var(--weight-regular); color: var(--text-secondary); line-height: 1.4; }

input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  /* 16px or more, or iOS Safari zooms the page on focus. */
  font-size: max(16px, var(--fs-body));
  font-weight: var(--weight-regular);
  line-height: var(--lh-tight);
  color: var(--text-primary);
  background-color: var(--surface-card);
  border: var(--stroke-thin) solid var(--field-border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-3);
  width: 100%;
  height: var(--field-height);
  margin: 0;
  transition: border-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard);
}
input::placeholder { color: var(--text-muted); opacity: 1; }
input:hover, select:hover { border-color: rgba(0, 0, 0, 0.35); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus-ring); box-shadow: 0 0 0 3px rgba(0, 62, 38, 0.15); }
input:user-invalid { border-color: var(--danger); }
/* One chevron for every select, so they match the inputs in height and look. */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--space-7);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%232e2e2e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  cursor: pointer;
}
input[type="date"] { min-width: 0; }
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.6; }
input[type="search"] { -webkit-appearance: none; }

.actions-row { grid-column: 1 / -1; display: flex; gap: var(--space-4); align-items: center; flex-wrap: wrap; margin-top: var(--space-2); }
.actions-row .status { margin: 0; }

/* Customer picker on the opportunity form. */
.chosen {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-3);
  min-height: var(--field-height); padding: var(--space-1) var(--space-1) var(--space-1) var(--space-3);
  border: var(--stroke-thin) solid var(--focus-ring); border-radius: var(--radius-md); background: var(--color-sage);
  font-size: var(--fs-body); font-weight: var(--weight-medium); color: var(--text-primary);
}
.pick-list { list-style: none; margin: 0; padding: 0; max-height: 264px; overflow-y: auto;
  border: var(--stroke-thin) solid var(--border-subtle); border-radius: var(--radius-md); }
.pick-list:empty { display: none; }
.pick-list li + li { border-top: var(--stroke-thin) solid var(--border-subtle); }
button.pick { display: flex; justify-content: space-between; gap: var(--space-3); width: 100%; text-align: left; background: none; border: 0;
  padding: var(--space-3); font-size: var(--fs-body); font-weight: var(--weight-regular); color: var(--text-primary); cursor: pointer; }
button.pick:hover, button.pick:focus-visible { background: var(--color-sage); }
button.pick .meta { color: var(--text-secondary); font-size: var(--fs-small); }
.pick-empty { padding: var(--space-3); font-size: var(--fs-small); font-weight: var(--weight-regular); color: var(--text-secondary); }
.note {
  grid-column: 1 / -1;
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-sand);
  font-size: var(--fs-small);
  font-weight: var(--weight-regular);
  color: var(--text-secondary);
}
.problems { grid-column: 1 / -1; color: var(--danger); font-size: var(--fs-small); margin: 0; padding-left: var(--space-5); }
.problems:empty { display: none; }

/* ----------------------------------------------------------------- buttons */
/* Capsule CTAs, per the brand's pill UI. */
button.btn {
  font-size: var(--fs-body);
  font-weight: var(--weight-medium);
  line-height: 1;
  padding: 0 var(--space-5);
  height: var(--field-height);
  border-radius: var(--radius-capsule);
  border: var(--stroke-thin) solid var(--field-border);
  background: var(--surface-card);
  color: var(--text-primary);
  cursor: pointer;
}
button.btn:hover:not(:disabled) { border-color: var(--text-primary); }
button.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); }
button.btn.primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
button.btn:disabled { opacity: 0.45; cursor: default; }
button.btn.small { font-size: var(--fs-small); padding: 0 var(--space-4); height: 32px; }
.who button.btn { background: transparent; border-color: var(--border-on-dark); color: var(--text-on-dark); }
.who button.btn:hover { border-color: var(--text-on-dark); }
button:focus-visible, .list button.item:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* -------------------------------------------------------------------- lists */
.list { list-style: none; margin: var(--space-2) 0 0; padding: 0; }
.list li { border-top: var(--stroke-thin) solid var(--border-subtle); }
.list li:last-child { border-bottom: var(--stroke-thin) solid var(--border-subtle); }
.list .item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-2);
  font-size: var(--fs-body);
  font-weight: var(--weight-medium);
  line-height: var(--lh-tight);
  text-align: left;
  color: var(--text-primary);
  background: none;
  border: 0;
}
.list button.item { cursor: pointer; border-radius: var(--radius-sm); }
.list button.item:hover { background: var(--color-sand); }
.item .meta { display: inline-block; margin-top: 4px; color: var(--text-secondary); font-size: var(--fs-small); font-weight: var(--weight-regular); }
.item .amount { font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge {
  flex: none;
  border-radius: var(--radius-capsule);
  padding: 2px var(--space-2);
  font-size: var(--fs-caption);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  background: var(--color-heather);
  color: var(--text-secondary);
}
.badge.ok { background: var(--color-sage); color: var(--ok-ink); }
.badge.wait { background: var(--color-cream); color: var(--wait-ink); }

/* ------------------------------------------------------------------ detail */
#backToCustomers { margin-bottom: var(--space-4); }
.facts { display: grid; grid-template-columns: 11em 1fr; gap: var(--space-3) var(--space-4); margin: 0 0 var(--space-5); }
.facts dt { font-size: var(--fs-small); color: var(--text-secondary); }
.facts dd { margin: 0; word-break: break-word; }
@media (max-width: 560px) {
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: var(--space-3); }
}

/* -------------------------------------------------------------------- gate */
.gate {
  position: fixed;
  inset: 0;
  background: var(--surface-page);
  display: grid;
  place-items: center;
  padding: var(--space-5);
  z-index: 5;
}
.gate-card {
  background: var(--surface-card);
  border: var(--stroke-thin) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-5);
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-sm);
}
.gate-card h2 { font-family: var(--font-display); font-weight: var(--weight-medium); font-size: var(--fs-h4); margin: 0 0 var(--space-3); }
.gate-card p { white-space: pre-line; color: var(--text-secondary); margin: 0 0 var(--space-4); }
