:root,
html[data-theme="light"] {
  --bg: #eef2ef;
  --bg-sidebar: #f7faf8;
  --bg-header: rgba(247, 250, 248, 0.92);
  --bg-card: #ffffff;
  --bg-input: #f4f7f5;
  --bg-code: #102117;
  --text: #122018;
  --text-soft: #5c6d64;
  --accent: #146b45;
  --accent-soft: rgba(20, 107, 69, 0.1);
  --on-accent: #f4fff8;
  --line: rgba(18, 32, 24, 0.1);
  --ok: #157a48;
  --warn: #9a6408;
  --danger: #b42318;
  --shadow: none;
  --sidebar-w: 252px;
  --radius: 12px;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  --bg: #070807;
  --bg-sidebar: #101411;
  --bg-header: #101411;
  --bg-card: #161b17;
  --bg-input: #0c0f0d;
  --bg-code: #050605;
  --text: #f4f7f5;
  --text-soft: #9aa89f;
  --accent: #c6f36a;
  --accent-soft: rgba(198, 243, 106, 0.12);
  --on-accent: #102116;
  --line: rgba(244, 247, 245, 0.08);
  --ok: #8fd63a;
  --warn: #e2b34a;
  --danger: #ef6b55;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0 0 0.4rem; font-weight: 650; letter-spacing: -0.02em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.05rem; }

.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 1.1rem 0.85rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--text);
  font-weight: 650;
  font-size: 1.05rem;
  padding: 0.2rem 0.45rem 1rem;
  letter-spacing: -0.03em;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-sub {
  margin-top: 0.18rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  display: block; flex-shrink: 0;
  object-fit: cover;
}
svg.brand-mark { overflow: hidden; }
.nav-label {
  font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-soft); padding: 0.55rem 0.7rem 0.35rem;
}
.nav a {
  display: flex; align-items: center; gap: 0.65rem;
  color: var(--text-soft); padding: 0.62rem 0.75rem;
  border-radius: 10px; margin-bottom: 0.15rem;
}
.nav a:hover { background: var(--accent-soft); color: var(--text); }
.nav a.is-active {
  background: var(--accent-soft); color: var(--text); font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}
.sidebar-foot { margin-top: auto; padding: 0.6rem; }
.workspace { min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.85rem 1.4rem; background: var(--bg-header);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
  backdrop-filter: blur(10px);
}
.top h1 { font-size: 1.05rem; margin: 0; flex: none; }
.search { flex: 1; max-width: 420px; margin: 0 auto; }
.search input { width: 100%; border-radius: 8px; background: var(--bg-input); }
.top-actions { display: flex; align-items: center; gap: 0.7rem; margin-left: auto; }
.user-chip { display: flex; align-items: center; gap: 0.55rem; color: var(--text-soft); font-size: 0.88rem; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent);
  color: #101411; display: grid; place-items: center; font-weight: 700;
}
.content { padding: 1.35rem 1.5rem 2.4rem; }
.back-link {
  display: inline-block;
  margin: 0 0 0.85rem;
  color: var(--text);
  font-weight: 550;
  font-size: 0.95rem;
}
.back-link:hover { color: var(--accent); }
.grid { display: grid; gap: 1rem; }
.cards { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.05rem 1.15rem; box-shadow: var(--shadow);
}
.muted { color: var(--text-soft); font-size: 0.9rem; }
.stat {
  font-size: 1.7rem; font-weight: 650; letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 0.72rem 0.85rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
td { font-variant-numeric: tabular-nums; }
th {
  color: var(--text-soft);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  background: var(--bg-input);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--accent-soft); }
thead th:first-child { border-top-left-radius: 10px; }
thead th:last-child { border-top-right-radius: 10px; }
.btn, button, input[type=submit], a.btn, .button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 38px;
  padding: 0 0.95rem;
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover, button:hover, input[type=submit]:hover, a.btn:hover, .button-link:hover {
  filter: brightness(1.08);
}
.btn:active, button:active, input[type=submit]:active { transform: translateY(1px); }
.btn.ghost, .ghost, .theme-btn, button.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
  filter: none;
}
.btn.ghost:hover, .ghost:hover, .theme-btn:hover, button.ghost:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  filter: none;
}
.btn.danger, button.danger {
  background: var(--danger);
  color: #fff;
  border-color: transparent;
}
td .btn, td button, .actions .btn, .actions button {
  min-height: 32px;
  padding: 0 0.7rem;
  font-size: 0.82rem;
}
.page-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  margin-bottom: 1.25rem; flex-wrap: wrap;
}
.page-head .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; margin-top: 0.35rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.5rem; }
.actions form { margin: 0; }
.badge {
  display: inline-flex; align-items: center; border-radius: 999px; padding: 0.2rem 0.6rem;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
  background: var(--accent-soft); color: var(--text);
}
.badge.is-ok { background: rgba(143, 214, 58, 0.16); color: var(--ok); }
.badge.is-warn { background: rgba(226, 179, 74, 0.18); color: var(--warn); }
.badge.is-danger { background: rgba(239, 107, 85, 0.18); color: var(--danger); }
.mono {
  font-family: ui-monospace, SFMono-Regular, monospace; font-size: 0.86rem;
  color: var(--accent); word-break: break-all;
}
.form-panel { max-width: 36rem; }
.panel-split {
  margin-top: 1.15rem; padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}
