/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  --sidebar-w: 236px;

  /* Sidebar */
  --sb-bg: #0C111D;
  --sb-border: rgba(255, 255, 255, 0.07);
  --sb-text: #8A9BB5;
  --sb-text-hover: #D0D9E8;
  --sb-hover-bg: rgba(255, 255, 255, 0.05);
  --sb-active-bg: rgba(33, 150, 243, 0.12);
  --sb-active-text: #FFFFFF;
  --sb-active-stripe: #2196F3;
  --sb-section-lbl: #445060;

  /* Content */
  --bg: #F2F5FA;
  --card: #FFFFFF;
  --card-border: #E3E8F0;
  --card-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);

  /* Text */
  --t1: #0D1424;
  --t2: #5C6B82;
  --t3: #9AAABB;

  /* Accent */
  --accent: #0EA5E9;
  --accent-h: #0369A1;
  --accent-light: #E0F2FE;

  /* Status */
  --ok: #10B981;
  --ok-bg: #ECFDF5;
  --ok-bd: #A7F3D0;
  --warn: #D97706;
  --warn-bg: #FFFBEB;
  --warn-bd: #FDE68A;
  --err: #E53E3E;
  --err-bg: #FFF5F5;
  --err-bd: #FEB2B2;
  --info: #2B6CB0;
  --info-bg: #EBF8FF;
  --info-bd: #90CDF4;
  --mute: #718096;
  --mute-bg: #F7FAFC;
  --mute-bd: #E2E8F0;

  --font: 'Outfit', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--t1);
  -webkit-font-smoothing: antialiased;
}

/* ── Layout Shell ──────────────────────────────────────────── */
.shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
}

/* Logo */
.sb-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--sb-border);
  text-decoration: none;
}

.sb-logo-img {
  height: 26px;
  width: auto;
  filter: brightness(0) invert(1);
  opacity: 0.88;
  flex-shrink: 0;
}

.sb-logo-words {
  line-height: 1.2;
}

.sb-logo-name {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.04em;
  display: block;
}

.sb-logo-sub {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--sb-section-lbl);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  display: block;
  margin-top: 1px;
}

/* Nav */
.sb-nav {
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
  scrollbar-width: none;
}

.sb-nav::-webkit-scrollbar {
  display: none;
}

.sb-group {
  margin-bottom: 2px;
}

.sb-group-label {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--sb-section-lbl);
  text-transform: uppercase;
  letter-spacing: 0.11em;
  padding: 12px 12px 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
}

.sb-group-label:hover {
  color: var(--sb-text);
}

.sb-group-label:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.sb-chevron {
  font-size: 8px;
  opacity: 0.45;
  transition: transform 0.22s ease;
  flex-shrink: 0;
}

.sb-group.is-open .sb-chevron {
  transform: rotate(180deg);
}

.sb-section-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.22s ease;
}

.sb-group.is-open .sb-section-body {
  max-height: 600px; /* generous cap — largest section ~240px */
}

@media (prefers-reduced-motion: reduce) {
  .sb-section-body, .sb-chevron { transition: none; }
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--sb-text);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  margin-bottom: 2px;
  position: relative;
}

.sb-link:hover {
  background: var(--sb-hover-bg);
  color: var(--sb-text-hover);
}

.sb-link.is-active {
  background: var(--sb-active-bg);
  color: var(--sb-active-text);
  font-weight: 600;
}

.sb-link.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 5px;
  bottom: 5px;
  width: 3px;
  background: var(--sb-active-stripe);
  border-radius: 0 3px 3px 0;
}

.sb-link i {
  width: 15px;
  text-align: center;
  font-size: 12.5px;
  opacity: 0.7;
  flex-shrink: 0;
}

.sb-link.is-active i {
  opacity: 1;
}

.sb-divider {
  height: 1px;
  background: var(--sb-border);
  margin: 6px 8px;
}

/* User footer */
.sb-footer {
  border-top: 1px solid var(--sb-border);
  padding: 10px 8px;
}

.sb-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 7px;
}

.sb-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #C0CDD8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}

.sb-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sb-user-info {
  flex: 1;
  min-width: 0;
}

.sb-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #D0DAE8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-user-email {
  font-size: 11px;
  color: var(--sb-section-lbl);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.sb-signout {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--sb-section-lbl);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  margin-top: 2px;
}

.sb-signout:hover {
  background: rgba(229, 62, 62, 0.1);
  color: #FC8181;
}

.sb-signout i {
  width: 15px;
  text-align: center;
  font-size: 12px;
}

.sb-version {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 4px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  font-family: var(--mono);
}

.sb-env-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 3px;
}

.sb-env-staging {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn-bd);
}

.sb-env-production {
  background: var(--ok-bg);
  color: var(--ok);
  border: 1px solid var(--ok-bd);
}

.sb-env-development {
  background: var(--mute-bg);
  color: var(--mute);
  border: 1px solid var(--mute-bd);
}

/* ── Content Area ──────────────────────────────────────────── */
.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Page Structure ────────────────────────────────────────── */
.page {
  padding: 32px 40px;
  max-width: 1360px;
}

/* Pages with a scrollable table stretch to fill the viewport
   instead of relying on a hard-coded --table-max-h guess. */
