/* Handover: component classes copied from mews-kit.html, then layout.
 *
 * Two sections, and the line between them matters.
 *
 * COMPONENTS are transcribed from public/mews-kit.html without changes. That
 * file is the visual source of truth. If a measurement here disagrees with the
 * kit, the kit is right and this is a bug. Do not add a component class that is
 * not in the kit.
 *
 * LAYOUT is everything this application needs on top, and every one of those
 * classes is prefixed l-. The prefix is the contract: an unprefixed class in
 * this file should be findable, character for character, in the kit.
 */

@import url("mews-tokens.css");

/* =========================================================================
   COMPONENTS, from mews-kit.html
   ========================================================================= */

* { box-sizing: border-box }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-static-sunken);
  -webkit-font-smoothing: antialiased;
}

/* BUTTON. Heights 32/40/48/56. Side padding 12/16/24, gap 8/12/12. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  height: 40px; padding: 0 16px; border-radius: 8px; border: 1px solid transparent;
  font: 500 14px/1.5 var(--font-ui); cursor: pointer; white-space: nowrap;
  transition: background-color .12s ease, border-color .12s ease }
.btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px }
.btn-sm { height: 32px; padding: 0 12px; gap: 8px; font-size: 12px }
.btn-lg { height: 48px; padding: 0 24px }
.btn-primary { background: var(--bg-interactive-primary); color: var(--text-on-color) }
.btn-primary:hover { background: var(--bg-interactive-primary-hover) }
.btn-primary:active { background: var(--bg-interactive-primary-active) }
.btn-secondary { background: var(--bg-interactive-secondary); color: var(--text-interactive-primary) }
.btn-secondary:hover { background: var(--bg-interactive-secondary-hover) }
.btn-tertiary { background: var(--bg-interactive-neutral-subtle); color: var(--text-interactive-secondary);
  border-color: var(--border-interactive-secondary) }
.btn-tertiary:hover { background: var(--bg-interactive-neutral-subtle-hover);
  border-color: var(--border-interactive-secondary-hover) }
.btn-ghost { background: transparent; color: var(--text-interactive-secondary) }
.btn-ghost:hover { background: var(--bg-interactive-neutral-subtle-hover) }

/* BADGE. If the count is 0, do not render it. */
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px;
  height: 18px; padding: 0 6px; border-radius: 999px; background: var(--bg-accent-primary);
  color: var(--text-inverse); font: 500 11px/1 var(--font-ui); letter-spacing: .2px }
.badge-subtle { background: var(--bg-interactive-neutral); color: var(--text-secondary) }
.badge-warning { background: var(--bg-accent-warning) }
.badge-danger { background: var(--bg-accent-danger) }

/* STATUS INDICATOR. Published exactly: 24px high, 4px radius, 1px border,
   8px side padding with background, gap 4px, truncating at 200px. */
.status { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px;
  border-radius: 4px; border: 1px solid transparent; max-width: 200px;
  font: 500 12px/1 var(--font-ui); overflow: hidden; white-space: nowrap; text-overflow: ellipsis }