.panel-split > .panel-label {
  font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-soft); margin: 0 0 0.65rem; font-weight: 650;
}
.data-list { display: flex; flex-direction: column; gap: 0.55rem; margin: 0.6rem 0 0; }
.data-row {
  display: grid; grid-template-columns: 4.5rem 1fr auto auto auto; gap: 0.65rem;
  align-items: center; padding: 0.55rem 0.7rem;
  background: var(--bg-input); border-radius: 10px; border: 1px solid var(--line);
  font-size: 0.9rem;
}
.data-row .cur { font-weight: 700; }
.stack-sections { display: flex; flex-direction: column; gap: 1rem; }
.tier-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.55rem 0.7rem;
  margin: 0.4rem 0 0.85rem;
}
.tier-grid .tier-head {
  font-size: 0.72rem; color: var(--text-soft); text-transform: uppercase;
  letter-spacing: 0.05em; font-weight: 650;
}
.tier-grid.is-hidden { display: none; }
.card.priority, .modal.priority {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft), var(--shadow);
}
.section-lead { color: var(--text-soft); font-size: 0.9rem; margin: 0 0 0.85rem; }
label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0.85rem 0 0.35rem;
  color: var(--text-soft);
}
input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  font: inherit;
  font-size: 0.95rem;
  background: var(--bg-input);
  color: var(--text);
}
textarea { min-height: 96px; resize: vertical; padding-top: 0.65rem; }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-soft) 50%),
    linear-gradient(135deg, var(--text-soft) 50%, transparent 50%);
  background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--text-soft); opacity: 0.8; }
