/* Rakhmet Dashboard — Google/Material-like look with rakhmet.com palette */
:root {
  --brand-blue: #3c67a6;
  --brand-navy: #282b62;
  --brand-sky: #55a8db;
  --brand-light: #59b3e4;
  --brand-bright: #4179e5;
  --brand-ink: #000d1a;
  --brand-tint: #f0f5ff;
  --nav-active: #e1eaff;
  --border: #dde3ec;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --text: #1f2430;
  --muted: #5f6b7d;
  --ok: #1e8e3e;
  --ok-bg: #e6f4ea;
  --err: #d93025;
  --err-bg: #fce8e6;
  --wait: #b06000;
  --wait-bg: #fef7e0;
  --shadow: 0 1px 2px rgba(60, 64, 67, .15), 0 1px 3px 1px rgba(60, 64, 67, .08);
  --on-primary: #ffffff;
  --primary-hover: #335a93;
  --input-border: #c4cbd6;
  --table-head: #fafbfd;
  --row-border: #edf0f5;
  --chart-prev: #59b3e4;
  color-scheme: light;
  --radius: 12px;
  --topbar-h: 64px;
  --drawer-w: 248px;
}

/* Night theme: dark palette of rakhmet.com. Set by theme.js as <html data-theme="dark">. */
:root[data-theme="dark"] {
  --brand-blue: #55a8db;
  --brand-navy: #eef3fb;
  --brand-ink: #eef3fb;
  --brand-bright: #8fb4f0;
  --brand-tint: #1a2a47;
  --nav-active: #1a2a47;
  --border: #24365a;
  --bg: #0b1324;
  --surface: #111d33;
  --text: #eef3fb;
  --muted: #9aa8bd;
  --ok: #81c995;
  --ok-bg: #16352a;
  --err: #f28b82;
  --err-bg: #3c1f24;
  --wait: #fdd663;
  --wait-bg: #3a3214;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 1px 3px 1px rgba(0, 0, 0, .3);
  --on-primary: #000d1a;
  --primary-hover: #6db7e3;
  --input-border: #34496f;
  --table-head: #15233d;
  --row-border: #1d2d4b;
  --chart-prev: #8fb4f0;
  color-scheme: dark;
}

/* Logo: dark-text version by day, white-text version at night */
:root .logo-night { display: none; }
:root[data-theme="dark"] .logo-day { display: none; }
:root[data-theme="dark"] .logo-night { display: inline-block; }