/* Most pages wrap their table in Tailwind's .overflow-x-auto, which sets
   overflow on BOTH axes and so becomes the sticky containing block. With
   no height bound it never scrolls, so the frozen header would scroll
   away with the page. Give it the same bounded, internally-scrolling box
   as .table-scroll-wrapper. Short tables are unaffected — a max-height
   only engages once the content exceeds it. */
.overflow-x-auto:has(> .dtable) {
  overflow-y: auto;
  max-height: var(--table-max-h, calc(100vh - 230px));
}

/* Clamp the height chain on table pages so the wrapper actually gets a
   bounded height and scrolls internally — without this it grows to the
   full table height, the window scrolls instead, and the sticky header
   (anchored to the wrapper) scrolls away with it. */
.content:has(> .page > .card > .table-scroll-wrapper) {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.page:has(> .card > .table-scroll-wrapper) {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.card:has(> .table-scroll-wrapper) {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.card:has(> .table-scroll-wrapper) > .table-scroll-wrapper {
  flex: 1;
  min-height: 0;
  max-height: none;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--t1);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.page-sub {
  font-size: 13.5px;
  color: var(--t2);
  margin-top: 4px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Card ──────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.card-body {
  padding: 20px 24px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--t1);
  margin-bottom: 14px;
}

/* ── Data Table ────────────────────────────────────────────── */
.dtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.dtable thead th {
  padding: 9px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: #F8FAFD;
  white-space: nowrap;
  /* Frozen on scroll. Applied to the cells, not the row: with
     border-collapse a sticky <tr> is ignored by most browsers. This
     sticks to the scroll wrapper on pages that have one, and to the
     viewport on pages that scroll normally. */
  position: sticky;
  top: 0;
  z-index: 5;
  /* A collapsed border is painted by the table, not the cell, so it
     scrolls away with the body — draw the rule on the cell instead. */
  box-shadow: inset 0 -1px 0 var(--card-border);
}

.dtable tbody tr {
  border-bottom: 1px solid #F0F4FA;
  transition: background 0.1s;
}

.dtable tbody tr:last-child {
  border-bottom: none;
}

.dtable tbody tr:hover {
  background: #F7FAFD;
}

.dtable tbody td {
  padding: 11px 16px;
  vertical-align: middle;
  color: var(--t1);
}

.dtable .mono {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.03em;
  color: var(--t1);
}

.dtable .muted {
  color: var(--t3);
  font-size: 12.5px;
}

.dtable .id-cell {
  color: var(--t3);
  font-size: 12px;
  font-family: var(--mono);
}

/* ── Status Chips ──────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.chip::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chip-ok {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: var(--ok-bd);
}

.chip-ok::before {
  background: var(--ok);
}

.chip-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: var(--warn-bd);
}

.chip-warn::before {
  background: var(--warn);
}

.chip-err {
  background: var(--err-bg);
  color: var(--err);
  border-color: var(--err-bd);
}

.chip-err::before {
  background: var(--err);
}

.chip-info {
  background: var(--info-bg);
  color: var(--info);
  border-color: var(--info-bd);
}

.chip-info::before {
  background: var(--info);
}

.chip-mute {
  background: var(--mute-bg);
  color: var(--mute);
  border-color: var(--mute-bd);
}

.chip-mute::before {
  background: var(--mute-bd);
}

.chip-custom::before {
  background: currentColor;
}

/* ── Buttons ───────────────────────────────────────────────── */
.abtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.13s, border-color 0.13s, color 0.13s;
  line-height: 1.4;
  white-space: nowrap;
}

.abtn-sm {
  padding: 5px 11px;
  font-size: 12.5px;
}

.abtn-xs {
  padding: 3px 9px;
  font-size: 11.5px;
}

.abtn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.abtn-primary:hover {
  background: var(--accent-h);
  border-color: var(--accent-h);
  color: #fff;
}

.abtn-outline {
  background: #fff;
  color: var(--t1);
  border-color: var(--card-border);
}

.abtn-outline:hover {
  background: #F7FAFC;
  border-color: #C8D3E0;
  color: var(--t1);
}

.abtn-ghost {
  background: transparent;
  color: var(--t2);
  border-color: transparent;
}

.abtn-ghost:hover {
  background: var(--mute-bg);
  color: var(--t1);
}

.abtn-danger {
  background: var(--err-bg);
  color: var(--err);
  border-color: var(--err-bd);
}

.abtn-danger:hover {
  background: #FED7D7;
}

.abtn-success {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: var(--ok-bd);
}

.abtn-success:hover {
  background: #D1FAE5;
}

/* ── Forms ─────────────────────────────────────────────────── */
.flabel {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--t1);
  margin-bottom: 5px;
}

.flabel-hint {
  font-weight: 400;
  color: var(--t3);
  font-size: 12px;
}

.finput,
.fselect {
  width: 100%;
  padding: 9px 12px;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 7px;
  font-size: 13.5px;
  font-family: var(--font);
  color: var(--t1);
  transition: border-color 0.13s, box-shadow 0.13s;
  outline: none;
  -webkit-appearance: none;
}

.finput:focus,
.fselect:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

.finput::placeholder {
  color: var(--t3);
}

.fselect {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%239AAABB' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
  padding-right: 34px;
}

.fgroup {
  margin-bottom: 16px;
}

/* ── Alert ─────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 20px;
}

.alert-err {
  background: var(--err-bg);
  border: 1px solid var(--err-bd);
  color: #C53030;
}

/* ── Toggle (statuses) ────────────────────────────────────── */
.tog {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s;
  letter-spacing: 0.04em;
}

.tog-on {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: var(--ok-bd);
}

.tog-on:hover {
  background: #D1FAE5;
}

.tog-off {
  background: var(--mute-bg);
  color: var(--t3);
  border-color: var(--mute-bd);
}

.tog-off:hover {
  background: #E2E8F0;
  color: var(--t2);
}

/* ── Info row (detail pages) ───────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0;
}

.info-item {
  padding: 14px 20px;
  border-right: 1px solid var(--card-border);
  border-bottom: 1px solid var(--card-border);
}

.info-item:nth-child(even):last-child {
  border-right: none;
}

.info-item-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--t3);
  margin-bottom: 5px;
}

.info-item-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--t1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Long free-text values (emails, addresses) wrap instead of being
   clipped — the grid row grows to fit rather than hiding characters. */
.info-item-value.info-item-value-wrap {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

.info-item-value.mono {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
}

/* ── Stat Card ─────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--card-shadow);
  overflow: visible;
}

.stat-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--t3);
  margin: 20px 0 8px;
}

.stat-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--t3);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--t1);
  letter-spacing: -0.02em;
  line-height: 1;
}

.stat-sub {
  font-size: 12px;
  color: var(--t3);
  margin-top: 5px;
}


.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

/* ── Dashboard matrix ──────────────────────────────────── */
.global-tabs {
  display: flex;
  gap: 3px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 4px;
  box-shadow: var(--card-shadow);
  flex-shrink: 0;
}

.gtab {
  font-size: 13px;
  font-weight: 700;
  padding: 7px 22px;
  border-radius: 7px;
  color: var(--t3);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  user-select: none;
  white-space: nowrap;
}

.gtab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px rgba(14, 165, 233, 0.35);
}

.matrix-wrap {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  margin-bottom: 10px;
}

.matrix-wrap:last-child {
  margin-bottom: 0;
}

.matrix-entity-hdr {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--t3);
  padding: 9px 16px 7px;
  border-bottom: 1px solid var(--card-border);
  background: #FAFBFD;
  display: flex;
  align-items: center;
  gap: 6px;
}

