/* ==========================================================================
   Sourdi partner console — additions on top of /business/merchant/dashboard/dashboard.css
   Same tokens (one accent, neutral surfaces, hairline borders), logical properties only.
   ========================================================================== */

body.partner-console { font-family: var(--font); }
.partner-content { padding: 24px clamp(16px, 3vw, 32px) 56px; }
.dashboard-page > * + * { margin-top: 16px; }

/* --------------------------------------------------------------------------
   Topbar
   -------------------------------------------------------------------------- */
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; justify-content: flex-end; flex-shrink: 0; }
body.partner-console .language-toggle { min-height: 40px; }
.account-name { color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }

.env-switch { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.env-switch button { min-height: 34px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; white-space: nowrap; transition: background .15s ease, color .15s ease; }
.env-switch button.active { background: var(--ink); color: #fff; }
.env-switch button.active[data-env="sandbox"] { background: var(--amber-soft); color: var(--amber); }
.env-switch button.active[data-env="live"] { background: var(--green-soft); color: var(--green); }
.env-switch button:disabled { cursor: not-allowed; opacity: .45; }
.env-hint { color: var(--faint); font-size: 11px; white-space: nowrap; }

/* --------------------------------------------------------------------------
   Section heading and panels
   -------------------------------------------------------------------------- */
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 20px; }
.section-heading > div { min-width: 0; flex: 1 1 320px; }
.section-heading h1 { margin: 0; color: var(--ink); font-size: clamp(22px, 2.6vw, 28px); font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.section-heading p, .panel-heading p, .panel-note { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; max-width: 62ch; }
.panel-heading p { margin-top: 3px; }
.panel-note { font-size: 13px; }
.panel-note.mt-3, .panel .mt-3 { margin-top: 12px; }

.panel { position: relative; min-width: 0; padding: 22px 24px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-card); }
.panel--table { padding: 0; overflow: hidden; }
.panel--table .panel-note { padding: 12px 20px 14px; margin: 0; border-top: 1px solid var(--line); background: var(--surface-2); }
.panel--table .form-actions { margin: 0; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--surface-2); justify-content: center; }
.panel--table .warning-text { margin: 0; padding: 10px 20px; border-bottom: 1px solid var(--line); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-heading > div:first-child { min-width: 0; flex: 1 1 200px; }
.panel h2 { margin: 0; color: var(--ink); font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.panel h2.mt-2 { margin-top: 24px; }
.grid-two { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
.grid-halves { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* Metric cards */
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.metric-grid.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.metric-card { min-width: 0; min-height: 96px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-card); }
.panel .metric-card { box-shadow: none; background: var(--surface-2); }
.metric-card span { display: block; color: var(--muted); font-size: 12.5px; font-weight: 500; line-height: 1.3; }
.metric-card strong { display: block; margin-top: 8px; color: var(--ink); font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric-card strong.text-base { font-size: 16px; line-height: 1.3; }
.metric-card small { display: block; margin-top: 6px; color: var(--faint); font-size: 12px; }

/* Badges, pills, segmented, text buttons */
.badge { display: inline-flex; align-items: center; gap: 5px; width: max-content; max-width: 100%; min-height: 24px; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.error { background: var(--red-soft); color: var(--red); }
.badge.muted { background: rgba(15, 23, 42, .06); color: var(--muted); }
.segmented { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.segmented button { min-height: 34px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(15, 23, 42, .08); }
.text-button { display: inline-flex; align-items: center; min-height: 36px; padding: 0 4px; border: 0; border-radius: 6px; background: transparent; color: var(--accent-ink); font-size: 13.5px; font-weight: 600; cursor: pointer; }
.text-button:hover { text-decoration: underline; }
.text-button.danger { color: var(--red); }
.row-actions { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.empty-inline { padding: 32px 16px !important; color: var(--faint); font-size: 13.5px; text-align: center; }
.code-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.code-list li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 13px; color: var(--ink-2); }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 10px; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.steps li { position: relative; padding-inline-start: 36px; counter-increment: step; min-height: 24px; }
.steps li::before { content: counter(step); position: absolute; inset-inline-start: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; font-weight: 700; line-height: 24px; text-align: center; }
.error-codes { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.error-codes li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--ink-2); }
.error-codes li:first-child { border-top: 0; }
.usage-chart { min-height: 260px; }
.usage-chart .apexcharts-text, .usage-chart .apexcharts-legend-text { font-family: var(--font) !important; fill: var(--muted); }
.usage-chart .apexcharts-legend-text { color: var(--muted) !important; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.data-table-wrap { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.panel:not(.panel--table) .data-table-wrap { border: 1px solid var(--line); border-radius: 12px; }
.data-table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 13.5px; }
.dashboard-page .data-table th { padding: 10px 20px !important; background: var(--surface-2); color: var(--muted) !important; font-size: 11px !important; font-weight: 600 !important; letter-spacing: .04em; text-transform: uppercase; text-align: start; white-space: nowrap; border: 0 !important; border-bottom: 1px solid var(--line) !important; }
.dashboard-page .data-table td { padding: 13px 20px !important; border: 0 !important; border-bottom: 1px solid var(--line) !important; color: var(--ink-2); vertical-align: middle; }
.dashboard-page .data-table tbody tr:last-child td { border-bottom: 0 !important; }
.dashboard-page .data-table tr.clickable { cursor: pointer; }
.dashboard-page .data-table tr.clickable:hover td, .dashboard-page .data-table tr.clickable:focus-visible td { background: rgba(15, 23, 42, .025); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; direction: ltr; unicode-bidi: isolate; }
.method { display: inline-block; min-width: 52px; padding: 2px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-ink); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; font-weight: 700; text-align: center; }
.method.get { background: var(--green-soft); color: var(--green); }
.method.delete { background: var(--red-soft); color: var(--red); }

/* --------------------------------------------------------------------------
   Toolbar, fields and forms
   -------------------------------------------------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-card); }
.toolbar .field { flex: 1 1 150px; }
.toolbar .action-button { flex: 0 0 auto; }
.field { display: grid; gap: 6px; min-width: 0; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.field > span { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.dashboard-page .field :is(input, select, textarea), .modal .field :is(input, select, textarea) { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-ctl); background: var(--surface); color: var(--ink); font-size: 14.5px; font-weight: 400; line-height: 1.35; box-shadow: none; transition: border-color .15s ease, box-shadow .15s ease; }
.dashboard-page .field :is(input, select, textarea):focus, .modal .field :is(input, select, textarea):focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .16); }
.dashboard-page .field input[readonly] { background: var(--surface-2); color: var(--muted); }
.dashboard-page .field textarea { min-height: 200px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; direction: ltr; text-align: start; unicode-bidi: isolate; }
.field small { color: var(--faint); font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid:empty { display: none; }
.form-stack { display: grid; gap: 14px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 4px; }
.form-message { margin: 0; font-size: 13px; }
.form-message.ok { color: var(--green); }
.form-message.error { color: var(--red); }
.dashboard-page .action-button, .modal .action-button, .sidebar-footer .action-button, .demo-banner .action-button { min-height: 40px; text-decoration: none; white-space: nowrap; }
.dashboard-page .action-button i, .modal .action-button i { font-size: 13px; color: inherit; }

/* Code blocks */
.code-block { position: relative; margin: 0; padding: 14px 16px; max-height: 360px; overflow: auto; border-radius: 12px; background: var(--ink); color: #e5e5ea; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; direction: ltr; text-align: left; }
.code-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 16px 0 6px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.code-label:first-of-type { margin-top: 0; }
.panel-heading + .code-label { margin-top: 0; }
.sandbox-banner { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--ink-2); font-size: 13.5px; line-height: 1.5; }
.sandbox-banner i { color: var(--amber); font-size: 14px; flex-shrink: 0; }
.feedback { padding: 12px 16px; border-radius: 12px; font-size: 13.5px; font-weight: 500; border: 1px solid transparent; }
.feedback.ok { background: var(--green-soft); color: var(--green); border-color: rgba(5, 150, 105, .18); }
.feedback.error { background: var(--red-soft); color: var(--red); border-color: rgba(220, 38, 38, .18); }
.feedback + .dashboard-page { margin-top: 16px; }
.warning-text { margin: 0; color: var(--amber); font-size: 13px; font-weight: 500; }
.hidden { display: none !important; }

/* --------------------------------------------------------------------------
   Modal and drawer
   -------------------------------------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 16px; background: rgba(15, 23, 42, .45); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.modal-card { width: min(480px, 100%); max-height: calc(100dvh - 32px); overflow: auto; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-pop); }
.modal-card h2 { margin: 0 0 4px; color: var(--ink); font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.modal-card .form-stack.mt-4 { margin-top: 18px; }
.modal-card .warning-text { margin-top: 8px; }
.secret-box { display: flex; gap: 8px; align-items: stretch; margin: 16px 0; }
.secret-box code { flex: 1; min-width: 0; display: flex; align-items: center; padding: 10px 12px; border-radius: var(--radius-ctl); background: var(--ink); color: #e5e5ea; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; word-break: break-all; direction: ltr; unicode-bidi: isolate; }
.drawer { position: fixed; inset-block: 0; inset-inline-end: 0; z-index: 1900; width: min(420px, 100vw); padding: 22px 24px; overflow-y: auto; background: var(--surface); border-inline-start: 1px solid var(--line); box-shadow: var(--shadow-pop); }
.drawer-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.drawer h2 { margin: 0; color: var(--ink); font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.drawer dl { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; margin: 18px 0 0; font-size: 13.5px; }
.drawer dt { padding-top: 12px; color: var(--muted); font-size: 12px; font-weight: 500; }
.drawer dd { margin: 2px 0 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); color: var(--ink); word-break: break-word; }
.drawer dd:last-child { border-bottom: 0; }

/* Session loader */
.session-loading { position: fixed; inset: 0; z-index: 3000; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.session-spinner { width: 28px; height: 28px; border: 3px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: partner-spin .8s linear infinite; }
@keyframes partner-spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   Demo mode (?demo=1)
   -------------------------------------------------------------------------- */
.demo-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 16px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-card); color: var(--ink-2); font-size: 13.5px; line-height: 1.5; }
.demo-banner-text { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 320px; }
.demo-banner-text .badge { flex-shrink: 0; }
.demo-banner-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.demo-banner-actions .action-button { min-height: 36px; font-size: 13.5px; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1280px) {
  .metric-grid.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .grid-two, .grid-halves { grid-template-columns: 1fr; }
  .account-name { display: none; }
}
@media (max-width: 820px) {
  .panel { padding: 18px 16px; }
  .panel--table { padding: 0; }
  .dashboard-page .data-table th { padding: 10px 16px !important; }
  .dashboard-page .data-table td { padding: 12px 16px !important; }
  .panel--table .panel-note, .panel--table .warning-text { padding-inline: 16px; }
}
@media (max-width: 768px) {
  /* dashboard.css turns .topbar-inner into a grid for the merchant markup; the console keeps a flex row. */
  body.partner-console .topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; }
  body.partner-console #navbar-menu { width: 40px; min-height: 40px; flex-shrink: 0; }
  .topbar-left { flex: 1 1 auto; }
  .page-title { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-actions { gap: 8px; }
  .env-hint { display: none; }
  .env-switch button { padding: 0 10px; font-size: 12px; }
  .language-toggle #language-current-label { display: none; }
  .partner-content { padding: 16px 16px 48px; }
  .section-heading { margin-bottom: 16px; }
  .section-heading > .action-button { width: 100%; justify-content: center; }
  .metric-grid, .metric-grid.six { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric-card { min-height: 84px; padding: 14px 16px; }
  .metric-card strong { font-size: 22px; }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar { padding: 12px 14px; }
  .toolbar .field { flex: 1 1 calc(50% - 12px); }
  .toolbar .action-button { flex: 1 1 100%; justify-content: center; }
  .panel-heading .segmented { width: 100%; }
  .panel-heading .segmented button { flex: 1; }
  .drawer { width: 100vw; padding: 18px 16px; }
  .modal { padding: 12px; align-items: end; }
  .modal-card { padding: 20px 18px; }
  .secret-box { flex-direction: column; }
  .demo-banner { padding: 12px 14px; }
  .demo-banner-actions, .demo-banner-actions .action-button { width: 100%; }
  .demo-banner-actions .action-button { justify-content: center; }
  .form-actions .action-button { flex: 1 1 auto; justify-content: center; }
  .dashboard-page .action-button { white-space: normal; }
}
@media (max-width: 420px) {
  .env-switch button { padding: 0 8px; }
  .metric-grid, .metric-grid.six { grid-template-columns: 1fr 1fr; }
}