/* Theme switch: icon-only segmented control */
.theme-switch { display: flex; gap: 2px; padding: 2px; border-radius: 18px; background: var(--brand-tint); }
.theme-switch button {
  border: 0; background: transparent; width: 32px; height: 28px; border-radius: 14px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted);
}
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--brand-blue); box-shadow: var(--shadow); }
.theme-switch.center { justify-content: center; width: max-content; margin: 16px auto 0; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Roboto, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 22px; font-weight: 400; margin: 0; color: var(--brand-ink); }
h2 { font-size: 15px; font-weight: 500; margin: 0 0 12px; color: var(--brand-navy); }
a { color: var(--brand-bright); text-decoration: none; }
.muted { color: var(--muted); }
.mono { font-family: "Roboto Mono", ui-monospace, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ell.narrow { max-width: 160px; }
.ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up { color: var(--ok); }
.down { color: var(--err); }

/* Top app bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand img { display: block; }
.spacer { flex: 1; }
.icon-btn {
  border: 0; background: transparent; width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--bg); }
.menu-btn { display: none; }
.lang-switch { display: flex; gap: 4px; }
.lang-switch a {
  padding: 6px 10px; border-radius: 16px; color: var(--muted); font-weight: 500; font-size: 13px;
}
.lang-switch a.active { background: var(--brand-tint); color: var(--brand-blue); }
.lang-switch.center { justify-content: center; margin-top: 20px; }
.user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--brand-blue); color: var(--on-primary);
  display: flex; align-items: center; justify-content: center; font-weight: 500;
}
.user-name { font-weight: 500; font-size: 13px; }
.user-sub { font-size: 12px; color: var(--muted); }
.user form { margin: 0; }
.user-link { display: flex; align-items: center; gap: 10px; color: inherit; padding: 4px 10px 4px 4px; border-radius: 22px; }
.user-link:hover { background: var(--brand-tint); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Profile */
.profile { display: grid; gap: 16px; max-width: 1100px; align-content: start; }
.profile-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.profile-head form { margin: 0 0 0 auto; }
.avatar-lg { width: 64px; height: 64px; font-size: 28px; }
.profile-who { min-width: 0; }
.profile-name { font-size: 22px; color: var(--brand-ink); margin-bottom: 4px; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: 10px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.crumbs { color: var(--text); }
.hint-text { margin: -4px 0 14px; font-size: 13px; }
.theme-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.theme-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 8px 12px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer;
}
.theme-card:hover { border-color: var(--input-border); }
.theme-card[aria-pressed="true"] { border: 2px solid var(--brand-blue); padding: 9px 7px 11px; color: var(--brand-blue); font-weight: 500; }
.theme-preview { position: relative; display: block; width: 100%; height: 56px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.theme-preview i { position: absolute; left: 0; top: 0; bottom: 0; width: 26%; }
.theme-preview b { position: absolute; left: 34%; right: 10%; top: 22%; height: 26%; border-radius: 4px; }
.tp-light { background: #f3f5f9; } .tp-light i { background: #ffffff; } .tp-light b { background: #3c67a6; }
.tp-dark { background: #0b1324; } .tp-dark i { background: #111d33; } .tp-dark b { background: #55a8db; }
.tp-system { background: linear-gradient(135deg, #f3f5f9 50%, #0b1324 50%); }
.tp-system i { background: linear-gradient(135deg, #ffffff 50%, #111d33 50%); }
.tp-system b { background: linear-gradient(90deg, #3c67a6 50%, #55a8db 50%); }

/* Layout */
.layout { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.drawer {
  width: var(--drawer-w); flex-shrink: 0; padding: 12px 12px 12px 0; background: var(--surface);
  border-right: 1px solid var(--border);
}
.drawer a {
  display: flex; align-items: center; gap: 16px;
  height: 44px; padding: 0 24px; margin-bottom: 2px;
  border-radius: 0 22px 22px 0; color: var(--text); font-weight: 500;
}
.drawer a svg { color: var(--muted); }
.drawer-section { padding: 16px 24px 6px; font-size: 11px; font-weight: 500; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.drawer a:hover { background: var(--bg); }
.drawer a.active { background: var(--nav-active); color: var(--brand-navy); }
.drawer a.active svg { color: var(--brand-blue); }
.content { flex: 1; min-width: 0; padding: 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 16px; }
.period { margin: -4px 0 16px; }

/* Cards */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px;
}
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-size: 26px; font-weight: 400; color: var(--brand-ink); margin: 8px 0 6px; white-space: nowrap; }
.kpi-value .cur { font-size: 14px; color: var(--muted); margin-left: 6px; }
.kpi-foot { display: flex; gap: 8px; font-size: 12.5px; align-items: baseline; }
.delta { font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1.4fr); gap: 16px; }
.cards-tops { margin-top: 16px; }
.cards-tops .hint-text { margin: -6px 0 10px; font-size: 12px; }
.chart-box { position: relative; height: 280px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); border: 0; padding: 0; margin: 0; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; }
.field-input {
  height: 40px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--text);
  border: 1px solid var(--input-border); border-radius: 8px; background: var(--surface); min-width: 0;
}
.field-input:focus { outline: none; border-color: var(--brand-blue); box-shadow: 0 0 0 1px var(--brand-blue); }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.toolbar select.field-input { max-width: 280px; }
.filters {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; align-items: end; margin-bottom: 16px;
}
.filters .wide { grid-column: span 2; }
.datetime { display: grid; grid-template-columns: minmax(0, 1fr) 76px; gap: 6px; }
.time-input { text-align: center; font-variant-numeric: tabular-nums; }
.time-input:invalid { border-color: var(--err); }
.filters .field:has(.datetime) { grid-column: span 2; }
/* Payments filters: flowing row, each field keeps its natural width and wraps as a whole */
.ops-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 16px; }
.ops-filters > .field { flex: 0 0 auto; width: 190px; }
.ops-filters > .field.period-field { width: auto; }
.ops-filters > .field.states { width: auto; }
.ops-filters .checks { min-height: 40px; flex-wrap: nowrap; gap: 14px; }
.ops-filters .filter-actions { margin-left: auto; }
.ops-filters .hint { flex-basis: 100%; }
.ops-filters .period { flex-wrap: nowrap; }
@media (max-width: 860px) {
  .ops-filters > .field { width: calc(50% - 8px); }
  .ops-filters > .field.period-field, .ops-filters > .field.states { width: 100%; }
  .ops-filters .period { flex-wrap: wrap; }
  .ops-filters .checks { flex-wrap: wrap; }
  .ops-filters .filter-actions { margin-left: 0; }
}
@media (max-width: 480px) { .ops-filters > .field { width: 100%; } }
/* Period "С" / "По": one text field "YYYY.MM.DD HH:MM" + calendar button (native datetime-local picker) */
.ops-filters > .field.dt-field { width: 200px; }
.dt { position: relative; }
.dt-input { width: 100%; padding-right: 38px; font-variant-numeric: tabular-nums; }
.dt-input:invalid { border-color: var(--err); }
.dt .date-btn { right: 4px; }
@media (max-width: 860px) { .ops-filters > .field.dt-field { width: calc(50% - 8px); } }
@media (max-width: 480px) { .ops-filters > .field.dt-field { width: 100%; } }
/* Compact period: [date][time] — [date][time] in one row */
.filters .period-field { grid-column: span 2; }
.period { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.period .date-field { width: 128px; }
.period .date-input { padding-left: 8px; padding-right: 30px; font-size: 13px; }
.period .date-btn { width: 26px; height: 26px; right: 2px; }
.period .time-input { width: 56px; padding: 0 4px; font-size: 13px; }
.period-sep { color: var(--muted); padding: 0 2px; }
.filters .states { grid-column: span 2; }
.checks { display: flex; gap: 14px; flex-wrap: wrap; min-height: 40px; align-items: center; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; cursor: pointer; }
.check input { accent-color: var(--brand-blue); width: 16px; height: 16px; }
.filter-actions { display: flex; gap: 8px; }
.hint { grid-column: 1 / -1; margin: 0; font-size: 12px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 20px; border-radius: 20px; border: 0; font: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap; letter-spacing: .1px;
}
.btn-primary { background: var(--brand-blue); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow); }
.btn-outline { border: 1px solid var(--input-border); color: var(--brand-blue); background: var(--surface); }
.btn-outline:hover { background: var(--brand-tint); }
.btn-text { background: transparent; color: var(--brand-blue); padding: 0 12px; }
.btn-text:hover { background: var(--brand-tint); }
.btn-block { width: 100%; }
.btn.disabled { pointer-events: none; opacity: .4; }

/* Chips & totals */
.chip {
  display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 500;
  background: var(--bg); color: var(--muted);
}
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.err { background: var(--err-bg); color: var(--err); }
.chip.wait { background: var(--wait-bg); color: var(--wait); }
.dir-filters { grid-template-columns: minmax(220px, 2fr) minmax(160px, 1fr) auto; }
.dir-filters .wide { grid-column: auto; }
@media (max-width: 860px) { .dir-filters { grid-template-columns: 1fr; } }
.sub { font-size: 12px; color: var(--muted); }
a.cell-link { color: inherit; }
a.cell-link:hover { color: var(--brand-bright); text-decoration: underline; }
.route-arrow { padding-left: 0; padding-right: 0; font-size: 16px; }
.totals { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.total-chip {
  display: flex; align-items: center; gap: 8px; background: var(--surface); box-shadow: var(--shadow);
  border-radius: 20px; padding: 6px 14px;
}

/* Tables */
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--muted);
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--table-head); white-space: nowrap;
}
.table th.num { text-align: right; }
.table td { white-space: nowrap; padding: 10px 16px; border-bottom: 1px solid var(--row-border); vertical-align: middle; }
.table tbody tr:hover { background: var(--brand-tint); }
.table.compact td, .table.compact th { padding: 8px 6px; background: transparent; }
.empty { padding: 32px; text-align: center; margin: 0; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 12px 16px; }

/* Date field YYYY.MM.DD + calendar button */
.date-field { position: relative; min-width: 0; }
.date-input { width: 100%; padding-right: 38px; font-variant-numeric: tabular-nums; }
.date-input:invalid { border-color: var(--err); }
.date-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border: 0;
  border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.date-btn:hover { background: var(--brand-tint); color: var(--brand-blue); }
.date-native { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.field.inline .date-field { width: 150px; }

/* Multi-ID fields: one line, count badge inside */
.ids-wrap { position: relative; }
.ids-input { width: 100%; padding-right: 40px; font-family: "Roboto Mono", ui-monospace, monospace; font-size: 13px; text-overflow: ellipsis; }
.ids-input.bad { border-color: var(--err); }
.ids-count {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%); display: none;
  min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; align-items: center; justify-content: center;
  background: var(--brand-tint); color: var(--brand-blue); font-size: 11px; font-weight: 500; pointer-events: none;
}
.ids-count.on { display: inline-flex; }
.ids-count.err { background: var(--err-bg); color: var(--err); }
.ids-hint { color: var(--err); font-size: 11.5px; }
.table td .cur { color: var(--muted); font-size: 12px; }

/* Multi-select dropdown (points filter) */
.ms { position: relative; }
.ms-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 6px; cursor: pointer; text-align: left; }
.ms-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-toggle[aria-expanded="true"] { border-color: var(--brand-blue); box-shadow: 0 0 0 1px var(--brand-blue); }
.ms-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.ms-panel {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; width: max(100%, 340px); max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 8px;
}
.ms-panel.ms-right { left: auto; right: 0; }
.ms-top { display: flex; gap: 6px; margin-bottom: 6px; }
.ms-search { flex: 1; height: 36px; }
.ms-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; }
.ms-list label { display: grid; grid-template-columns: 18px minmax(0, 1fr); column-gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; color: var(--text); font-size: 13.5px; }
.ms-list label:hover { background: var(--brand-tint); }
.ms-list input { grid-row: span 2; margin-top: 2px; accent-color: var(--brand-blue); }
.ms-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-empty { padding: 8px; }

/* Clickable payment rows */
.row-link { cursor: pointer; }
.row-link:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: -2px; }

/* Modal (native <dialog>) */
.modal {
  width: min(960px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0;
  border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.modal::backdrop { background: rgba(8, 15, 30, .5); }
.modal[open] { display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 14px 24px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 500; }
.modal-body { overflow: auto; padding: 20px 24px 24px; }
.modal-msg { padding: 24px 0; text-align: center; }
.opd { display: grid; gap: 20px; }
.opd h3 { font-size: 13px; font-weight: 500; color: var(--brand-navy); margin: 0 0 10px; text-transform: uppercase; letter-spacing: .4px; }
.opd-head { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.opd-id { font-size: 18px; }
.opd-sum { font-size: 26px; color: var(--brand-ink); }
.opd-sum small { font-size: 14px; color: var(--muted); margin-left: 6px; }
.opd-status { margin-left: auto; text-align: right; }
.opd-error { padding: 10px 14px; border-radius: 8px; background: var(--err-bg); color: var(--err); display: grid; gap: 4px; }
.opd-provider-reason { word-break: break-word; }
.provider-reason { color: var(--err); }
.opd-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }
.opd-grid section h3 + .kv + h3 { margin-top: 18px; }
.opd-note { margin: -4px 0 10px; font-size: 12.5px; }
.attrs { grid-template-columns: minmax(140px, 30%) 1fr; }
.attr-value { white-space: pre-wrap; word-break: break-all; max-height: 7.5em; overflow: auto; font-family: "Roboto Mono", ui-monospace, monospace; font-size: 12.5px; }
.num-l { font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .opd-status { margin-left: 0; text-align: left; } .modal-body { padding: 16px; } }

/* Tabs (payment details) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: -4px; }
.tab {
  position: relative; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 500;
  padding: 10px 16px; cursor: pointer; border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--text); background: var(--brand-tint); }
.tab[aria-selected="true"] { color: var(--brand-blue); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--brand-blue); }
.tab:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: -2px; }
.tab-count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand-tint); color: var(--brand-blue); font-size: 11px; line-height: 18px; text-align: center; }
.tab-panel[hidden] { display: none; }
.attr-table td { vertical-align: top; white-space: normal; }
.masked { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.masked .mono { color: var(--text); }
.attr-table td.mono { white-space: nowrap; }
.log-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.log-list > li + li { border-top: 1px solid var(--row-border); }
.log-row summary {
  display: grid; grid-template-columns: 16px 150px minmax(80px, 140px) 44px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 7px 12px; cursor: pointer; list-style: none; font-size: 12.5px;
}
.log-row summary::-webkit-details-marker { display: none; }
.log-row summary::before { content: "›"; color: var(--muted); font-size: 16px; line-height: 1; transition: transform .15s; }
.log-row[open] summary::before { transform: rotate(90deg); }
.log-row summary:hover { background: var(--brand-tint); }
.log-row summary:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: -2px; }
.log-row[open] summary { background: var(--table-head); border-bottom: 1px solid var(--row-border); }
.log-time { white-space: nowrap; }
.log-person { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: "Roboto Mono", ui-monospace, monospace; font-size: 12px; }
.log-row[open] .log-preview { color: var(--muted); }
.log-size { white-space: nowrap; font-size: 11.5px; }
.log-format { visibility: hidden; justify-self: start; padding: 1px 6px; border-radius: 6px; font-size: 10.5px; font-weight: 500; letter-spacing: .3px; background: var(--brand-tint); color: var(--brand-blue); }
.log-format.on { visibility: visible; }
.log-format.fmt-xml { background: var(--ok-bg); color: var(--ok); }
.log-format.fmt-html { background: var(--wait-bg); color: var(--wait); }
.log-format.fmt-form { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.log-text {
  margin: 0; padding: 10px 12px 12px 40px; max-height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font-family: "Roboto Mono", ui-monospace, monospace; font-size: 12px; line-height: 1.5; color: var(--text);
}
@media (max-width: 700px) { .log-row summary { grid-template-columns: 16px auto minmax(0, 1fr); } .log-person, .log-size, .log-format { display: none; } }

/* Alerts */
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; }
.alert-error { background: var(--err-bg); color: var(--err); }
.alert-info { background: var(--brand-tint); color: var(--brand-blue); }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 28px; padding: 40px 40px 28px; text-align: center;
}
.login-logo { height: 40px; margin-bottom: 20px; }
.login-card h1 { font-size: 24px; margin-bottom: 6px; }
.login-card > p { margin: 0 0 24px; }
.login-card form { text-align: left; display: flex; flex-direction: column; gap: 16px; }
.login-card .btn-block { margin-top: 8px; }

/* Responsive */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  .drawer {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: 15;
    transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow);
  }
  body.nav-open .drawer { transform: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .user-meta { display: none; }
  .filters .wide, .filters .states { grid-column: auto; }
}
@media (max-width: 520px) {
  .brand img { height: 26px; }
  .login-card { padding: 28px 20px 20px; border: 0; }
  .kpi-value { font-size: 22px; }
}