.matrix-scroll {
  overflow-x: auto;
}

.mtable {
  width: 100%;
  border-collapse: collapse;
}

.mtable th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--t3);
  padding: 8px 16px;
  text-align: left;
  background: #FAFBFD;
  border-bottom: 1px solid var(--card-border);
}

.mtable th:not(:first-child) {
  text-align: right;
}

.mtable td {
  padding: 9px 16px;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
}

.mtable tr:last-child td {
  border-bottom: none;
}

.mtable td:not(:first-child) {
  text-align: right;
  white-space: nowrap;
}

.mtable .mtotal td {
  background: #FAFBFD;
}

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

.mrdot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.mrname {
  font-size: 12.5px;
  font-weight: 700;
}

.mrsub {
  font-size: 10.5px;
  color: var(--t3);
  margin-top: 1px;
}

.mn {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.mn-total {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--t1);
}

.mn-eu {
  color: #2563EB;
}

.mn-us {
  color: #DC2626;
}

.mn-weight {
  font-size: 17px;
  font-weight: 600;
  color: var(--t2);
  font-variant-numeric: tabular-nums;
}

.matrix-section-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 1024px) {
  .matrix-section-row {
    display: block;
  }
}

/* ── Back link ─────────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--t2);
  text-decoration: none;
  margin-bottom: 16px;
  transition: color 0.12s;
}

.back-link:hover {
  color: var(--t1);
}

/* ── Filter bar ────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.filter-bar .finput {
  width: auto;
  min-width: 220px;
}

/* ── Card sub-parts ────────────────────────────────────────── */
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--card-border);
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title-tight {
  margin-bottom: 0;
}

.card-sub {
  font-size: 12px;
  color: var(--t3);
  margin-top: 2px;
}

/* ── Form scaffolding ──────────────────────────────────────── */
.form-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-body-lg-gap {
  gap: 16px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-actions {
  padding-top: 4px;
}

.form-actions-row {
  padding-top: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-actions-inline {
  padding-top: 4px;
  display: flex;
  gap: 8px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.form-help {
  font-size: 12px;
  color: var(--t3);
  margin-top: 4px;
}

.form-subsection {
  padding-top: 14px;
}

.form-subsection-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--t3);
  margin-bottom: 12px;
}

.req-mark {
  color: var(--err);
}

/* ── Input row (input + buttons inline) ────────────────────── */
.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-row .finput {
  flex: 1;
  min-width: 0;
}

.abtn-icon {
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 13px;
}

.abtn-icon-only {
  flex-shrink: 0;
  padding: 8px 10px;
  font-size: 13px;
}

.copy-hint {
  font-size: 12px;
  color: #065F46;
  margin-top: 4px;
}

.is-hidden {
  display: none;
}

.copy-btn {
  background: none;
  border: none;
  padding: 0 2px;
  cursor: pointer;
  color: var(--t3);
  font-size: 10px;
  opacity: 0;
  transition: opacity 0.1s, color 0.1s;
  line-height: 1;
  vertical-align: middle;
}
tr:hover .copy-btn,
.info-item:hover .copy-btn,
.copy-btn:focus {
  opacity: 1;
}
.copy-btn.copied {
  color: #065F46;
  opacity: 1;
}
.copy-btn-heading {
  opacity: 0.3;
  font-size: 13px;
}
.copy-btn-heading:hover,
.copy-btn-heading:focus {
  opacity: 1;
}
.copy-btn-heading.copied {
  color: #065F46;
  opacity: 1;
}

/* ── API key masked display ────────────────────────────────── */
.api-key-display {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--t1);
  padding: 8px 12px;
  background: var(--mute-bg);
  border: 1px solid var(--card-border);
  border-radius: 6px;
}

