/* Reset, typography and reusable components. */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--c-olive-dark); }
a:hover { color: #334600; }
h1, h2, h3 { margin: 0; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--c-muted); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Headings */
.h-page { font-size: 24px; font-weight: 700; line-height: 1.25; }
.h-card { font-size: 14px; font-weight: 700; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; color: var(--c-muted); text-transform: uppercase; }
.eyebrow.accent { color: var(--c-olive-dark); }
.lead { color: var(--c-text-2); line-height: 1.55; max-width: 780px; margin: 6px 0 20px; }
.small { font-size: 12px; }
.hint { font-size: 12px; color: var(--c-muted-2); line-height: 1.5; }

/* Cards */
.card {
  background: var(--c-surface);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 20px;
  min-width: 0;
}
.card.pad-lg { padding: 28px 32px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-sub { margin: 4px 0 12px; font-size: 12px; color: var(--c-muted); line-height: 1.45; }

/* Buttons */
.btn {
  height: var(--h-control);
  padding: 0 20px;
  border-radius: var(--r-control);
  border: 1px solid var(--c-line-input);
  background: var(--c-surface);
  color: var(--c-text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--c-lime); border-color: var(--c-lime); color: var(--c-anthracite); font-weight: 700; }
.btn.dark { background: var(--c-anthracite); border-color: var(--c-anthracite); color: #fff; }
.btn.sm { height: 36px; padding: 0 14px; font-size: 13px; border-radius: 10px; }
.btn.warn { border-color: var(--c-warn-border); color: var(--c-warn); }
.link-btn {
  border: 0; background: transparent; padding: 0; min-height: 32px;
  font-weight: 700; font-size: 13px; color: var(--c-olive-dark); cursor: pointer;
}
.link-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Inputs */
.input, .select, .textarea {
  width: 100%;
  height: var(--h-control);
  border: 1px solid var(--c-line-input);
  border-radius: var(--r-control);
  padding: 0 14px;
  background: var(--c-surface);
  font-size: 15px;
}
.input.mono, .textarea.mono { font-family: var(--font-mono); }
/* Custom arrow: native select arrows sit flush against the border and differ per browser */
.select {
  appearance: none; -webkit-appearance: none;
  padding-right: 42px; cursor: pointer;
  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='%235F5A5B' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}
/* Date field with the English calendar (js/core/datepicker.js): calendar icon like the select arrow */
.input.date-input {
  padding-right: 42px; cursor: pointer; font-family: var(--font-mono);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Crect x='1.5' y='2.5' width='13' height='12' rx='2' fill='none' stroke='%235F5A5B' stroke-width='1.5'/%3E%3Cpath d='M1.5 6.5h13M5 1v3M11 1v3' stroke='%235F5A5B' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}
.flatpickr-calendar { font-family: var(--font-sans); border-radius: 12px; box-shadow: var(--shadow-float); }
.flatpickr-calendar.arrowTop::before, .flatpickr-calendar.arrowTop::after,
.flatpickr-calendar.arrowBottom::before, .flatpickr-calendar.arrowBottom::after { display: none; }
.flatpickr-months .flatpickr-month, .flatpickr-current-month { font-weight: 700; }
.flatpickr-day:hover, .flatpickr-day:focus { background: var(--c-lime-soft); border-color: var(--c-lime-soft); }
.flatpickr-day.today { border-color: var(--c-olive); }
.flatpickr-day.selected, .flatpickr-day.selected:hover, .flatpickr-day.selected:focus {
  background: var(--c-olive); border-color: var(--c-olive); color: #fff;
}
.textarea { height: auto; min-height: 96px; padding: 10px 14px; resize: vertical; font-family: var(--font-mono); font-size: 13px; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--c-lime); outline-offset: 1px; border-color: var(--c-olive); }
.label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
/* Instant field feedback (js/valuation/fieldcheck.js): error blocks the run, warn does not, ok echoes */
.field-msg { font-size: 12px; line-height: 1.4; }
.field-msg:empty { display: none; }
.field-msg.err { color: var(--c-error); }
.field-msg.warn { color: var(--c-warn); }
.field-msg.ok { color: var(--c-olive-ink); font-family: var(--font-mono); }
.input.invalid { border-color: var(--c-error); }
.input.warn { border-color: var(--c-warn-border); }
.req { color: var(--c-error); }

/* Segmented control */
.seg { display: inline-flex; background: var(--c-surface-3); border-radius: var(--r-seg); padding: 3px; gap: 2px; }
.seg button {
  height: var(--h-seg-btn); padding: 0 14px; border: 0; border-radius: var(--r-seg-btn);
  background: transparent; font-size: 13px; font-weight: 600; cursor: pointer;
}
.seg button.active { background: var(--c-surface); box-shadow: var(--shadow-card); }

/* Tags */
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.tag.auto { background: #F2F1EF; color: var(--c-muted); }
.tag.override { background: var(--c-override-soft); color: var(--c-override); }
.tag.public { background: var(--c-lime-soft); color: var(--c-olive-ink); }
.tag.private { background: #F2F1EF; color: var(--c-muted); }
.tag.qip { background: var(--c-lime-soft); color: var(--c-olive-ink); }
.tag.snp { background: var(--c-override-soft); color: var(--c-override); }
.tag.admin { background: var(--c-warn-soft); color: var(--c-warn); }
.tag.user, .tag.portfolio { background: #F2F1EF; color: var(--c-muted); }
.tag.patents { background: var(--c-override-soft); color: var(--c-override); }
.tag.active { background: var(--c-lime-soft); color: var(--c-olive-ink); }
.tag.inactive { background: var(--c-error-soft); color: var(--c-error); }

/* Help button (?) and inline help */
.help-btn {
  width: 26px; height: 26px; padding: 0; flex: 0 0 26px;
  border: 1px solid var(--c-line-input); border-radius: 13px;
  background: var(--c-surface); color: var(--c-muted);
  font-size: 12px; font-weight: 700; cursor: pointer;
}
.help-btn[aria-expanded="true"] { background: var(--c-anthracite); border-color: var(--c-anthracite); color: #fff; }
.help-text {
  font-size: 13px; line-height: 1.55; color: var(--c-text-2);
  background: var(--c-surface-2); border-radius: var(--r-control); padding: 10px 12px;
}

/* Hover tooltip for small info icons (ported from v1) */
.info-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 8px; border: 1px solid #A8A3A4;
  color: var(--c-muted); font-size: 10px; font-weight: 700; font-style: normal;
  cursor: help; vertical-align: middle; margin-left: 2px;
}
#mpv-tooltip {
  position: fixed; z-index: 10000; display: none; max-width: 320px;
  background: var(--c-anthracite); color: #fff; font-size: 12px; line-height: 1.5;
  padding: 8px 10px; border-radius: 8px; pointer-events: none; box-shadow: var(--shadow-float);
}

/* Status boxes */
.box { display: none; border-radius: var(--r-control); padding: 10px 14px; font-size: 13px; line-height: 1.5; }
.box.show { display: block; }
.box.error { background: var(--c-error-soft); color: var(--c-error); }
.box.ok { background: var(--c-lime-soft); color: var(--c-olive-ink); }
.box.warn { background: var(--c-warn-soft); color: var(--c-warn); }
.spinner { display: none; align-items: center; gap: 10px; font-size: 13px; color: var(--c-muted); }
.spinner.show { display: flex; }
.spinner::before {
  content: ''; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--c-line); border-top-color: var(--c-olive);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Notes under results (benchmark, plan, RBICS proxy) */
.note { display: none; margin-top: 12px; border-left: 3px solid var(--c-override); padding: 2px 0 2px 12px; font-size: 13px; line-height: 1.55; color: var(--c-override); }
.note.show { display: block; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; font-weight: 600; font-size: 12px; color: var(--c-muted); padding: 8px 10px; background: var(--c-surface-2); white-space: nowrap; }
table.tbl td { padding: 9px 10px; border-top: 1px solid var(--c-line-soft); vertical-align: middle; }
table.tbl td.num, table.tbl th.num { text-align: right; font-family: var(--font-mono); }
table.tbl tr.selected td { background: #F4F7E6; }
.empty { color: var(--c-muted); font-size: 13px; padding: 8px 0; }
.note.plan { border-left-color: var(--c-warn-line); color: var(--c-warn); }