.status .dot { width: 8px; height: 8px; border-radius: 50%; flex: none }
.status-danger  { background: #fff; border-color: var(--border-alert-danger);  color: var(--text-alert-danger) }
.status-warning { background: #fff; border-color: var(--border-alert-warning); color: var(--text-alert-warning) }
.status-success { background: #fff; border-color: var(--border-alert-success); color: var(--text-alert-success) }
.status-info    { background: #fff; border-color: var(--border-alert-info);    color: var(--text-alert-info) }
.status-basic   { background: #fff; border-color: var(--border-alert-basic);   color: var(--text-alert-basic) }
.status-danger  .dot { background: var(--va-danger) }
.status-warning .dot { background: var(--va-warning) }
.status-success .dot { background: var(--va-success) }
.status-info    .dot { background: var(--va-info) }
.status-basic   .dot { background: var(--border-static-tertiary) }

/* Bare comes AFTER the tone rules on purpose, which is the one place this file
   departs from the ordering in mews-kit.html.
 *
 * MDS publishes "side padding 8px with background, 0 without", so bare means no
 * box at all: dot and label in the tone colour, nothing around them. In the kit
 * .status-bare is declared before the tone rules, and since they carry equal
 * specificity and set border-color again, the border survives while bare's
 * padding: 0 still applies. The result is a bordered pill with the text jammed
 * against the edges, which is what this fixes. The kit page renders its own
 * "Bare, no background" example the same wrong way.
 *
 * The distinction matters here: Mostly overridden is bare danger and Too
 * expensive is boxed danger, which is MDS's own emphasis mechanism rather than
 * a sixth colour level. If bare keeps its border, those two look identical. */
.status-bare { padding: 0; border-color: transparent; background: none !important }

/* CHIP. 24px high, padding-left 8, padding-right 4 with close, gap 4. */
.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 4px 0 8px;
  border-radius: 4px; background: var(--bg-interactive-neutral);
  color: var(--text-primary); font: 400 12px/1 var(--font-ui) }
.chip.no-close { padding: 0 8px }

/* CARD. Radius 8/16/24. Cards are not interactive and never navigate. */
.card { background: var(--bg-static-flat); border: 1px solid var(--border-static-primary);
  border-radius: 16px; overflow: hidden }
.card-sm { border-radius: 8px }
.card-content { padding: 16px }
.card-content.highlighted { background: var(--bg-interactive-secondary) }
.card-content.subtle { background: var(--bg-interactive-neutral) }

/* DATA GRID. Row height 56px. Links: no underline at rest, underlined on row hover. */
.grid { width: 100%; border-collapse: collapse; background: var(--bg-static-flat); font-size: 14px }
.grid th { text-align: left; font: 500 12px/1.5 var(--font-ui); color: var(--text-tertiary);
  padding: 8px 12px; border-bottom: 1px solid var(--border-static-primary); white-space: nowrap }
.grid th.num, .grid td.num { text-align: right; font-variant-numeric: tabular-nums }
.grid td { padding: 0 12px; height: 56px; border-bottom: 1px solid var(--border-static-secondary);
  vertical-align: middle }
.grid tbody tr:hover { background: var(--bg-interactive-neutral-subtle-hover) }
.grid a { color: inherit; text-decoration: none }
.grid tbody tr:hover a { text-decoration: underline }

/* TABS. Active indicator plus optional badge. */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-static-primary) }
.tab { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 12px; font: 500 14px/1.5 var(--font-ui); color: var(--text-tertiary);
  border-bottom: 2px solid transparent; margin-bottom: -1px }
.tab:hover { color: var(--text-primary) }
.tab[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--bg-interactive-primary) }

/* FIELDS. Heights follow the 40px control rhythm. */
.field { display: block; margin-bottom: 16px; max-width: 360px }
.field label { display: block; font: 500 12px/1.5 var(--font-ui); color: var(--text-secondary); margin-bottom: 4px }
.input { width: 100%; height: 40px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border-interactive-secondary); background: var(--bg-static-flat);
  font: 400 14px/1.5 var(--font-ui); color: var(--text-primary) }
.input:hover { border-color: var(--border-interactive-secondary-hover) }
.input:focus { outline: 2px solid var(--border-focus); outline-offset: -1px; border-color: var(--border-focus) }
.field .msg { font-size: 12px; color: var(--text-alert-danger); margin-top: 4px }

/* ALERT */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 8px;
  border: 1px solid; font-size: 14px }