.api-key-display + .finput,
.api-key-display.has-input-below {
  margin-bottom: 8px;
}

.api-key-mask {
  color: var(--t3);
}

/* ── Checkbox row ──────────────────────────────────────────── */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #F8FAFC;
  border-radius: 7px;
  border: 1px solid var(--card-border);
}

.checkbox-input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.checkbox-label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--t1);
  cursor: pointer;
}

/* ── Toggle switch ─────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #F8FAFC;
  border-radius: 7px;
  border: 1px solid var(--card-border);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: #CBD5E1;
  border-radius: 999px;
  transition: background 0.15s ease;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25);
  transition: transform 0.15s ease;
}

.toggle-switch input:checked + .toggle-track {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-track .toggle-thumb {
  transform: translateX(16px);
}

.toggle-switch input:focus-visible + .toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toggle-label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--t1);
  cursor: pointer;
}

/* ── Inline code chip ──────────────────────────────────────── */
.code-inline {
  font-family: var(--mono);
  background: #F1F5F9;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11.5px;
}

/* ── Alert (success variant) ───────────────────────────────── */
.alert-ok {
  background: var(--ok-bg);
  border: 1px solid var(--ok-bd);
  color: #065F46;
  align-items: center;
}

/* ── Page content widths ───────────────────────────────────── */
.page-full {
  max-width: none;
}

.page-narrow {
  max-width: 680px;
}

.page-narrow-sm {
  max-width: 480px;
}

.page-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Misc utility ──────────────────────────────────────────── */
.mt-1 { margin-top: 4px; }
.icon-xs { font-size: 11px; }
.icon-2xs { font-size: 10px; }
.icon-sm { font-size: 12px; }
.finput-narrow { width: 160px; }
.text-uppercase { text-transform: uppercase; }
.back-link i { font-size: 11px; }

/* ── Override DaisyUI to not conflict with admin tables ─────── */
.dtable.table {
  display: table;
}

.dtable.table :where(thead tr) {
  background: #F8FAFD;
}

/* ── Mobile Top Bar (hidden on desktop) ──────────────────────── */
.topbar {
  display: none;
}

/* ── Responsive (≤768px) ─────────────────────────────────────── */
@media (max-width: 768px) {
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: var(--sb-bg);
    border-bottom: 1px solid var(--sb-border);
    padding: 0 16px;
    z-index: 300;
  }

  .topbar-hamburger {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 40px;
  }

  .topbar-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--sb-text);
    border-radius: 2px;
  }

  .topbar-hamburger:focus-visible {
    outline: 2px solid var(--sb-active-stripe);
    outline-offset: 2px;
    border-radius: 4px;
  }

  .topbar-hamburger:active {
    opacity: 0.6;
  }

  .topbar-logo {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: #fff;
  }

  /* Sidebar: hidden off-screen by default on mobile */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 250;
  }

  /* Backdrop: invisible until sidebar opens */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 240;
  }

  /* Open state */
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  /* Content: full-width, push down below topbar */
  .content {
    margin-left: 0;
    padding-top: 52px;
  }

  /* Page: tighter padding on small screens */
  .page {
    padding: 20px 16px;
  }

  /* Page header: stack title and actions vertically */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .page-actions {
    width: 100%;
    flex-wrap: wrap;
    align-items: center;
  }

  /* Filter inputs: go full width on mobile */
  .filter-bar .finput {
    width: 100% !important;
    min-width: 0 !important;
  }

  .filter-form {
    flex-wrap: wrap;
    width: 100%;
  }

  .filter-form .finput {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Partners config grid: stack to single column on mobile */
  .partner-config-grid {
    grid-template-columns: 1fr !important;
  }

  /* Logistics inline grid (integration type + polling interval): stack on mobile */
  .logistics-inline-grid {
    grid-template-columns: 1fr !important;
  }

  /* Form grid: stack to single column on mobile */
  .form-grid-2 {
    grid-template-columns: 1fr !important;
  }
}

/* ── Confirmation Modal ────────────────────────────── */
#app-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(13, 20, 36, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

#app-modal[hidden] {
  display: none;
}

.modal-card {
  background: #fff;
  border-radius: 12px;
  padding: 28px 28px 22px;
  width: 340px;
  max-width: calc(100vw - 40px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
}

.modal-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 14px;
}

.modal-icon.is-danger {
  background: var(--err-bg);
}

.modal-icon.is-primary {
  background: var(--warn-bg);
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--t1);
  margin-bottom: 6px;
}