/* Developer portal (/developers) */
.dev { display: grid; gap: 16px; align-content: start; max-width: 1280px; }
.dev .page-head { margin-bottom: 0; }
.dev h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dev-desc { margin: 0; max-width: 900px; line-height: 1.55; color: var(--text); }
.dev-hero h1 { font-size: 28px; margin: 6px 0 8px; }
.dev-hero p { line-height: 1.55; max-width: 900px; }
.dev-hero .lead { font-size: 16px; color: var(--muted); margin: 0 0 8px; }
.dev-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--brand-tint); color: var(--brand-blue); font-size: 11.5px; font-weight: 500; }
.tag.warn { background: var(--wait-bg); color: var(--wait); margin-left: 6px; }
.small { font-size: 12.5px; }
.wrap { white-space: normal !important; min-width: 240px; line-height: 1.45; }
.method-badge { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--ok-bg); color: var(--ok); font: 600 11px/18px "Roboto Mono", ui-monospace, monospace; letter-spacing: .3px; }
.method-badge.lg { font-size: 13px; line-height: 24px; padding: 0 10px; }
.dev-nav a .method-badge { width: 40px; text-align: center; flex-shrink: 0; }
.dev-nav a { gap: 12px; }
.dev-endpoint { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin: 12px 0 4px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); }
.dev-endpoint code { overflow-wrap: anywhere; }
.dev-endpoint.inline { margin: 8px 0 0; padding: 6px 12px; display: inline-flex; }
.dev-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.dev-steps, .dev-list { margin: 0; padding-left: 20px; line-height: 1.7; }
.dev-person { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--brand-tint); }
.dev-person .avatar { width: 40px; height: 40px; font-size: 18px; }
.card-title { padding: 16px 16px 0; }
.card-sub { margin: -4px 16px 12px; font-size: 13px; }
.card-foot { margin: 0; padding: 10px 16px 14px; }
.dev-table td { vertical-align: top; }
.dev-next { margin: 0; }
.req { color: var(--err); font-style: normal; }
.warn-text { color: var(--wait) !important; }

