/* ============================================================
   Montar CRM — shell: reset, app bar, overview, panel, forms
   Board and card styles live in pipeline.css
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

/* The shell is a flex column so the board simply takes whatever height
   the bars above it leave. Measuring that in JS meant re-deriving it on
   every resize, and getting it wrong whenever a bar was added. */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.app-bar, .demo-bar, .overview { flex: none; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;              /* the board scrolls, the page does not */
}

h1, h2, h3, p, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

:where(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* ---------------------------------------------------------- app bar */
.app-bar {
  position: relative;
  z-index: 30;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 clamp(0.9rem, 0.4rem + 1.6vw, 1.9rem);
  background: var(--card);
  border-bottom: 1px solid var(--hair);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark { width: 26px; height: 26px; flex: none; display: block; }

.brand-name {
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: var(--text-micro);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
}

.app-bar-spacer { flex: 1 1 auto; }

/* Search is the most-used control in the bar, so it gets real width
   rather than being squeezed to an icon. */
.search {
  position: relative;
  flex: 0 1 300px;
  min-width: 0;
}

.search input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: 999px;
  font-size: var(--text-sm);
  transition: border-color var(--duration) var(--ease),
              background var(--duration) var(--ease);
}
.search input:hover { border-color: var(--hair-2); }
.search input:focus { background: var(--card); border-color: var(--accent); }
.search input::placeholder { color: var(--ink-faint); }

.search-icon {
  position: absolute;
  left: 11px; top: 50%;
  translate: 0 -50%;
  width: 14px; height: 14px;
  color: var(--ink-faint);
  pointer-events: none;
}

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--duration) var(--ease),
              border-color var(--duration) var(--ease),
              transform var(--duration) var(--ease),
              opacity var(--duration) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--action); color: #fff; }
.btn-primary:hover:not([disabled]) { background: color-mix(in oklab, var(--action) 88%, #000); }

.btn-quiet { border-color: var(--hair); background: var(--card); }
.btn-quiet:hover:not([disabled]) { border-color: var(--hair-2); background: var(--card-2); }

.btn-ghost { color: var(--ink-soft); padding: 7px 9px; }
.btn-ghost:hover:not([disabled]) { background: var(--paper-2); color: var(--ink); }

.btn-icon { width: 15px; height: 15px; flex: none; }

/* ----------------------------------------------------------- overview
   Deliberately not a row of four equal cards. One figure carries the
   headline — how much work is actually open — and the rest sit beside
   it as supporting text at a fraction of the size. */
.overview {
  display: flex;
  align-items: stretch;
  gap: clamp(1.2rem, 0.6rem + 2.4vw, 3rem);
  padding: clamp(1.1rem, 0.7rem + 1.4vw, 1.9rem) clamp(0.9rem, 0.4rem + 1.6vw, 1.9rem);
  background: var(--card);
  border-bottom: 1px solid var(--hair);
  overflow-x: auto;
  scrollbar-width: thin;
}

.headline-figure { flex: none; min-width: 0; }

.headline-figure .figure {
  display: block;
  font-size: var(--text-figure);
  font-weight: 800;
  line-height: 0.85;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
}

.headline-figure .figure-label {
  display: block;
  margin-top: 8px;
  font-size: var(--text-eyebrow);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* The one place colour is allowed to shout: leads going cold. */
.alert-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--action-tint);
  color: color-mix(in oklab, var(--action) 78%, var(--ink));
  font-size: var(--text-sm);
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background var(--duration) var(--ease);
}
.alert-pill:hover { background: color-mix(in oklab, var(--action) 20%, var(--card)); }
.alert-pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--action);
}

.stat-row {
  display: flex;
  align-items: flex-start;
  gap: clamp(1.1rem, 0.5rem + 2vw, 2.4rem);
  padding-left: clamp(1.1rem, 0.5rem + 2vw, 2.4rem);
  border-left: 1px solid var(--hair);
}

.stat { min-width: 0; }

