/*
 * @cfm/provider-tg — provider console styles ("Лаконичный свет" + IBM Plex).
 *
 * The operator console for exchange providers: publish your OWN rate (attested +
 * fat-finger advisory), auto-price on YOUR spread, set office cash limits, manage
 * offices, create tradeable pairs, and read a KYB-locked profile. RBAC adds no
 * platform capability; every write is a provider-side action the provider owns.
 *
 * Design tokens + the self-hosted Plex faces live in tokens.css (shared, byte-
 * identical with the client — guarded by a sync test). This sheet is component
 * styling only; it references var(--…) tokens exclusively, restyling the existing
 * class vocabulary (panel / offer-card / membership-card / badge / switch …) in
 * place and adding a bottom tab bar for the console's top-level navigation.
 */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  background: var(--bg);
}

body {
  color: var(--ink);
  font-family: var(--ff);
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ *
 * Shell — a phone-width column; the bottom tab bar clears via padding.
 * ------------------------------------------------------------------ */

.shell {
  max-width: var(--col);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 8px 18px calc(84px + env(safe-area-inset-bottom));
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--line);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 0 12px;
  background: var(--bg);
}

.topbar h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

h2 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

h3 {
  font-size: 15px;
  font-weight: 600;
}

.status-line {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.status-line.is-error {
  color: var(--danger);
}

/* ------------------------------------------------------------------ *
 * Panels → clean cards; a bare disclaimer-only panel reads as a quiet note.
 * ------------------------------------------------------------------ */

.panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--s1);
  overflow: hidden;
}

.panel-heading {
  padding: 12px 14px 0;
}

.panel-heading h2 {
  color: var(--muted);
}

.panel-body {
  padding: 13px 14px;
}

.panel:has(> .panel-body > .disclaimer:only-child) {
  border: 0;
  background: var(--s2);
  border-radius: var(--r-md);
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.disclaimer {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin-top: 6px;
}

.disclaimer:first-child {
  margin-top: 0;
}

.empty {
  padding: 18px 6px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.mono {
  font-family: var(--mono);
  font-weight: 500;
}

/* ------------------------------------------------------------------ *
 * Fields
 * ------------------------------------------------------------------ */

.field {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  min-width: 0;
}

.field span {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--s1);
  color: var(--ink);
  padding: 11px 12px;
  font-size: 15px;
  font-weight: 600;
  outline: none;
}

textarea {
  min-height: 78px;
  resize: vertical;
  line-height: 1.45;
  font-weight: 400;
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
  font-weight: 400;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--asoft);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 10px;
}

.form-grid .field.span-2 {
  grid-column: 1 / -1;
}

/* ------------------------------------------------------------------ *
 * Buttons
 * ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--s1);
  color: var(--ink);
  padding: 0 16px;
  font-family: var(--ff);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
}

.btn.block {
  width: 100%;
  margin-top: 12px;
}

.btn.primary {
  background: var(--accent);
  color: var(--on);
  border-color: transparent;
}

.btn.ok {
  color: var(--accent);
}

.btn:disabled,
.is-busy {
  opacity: 0.5;
  pointer-events: none;
}

.btn-row {
  display: flex;
  gap: 9px;
  margin-top: 12px;
}

.btn-row .btn {
  margin-top: 0;
  flex: 1 1 auto;
}

.text-button {
  border: 0;
  background: none;
  color: var(--accent);
  font-family: var(--ff);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 0;
}

/* Nav grid → a 2-col tile menu (the "Setup" section). */
.nav-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 4px;
}

.nav-grid .btn {
  margin-top: 0;
}

/* ------------------------------------------------------------------ *
 * Lists + cards (offers, memberships, liquidity, offices, pricing)
 * ------------------------------------------------------------------ */

.list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 12px;
}

.offer-card,
.membership-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--s1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 13px;
  color: var(--ink);
  font-family: var(--ff);
}

.membership-card.is-active {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: var(--asoft);
}

.membership-card.is-selectable:active,
.offer-card.is-selectable:active {
  background: var(--s2);
}

