/* App-specific glue for the Cross Currency Quotes Tool.
 *
 * All colour and typography comes from the Grain design system (grain-ds.css) via its
 * semantic classes — text-primary, bg-neutral, heading-md, text-2-regular and so on.
 * This file only supplies what the DS bundle does NOT compile in: the library ships
 * only the utility classes its own 42 components happen to use, so common layout
 * helpers (max-width containers, tabular numerals, table borders) are absent.
 *
 * Any hex value below is copied verbatim from a DS token so the two stay consistent:
 *   --grain-navy       #283674  (text-primary)
 *   --grain-blue       #3D82F7  (brand-blue)
 *   --grain-border     #D4D7E3  (border-primary)
 *   --grain-border-2   #E9EBF1  (border-tertiary)
 *   --grain-neutral    #F4F5F8  (bg-neutral)
 */

:root {
  --grain-navy: #283674;
  --grain-blue: #3D82F7;
  --grain-secondary: #69729E;
  --grain-tertiary: #A9AFC7;
  --grain-border: #D4D7E3;
  --grain-border-2: #E9EBF1;
  --grain-neutral: #F4F5F8;
  --grain-warning: #FF842B;
  --grain-warning-bg: #FFF2E9;
  --grain-error: #FF8484;
  --grain-error-bg: #FFF2F2;
}

/* ---------- page shell ---------- */

body {
  background-color: var(--grain-neutral);
  min-height: 100vh;
}

.app-header {
  background-color: #fff;
  border-bottom: 1px solid var(--grain-border);
}

.container {
  width: 100%;
  max-width: 62rem;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.logo {
  height: 26px;
  width: auto;
  display: block;
}

.header-divider {
  width: 1px;
  height: 24px;
  background-color: var(--grain-border);
}

/* ---------- cards ---------- */

.card {
  background-color: #fff;
  border: 1px solid var(--grain-border);
  border-radius: 12px;
  padding: 1.5rem;
}

/* ---------- banners ---------- */

.banner {
  border-radius: 10px;
  padding: 0.875rem 1rem;
  border: 1px solid;
  display: flex;
  gap: 0.625rem;
  align-items: flex-start;
}

.banner-warning { background-color: var(--grain-warning-bg); border-color: #F5C9A8; }
.banner-error   { background-color: var(--grain-error-bg);   border-color: #F5BFBF; }

.banner-icon { flex-shrink: 0; margin-top: 1px; }

/* ---------- form controls (preflight strips native styling) ---------- */

.field-label {
  display: block;
  margin-bottom: 0.375rem;
  color: var(--grain-secondary);
}

select.grain-select,
input.grain-input {
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--grain-navy);
  background-color: #fff;
  border: 1px solid var(--grain-border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  min-width: 8.5rem;
  outline: none;
}

select.grain-select { padding-right: 2rem; cursor: pointer; }

select.grain-select:focus,
input.grain-input:focus {
  border-color: var(--grain-blue);
  box-shadow: 0 0 0 3px rgba(61, 130, 247, 0.15);
}

input.grain-input::placeholder { color: var(--grain-tertiary); }

/* tenor multi-select dropdown
 *
 * A native <select multiple> would need cmd-click and gives no clear affordance, so
 * this is a button plus a checkbox panel. The checkboxes are real form inputs inside
 * the form, so hiding the panel with [hidden] does not stop them submitting — only
 * `disabled` would. */

.dropdown { position: relative; display: inline-block; }

button.dropdown-toggle {
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 17rem;
  padding: 0.5rem 0.75rem;
  color: var(--grain-navy);
  background-color: #fff;
  border: 1px solid var(--grain-border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

button.dropdown-toggle:hover { border-color: var(--grain-tertiary); }

.dropdown.is-open button.dropdown-toggle,
button.dropdown-toggle:focus-visible {
  border-color: var(--grain-blue);
  box-shadow: 0 0 0 3px rgba(61, 130, 247, 0.15);
  outline: none;
}

#tenor-summary.is-placeholder { color: var(--grain-tertiary); }

.dropdown-caret { flex-shrink: 0; color: var(--grain-secondary); transition: transform 120ms ease; }
.dropdown.is-open .dropdown-caret { transform: rotate(180deg); }

.dropdown-panel {
  position: absolute;
  top: calc(100% + 0.375rem);
  left: 0;
  z-index: 20;
  min-width: 100%;
  background-color: #fff;
  border: 1px solid var(--grain-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(40, 54, 116, 0.12);
  padding: 0.5rem;
}

.dropdown-panel[hidden] { display: none; }

.dropdown-actions {
  display: flex;
  gap: 0.875rem;
  padding: 0.25rem 0.5rem 0.5rem;
  border-bottom: 1px solid var(--grain-border-2);
  margin-bottom: 0.375rem;
}

.dropdown-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(8rem, 1fr));
  gap: 0.0625rem 0.75rem;
}

.dropdown-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--grain-navy);
  user-select: none;
  white-space: nowrap;
}

.dropdown-option:hover { background-color: #F5F9FF; }

.dropdown-option input { position: absolute; opacity: 0; pointer-events: none; }

.dropdown-check {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  border: 1px solid var(--grain-border);
  border-radius: 4px;
  background-color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
}

.dropdown-option input:checked + .dropdown-check {
  background-color: var(--grain-blue);
  border-color: var(--grain-blue);
  color: #fff;
}

.dropdown-option input:focus-visible + .dropdown-check {
  box-shadow: 0 0 0 3px rgba(61, 130, 247, 0.15);
}

/* buttons */

button.grain-button {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25rem;
  background-color: var(--grain-blue);
  color: #fff;
  border: 1px solid var(--grain-blue);
  border-radius: 8px;
  padding: 0.5625rem 1.25rem;
  cursor: pointer;
}

button.grain-button:hover { background-color: #2E74EA; border-color: #2E74EA; }

button.grain-link {
  font-family: inherit;
  font-size: 0.75rem;
  background: none;
  border: 0;
  padding: 0;
  color: var(--grain-blue);
  cursor: pointer;
  text-decoration: underline;
}

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

.table-scroll { overflow-x: auto; }

table.grain-table {
  width: 100%;
  border-collapse: collapse;
}

table.grain-table th,
table.grain-table td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--grain-border-2);
  white-space: nowrap;
}

table.grain-table th {
  color: var(--grain-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.6875rem;
  font-weight: 600;
}

table.grain-table th:first-child,
table.grain-table td:first-child { padding-left: 0; }

table.grain-table th:last-child,
table.grain-table td:last-child { padding-right: 0; }

table.grain-table tbody tr:last-child td { border-bottom: 0; }

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ---------- misc ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.1875rem 0.625rem;
  background-color: #ECF2FE;
  color: var(--grain-blue);
  font-weight: 600;
}

.pill-sample { background-color: var(--grain-warning-bg); color: var(--grain-warning); }

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--grain-border-2);
}