.modal-body {
  font-size: 13px;
  color: var(--t2);
  line-height: 1.55;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 7px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.13s, border-color 0.13s;
}

.modal-btn.is-cancel {
  background: #fff;
  color: var(--t2);
  border-color: var(--card-border);
}

.modal-btn.is-cancel:hover {
  background: #F7FAFC;
}

.modal-btn.is-confirm-danger {
  background: var(--err);
  color: #fff;
  border-color: var(--err);
}

.modal-btn.is-confirm-danger:hover {
  background: #C53030;
}

.modal-btn.is-confirm-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.modal-btn.is-confirm-primary:hover {
  background: var(--accent-h);
}

.modal-btn:focus-visible {
  outline: 2px solid var(--sb-active-stripe);
  outline-offset: 2px;
}

/* ── Toast Stack ───────────────────────────────────── */
#toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1100;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  align-items: flex-end;
  pointer-events: none;
}

.toast-item {
  background: #fff;
  border: 1px solid var(--card-border);
  border-left: 4px solid var(--t3);
  border-radius: 10px;
  padding: 13px 14px 15px 14px;
  font-family: var(--font);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.11), 0 1px 4px rgba(15, 23, 42, 0.06);
  max-width: 360px;
  min-width: 240px;
  pointer-events: auto;
  position: relative;
  overflow: hidden;
  animation: toast-in 0.24s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.toast-item.is-hiding {
  animation: toast-out 0.18s ease forwards;
}

.toast-item.toast-success { border-left-color: var(--ok); }
.toast-item.toast-error   { border-left-color: var(--err); }
.toast-item.toast-warning { border-left-color: var(--warn); }
.toast-item.toast-info    { border-left-color: var(--accent); }

@keyframes toast-in {
  from { transform: translateX(28px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes toast-out {
  to { transform: translateX(28px); opacity: 0; }
}

.toast-icon {
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--t3);
}

.toast-success .toast-icon { color: var(--ok); }
.toast-error   .toast-icon { color: var(--err); }
.toast-warning .toast-icon { color: var(--warn); }
.toast-info    .toast-icon { color: var(--accent); }

.toast-msg {
  flex: 1;
  line-height: 1.45;
  color: var(--t1);
  font-size: 13.5px;
  font-weight: 500;
}

.toast-close {
  background: none;
  border: none;
  color: var(--t3);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 1px;
  transition: color 0.12s;
}

.toast-close:hover {
  color: var(--t1);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--t3);
  border-radius: 0;
  animation: toast-progress 4s linear forwards;
}

.toast-success .toast-progress { background: var(--ok); }
.toast-error   .toast-progress { background: var(--err); }
.toast-warning .toast-progress { background: var(--warn); }
.toast-info    .toast-progress { background: var(--accent); }

@keyframes toast-progress {
  from { width: 100%; }
  to   { width: 0; }
}

/* ── Tom Select overrides (match .finput) ─────────────────── */
.ts-wrapper.tz-select {
  font-family: var(--font);
}
/* Neutralize .fselect if Tom Select copies it onto the wrapper */
.ts-wrapper.tz-select.fselect {
  padding: 0;
  background: transparent;
  background-image: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
}
.ts-wrapper.tz-select .ts-control {
  padding: 8px 34px 8px 12px;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 7px;
  font-size: 13.5px;
  font-family: var(--font);
  color: var(--t1);
  min-height: 0;
  box-shadow: none;
  transition: border-color 0.13s, box-shadow 0.13s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%239AAABB' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
}
.ts-wrapper.tz-select.focus .ts-control,
.ts-wrapper.tz-select.dropdown-active .ts-control {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}
.ts-wrapper.tz-select .ts-control > input,
.ts-wrapper.tz-select .ts-control .item {
  font-size: 13.5px;
  color: var(--t1);
  margin: 0;
  padding: 0;
  line-height: 1.4;
}
.ts-wrapper.tz-select .ts-control > input::placeholder {
  color: var(--t3);
}
.ts-dropdown.tz-select {
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 7px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--t1);
  overflow: hidden;
}
.ts-dropdown.tz-select .ts-dropdown-content {
  padding: 4px 0;
}
.ts-dropdown.tz-select .option {
  padding: 7px 12px;
  cursor: pointer;
}
.ts-dropdown.tz-select .option.active,
.ts-dropdown.tz-select .active {
  background: rgba(14, 165, 233, 0.10);
  color: var(--t1);
}
.ts-dropdown.tz-select .option.selected {
  background: rgba(14, 165, 233, 0.16);
}
.ts-dropdown.tz-select .no-results {
  padding: 8px 12px;
  color: var(--t3);
}
.dt-tip {
  cursor: default;
}
#dt-tip-box {
  position: fixed;
  background: #1a202c;
  color: #e2e8f0;
  border: 1px solid #2d3748;
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 11.5px;
  font-family: var(--mono);
  white-space: nowrap;
  pointer-events: none;
  z-index: 9999;
  display: none;
}

/* ── Scrollable table with sticky header ──────────────────── */
.table-scroll-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  max-height: var(--table-max-h, 60vh);
}
/* Sticky headers live on .dtable thead th so they work both here and on
   pages that scroll with the viewport. Nothing row-level needed. */