.dev-console { display: grid; gap: 16px; }
.dev-console-head, .dev-response-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dev-console-head h2, .dev-response-head h2 { margin: 0; }
.dev-console-body { display: grid; grid-template-columns: minmax(300px, 5fr) minmax(0, 7fr); gap: 20px; align-items: start; }
.dev-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; margin: 0; }
.dev-form .span2 { grid-column: 1 / -1; }
.dev-form .field > span { display: flex; gap: 4px; align-items: baseline; font-family: "Roboto Mono", ui-monospace, monospace; font-size: 11.5px; }
.dev-form .field em { font-style: normal; font-family: Roboto, "Segoe UI", Arial, sans-serif; }
.dev-form .field-input { width: 100%; min-width: 0; }
.dev-form.inner { margin-top: 10px; }
.input-btn { display: flex; gap: 4px; align-items: center; }
.input-btn .icon-btn { width: 36px; height: 36px; flex-shrink: 0; }
.dev-more summary { cursor: pointer; color: var(--brand-blue); font-weight: 500; font-size: 13px; padding: 4px 0; }
.dev-code { min-width: 0; display: grid; gap: 8px; }
.code-tabs { overflow-x: auto; scrollbar-width: none; margin-bottom: 0; }
.code-tabs::-webkit-scrollbar { display: none; }
.code[hidden], .dev-response[hidden] { display: none; }
.code-tabs .tab { white-space: nowrap; }
.code-box { position: relative; }
.code-copy { position: absolute; top: 6px; right: 6px; z-index: 1; background: var(--surface); }
.code {
  display: block; width: 100%; margin: 0; padding: 14px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 12.5px; line-height: 1.55; white-space: pre; overflow: auto;
  max-height: 640px; tab-size: 2;
}
textarea.code { resize: vertical; min-height: 160px; font-family: "Roboto Mono", ui-monospace, monospace; }
textarea.code:focus { outline: none; border-color: var(--brand-blue); box-shadow: 0 0 0 1px var(--brand-blue); }
.code-box .code { padding-top: 40px; }
.dev-console-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dev-response { display: grid; gap: 12px; padding-top: 16px; border-top: 1px solid var(--border); }
.dev-results { display: grid; gap: 8px; }
.dev-result { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px; background: var(--brand-tint); }
.dev-examples { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.dev-examples figure { margin: 0; display: grid; gap: 6px; }
.dev-examples figcaption { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.topbar .login-link { margin-left: 4px; }

@media (max-width: 1100px) {
  .dev-console-body { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .dev-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .dev-form { grid-template-columns: 1fr; }
  .dev-hero h1 { font-size: 22px; }
}
.login-dev { display: inline-flex; align-items: center; gap: 8px; margin-top: 18px; font-size: 13px; font-weight: 500; }
@media (max-width: 520px) {
  .topbar:has(.login-link) .theme-switch { display: none; }
  .topbar .login-link { padding: 0 12px; }
  .topbar .lang-switch a { padding: 6px 7px; }
}
.dev > * { min-width: 0; }
.dev .table-card { overflow-x: auto; }
@media (max-width: 1100px) { .dev-console-body { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) { .dev-grid { grid-template-columns: minmax(0, 1fr); } }
.dev-subs { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; font-size: 13px; }
.dev-subs .mono { color: var(--muted); text-align: right; }

/* Routing modal */
.rd { display: grid; gap: 20px; }
.rd h3 { font-size: 13px; font-weight: 500; color: var(--brand-navy); margin: 0; text-transform: uppercase; letter-spacing: .4px; }
.rd-msg { margin: 0; padding: 10px 14px; border-radius: 8px; }
.rd-msg.ok { background: var(--ok-bg); color: var(--ok); }
.rd-msg.err { background: var(--err-bg); color: var(--err); }
.rd-flow { display: flex; align-items: stretch; gap: 12px; flex-wrap: wrap; }
.rd-node {
  flex: 1 1 260px; display: flex; flex-direction: column; gap: 4px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg);
}
.rd-target { border-color: var(--brand-blue); background: var(--brand-tint); }
.rd-label { font-size: 12px; color: var(--muted); }
.rd-arrow { align-self: center; font-size: 22px; color: var(--brand-blue); }
.rd-main-form { display: flex; gap: 8px; flex-wrap: wrap; }
.rd-main-form select { flex: 1 1 180px; }
.rd-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.rd-cond {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 24px minmax(200px, 240px); gap: 10px 12px; align-items: center;
  padding: 12px 14px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 12px;
}
.rd-cond.draft { border-color: var(--err); }
.rd-cond.view { grid-template-columns: 44px minmax(0, 1fr) 24px minmax(160px, auto); }
.rd-cond .field-input { height: 36px; padding: 0 8px; font-size: 13px; }
.rd-fields { display: grid; gap: 6px; }
.rd-line { display: grid; grid-template-columns: 170px minmax(0, 1fr); align-items: center; gap: 10px; min-height: 36px; }
.rd-line + .rd-line { border-top: 1px dashed var(--border); padding-top: 6px; }
.rd-key { font-size: 12.5px; color: var(--muted); }
.rd-pair { display: flex; align-items: center; gap: 6px; min-width: 0; }
.rd-pair .rd-re { flex: 1 1 auto; min-width: 0; }
.rd-side { display: grid; gap: 8px; padding: 10px; border-radius: 10px; background: var(--brand-tint); }
.rd-id { color: var(--muted); }
.rd-time { display: flex; align-items: center; gap: 4px; }
.rd-hm { width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.rd-attr { width: 130px; }
.rd-re { width: 220px; }
.rd-err { width: 84px; }
.rd-pct { width: 64px; }
.rd-prov { width: 100%; }
.rd-actions { display: flex; gap: 4px; align-items: center; justify-content: flex-end; }
.rd-actions .btn { height: 36px; padding: 0 16px; }
.rd-del { color: var(--err); }
.rd-other { grid-column: 2 / -1; }
.rd-new-title { margin-top: 8px !important; margin-bottom: 10px !important; }
@media (max-width: 720px) {
  .rd-cond, .rd-cond.view { grid-template-columns: minmax(0, 1fr); }
  .rd-line { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .rd-pair .rd-attr { width: 40%; }
  .rd-cond > .rd-arrow { transform: rotate(90deg); justify-self: center; }
  .rd-other { grid-column: auto; }
  .rd-flow .rd-arrow { transform: rotate(90deg); width: 100%; text-align: center; }
}

/* Routing page: view / edit buttons, "Add" in the header */
/* sticky on the right: stays visible when the wide table scrolls horizontally */
.rt-open-cell {
  width: 1%; white-space: nowrap; text-align: right; padding-top: 4px; padding-bottom: 4px;
  position: sticky; right: 0; background: var(--surface); box-shadow: -1px 0 0 var(--border);
}
.table thead .rt-open-cell { background: var(--table-head); }
.table tbody tr:hover .rt-open-cell { background: var(--brand-tint); }
.rt-open { color: var(--brand-blue); }
.page-head-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rd-node .field + .field { margin-top: 10px; }
.rd-flow > .rd-node { flex: 1 1 0; min-width: 240px; }
.rd-node select.field-input { width: 100%; }

/* Dashboard: merchant × provider matrix (successful / total sum) */
.pm-card .hint-text { margin: -6px 0 10px; font-size: 12px; }
.table.pm th, .table.pm td { white-space: nowrap; vertical-align: top; }
.table.pm .pm-name { white-space: normal; min-width: 160px; }
.table.pm .pm-total { border-left: 1px solid var(--border); }
.table.pm tfoot td { border-top: 1px solid var(--border); font-weight: 500; }
.pm-sum { font-variant-numeric: tabular-nums; }
.pm-sum b { font-weight: 500; }
.pm-bar { height: 4px; border-radius: 2px; background: var(--border); margin: 4px 0 3px auto; max-width: 160px; overflow: hidden; }
.pm-bar i { display: block; height: 100%; background: var(--brand-blue); }
.pm-sub { font-size: 12px; }
