:root {
  --navy: #1F4E78;
  --navy-dark: #1a4268;
  --green: #10B981;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748B;
  --line: #E2E8F0;
  --bg: #F1F5F9;
  --panel: #FFFFFF;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --radius: 12px;
  --body: -apple-system, 'Inter', BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--body);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

/* ─── LIST CARDS (rendered by app.js) ─── */

.list-stack { display: grid; gap: 12px; }

.list-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}
.list-card:hover { box-shadow: var(--shadow-md); }

.list-card strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.card-head > div:first-child { display: grid; gap: 2px; }
.card-head span { font-size: 12px; color: var(--muted); }

.card-mode {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.meta {
  display: flex;
  gap: 8px 16px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: #F8FAFC;
  border-radius: 8px;
  border: 1px solid #F1F5F9;
}
.meta span { font-size: 12px; color: var(--muted); }
.meta strong { color: var(--ink-soft); font-weight: 600; }

.assign-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.assign-row .assign-select,
.assign-row .shared-assign-select { flex: 1 1 220px; }
.assign-row .assign-button,
.assign-row .shared-assign-button { flex: 0 1 180px; }

.whatsapp-section { border-top: 1px solid var(--line); padding-top: 10px; }

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.actions button,
.actions .ghost-link,
.actions .primary-link,
.actions .ghost-button,
.actions .accent-link { flex: 1 1 120px; }

/* ─── FORM ELEMENTS ─── */

input, select {
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  height: 38px;
}
input:focus, select:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(31,78,120,0.08);
}
label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }

/* ─── BUTTONS ─── */

button, .primary-link, .ghost-link, .ghost-button, .accent-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

button, .primary-link {
  background: var(--navy);
  color: #fff;
  border: none;
}
button:hover, .primary-link:hover { background: var(--navy-dark); }

.ghost-link, .ghost-button {
  background: #fff;
  color: var(--ink-soft);
  border: 1.5px solid var(--line);
}
.ghost-link:hover, .ghost-button:hover { background: #F8FAFC; border-color: #CBD5E1; }

.accent-link {
  background: #EFF6FF;
  color: #1D4ED8;
  border: 1px solid #BFDBFE;
}
.accent-link:hover { background: #DBEAFE; }
.accent-link[aria-disabled="true"] { opacity: 0.4; pointer-events: none; }

/* Branded QR / Dashboard links with logo background */
.logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 48px;
  padding: 6px 14px 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  background-color: #fff;
  border: 1.5px solid var(--line);
  flex: 1 1 120px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.logo-link::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 52px;
  background-image: url('/branding/payqu-logo.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center left 4px;
  opacity: 0.18;
}
.logo-link:hover { border-color: #94A3B8; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.logo-link--qr  { color: #059669; border-color: #A7F3D0; }
.logo-link--qr::before  { opacity: 0.22; }
.logo-link--qr:hover  { background: #F0FDF4; border-color: #6EE7B7; }
.logo-link--dash { color: #1D4ED8; border-color: #BFDBFE; }
.logo-link--dash:hover { background: #EFF6FF; border-color: #93C5FD; }

/* ─── STATUS CHIPS ─── */

.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  background: #F1F5F9;
  color: var(--muted);
}
.status-chip.available  { background: #ECFDF5; color: #059669; }
.status-chip.assigned   { background: #FFFBEB; color: #D97706; }
.status-chip.live       { background: #ECFDF5; color: #047857; }
.status-chip.blocked    { background: #FEF2F2; color: #DC2626; }
.status-chip.connected  { background: #ECFDF5; color: #059669; }
.status-chip.expired    { background: #FEF2F2; color: #DC2626; }
.status-chip.shared-mode    { background: #EFF6FF; color: #1D4ED8; }
.status-chip.dedicated-mode { background: #F5F3FF; color: #6D28D9; }

/* ─── VALIDATION ─── */

.validation-block { display: grid; gap: 8px; padding-top: 6px; }
.validation-empty { margin: 0; color: var(--muted); font-size: 12px; }

.validation-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.validation-summary.live    { background: rgba(16,185,129,0.06); border-color: #A7F3D0; }
.validation-summary.blocked { background: rgba(239,68,68,0.05);  border-color: #FECACA; }
.validation-summary span { color: var(--muted); font-size: 12px; }

.validation-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.validation-item {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #FAFBFC;
}
.validation-item.ok   { background: rgba(16,185,129,0.06); border-color: #A7F3D0; }
.validation-item.fail { background: rgba(239,68,68,0.05);  border-color: #FECACA; }
.validation-item-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.validation-item-top span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
.validation-item p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }

/* ─── EMPTY STATE ─── */
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 24px 0; }

/* ─── RESPONSIVE ─── */
@media (max-width: 980px) {
  .assign-row { flex-direction: column; }
  .assign-row .assign-button,
  .assign-row .assign-select,
  .assign-row .shared-assign-button,
  .assign-row .shared-assign-select { width: 100%; flex: 1 1 auto; }
  .validation-grid { grid-template-columns: 1fr; }
}

/* ─── BULK ASSIGN PANEL ─── */
.bo-bulk-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin: 0 0 22px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}

.bo-bulk-panel > summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 22px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}

.bo-bulk-panel > summary::-webkit-details-marker { display: none; }
.bo-bulk-panel > summary::after {
  content: "▾";
  position: absolute;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
  transition: transform 0.2s ease;
}
.bo-bulk-panel[open] > summary::after { transform: translateY(-50%) rotate(180deg); }

.bo-bulk-title { font-size: 15px; font-weight: 700; color: var(--ink); }
.bo-bulk-hint { font-size: 12px; color: var(--muted); }

.bo-bulk-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  background: #F8FAFC;
  border-top: 1px solid var(--line);
}

.bo-bulk-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.bo-bulk-status { font-size: 12px; color: var(--muted); margin-left: auto; }

.bo-bulk-table-wrap {
  padding: 0 22px 18px;
  overflow-x: auto;
}

.bo-bulk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.bo-bulk-table th,
.bo-bulk-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}

.bo-bulk-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  font-weight: 600;
}

.bo-bulk-table tbody tr:hover { background: #F8FAFC; }

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

/* ─── SENDER DRILLDOWN (merchants per sender) ─── */
.sender-merchants {
  border-top: 1px solid var(--line);
  margin-top: 10px;
  padding-top: 6px;
}

.sender-merchants > summary {
  list-style: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--navy);
  font-weight: 600;
  padding: 6px 0;
  position: relative;
  padding-right: 18px;
}
.sender-merchants > summary::-webkit-details-marker { display: none; }
.sender-merchants > summary::after {
  content: "▾";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--muted);
  transition: transform 0.2s ease;
}
.sender-merchants[open] > summary::after { transform: translateY(-50%) rotate(180deg); }

.sender-merchants-list {
  list-style: none;
  padding: 6px 0 0;
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
  max-height: 200px;
  overflow-y: auto;
}

.sender-merchants-list li {
  padding: 4px 0;
  border-bottom: 1px dashed var(--line);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.sender-merchants-list li:last-child { border-bottom: 0; }
.sender-merchants-list .sm-email { color: var(--muted); font-size: 11px; }
.sender-merchants-empty { padding: 8px 0; font-size: 12px; color: var(--muted); }