/* ── Pagination bar ────────────────────────────────────────── */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-top: 1px solid var(--card-border);
  flex-wrap: wrap;
  gap: 8px;
}
.pager-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pager-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--card-border);
  border-radius: 5px;
  font-size: 12px;
  color: var(--t2);
  text-decoration: none;
  background: var(--card, #fff);
  transition: border-color .15s, color .15s;
}
.pager-btn:hover:not(.pager-btn-disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.pager-btn-disabled {
  opacity: 0.4;
  pointer-events: none;
}
.pager-input {
  width: 46px;
  padding: 2px 5px;
  border: 1px solid var(--card-border);
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--font);
  color: var(--t1);
  text-align: center;
  background: var(--card, #fff);
}
.pager-select {
  border: 1px solid var(--card-border);
  border-radius: 4px;
  font-size: 12px;
  color: var(--t2);
  padding: 3px 6px;
  background: var(--card, #fff);
  font-family: var(--font);
}

/* ── Column header filters ─────────────────────────────────── */
.th-filterable {
  cursor: pointer;
  user-select: none;
}
.th-filterable:hover {
  background: #EFF4FB;
  color: var(--t2);
}
.th-filtered {
  background: var(--accent-light) !important;
  color: var(--accent) !important;
}
.col-filter-popover {
  position: fixed;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.12);
  padding: 10px;
  z-index: 600;
  min-width: 200px;
  max-width: 280px;
}
.col-filter-content {
  margin-bottom: 8px;
}
.col-filter-input {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  font-family: var(--font);
  color: var(--t1);
  outline: none;
}
.col-filter-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}
.col-filter-enum-list {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.col-filter-enum-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 6px;
  border-radius: 5px;
  font-size: 13px;
  color: var(--t1);
  cursor: pointer;
}
.col-filter-enum-item:hover {
  background: #F7FAFD;
}
.col-filter-enum-item input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
/* Mutually-exclusive option is greyed out rather than hidden, so it
   stays visible and explains why it can't be combined. */
.col-filter-enum-item-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.col-filter-enum-item-disabled:hover {
  background: transparent;
}
.col-filter-enum-item-disabled input[type="checkbox"] {
  cursor: not-allowed;
}

.col-filter-enum-all {
  font-weight: 600;
  border-bottom: 1px solid var(--card-border);
  border-radius: 0;
  margin-bottom: 3px;
  padding-bottom: 8px;
}
.col-filter-date-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.col-filter-date-chip {
  padding: 3px 9px;
  border: 1px solid var(--card-border);
  border-radius: 99px;
  font-size: 11.5px;
  font-family: var(--font);
  background: #fff;
  color: var(--t2);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.col-filter-date-chip:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}
.col-filter-fp-input {
  width: 100%;
  padding: 7px 10px;
  font-size: 12px;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  font-family: var(--font);
  color: var(--t1);
  outline: none;
}
.col-filter-footer {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--card-border);
}
.col-filter-numeric-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.col-filter-num-op {
  width: 50px;
  flex-shrink: 0;
  padding: 6px 4px;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--t1);
  background: #fff;
  outline: none;
  text-align: center;
}
.col-filter-num-op:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}
.col-filter-num-val {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  font-family: var(--font);
  color: var(--t1);
  outline: none;
}
.col-filter-num-val:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}
.col-filter-num-unit {
  font-size: 11.5px;
  color: var(--t3);
  flex-shrink: 0;
  white-space: nowrap;
}
.col-filter-add-cond {
  font-size: 12px;
  color: var(--accent);
  background: none;
  border: none;
  padding: 2px 0 4px;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 500;
  display: block;
  text-align: left;
}
.col-filter-add-cond:hover {
  text-decoration: underline;
}
/* ── Impersonation Banner ───────────────────────────────── */
.impersonation-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #7C3AED;
  color: #fff;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.impersonation-email {
  opacity: 0.75;
  font-size: 12px;
  margin-left: 4px;
}
.impersonation-exit-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.impersonation-exit-btn:hover {
  background: rgba(255,255,255,0.28);
}
/* Push page content down when banner is active */
body:has(.impersonation-banner) .shell {
  margin-top: 37px;
}
/* ── Maintenance Mode Banner ──────────────────────────────── */
.maintenance-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9998;
  background: var(--warn-bg);
  color: var(--warn);
  border-bottom: 1px solid var(--warn-bd);
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  text-align: center;
}
.maintenance-banner a {
  color: var(--warn);
  text-decoration: underline;
}
body:has(.maintenance-banner) .shell {
  margin-top: 37px;
}
body:has(.impersonation-banner):has(.maintenance-banner) .maintenance-banner {
  top: 37px;
}
body:has(.impersonation-banner):has(.maintenance-banner) .shell {
  margin-top: 74px;
}

/* ── E-Invoicing additions ─────────────────────────────────── */
.overflow-x-auto { overflow-x: auto; }

.sb-logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2196F3 0%, #0EA5E9 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.35);
}

.empty-state {
  padding: 64px 24px;
  text-align: center;
}
.empty-state-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: var(--accent-light);
  color: var(--accent-h);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.empty-state-title { font-size: 16px; font-weight: 700; color: var(--t1); }
.empty-state-sub { font-size: 13.5px; color: var(--t3); margin-top: 6px; max-width: 420px; margin-left: auto; margin-right: auto; line-height: 1.5; }