.offer-head,
.membership-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.offer-head strong,
.membership-head strong {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.offer-rate {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.offer-rate .mono {
  font-size: 20px;
  letter-spacing: -0.01em;
}

.offer-meta {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 9px;
  line-height: 1.5;
}

/* Rate publish / pricing edit block inside a card */
.rate-form,
.pricing-inline {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.flag-box {
  border: 1px solid color-mix(in srgb, var(--warn) 34%, var(--line));
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--warn) 12%, var(--s1));
  color: var(--warn);
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}

.confirm-btn {
  margin-top: 4px;
}

/* ------------------------------------------------------------------ *
 * Badges + chips
 * ------------------------------------------------------------------ */

.badge {
  flex: none;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--s2);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.st-role {
  background: var(--asoft);
  color: var(--aink);
}

.badge.st-on,
.badge.st-fresh {
  background: color-mix(in srgb, var(--pos) 14%, var(--s1));
  color: var(--pos);
}

.badge.st-off,
.badge.st-stale,
.badge.st-pin {
  background: color-mix(in srgb, var(--warn) 16%, var(--s1));
  color: var(--warn);
}

.badge.st-off,
.badge.st-pin {
  background: var(--s2);
  color: var(--muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}

.chip {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--s2);
  padding: 3px 8px;
  border-radius: 5px;
  word-break: break-word;
}

/* ------------------------------------------------------------------ *
 * Key/value (profile, summaries)
 * ------------------------------------------------------------------ */

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-top: 8px;
}

.kv dt,
.kv dd {
  padding: 11px 13px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  text-align: right;
  font-weight: 600;
  word-break: break-word;
}

.kv dt:first-of-type,
.kv dd:first-of-type {
  border-top: 0;
}

/* ------------------------------------------------------------------ *
 * Checkboxes / switch
 * ------------------------------------------------------------------ */

.checkbox-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.checkbox-field input[type="checkbox"] {
  width: 21px;
  height: 21px;
  flex: none;
  accent-color: var(--accent);
}

.checkbox-field span {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.4;
}

.chks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.chks label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 7px 12px;
  background: var(--s1);
}

.chks input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.switch input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 42px;
  height: 25px;
  border-radius: var(--r-pill);
  background: var(--s2);
  border: 1px solid var(--line);
  position: relative;
  flex: none;
  transition: background 0.12s;
}

.switch input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: left 0.12s;
}

.switch input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: transparent;
}

.switch input[type="checkbox"]:checked::after {
  left: 19px;
}

.switch-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.pricing-toggle-field {
  align-content: start;
}

/* ------------------------------------------------------------------ *
 * Notices
 * ------------------------------------------------------------------ */

.notice {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--s2);
  color: var(--ink);
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  margin-top: 12px;
}

.notice.is-info {
  border-color: color-mix(in srgb, var(--accent) 26%, var(--line));
  background: var(--asoft);
  color: var(--aink);
}

.notice.is-ok {
  border-color: color-mix(in srgb, var(--pos) 30%, var(--line));
  background: color-mix(in srgb, var(--pos) 9%, var(--s1));
  color: var(--pos);
}

.notice.is-error {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--line));
  background: color-mix(in srgb, var(--danger) 8%, var(--s1));
  color: var(--danger);
}

.notice.is-warn {
  border-color: color-mix(in srgb, var(--warn) 34%, var(--line));
  background: color-mix(in srgb, var(--warn) 12%, var(--s1));
  color: var(--warn);
}

/* ------------------------------------------------------------------ *
 * Bottom tab bar — the console's top-level navigation.
 * ------------------------------------------------------------------ */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  max-width: var(--col);
  margin: 0 auto;
  border-top: 1px solid var(--line);
  background: var(--s1);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar.hidden {
  display: none !important;
}

.tabbar button {
  flex: 1;
  border: 0;
  background: none;
  color: var(--faint);
  font-family: var(--ff);
  font-size: 10px;
  font-weight: 600;
  padding: 9px 2px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.tabbar button .ic {
  width: 20px;
  height: 20px;
}

.tabbar button.is-active {
  color: var(--accent);
}