.alert-info    { background: #fff; border-color: var(--border-alert-info);    color: var(--text-alert-info) }
.alert-warning { background: #fff; border-color: var(--border-alert-warning); color: var(--text-alert-warning) }
.alert-danger  { background: #fff; border-color: var(--border-alert-danger);  color: var(--text-alert-danger) }
.alert b { display: block; color: var(--text-primary) }
.alert span { color: var(--text-secondary) }

/* EMPTY STATE */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 24px; gap: 24px; max-width: 600px; margin: 0 auto }
.empty h3 { font: 500 16px/1.5 var(--font-ui); margin: 0 0 8px }
.empty p { font: 400 14px/1.5 var(--font-ui); color: var(--text-secondary); margin: 0 }

/* APP BAR */
.appbar { display: flex; align-items: center; gap: 16px; height: 50px; padding: 0 16px;
  background: #F2F2F2; border-radius: 8px }
.appbar .mark { font-weight: 600; letter-spacing: .02em }

/* =========================================================================
   LAYOUT. Everything below is l- prefixed and belongs to this app only.
   ========================================================================= */

.l-page { max-width: 1400px; margin: 0 auto; padding: 16px 24px 96px }
.l-stack { display: grid; gap: 24px }
.l-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap }
.l-row-tight { display: flex; align-items: center; gap: 8px; flex-wrap: wrap }
.l-spacer { flex: 1 }

.l-screen-head { display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; flex-wrap: wrap; margin: 24px 0 0 }
.l-screen-head h1 { font-size: 22px; font-weight: 600; line-height: 1.5; margin: 0 }
.l-sub { color: var(--text-secondary); font-size: 14px; margin: 4px 0 0 }
.l-total { font-size: 25px; font-weight: 500; line-height: 1.3; letter-spacing: -.2px;
  font-variant-numeric: tabular-nums }
.l-total-label { color: var(--text-tertiary); font-size: 12px; margin: 0 0 2px }

/* Three stat tiles across, collapsing on narrow screens. */
.l-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px }
.l-tile-value { font-size: 25px; font-weight: 500; line-height: 1.3; letter-spacing: -.2px;
  font-variant-numeric: tabular-nums; margin: 8px 0 4px }
.l-tile-value.l-muted { font-size: 16px; font-weight: 400; color: var(--text-tertiary);
  letter-spacing: 0 }
.l-tile-note { color: var(--text-tertiary); font-size: 12px; margin: 0 }
.l-mix { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 4px }

/* The thresholds panel. Four numbers, editable, re-evaluating every row. */
.l-thresholds { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 16px;
  align-items: end }
.l-thresholds .field { margin: 0; max-width: none }
.l-threshold-input { max-width: 110px }

.l-grid-wrap { overflow-x: auto }
.l-plain { color: var(--text-secondary); font-size: 12px; display: block; margin-top: 2px }
.l-name { font-weight: 500 }
.l-nowrap { white-space: nowrap }
.l-help { color: var(--text-tertiary); font-size: 12px; margin: 0; max-width: 78ch }
.l-insufficient { color: var(--text-tertiary); font-style: normal }

/* A dotted underline is the affordance for "there is a reason behind this".
   Not a link: it navigates nowhere and the kit reserves links for navigation. */
.l-why { text-decoration: underline dotted var(--border-interactive-secondary);
  text-underline-offset: 3px; cursor: help }

.l-screen[hidden] { display: none }
.l-nav { margin-top: 12px }
.l-grow { flex: 1; min-width: 0 }

/* Review screen. The proposal is quoted rather than styled as a form field:
   the reader is judging something an agent wrote, not filling anything in. */
.l-quote { border-bottom: 1px solid var(--border-static-secondary) }
.l-msg { margin: 4px 0 0; font-size: 14px; line-height: 1.5; white-space: pre-wrap }

/* Four reasons, four buttons, all equal weight. A dropdown would hide the fact
   that the set is closed, and closing the set is the entire argument. */
.l-reasons { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px }
.l-note-field, .l-edit-field { max-width: 560px }

.l-badge-slot { display: inline-flex; align-items: center; gap: 8px }
