.rate-sheet-page .standalone-rate-panel {
  background: linear-gradient(180deg, rgba(13, 24, 38, 0.98), rgba(8, 14, 24, 0.99)) !important;
  border-color: rgba(86, 185, 193, 0.22) !important;
  min-height: auto !important;
}

.rate-sheet-page .compact-card-head {
  border-bottom: 1px solid rgba(86, 185, 193, 0.16) !important;
  padding-bottom: 14px !important;
}

.rate-sheet-page .rate-sheet-action-panel {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  margin-left: auto;
  max-width: min(430px, 48%);
}

.rate-sheet-page .rate-sheet-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-left: 0;
}

.rate-sheet-page .rate-sheet-save-status,
.rate-sheet-page .rate-sheet-hint {
  margin: 0;
  color: #aebdca;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  text-align: right;
}

.rate-sheet-page .rate-sheet-save-status[data-state="saved"] {
  color: #9ee9dc;
}

.rate-sheet-page .rate-sheet-save-status[data-state="dirty"],
.rate-sheet-page .rate-sheet-save-status[data-state="saving"] {
  color: #e8cf8f;
}

.rate-sheet-page .rate-sheet-save-status[data-state="error"],
.rate-sheet-page .rate-sheet-save-status[data-state="conflict"],
.rate-sheet-page .rate-sheet-hint {
  color: #ffbdc2;
}

.rate-page-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 28px;
}

.rate-page-title-row h1 {
  margin: 2px 0 6px !important;
  color: #f5fbff !important;
  font-size: clamp(26px, 2.6vw, 36px) !important;
  font-weight: 950 !important;
  letter-spacing: -0.055em !important;
}

.rate-date-title {
  color: #67e8d7;
  border: 1px solid rgba(103, 232, 215, 0.22);
  background: rgba(103, 232, 215, 0.075);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.rate-sheet-page .editable-rate-grid {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 12px !important;
  align-items: start !important;
}

.rate-sheet-page .editable-rate-block {
  border-color: rgba(86, 185, 193, 0.24) !important;
  background: linear-gradient(180deg, rgba(9, 25, 40, 0.96), rgba(6, 15, 26, 0.98)) !important;
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.04) !important;
  overflow: visible !important;
}

.rate-sheet-page .editable-rate-title {
  background: linear-gradient(90deg, rgba(103, 232, 215, 0.08), transparent) !important;
  border-bottom: 1px solid rgba(86, 185, 193, 0.13) !important;
  padding: 9px 12px 7px !important;
}

.rate-sheet-page .editable-rate-title span {
  color: #67e8d7 !important;
  font-size: 13px !important;
}

.rate-sheet-page .editable-rate-title small {
  color: #96a8b8 !important;
}

.rate-sheet-page .rate-table-wrap {
  overflow: visible !important;
}

.rate-sheet-page .editable-rate-table {
  width: 100% !important;
  min-width: 0 !important;
  table-layout: fixed !important;
}

.rate-sheet-page .editable-rate-table th,
.rate-sheet-page .editable-rate-table td {
  padding: 3px !important;
}

.rate-sheet-page .editable-rate-table input,
.rate-sheet-page .rate-sort-header {
  min-height: 30px !important;
  border-radius: 6px !important;
  border: 1px solid #253145 !important;
  background: #0d1320 !important;
  color: #eef6fb !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  padding: 5px 6px !important;
}

/* styles.css points inputs at the undefined var(--mono); pin the real token. */
.rate-sheet-page .editable-rate-table input {
  font-family: var(--font-mono) !important;
}

.rate-sheet-page .rate-sort-header {
  width: 100%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: #c5fff7 !important;
  background: rgba(103, 232, 215, 0.1) !important;
  border-color: rgba(103, 232, 215, 0.24) !important;
}

.rate-sheet-page .rate-sort-header:hover,
.rate-sheet-page .rate-sort-header.active {
  border-color: rgba(103, 232, 215, 0.82) !important;
  box-shadow: 0 0 0 2px rgba(103, 232, 215, 0.18) !important;
}