details.legs summary {
  cursor: pointer;
  color: var(--grain-blue);
  font-weight: 500;
  list-style: none;
}

details.legs summary::-webkit-details-marker { display: none; }
details.legs summary::before { content: "▸ "; }
details.legs[open] summary::before { content: "▾ "; }

code.inline {
  background-color: var(--grain-neutral);
  border: 1px solid var(--grain-border-2);
  border-radius: 4px;
  padding: 0.0625rem 0.3125rem;
  font-size: 0.75rem;
}

.stack { display: flex; flex-direction: column; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.row-wrap { display: flex; flex-wrap: wrap; }
.items-end { align-items: flex-end; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.arrow-sep { color: var(--grain-tertiary); padding-bottom: 0.5625rem; }

/* "interpolated" tag — marks a rate derived between two published tenors rather
   than read from one. Visible without shouting: the number is legitimate (it is
   Grain's documented live-pricing method) but it is not a published rate. */
.tag-interp {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.0625rem 0.4375rem;
  border-radius: 999px;
  background-color: #ECF2FE;
  color: var(--grain-blue);
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
  white-space: nowrap;
}

/* Grain-styled calendar (replaces the unthemable native date popup) */

.cal-panel { min-width: 17.5rem; }

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.5rem 0.5rem;
  border-bottom: 1px solid var(--grain-border-2);
  margin-bottom: 0.375rem;
}

button.cal-nav {
  font-family: inherit;
  font-size: 1rem;
  line-height: 1;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--grain-border);
  border-radius: 6px;
  background-color: #fff;
  color: var(--grain-secondary);
  cursor: pointer;
}

button.cal-nav:hover:not(:disabled) { border-color: var(--grain-blue); color: var(--grain-blue); }
button.cal-nav:disabled { opacity: 0.35; cursor: default; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 2.25rem);
  gap: 0.125rem;
  padding: 0 0.25rem;
}

.cal-dow {
  text-align: center;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--grain-tertiary);
  padding: 0.25rem 0;
}

button.cal-day {
  font-family: inherit;
  font-size: 0.8125rem;
  height: 2.25rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--grain-navy);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