.flash { padding: 0.8rem 1rem; border-radius: 12px; margin-bottom: 1rem; }
.flash.ok { background: var(--accent-soft); }
.flash.err { background: rgba(196, 71, 50, 0.16); }
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--bg);
}
.login-stage {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: var(--bg-card);
}
.login-aside {
  padding: 2.2rem 2rem;
  background: #102116;
  color: #f4f7f5;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 460px;
}
.login-aside .eyebrow {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #c6f36a;
}
.login-aside h1 {
  font-size: 2rem;
  line-height: 1.05;
  letter-spacing: -0.04em;
  margin: 0.8rem 0 0.7rem;
  color: #f4f7f5;
}
.login-aside p { color: #b7c4bb; margin: 0; max-width: 28rem; }
.login-flow {
  display: grid;
  gap: 0.55rem;
  margin-top: 2rem;
}
.login-flow span {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid rgba(244, 247, 245, 0.12);
  padding-top: 0.55rem;
  font-size: 0.86rem;
  color: #d5e0d8;
}
.login-flow b { font-weight: 500; color: #c6f36a; font-variant-numeric: tabular-nums; }
.login-card { width: auto; border: 0; border-radius: 0; box-shadow: none; padding: 2rem 1.7rem; }
.login-brand {
  display: flex; align-items: center;
  margin: 0.35rem 0 0.75rem;
}
.login-brand img {
  display: block; width: 176px; height: 48px;
  flex-shrink: 0; border-radius: 0;
}
html[data-theme="light"] .login-brand img {
  filter: invert(1) hue-rotate(180deg);
}
.password-field {
  display: flex; gap: 0.5rem; align-items: stretch;
}
.password-field input { flex: 1; margin-bottom: 0; }
.password-toggle { flex-shrink: 0; white-space: nowrap; }
.secret-box {
  background: var(--bg-code); color: var(--accent); padding: 0.9rem 1rem; border-radius: 12px;
  font-family: ui-monospace, SFMono-Regular, monospace; overflow-wrap: anywhere; font-size: 0.86rem;
}
.checkout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem 1rem 2rem;
  background: #e7eee9;
  color: #122018;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}
.pay-sheet { width: min(440px, 100%); }
.pay-top {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 0.75rem; color: #5c6d64; font-size: 0.78rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}
.checkout .card {
  width: 100%;
  background: #fff;
  color: #122018;
  border-radius: 16px;
  border: 1px solid rgba(18, 32, 24, 0.08);
  padding: 1.25rem 1.25rem 1.1rem;
}
.checkout a { color: #146b45; }
.pay-merchant { margin: 0; font-size: 0.92rem; color: #5c6d64; }
.pay-amount {
  font-size: 2.4rem;
  letter-spacing: -0.045em;
  margin: 0.15rem 0 0.35rem;
  font-variant-numeric: tabular-nums;
}
.pay-status-row {
  display: flex; justify-content: space-between; align-items: center;
  margin: 0.85rem 0 0.2rem; font-size: 0.88rem;
}
.checkout .btn, .checkout button, .checkout input[type=submit] {
  background: #146b45; color: #f4fff8; width: 100%; border-radius: 8px; margin-top: 0.45rem;
}
.checkout .ghost, .checkout button.ghost {
  background: #fff; color: #122018; border: 1px solid rgba(18, 32, 24, 0.16); width: 100%;
  filter: none;
}
.pay-foot {
  margin: 0.8rem 0 0; text-align: center; color: #5c6d64; font-size: 0.78rem;
}
.checkout-method {
  margin: 1rem 0;
  padding: 1rem 0 0.25rem;
  border-top: 1px solid rgba(20, 32, 26, 0.1);
}
.checkout-method h2 { font-size: 1rem; margin-bottom: 0.35rem; }
.card-hosted .row-2 { margin-top: 0.5rem; }
.checkout .button-link {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(20, 32, 26, 0.2);
  text-decoration: none;
}
.status-SUCCESS { color: var(--ok); }
.status-PENDING, .status-SENT, .status-CREATED { color: var(--warn); }
.status-FAILED, .status-HELD, .status-CANCELLED, .status-DISABLED, .status-REVOKED { color: var(--danger); }
.live { font-family: ui-monospace, monospace; font-size: 0.82rem; max-height: 360px; overflow: auto; color: var(--text-soft); }

/* Dashboard (maquette layout) */
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}
.dash-kpi-top {
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.dash-kpi-icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.85rem; font-weight: 700;
}
.dash-trend { font-size: 0.82rem; margin-top: 0.35rem; }
.dash-trend.is-up { color: var(--ok); }
.dash-trend.is-down { color: var(--danger); }
.dash-main {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr);
  gap: 1rem;
  align-items: start;
}
.dash-side { display: flex; flex-direction: column; gap: 1rem; }
.dash-chart-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem;
}
.dash-chart-head h2 { margin: 0; }
.dash-legend {
  display: flex; flex-wrap: wrap; gap: 0.65rem 0.9rem;
  font-size: 0.78rem; color: var(--text-soft);
}
.dash-legend .lg {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 0.25rem; vertical-align: middle;
}
.lg-total { background: var(--accent); }
.lg-ok { background: var(--text-soft); }
.dash-cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.65rem; }
.dash-cal-head h2 { margin: 0; font-size: 1rem; text-transform: capitalize; }
.dash-cal-week, .dash-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.25rem;
  text-align: center;
}
.dash-cal-week { margin-bottom: 0.35rem; }
.dash-cal-week span {
  font-size: 0.7rem; color: var(--text-soft); font-weight: 650;
  letter-spacing: 0.04em;
}
.dash-day {
  aspect-ratio: 1; display: grid; place-items: center;
  border-radius: 8px; font-size: 0.82rem; color: var(--text);
}
.dash-day.is-empty { visibility: hidden; }
.dash-day.is-active { background: var(--accent-soft); font-weight: 650; }
.dash-day.is-today {
  background: var(--accent); color: #101411; font-weight: 720;
}
.dash-live { max-height: 160px; }
.dash-app-list {
  list-style: none; padding: 0; margin: 0.5rem 0 0;
  display: flex; flex-direction: column; gap: 0.35rem;
}
.dash-app-list li {
  padding: 0.45rem 0.65rem; border-radius: 8px;
  background: var(--bg-input); border: 1px solid var(--line); font-size: 0.9rem;
}
.status-pill {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: 0.15rem 0.55rem; font-size: 0.72rem; font-weight: 700;
  background: var(--accent-soft);
}
.status-pill.status-SUCCESS { background: rgba(143, 214, 58, 0.16); color: var(--ok); }
.status-pill.status-PENDING, .status-pill.status-CREATED, .status-pill.status-SENT {
  background: rgba(226, 179, 74, 0.18); color: var(--warn);
}
.status-pill.status-FAILED, .status-pill.status-CANCELLED, .status-pill.status-EXPIRED {
  background: rgba(239, 107, 85, 0.18); color: var(--danger);
}
.dash-table { overflow-x: auto; }
.finance-period { margin-bottom: 1.25rem; }
.finance-currency-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.finance-currency h3 { margin: 0 0 0.65rem; font-size: 1rem; }
.finance-dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem 1rem;
  margin: 0;
}
.finance-dl div { display: flex; flex-direction: column; gap: 0.1rem; }
.finance-dl dt { font-size: 0.75rem; color: var(--text-soft); }
.finance-dl dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 1100px) {
  .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-main { grid-template-columns: 1fr; }
  .finance-currency-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .dash-kpis { grid-template-columns: 1fr; }
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.8rem; }
.split { display: grid; grid-template-columns: 240px 1fr; gap: 1.4rem; align-items: start; }
.toc {
  position: sticky; top: 5rem; background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem;
}
.toc a { display: block; color: var(--text-soft); padding: 0.28rem 0; font-size: 0.92rem; }
.toc a:hover { color: var(--accent); }
.method {
  display: inline-block; background: var(--accent); color: #101411; border-radius: 6px;
  padding: 0.12rem 0.45rem; font-size: 0.72rem; font-weight: 800; margin-right: 0.4rem;
}
.code {
  background: var(--bg-code); color: var(--accent); border-radius: 12px;
  padding: 0.9rem 1rem 0.9rem; overflow: auto; font-family: ui-monospace, monospace;
  font-size: 0.82rem; position: relative; white-space: pre-wrap;
}
.copy { position: absolute; top: 0.45rem; right: 0.45rem; font-size: 0.75rem; padding: 0.25rem 0.6rem; }
.auth-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.8rem; }
.mt { margin-top: 1rem; }
.tabs {
  display: flex; gap: 0.25rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); margin-bottom: 1.1rem;
}
.tab {
  background: transparent; color: var(--text-soft); border: 0; border-radius: 10px 10px 0 0;
  min-height: 0; padding: 0.65rem 1rem; font: inherit; font-weight: 600; cursor: pointer;
  filter: none;
}
.tab:hover { color: var(--text); background: var(--accent-soft); }
.tab.is-active {
  color: var(--text); background: var(--bg-card);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }
.tab-toolbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.table-row[data-href] { cursor: pointer; }
.table-row.is-selected td {
  background: var(--accent-soft);
}
.app-inline {
  margin-top: 1.5rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--line);
}
.app-inline-hint { margin-top: 1.25rem; }
.playground {
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}
.playground-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--accent);
}
.playground-creds .section-lead { margin-top: 0.25rem; }
.playground-result {
  margin-top: 0.85rem;
  background: var(--bg-code);
  color: var(--text);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 320px;
  border: 1px solid var(--line);
}
.playground-result.is-error { border-color: var(--danger, #e45); color: var(--danger, #e45); }
.playground-live { margin-left: 0.35rem; vertical-align: middle; }
.playground-webhook { margin-top: 0.5rem; }
.button-link {
  text-decoration: none;
  background: var(--accent);
  color: var(--on-accent);
}
.button-link.ghost,
a.ghost.button-link {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.button-link[hidden],
a[hidden] { display: none !important; }
body.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, 0.55);
  display: none; align-items: center; justify-content: center;
  padding: 1.25rem;
}
.modal-backdrop.is-open { display: flex; }
.modal {
  width: min(520px, 100%);
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.2rem 1.25rem 1.3rem;
  max-height: min(90vh, 720px); overflow: auto;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 0.75rem; margin-bottom: 0.75rem;
}
.modal-head h2 { margin: 0; font-size: 1.1rem; }
.modal-close {
  background: transparent; border: 0; color: var(--text-soft);
  min-height: 0; font-size: 1.35rem; line-height: 1; cursor: pointer; padding: 0.1rem 0.35rem;
  filter: none;
}
.modal-close:hover { color: var(--text); }
[data-percentage-fields].is-hidden { display: none; }

/* —— Logs transactionnels —— */
.logs-dash { display: grid; gap: 1rem; }
.logs-tabs {
  display: flex; flex-wrap: wrap; gap: 0.35rem;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 999px; padding: 0.3rem; width: fit-content;
}
.logs-tabs a {
  color: var(--text-soft); text-decoration: none;
  padding: 0.45rem 0.95rem; border-radius: 999px; font-size: 0.92rem;
}
.logs-tabs a.is-active {
  background: var(--accent); color: #0b120e; font-weight: 650;
}
.logs-filters { display: grid; gap: 0.75rem; }
.logs-filter-actions {
  display: flex; align-items: flex-end; gap: 0.6rem; padding-bottom: 0.15rem;
}
.logs-stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.85rem;
}
.log-stat .log-stat-value {
  font-size: 1.85rem; font-weight: 750; margin: 0.15rem 0;
  font-variant-numeric: tabular-nums;
}
.log-stat.is-ok .log-stat-value { color: var(--ok); }
.log-stat.is-warn .log-stat-value { color: var(--warn); }
.log-stat.is-danger .log-stat-value { color: var(--danger); }
.logs-charts {
  display: grid; grid-template-columns: 1.6fr 1fr; gap: 0.85rem; margin-top: 0.85rem;
}
.logs-feed { list-style: none; margin: 0; padding: 0; }
.logs-feed-item {
  display: grid; grid-template-columns: 12px 1fr auto auto; gap: 0.75rem;
  align-items: start; padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}