.stat .stat-value {
  display: block;
  font-size: var(--text-lede);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat .stat-label {
  display: block;
  margin-top: 2px;
  font-size: var(--text-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
}

.stat-value.is-go   { color: var(--go); }
.stat-value.is-gold { color: var(--gold); }

/* Tablet and below: the supporting stats stop being a row and become a
   block, so their labels can wrap instead of running off the edge. */
@media (max-width: 860px) {
  .overview { display: block; }
  .stat-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem 1.2rem;
    margin-top: 1rem;
    padding-top: 1rem;
    padding-left: 0;
    border-left: none;
    border-top: 1px solid var(--hair);
  }
  .stat .stat-label { white-space: normal; }
}

/* Phone: this is where the owner actually stands, in the shop, one
   handed. The overview must not eat the screen before a single lead is
   visible, so the headline figure shrinks and the bar sheds everything
   that is not a control. */
@media (max-width: 560px) {
  :root { --text-figure: 2.7rem; --bar-h: 54px; }

  .app-bar { gap: 8px; }
  .app-bar-spacer { display: none; }
  .brand-text { display: none; }
  .search { flex: 1 1 auto; }
  .btn-label { display: none; }
  .btn-primary { padding-inline: 11px; }

  .overview { padding-block: 0.9rem; }
  .headline-figure .figure-label { margin-top: 6px; }
  .alert-pill { margin-top: 8px; }
}

/* -------------------------------------------------------------- toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  translate: -50% 0;
  z-index: 60;
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: var(--text-sm);
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity var(--duration) var(--ease),
              translate var(--duration) var(--ease);
  pointer-events: none;
}
.toast.is-visible { opacity: 1; translate: -50% -6px; }
.toast.is-error { background: var(--action); color: #fff; }

/* -------------------------------------------------------------- login */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--paper);
}

.login-card {
  width: min(380px, 100%);
  padding: clamp(1.6rem, 1rem + 2vw, 2.4rem);
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card .brand-mark { width: 34px; height: 34px; }

.login-card h1 {
  margin: 16px 0 4px;
  font-size: var(--text-h2);
  letter-spacing: -0.025em;
}

.login-card .login-sub { color: var(--ink-soft); font-size: var(--text-sm); }

.field { margin-top: 14px; }

.field label {
  display: block;
  margin-bottom: 5px;
  font-size: var(--text-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  transition: border-color var(--duration) var(--ease),
              background var(--duration) var(--ease);
}
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--hair-2); }
.field input:focus, .field select:focus, .field textarea:focus {
  background: var(--card);
  border-color: var(--accent);
}
.field textarea { resize: vertical; min-height: 74px; }

.form-error {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--action-tint);
  color: color-mix(in oklab, var(--action) 76%, var(--ink));
  font-size: var(--text-sm);
}

.login-card .btn-primary { width: 100%; justify-content: center; margin-top: 16px; }

/* --------------------------------------------------------- boot state */
.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--paper);
  color: var(--ink-faint);
  font-size: var(--text-sm);
  z-index: 70;
}

/* ------------------------------------------------------- demo notice
   Demo data must never be mistakable for the real board. The strip is
   the one piece of chrome allowed to interrupt the layout. */
.demo-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px clamp(0.9rem, 0.4rem + 1.6vw, 1.9rem);
  background: var(--gold-tint);
  border-bottom: 1px solid color-mix(in oklab, var(--gold) 32%, transparent);
  font-size: var(--text-sm);
  color: color-mix(in oklab, var(--gold) 74%, var(--ink));
}

.demo-bar strong { font-weight: 700; }

.demo-bar .btn {
  margin-left: auto;
  padding: 4px 10px;
  font-size: var(--text-micro);
  border: 1px solid color-mix(in oklab, var(--gold) 38%, transparent);
  color: inherit;
}
.demo-bar .btn:hover { background: color-mix(in oklab, var(--gold) 18%, transparent); }

/* ---------------------------------------------------- change requests */
.fb-list { list-style: none; margin: 0; padding: 0; }

.fb-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--hair);
}
.fb-item:last-child { border-bottom: none; }

/* Checkbox styled as a target big enough for a thumb. */
.fb-check {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  padding: 0;
  border: 1.5px solid var(--hair-2);
  border-radius: var(--radius-xs);
  background: var(--card);
  cursor: pointer;
  transition: background var(--duration) var(--ease),
              border-color var(--duration) var(--ease);
}
.fb-check:hover { border-color: var(--accent); }
.fb-check[aria-pressed="true"] {
  background: var(--go);
  border-color: var(--go);
}