button.cal-day:hover:not(:disabled) { background-color: #ECF2FE; }
button.cal-day:disabled { color: var(--grain-border); cursor: default; }
button.cal-day.is-today { box-shadow: inset 0 0 0 1px var(--grain-border); }
button.cal-day.is-selected { background-color: var(--grain-blue); color: #fff; font-weight: 600; }
button.cal-day.is-selected:hover { background-color: var(--grain-blue); }

/* Weekends: no settlement, so a pick here rolls forward to the Monday. Muted
   rather than disabled — greying them out would leave someone whose invoice is
   dated a Saturday with nowhere to click and no explanation of where to go
   instead (Toam, 2026-08-02). They stay clickable and the roll is announced. */
button.cal-day.is-weekend:not(.is-selected) { color: var(--grain-tertiary); }

/* the weekend roll-forward notice under the date chips */
.date-note {
  margin: 0.5rem 0 0;
  color: var(--grain-secondary);
}

.date-note[hidden] { display: none; }

/* selected-date chips under the calendar field */

.date-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.date-chips:empty { display: none; }

.date-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.1875rem 0.375rem 0.1875rem 0.625rem;
  border: 1px solid var(--grain-border);
  border-radius: 999px;
  background-color: #fff;
  color: var(--grain-navy);
  white-space: nowrap;
}

button.date-chip-x {
  font-family: inherit;
  font-size: 0.8125rem;
  line-height: 1;
  width: 1rem;
  height: 1rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--grain-tertiary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.date-chip-x:hover { background-color: var(--grain-error-bg); color: var(--grain-error); }

/* radio chip toggle on the verify page */
.chip-toggle {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--grain-border);
  background-color: #fff;
  border-radius: 999px;
  padding: 0.3125rem 0.75rem;
  cursor: pointer;
  user-select: none;
  color: var(--grain-secondary);
}
.chip-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.chip-toggle:has(input:checked) {
  background-color: #ECF2FE;
  border-color: var(--grain-blue);
  color: var(--grain-blue);
  font-weight: 600;
}

/* sub-labels inside the unified Due date group */
.sub-label {
  display: block;
  margin-bottom: 0.3125rem;
  color: var(--grain-tertiary);
}

/* the "or" separator between the two ways of choosing a due date */
.date-or {
  padding-bottom: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- currency fields with flag pickers ---------- */

.ccy-field {
  border: 1px solid var(--grain-border);
  border-radius: 10px;
  padding: 0.625rem 0.75rem 0.6875rem;
  background-color: #fff;
}

.ccy-field:focus-within {
  border-color: var(--grain-blue);
  box-shadow: 0 0 0 3px rgba(61, 130, 247, 0.15);
}

.ccy-field-label {
  display: block;
  color: var(--grain-secondary);
  margin-bottom: 0.25rem;
}

.ccy-field-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ccy-field-hint {
  flex: 1;
  color: var(--grain-tertiary);
}

input.ccy-amount {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 1.125rem;
  line-height: 1.5rem;
  color: var(--grain-navy);
  border: 0;
  outline: none;
  background: none;
  padding: 0;
  font-variant-numeric: tabular-nums;
}

input.ccy-amount::placeholder { color: var(--grain-tertiary); }

.ccy-picker { flex-shrink: 0; }

button.ccy-toggle {
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  padding: 0.25rem 0.375rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--grain-navy);
  cursor: pointer;
}

button.ccy-toggle:hover { background-color: #F5F9FF; }

.flag-badge {
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 999px;
  background-color: var(--grain-neutral);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9375rem;
  line-height: 1;
  overflow: hidden;
  flex-shrink: 0;
}

.ccy-panel {
  right: 0;
  left: auto;
  min-width: 9rem;
  padding: 0.375rem;
}

button.ccy-option {
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.375rem 0.5rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--grain-navy);
  cursor: pointer;
  text-align: left;
}

button.ccy-option:hover { background-color: #F5F9FF; }

/* ---------- tenor pills ---------- */

.tenor-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.375rem;
}

.tenor-pill {
  display: inline-flex;
  flex: 0 0 auto;
  justify-content: center;
  align-items: center;
  border: 1px solid var(--grain-border);
  background-color: #fff;
  border-radius: 999px;
  padding: 0.375rem 0.75rem;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  color: var(--grain-secondary);
  transition: background-color 80ms ease, border-color 80ms ease, color 80ms ease;
}

.tenor-pill:hover { background-color: #F5F9FF; }
.tenor-pill input { position: absolute; opacity: 0; pointer-events: none; }

.tenor-pill:has(input:checked) {
  background-color: #ECF2FE;
  border-color: var(--grain-blue);
  color: var(--grain-blue);
  font-weight: 600;
}

.tenor-pill:has(input:focus-visible) { box-shadow: 0 0 0 3px rgba(61, 130, 247, 0.15); }

/* section label sitting directly above the currency fields — pull it closer to
   the field it introduces than the stack's default gap allows */

/* Currency fields, restructured 2026-08-02 to Toam's sketch: the label sits ABOVE
   the box ("You pay with" / "You want to receive") and does the explaining, so the
   redundant in-box hint is gone. The pay-with field has no amount, so its picker
   leads on the left with the caret pushed right. */

.ccy-picker-lead { margin-right: auto; }
.ccy-spacer { flex: 1; }

/* Restructured again 2026-08-02: both pickers are now identical rows (flag left,
   caret right) and the amount moved to its own row below them, so the two
   currency choices read as a matched pair instead of one plain and one loaded.
   The suffix names the currency the amount is in — it mirrors the To picker. */
.ccy-suffix {
  flex-shrink: 0;
  color: var(--grain-secondary);
}

.stack > .field-label + div > .ccy-field { margin-top: 0; }
.stack > .field-label + div { margin-top: -0.25rem; }