.logs-dot {
  width: 10px; height: 10px; border-radius: 50%; margin-top: 0.4rem;
  background: var(--text-soft);
}
.logs-dot.is-ok { background: var(--ok); }
.logs-dot.is-bad { background: var(--danger); }
.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 0.35rem; background: var(--text-soft); vertical-align: middle;
}
.status-dot.status-SUCCESS { background: var(--ok); }
.status-dot.status-PENDING, .status-dot.status-CREATED { background: var(--warn); }
.status-dot.status-FAILED, .status-dot.status-CANCELLED { background: var(--danger); }
.badge.is-live { background: rgba(182, 242, 92, 0.15); color: var(--ok); }
.flexpay-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem;
  margin: 0.75rem 0 1rem;
}
.flexpay-balances { margin-bottom: 0.5rem; }
.logs-modal {
  width: min(720px, calc(100vw - 2rem));
  max-height: min(88vh, 900px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-card); color: var(--text);
  padding: 0; box-shadow: var(--shadow);
}
.logs-modal::backdrop { background: rgba(0, 0, 0, 0.55); }
.logs-modal-head {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.15rem; border-bottom: 1px solid var(--line); margin: 0;
}
.logs-modal-body { padding: 1rem 1.15rem 1.25rem; overflow: auto; max-height: 70vh; }
.logs-timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.logs-timeline-item { position: relative; padding: 0 0 1.1rem 1.1rem; }
.logs-timeline-item::before {
  content: ''; position: absolute; left: -6px; top: 0.35rem;
  width: 10px; height: 10px; border-radius: 50%; background: var(--text-soft);
}
.logs-timeline-item.is-ok::before { background: var(--ok); }
.logs-timeline-item.is-bad::before { background: var(--danger); }
.logs-timeline-head {
  display: flex; justify-content: space-between; gap: 0.75rem; align-items: baseline;
}
.logs-code {
  background: var(--bg-code); color: var(--accent);
  padding: 0.75rem; border-radius: 10px; overflow: auto;
  font-size: 0.78rem; max-height: 220px; white-space: pre-wrap;
}
@media (max-width: 920px) {
  .logs-stats, .logs-charts { grid-template-columns: 1fr 1fr; }
  .logs-feed-item { grid-template-columns: 12px 1fr; }
  .logs-feed-item time, .logs-feed-item .logs-open { grid-column: 2; }
}
@media (max-width: 640px) {
  .logs-stats, .logs-charts { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .login-stage { grid-template-columns: 1fr; }
  .login-aside { min-height: 0; gap: 1.4rem; }
}
@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .split, .row-2, .row-3, .data-row, .tier-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Composants transverses — toasts, filtres, tableaux de données, formulaires
   ========================================================================== */

/* ---------- Toasts ---------- */
.toast-stack {
  position: fixed; top: 1rem; right: 1rem; z-index: 90;
  display: flex; flex-direction: column; gap: 0.5rem;
  max-width: min(420px, calc(100vw - 2rem));
}
.toast {
  display: flex; align-items: flex-start; gap: 0.6rem;
  padding: 0.7rem 0.85rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg-card); color: var(--text);
  font-size: 0.88rem; line-height: 1.35;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
  animation: toast-in 0.18s ease-out;
}
.toast.flash { margin: 0; }
.toast.is-leaving { opacity: 0; transform: translateY(-6px); transition: opacity 0.2s, transform 0.2s; }
.toast-close {
  margin-left: auto; background: none; border: 0; cursor: pointer;
  color: inherit; opacity: 0.55; font-size: 1.05rem; line-height: 1; padding: 0 0.1rem;
}
.toast-close:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Filtres et pastilles ---------- */
.status-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.2rem 0 0.8rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.65rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-input);
  color: var(--text-soft); font-size: 0.8rem;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.is-active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }
.chip-count {
  font-variant-numeric: tabular-nums; font-size: 0.72rem;
  padding: 0 0.35rem; border-radius: 999px; background: rgba(127, 127, 127, 0.18);
}
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.6rem;
  padding: 0.7rem 0.8rem; margin-bottom: 0.9rem;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-input);
}
.filter-bar .field,
.recipient-row .field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 150px; }
.filter-bar .field.grow,
.recipient-row .field.grow { flex: 1 1 220px; }
.filter-bar .field > span,
.recipient-row .field > span {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-soft);
}
.filter-bar input, .filter-bar select, .recipient-row input { margin: 0; }
.list-summary { margin: 0.2rem 0 0.6rem; font-size: 0.88rem; color: var(--text-soft); }
.tab-count {
  margin-left: 0.35rem; font-size: 0.72rem; padding: 0 0.3rem;
  border-radius: 999px; background: rgba(127, 127, 127, 0.2);
}

/* ---------- Tableaux de données ---------- */
.table-wrap {
  width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line); border-radius: var(--radius);
}
.data-table { width: 100%; border-collapse: collapse; min-width: 880px; }
.data-table th, .data-table td {
  padding: 0.55rem 0.7rem; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--line); font-size: 0.87rem;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table thead th {
  background: var(--bg-card); color: var(--text-soft);
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap;
}
.data-table tbody tr:hover { background: var(--accent-soft); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table .cell-wrap { max-width: 340px; white-space: normal; word-break: break-word; }
.block { display: block; }

/* ---------- États vides et détails ---------- */
.empty-state {
  padding: 1.4rem; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center;
}
.empty-state p { margin: 0.2rem 0; }
.trace-details summary { cursor: pointer; display: inline-flex; align-items: center; gap: 0.35rem; }
.trace-details pre,
pre.json, pre.message-preview {
  margin: 0.4rem 0 0; padding: 0.55rem 0.65rem; border-radius: 10px;
  background: var(--bg-code); color: #d8f5c8;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.74rem; max-height: 220px; overflow: auto; white-space: pre-wrap;
}

/* ---------- Formulaires ---------- */
.check { display: inline-flex; align-items: flex-start; gap: 0.45rem; font-size: 0.88rem; }
.check input { margin-top: 0.15rem; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0.5rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.code-list { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.6rem; }
.code-row {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline;
  padding: 0.4rem 0.55rem; border-radius: 10px; background: var(--bg-input); font-size: 0.82rem;
}
.info-block { padding: 0.6rem 0.7rem; border-radius: var(--radius); background: var(--bg-input); border: 1px solid var(--line); }
.recipient-list { display: flex; flex-direction: column; gap: 0.55rem; }
.recipient-row {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.6rem;
  padding: 0.7rem 0.8rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-input);
}
.row-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-left: auto; }