/* Sort indicator: same stroke family and scale for the idle both-ways glyph
   and the active direction arrow (replaces the tiny fallback-font "↕"). */
.rate-sheet-page .rate-sort-header .rate-sort-icon {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  color: #67e8d7;
}

/* Bank names come from the counterparty list — plain row headers, no inputs.
   The global `.editable-rate-table th` block (styles.css tail) paints headers
   muted-grey UPPERCASE with !important, so these must out-!important it:
   registry short names render as written, bright, in the body face. */
.rate-sheet-page .editable-rate-table th.rate-bank-cell {
  padding: 5px 8px !important;
  color: #f6fbff !important;
  font-family: var(--font-sans) !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  letter-spacing: 0.01em !important;
  text-transform: none !important;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

/* The HKD/MOP corner is a label, not a field: nothing to focus or select. */
.rate-sheet-page .editable-rate-table th.rate-corner-cell {
  padding: 5px 8px !important;
  color: #c5fff7 !important;
  font-size: 11px !important;
  font-weight: 900 !important;
  letter-spacing: 0.06em !important;
  text-align: center;
  vertical-align: middle;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

/* Mobile plan R-2: this block used to stop at 720px, leaving the 721–1019px
   band with no scroll container at all; it now matches the ≤1019 mobile
   chrome cutoff. R-3/G-1: inputs go 16px (iOS focus-zoom floor — this sheet
   loads after styles.css, so the global floor there can't win) and the table
   widens to 1180px so 4-char rates still fit their columns. */
@media (max-width: 1019px) {
  .rate-sheet-page .editable-rate-block {
    overflow: hidden !important;
  }

  .rate-sheet-page .rate-table-wrap {
    max-width: 100%;
    overflow-x: auto !important;
    overscroll-behavior-inline: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
  }

  .rate-sheet-page .editable-rate-table {
    min-width: 1180px !important;
    table-layout: fixed !important;
  }

  .rate-sheet-page .editable-rate-table input {
    font-size: 16px !important;
  }

  .rate-sheet-page .editable-rate-table th:first-child,
  .rate-sheet-page .editable-rate-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    width: 108px;
    background: #091321 !important;
    box-shadow: 1px 0 0 rgba(103, 232, 215, 0.18);
  }

  .rate-sheet-page .editable-rate-table .rate-header-row th:first-child {
    z-index: 3;
  }

  /* Long short names must not overflow the 108px sticky column. */
  .rate-sheet-page .editable-rate-table th.rate-bank-cell {
    max-width: 108px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.rate-sheet-page .editable-rate-table td.rate-column-best {
  position: relative;
}

.rate-sheet-page .editable-rate-table td.rate-column-best::after {
  content: none !important;
  display: none !important;
}

@media (min-width: 1020px) {
  .rate-sheet-page .rate-sheet-main {
    padding-top: 14px !important;
    padding-bottom: 14px !important;
  }

  .rate-sheet-page .card-head.compact-card-head {
    padding-bottom: 10px !important;
  }

  .rate-sheet-page .card-sub {
    margin-bottom: 0 !important;
  }
}

.rate-sheet-page .editable-rate-table td.rate-column-best input {
  color: #eef6fb !important;
  background: #0d1320 !important;
  border-color: rgba(86, 185, 193, 0.82) !important;
  box-shadow:
    0 0 0 2px rgba(86, 185, 193, 0.48),
    0 0 0 4px rgba(86, 185, 193, 0.12) !important;
}

/* An empty cell whose week-high reference still beats every rate typed today:
   the same outline geometry as the best-rate ring, in grey — that bank might
   match its earlier quote again. */
.rate-sheet-page .editable-rate-table td.rate-column-prev-best input {
  border-color: rgba(174, 188, 201, 0.78) !important;
  box-shadow:
    0 0 0 2px rgba(174, 188, 201, 0.42),
    0 0 0 4px rgba(174, 188, 201, 0.12) !important;
}

.rate-sheet-page .editable-rate-table td.rate-column-prev-best input::placeholder {
  color: #cdd8e2;
}

/* Week-high reference. Empty cell: grey "(M) 2.85" placeholder. Typed cell:
   the reference flips to a left-aligned "2.85 (M)" overlay beside the rate. */
.rate-sheet-page .editable-rate-table input::placeholder {
  color: #7e93a6;
  font-weight: 700;
  opacity: 1;
}

.rate-sheet-page .editable-rate-table td {
  position: relative;
}

.rate-sheet-page .editable-rate-table .rate-week-ref {
  position: absolute;
  top: 50%;
  left: 10px;
  transform: translateY(-50%);
  display: none;
  color: #7e93a6;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}

.rate-sheet-page .editable-rate-table td.rate-cell-filled .rate-week-ref {
  display: block;
}

.rate-sheet-page .editable-rate-table td.rate-cell-filled.rate-has-ref input {
  padding-left: 48px !important;
}

/* Mobile plan R-7: the filled cell's week reference used to be dropped below
   the desktop breakpoint, leaving no way to see it on touch (the desktop
   affordance is a hover-adjacent overlay). It now sits under the value on its
   own line instead of beside it. */
@media (max-width: 1019px) {
  /* Filled cells only — empty cells already show the ref as the input's
     placeholder, and doubling it would read as two quotes. */
  .rate-sheet-page .editable-rate-table td.rate-cell-filled .rate-week-ref {
    display: block !important;
    top: auto !important;
    bottom: 1px !important;
    left: 6px !important;
    transform: none !important;
    font-size: 10px !important;
  }

  .rate-sheet-page .editable-rate-table td.rate-cell-filled.rate-has-ref input {
    padding-left: 6px !important;
    padding-bottom: 14px !important;
  }

  /* R-4: 30px cells and sort headers on a touch surface. */
  .rate-sheet-page .editable-rate-table input,
  .rate-sheet-page .rate-sort-header {
    min-height: 44px !important;
  }

  /* R-6: proximity snapping keeps whole rate columns in view — a half-column
     of digits reads as a real (wrong) rate. */
  .rate-sheet-page .rate-table-wrap {
    scroll-snap-type: x proximity;
    scroll-padding-left: 108px;
  }
  .rate-sheet-page .editable-rate-table td,
  .rate-sheet-page .editable-rate-table th {
    scroll-snap-align: start;
  }
}

/* Focused cell: a blue ring, unmistakably different from the teal best-rate
   outline and the grey week-reference outline. The td-scoped selector ties the
   best/prev-best rules' specificity and, being last, wins — focus must show
   even on a highlighted cell. */
.rate-sheet-page .editable-rate-table td input:focus {
  outline: none !important;
  border-color: #8ec1ff !important;
  background: #101a2e !important;
  box-shadow:
    0 0 0 2px rgba(142, 193, 255, 0.38),
    0 0 0 5px rgba(142, 193, 255, 0.14) !important;
}

.rate-sheet-page .editable-rate-table td.rate-cell-conflict input,
.rate-sheet-page .editable-rate-table th.rate-cell-conflict input {
  border-style: double !important;
  border-color: #ff8f99 !important;
  box-shadow: 0 0 0 2px rgba(255, 143, 153, 0.2) !important;
}

@media (max-width: 720px) {
  .rate-page-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .rate-sheet-page .compact-card-head {
    align-items: stretch;
    flex-direction: column;
  }

  .rate-sheet-page .compact-card-head > :first-child {
    min-width: 0;
    width: 100%;
  }

  .rate-sheet-page .rate-sheet-action-panel {
    align-items: flex-start;
    margin-left: 0;
    max-width: none;
    width: 100%;
  }

  .rate-sheet-page .rate-sheet-actions {
    justify-content: flex-start;
  }

  .rate-sheet-page .rate-sheet-save-status,
  .rate-sheet-page .rate-sheet-hint {
    text-align: left;
  }
}