.fb-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.fb-body {
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.fb-meta {
  font-size: var(--text-micro);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.fb-item.is-done .fb-body {
  text-decoration: line-through;
  color: var(--ink-faint);
}

/* Shown only when the clipboard API is unavailable. */
.fb-dump {
  width: 100%;
  min-height: 220px;
  margin-top: 10px;
  padding: 10px;
  font-family: var(--mono);
  font-size: 0.78rem;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  resize: vertical;
}

/* ------------------------------------------------------ shop switcher
   Only rendered for accounts with more than one shop, so a client never
   learns that other shops exist. */
.shop-switch { flex: none; margin-left: 4px; }

.shop-switch select {
  max-width: 190px;
  padding: 6px 26px 6px 10px;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--duration) var(--ease),
              background var(--duration) var(--ease);
}
.shop-switch select:hover { border-color: var(--hair-2); background: var(--card); }

/* --------------------------------------------------------- login foot */
.login-foot { margin-top: 14px; text-align: center; }

.link-button {
  padding: 4px 6px;
  border: none;
  background: none;
  color: var(--ink-soft);
  font-size: var(--text-sm);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: color var(--duration) var(--ease);
}
.link-button:hover { color: var(--accent); }

/* A confirmation rather than a failure — same slot, different weight. */
.form-error.is-note {
  background: var(--accent-tint);
  color: var(--accent-ink);
}

@media (max-width: 560px) {
  .shop-switch select { max-width: 120px; }
}

/* On a short laptop screen the overview was eating the board. Same
   information, less of the viewport. */
@media (min-width: 861px) and (max-height: 900px) {
  :root { --text-figure: 2.6rem; }
  .overview { padding-block: 0.85rem; }
  .headline-figure .figure-label { margin-top: 5px; }
  .alert-pill { margin-top: 7px; }
}

/* ------------------------------------------------------- client logos
   Supplied per shop as a data URI, so they cost no request. Constrained
   by height with width:auto, because client logos arrive at every
   aspect ratio imaginable and a wordmark must not be squashed. */
.shop-logo {
  height: 26px;
  width: auto;
  max-width: 132px;
  object-fit: contain;
  flex: none;
  display: block;
}

.login-logo {
  height: 42px;
  width: auto;
  max-width: 210px;
  object-fit: contain;
  display: block;
  margin-bottom: 4px;
}

@media (max-width: 560px) {
  .shop-logo { max-width: 96px; }
}

/* ------------------------------------------------------- form fields
   Safari paints autofilled inputs with its own yellow-green wash and
   ignores `background`. Only an inset shadow the size of the field can
   cover it, and the text colour has to be forced separately. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 100px var(--paper) inset;
  caret-color: var(--ink);
  transition: background-color 600000s 0s;   /* outlast the repaint */
}
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 100px var(--card) inset;
}

/* Placeholders in every field type, not just the ones app.css already
   covered. */
.field input::placeholder,
.field textarea::placeholder,
.search input::placeholder {
  color: var(--ink-faint);
  opacity: 1;                 /* Firefox dims placeholders by default */
}

/* Textareas in the editors are for lists — one item per line — so a
   monospaced-ish rhythm and a comfortable line height help. */
.field textarea {
  line-height: 1.55;
  min-height: 96px;
}

/* A native colour input renders as a small chip with its own border and
   padding. Left alone it looks like a bug next to real fields. */
.field input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 4px;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.field input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.field input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: var(--radius-xs);
}
.field input[type="color"]:hover { border-color: var(--hair-2); }

/* Dates and numbers pick up the platform's own chrome otherwise. */
.field input[type="date"],
.field input[type="number"] {
  font-variant-numeric: tabular-nums;
}

/* A disabled field should look inert rather than merely pale. */
.field input[disabled], .field textarea[disabled], .field select[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* A destructive action should not look like the primary one. Outlined
   rather than filled, so it reads as available but not inviting. */
.btn-danger {
  border-color: color-mix(in oklab, var(--action) 40%, transparent);
  color: var(--action);
  background: transparent;
}
.btn-danger:hover:not([disabled]) {
  background: var(--action-tint);
  border-color: var(--action);
}

/* --------------------------------------------------- logo shapes
   A wordmark carries the name itself, so the text beside it is
   redundant. A badge cannot — at bar height its lettering is a few
   pixels tall — so the name stays. */
.brand.has-wordmark .brand-name { display: none; }

.shop-logo[data-shape="badge"] {
  height: 34px;
  max-width: 44px;
}
.login-logo[data-shape="badge"] {
  height: 64px;
  max-width: 76px;
}
.client-card-logo[data-shape="badge"] {
  height: 30px;
  max-width: 38px;
}