.avatar-lg {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  background: #EFF6FF;
  color: #2B6CB0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  flex-shrink: 0;
}
.avatar-lg img { width: 100%; height: 100%; object-fit: cover; }

.avatar-sm {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: #EFF6FF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #2B6CB0;
}
.avatar-sm img { width: 100%; height: 100%; object-fit: cover; }

.two-col { display: flex; gap: 24px; align-items: flex-start; }
.two-col > .col-left { flex: 0 0 480px; max-width: 100%; display: flex; flex-direction: column; gap: 24px; }
.two-col > .col-right { flex: 1; min-width: 0; }
@media (max-width: 1100px) {
  .two-col { flex-direction: column; }
  .two-col > .col-left { flex: 1 1 auto; width: 100%; }
  .two-col > .col-right { width: 100%; }
}

.card-head { padding: 14px 20px; border-bottom: 1px solid var(--card-border); }
.card-head-sub { font-size: 12px; color: var(--t3); margin-top: 2px; }
.card-body-form { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.form-hint { font-size: 12px; color: var(--t3); margin-top: 4px; }

/* Status page: one card per connector */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

/* State shows as a tint of the whole card (and its chip), never a stripe */
.status-card {
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s, border-color 0.2s;
}

.status-card.status-ok {
  background: var(--ok-bg);
  border-color: var(--ok-bd);
}

.status-card.status-failed {
  background: var(--err-bg);
  border-color: var(--err-bd);
}

.status-card.status-queued,
.status-card.status-running {
  background: var(--info-bg);
  border-color: var(--info-bd);
}

.status-card.status-not-implemented {
  background: transparent;
  border-style: dashed;
  box-shadow: none;
}

.status-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px 10px;
}

.status-card-icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--card);
  color: var(--t2);
  font-size: 16px;
}

.status-card-name {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--t1);
}

.status-card-desc {
  font-size: 12.5px;
  color: var(--t3);
  margin-top: 2px;
}

.status-card-body {
  flex: 1;
  padding: 0 18px 12px;
  font-size: 12.5px;
  color: var(--t2);
}

.status-card-error {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--card);
  color: var(--err);
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.status-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 18px 16px;
}

.status-card-actions .abtn-ghost {
  margin-left: auto;
}

/* Status details: summary of the latest check, tinted by its outcome */
.status-run-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--bg);
}

.status-run-head.status-ok {
  background: var(--ok-bg);
}

.status-run-head.status-failed {
  background: var(--err-bg);
}

.status-run-head.status-queued,
.status-run-head.status-running {
  background: var(--info-bg);
}

.status-run-error {
  margin: 12px 20px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--err-bg);
  color: var(--err);
  font-size: 13px;
}

/* Dashboard health: state is shown by chips, icons and whole-block tints */
.health {
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: opacity 0.2s;
}

.health.is-loading {
  opacity: 0.6;
}

.health-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.health-seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 8px;
  background: var(--card-border);
}

.health-seg button {
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--t2);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.health-seg button:hover {
  color: var(--t1);
}

.health-seg button.is-active {
  background: var(--card);
  color: var(--t1);
  box-shadow: var(--card-shadow);
}

.health-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: var(--card);
}

.health-banner.tone-good { background: var(--ok-bg); border-color: var(--ok-bd); }
.health-banner.tone-warning { background: var(--warn-bg); border-color: var(--warn-bd); }
.health-banner.tone-serious,
.health-banner.tone-critical { background: var(--err-bg); border-color: var(--err-bd); }

.health-banner-icon {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: var(--card);
  color: var(--t3);
}

.tone-good .health-banner-icon { color: #0ca30c; }
.tone-warning .health-banner-icon { color: var(--warn); }
.tone-serious .health-banner-icon { color: #ec835a; }
.tone-critical .health-banner-icon { color: #d03b3b; }

.health-banner-text {
  flex: 1;
  min-width: 0;
}

.health-banner-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--t1);
}

.health-banner-sub {
  font-size: 13px;
  color: var(--t2);
  margin-top: 2px;
}

.health-banner-meta {
  font-size: 12px;
  color: var(--t2);
  text-align: right;
  line-height: 1.6;
}

.health-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.health-tile {
  padding: 16px 18px;
}

.health-tile.tone-warning { background: var(--warn-bg); border-color: var(--warn-bd); }
.health-tile.tone-serious,
.health-tile.tone-critical { background: var(--err-bg); border-color: var(--err-bd); }

.health-tile-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--t3);
}

.health-tile-value {
  font-size: 22px;
  font-weight: 650;
  color: var(--t1);
  margin-top: 6px;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.health-tile-value i {
  font-size: 16px;
  align-self: center;
}

.health-tile-of {
  font-size: 13px;
  font-weight: 500;
  color: var(--t2);
}

.health-tile-sub {
  font-size: 12px;
  color: var(--t2);
  margin-top: 4px;
}

.health-ok { color: #0ca30c; }
.health-err { color: #d03b3b; }
.health-mute { color: var(--t3); }

.health-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 20px 8px;
}

.health-card-sub {
  font-size: 12px;
  color: var(--t3);
  margin-top: 2px;
}

.health-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--t2);
}