/* ---------- États de chargement ---------- */
button.is-loading { position: relative; pointer-events: none; opacity: 0.85; padding-right: 1.9rem; }
button.is-loading::after {
  content: ""; position: absolute; top: 50%; right: 0.6rem;
  width: 12px; height: 12px; margin-top: -6px; border-radius: 50%;
  border: 2px solid var(--accent); border-top-color: transparent;
  animation: btn-spin 0.7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

.status-pill.status-AVAILABLE { background: var(--accent-soft); color: var(--accent); }
.status-pill.status-SENT { background: rgba(226, 179, 74, 0.18); color: var(--warn); }
.status-pill.status-HELD { background: rgba(239, 107, 85, 0.18); color: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .toast-stack { left: 0.6rem; right: 0.6rem; top: 0.6rem; max-width: none; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .field { min-width: 0; }
  .recipient-row { flex-direction: column; align-items: stretch; }
  .row-actions { margin-left: 0; }
  .grid-2 { grid-template-columns: 1fr; }
  .data-table { min-width: 640px; }
  .data-table .cell-wrap { max-width: 220px; }
}
.data-table .actions-col { width: 1%; white-space: nowrap; }
.data-table .actions { justify-content: flex-start; flex-wrap: wrap; gap: 0.35rem; }
.data-table .actions form { margin: 0; }
.table-wrap > table { border: 0; border-radius: 0; }
.table-wrap > table > thead > tr > th { white-space: nowrap; }

/* ==========================================================================
   Correctif : les champs de formulaire ne doivent pas styler les cases à cocher
   (width/min-height/padding hérités rendaient les cases énormes et décalaient
   les libellés).
   ========================================================================== */
input[type="checkbox"],
input[type="radio"] {
  width: 1.05rem;
  height: 1.05rem;
  min-height: 0;
  padding: 0;
  margin: 0;
  flex: 0 0 auto;
  border-radius: 5px;
  accent-color: var(--accent);
  box-shadow: none;
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Case + libellé sur une seule ligne, en casse normale */
.check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  cursor: pointer;
  user-select: none;
}
.check input { margin: 0; }

/* Événements : une carte cliquable par option */
.check-grid { margin-top: 0.35rem; }
.check-grid > .check {
  align-items: flex-start;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-input);
}
.check-grid > .check input { margin-top: 0.15rem; }
.check-grid > .check:hover { border-color: var(--accent); }
.check-grid > .check:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Pastilles de statut partenaire */
.status-pill.status-ACTIVE { background: rgba(143, 214, 58, 0.16); color: var(--ok); }
.status-pill.status-SUSPENDED { background: rgba(239, 107, 85, 0.18); color: var(--danger); }

.strong { font-weight: 600; }
.mt-xs { margin-top: 0.3rem; }

/* ==========================================================================
   Graphiques — jetons dédiés (les séries ne réutilisent pas warn/danger,
   qui ont un sens métier : « avertissement » et « erreur »).
   ========================================================================== */
:root,
html[data-theme="light"] {
  --chart-2: #2f7d8f;
  --chart-3: #a9761a;
  --chart-4: #b42318;
}
html[data-theme="dark"] {
  --chart-2: #6ec8f5;
  --chart-3: #e2b34a;
  --chart-4: #ef6b55;
}

.chart-box { position: relative; height: 280px; margin-top: 0.6rem; }
.chart-box-sm { height: 190px; }
.chart-box.is-empty { opacity: 0.35; }
.chart-empty { margin: 0.4rem 0 0; text-align: center; }

/* Sélecteur de devise (USD / CDF) */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-input);
  flex: 0 0 auto;
}
.segmented button {
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  min-height: 0;
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active {
  background: var(--accent);
  color: var(--on-accent);
}
.segmented button[hidden] { display: none; }

/* ==========================================================================
   Navigation latérale — icônes et état actif
   ========================================================================== */
.nav-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  opacity: 0.7;
}
.nav a:hover .nav-icon { opacity: 1; }
.nav a.is-active .nav-icon { opacity: 1; }
.nav a span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-logout {
  display: flex; align-items: center; gap: 0.6rem;
  width: 100%; justify-content: flex-start;
  padding: 0.55rem 0.7rem; font-size: 0.9rem;
}
.nav-logout .nav-icon { width: 16px; height: 16px; }

/* ==========================================================================
   Typographie — hiérarchie, chiffres alignés, coupures de ligne soignées
   ========================================================================== */
h1, h2, h3, h4 { text-wrap: balance; }
p, li, dd, .section-lead { text-wrap: pretty; }

/* Les libellés de formulaire passent en casse normale : l'uppercase systématique
   avec interlettrage large fatigue la lecture sur des libellés longs.
   Les micro-libellés de section gardent l'uppercase (voir .field > span, th). */
label {
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.82rem;
  font-weight: 600;
}