.health-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.health-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.health-line-key {
  width: 14px;
  height: 2px;
  border-radius: 1px;
}

.health-conns {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px 4px;
}

.health-conn {
  padding: 12px 10px;
  border-radius: 10px;
}

.health-conn:hover {
  background: var(--bg);
}

.health-conn.is-muted {
  opacity: 0.65;
}

.health-conn-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.health-conn-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--t2);
  font-size: 13px;
}

.health-conn-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--t1);
  text-decoration: none;
}

.health-conn-name:hover {
  text-decoration: underline;
}

.health-conn-stats {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--t2);
}

.health-conn-stats strong {
  color: var(--t1);
}

.health-bars {
  display: flex;
  gap: 2px;
  height: 30px;
  margin-top: 10px;
}

.health-bar {
  flex: 1;
  min-width: 2px;
  border-radius: 2px;
  cursor: default;
  transition: filter 0.1s;
}

.health-bar:hover,
.health-bar:focus-visible {
  filter: brightness(0.9);
  outline: none;
}

.health-conn-error {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--err-bg);
  color: var(--err);
  font-size: 12.5px;
  word-break: break-word;
}

.health-conn-foot {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--t3);
}

.health-axis-ends {
  display: flex;
  justify-content: space-between;
  padding: 0 22px 14px;
  font-size: 11.5px;
  color: var(--t3);
}

.health-chart {
  padding: 4px 12px 12px;
  min-height: 240px;
}

.health-chart-svg {
  display: block;
  font-family: inherit;
}

.health-chart-svg .grid { stroke: #ecedf0; stroke-width: 1; }
.health-chart-svg .axis { stroke: #c3c2b7; stroke-width: 1; }
.health-chart-svg .crosshair { stroke: #898781; stroke-width: 1; }
.health-chart-svg .tick { fill: #898781; font-size: 11px; font-variant-numeric: tabular-nums; }
.health-chart-svg .end-label { fill: var(--t2); font-size: 12px; font-weight: 600; }

.health-chart-empty {
  min-height: 200px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--t3);
  font-size: 13px;
}

.health-chart-empty i {
  font-size: 22px;
}

.health-tip {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  padding: 8px 10px;
  border-radius: 8px;
  background: #0d1424;
  color: #fff;
  font-size: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 280px;
}

.health-tip-value {
  font-weight: 700;
}

.health-tip-label {
  color: rgba(255, 255, 255, 0.7);
}

.health-tip-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.health-tip-key {
  width: 12px;
  height: 2px;
  border-radius: 1px;
}

/* Settings */
.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 760px;
}

.settings-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 4px;
}

.settings-card-sub {
  font-size: 12px;
  color: var(--t3);
  margin-top: 2px;
}

.settings-card-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 14px 22px 22px;
}

.settings-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--bg);
  font-size: 13px;
  color: var(--t1);
  cursor: pointer;
}

.settings-option i {
  color: var(--t3);
}

@media (max-width: 640px) {
  .health-banner { flex-wrap: wrap; padding: 16px; }
  .health-banner-text { flex: 1 1 200px; }
  .health-banner-meta { width: 100%; text-align: left; padding-left: 60px; }
  .health-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .health-tile { padding: 14px; }
  .health-tile-value { font-size: 18px; }
  .health-conn-stats { margin-left: 0; width: 100%; }
}

/* Scenarios: free-text tests Claude carries out */
.scenario-form {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scenario-prompt {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}

.scenario-examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.scenario-example {
  cursor: pointer;
  border: 0;
  font: inherit;
  font-size: 12px;
}

.scenario-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.scenario-list-prompt {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--t1);
  text-decoration: none;
}

.scenario-list-verdict {
  font-size: 12.5px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scenario-prompt-view {
  padding: 16px 20px;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.55;
  color: var(--t1);
}

.scenario-verdict {
  margin: 0 20px 16px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--bg);
}

.scenario-verdict.scenario-passed { background: var(--ok-bg); }
.scenario-verdict.scenario-failed { background: var(--err-bg); }
.scenario-verdict.scenario-error { background: var(--warn-bg); }

.scenario-outputs {
  padding: 0 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scenario-events {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 20px 18px;
}

.scenario-event {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg);
  font-size: 13px;
}

.scenario-event.is-error { background: var(--err-bg); }

.scenario-thinking {
  display: block;
  background: transparent;
}

.scenario-thinking summary {
  cursor: pointer;
  font-size: 12.5px;
}

.scenario-say { background: var(--info-bg); }

.scenario-event-icon {
  color: var(--t3);
  width: 14px;
  margin-top: 3px;
  text-align: center;
  flex-shrink: 0;
}

.scenario-tool-name {
  font-weight: 600;
  font-size: 12.5px;
  margin-right: 6px;
}

.scenario-tool-summary {
  color: var(--t2);
  word-break: break-word;
  white-space: pre-wrap;
  margin-top: 2px;
}

.scenario-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  color: var(--t1);
}

.scenario-thinking .scenario-text {
  color: var(--t2);
  font-size: 12.5px;
  margin-top: 6px;
}

.scenario-pre {
  margin: 4px 0 0;
  font-size: 11.5px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--t2);
}

.scenario-shot {
  display: block;
  margin-top: 8px;
  max-width: 360px;
  width: 100%;
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--card-border);
}