/* Chiffres à chasse fixe : les montants s'alignent verticalement. */
table,
.stat,
.mono,
.finance-dl dd,
.dash-kpi .dash-trend,
.chip-count,
.segmented button {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Titres de carte un peu plus affirmés, sous-titres plus discrets */
.card > h2:first-child { font-size: 1.02rem; letter-spacing: -0.015em; }
.dash-chart-head { align-items: flex-start; gap: 1rem; }
.dash-chart-head .section-lead { margin-bottom: 0; }

/* Calendrier d'activité — apaisé : la pastille pleine était réservée au jour
   courant, elle écrasait tout le reste. Aujourd'hui = anneau, jour actif = teinte. */
.dash-cal-grid { gap: 0.3rem; }
.dash-day {
  aspect-ratio: 1;
  max-width: 38px;
  margin-inline: auto;
  width: 100%;
  border-radius: 9px;
  font-size: 0.8rem;
  color: var(--text-soft);
}
.dash-day.is-active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.dash-day.is-today {
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.dash-day.is-today.is-active { background: var(--accent-soft); }

/* ==========================================================================
   Registre des payouts — pastille de notification et récapitulatif de modale
   ========================================================================== */
.notif-pill {
  display: inline-flex; align-items: center;
  padding: 0.15rem 0.55rem; border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
  color: var(--text-soft); background: var(--bg-input);
}
.notif-pill:hover { border-color: currentColor; }
.notif-pill.is-ok { background: rgba(143, 214, 58, 0.16); color: var(--ok); }
.notif-pill.is-warn { background: rgba(226, 179, 74, 0.18); color: var(--warn); }
.notif-pill.is-danger { background: rgba(239, 107, 85, 0.18); color: var(--danger); }
.notif-pill.is-muted { color: var(--text-soft); }

.confirm-recap {
  margin: 0.9rem 0 0; padding: 0.75rem 0.85rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-input);
  display: flex; flex-direction: column; gap: 0.45rem;
}
.confirm-recap > div { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.confirm-recap dt { color: var(--text-soft); font-size: 0.8rem; }
.confirm-recap dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.filter-notice {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding: 0.6rem 0.8rem; margin-bottom: 0.8rem;
  border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent-soft); font-size: 0.88rem;
}

/* Le bouton de confirmation hérite du ton de l'action */
#modal-payout-action [data-action-confirm].tone-warn { background: var(--warn); color: #1b1403; }
#modal-payout-action [data-action-confirm].tone-ghost {
  background: transparent; color: var(--text); border: 1px solid var(--line);
}

/* ==========================================================================
   Trésorerie — totaux par devise et tableau des soldes partenaires
   ========================================================================== */
.treasury-totals {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}
.treasury-total h3 {
  margin: 0 0 0.7rem;
  font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-soft);
}
.treasury-total-grid {
  display: grid; gap: 0.9rem 1.4rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.treasury-total-grid > div { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.treasury-total-grid strong {
  font-size: 1.22rem; font-weight: 700; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.treasury-total-grid .is-accent strong { color: var(--accent); }
.treasury-total-grid .block { font-size: 0.76rem; }

.data-table tfoot .is-total td {
  border-top: 2px solid var(--line);
  border-bottom: 0;
  background: var(--bg-input);
  font-weight: 600;
}
.data-table tr.is-idle { opacity: 0.55; }
.data-table .is-accent { color: var(--accent); }
.data-table .cur {
  display: inline-block; padding: 0.1rem 0.4rem; border-radius: 6px;
  background: var(--bg-input); font-size: 0.76rem; font-weight: 700; letter-spacing: 0.04em;
}

/* Tons de la modale de confirmation : le bouton reprend la gravité de l'action */
#modal-payout-action [data-action-confirm].tone-danger { background: var(--danger); color: #fff5f2; }
#modal-payout-action [data-action-reason-field] { margin-top: 0.9rem; }
#modal-payout-action [data-action-reason-field][hidden] { display: none; }

/* Statut « rejeté » : ni échec ni succès, une décision administrative */
.status-pill.status-REJECTED { background: rgba(154, 154, 154, 0.18); color: var(--text-soft); }
.status-pill.status-SENDING { background: rgba(110, 200, 245, 0.18); color: var(--chart-2); }

/* Écran Sécurité : enrôlement 2FA */
.security-setup { margin-top: 0.4rem; }
.security-qr {
  display: grid; grid-template-columns: auto 1fr; gap: 1.4rem; align-items: start;
}
.security-qr img {
  border-radius: var(--radius); background: #fff; padding: 0.5rem;
  border: 1px solid var(--line);
}
@media (max-width: 720px) {
  .security-qr { grid-template-columns: 1fr; }
}
.login-card { max-width: 420px; margin: 8vh auto; }
.manual-secret {
  display: inline-block; margin-top: 0.2rem; padding: 0.3rem 0.6rem;
  background: var(--bg-input); border: 1px solid var(--line); border-radius: 8px;
  font-family: 'IBM Plex Mono', monospace; font-size: 0.9rem;
  letter-spacing: 0.12em; word-break: break-all; user-select: all;
}
