:root {
  --ink-950: #111827;
  --ink-900: #172033;
  --ink-800: #263247;
  --ink-700: #3d4a5f;
  --ink-600: #59667a;
  --ink-500: #748094;
  --ink-400: #98a2b3;
  --ink-300: #c8ced8;
  --ink-200: #dfe3e9;
  --ink-100: #eef1f4;
  --ink-50: #f7f8fa;
  --white: #ffffff;
  --teal-700: #0b6b5f;
  --teal-600: #0f8272;
  --teal-100: #d8f1eb;
  --teal-50: #effaf7;
  --green-700: #147a43;
  --green-100: #dff4e7;
  --red-700: #b42318;
  --red-100: #fee4e2;
  --amber-800: #8a4b0f;
  --amber-100: #fef0c7;
  --blue-700: #175cd3;
  --blue-100: #dbeafe;
  --sidebar-width: 252px;
  --topbar-height: 68px;
  --radius: 6px;
  --shadow-lg: 0 18px 45px rgba(16, 24, 40, 0.16);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--ink-50); }

body {
  margin: 0;
  color: var(--ink-900);
  background: var(--ink-50);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}

button, input, select { font: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(15, 130, 114, .2); outline-offset: 2px; }
a { color: inherit; text-decoration: none; }
svg { width: 18px; height: 18px; stroke-width: 1.8; flex: 0 0 auto; }
h1, h2, h3, p { margin: 0; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--ink-950);
  color: var(--ink-300);
  border-right: 1px solid #293244;
}

.brand-row { height: 68px; display: flex; align-items: center; padding: 0 18px; border-bottom: 1px solid #293244; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; color: var(--white); }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 6px; background: #18a48f; color: #071d19; font-size: 19px; font-weight: 850; }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1.05; }
.brand strong { font-size: 17px; letter-spacing: 0; }
.brand small { margin-top: 4px; color: #8fa2a0; font-size: 9px; font-weight: 750; letter-spacing: 1.6px; }
.sidebar-close { display: none !important; margin-left: auto; color: var(--white) !important; }

.user-avatar { display: grid; place-items: center; flex: 0 0 auto; font-weight: 750; }

.nav-groups { min-height: 0; flex: 1; overflow-y: auto; padding: 4px 10px 16px; scrollbar-width: thin; }
.nav-group { margin-top: 16px; }
.nav-label { display: block; padding: 0 9px 6px; color: #718096; font-size: 10px; font-weight: 750; text-transform: uppercase; }
.nav-item { position: relative; height: 38px; display: flex; align-items: center; gap: 10px; padding: 0 10px; margin: 2px 0; border-radius: 5px; color: #aab4c3; font-size: 13px; font-weight: 550; }
.nav-item:hover { color: var(--white); background: #202a3b; }
.nav-item.active { color: var(--white); background: #263448; }
.nav-item.active::before { content: ""; position: absolute; left: -10px; width: 3px; height: 22px; background: #28bba4; border-radius: 0 3px 3px 0; }
.nav-item svg { width: 17px; height: 17px; }
.nav-count { min-width: 22px; margin-left: auto; padding: 1px 6px; border-radius: 9px; background: #344055; color: #d6dce5; font-size: 10px; text-align: center; }
.nav-count.danger { background: #5b2a2b; color: #fecaca; }
.nav-dot { width: 7px; height: 7px; margin-left: auto; border-radius: 50%; }
.nav-dot.warning { background: #f4b740; }

.sidebar-footer { padding: 10px 12px; border-top: 1px solid #293244; }
.profile-button { width: 100%; display: flex; align-items: center; gap: 9px; padding: 6px; color: var(--white); background: transparent; border: 0; text-align: left; }
.profile-button > span:nth-child(2) { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.profile-button strong { font-size: 12px; }
.profile-button small { color: var(--ink-400); font-size: 10px; }
.profile-button > svg { width: 16px; color: var(--ink-400); }
.user-avatar { width: 31px; height: 31px; border-radius: 50%; background: var(--teal-100); color: var(--teal-700); font-size: 10px; }
.user-avatar.blue { background: var(--blue-100); color: var(--blue-700); }
.user-avatar.amber { background: var(--amber-100); color: var(--amber-800); }

.main-shell { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-height); display: flex; align-items: center; gap: 16px; padding: 0 28px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--ink-200); }
.mobile-menu { display: none !important; }
.page-identity { min-width: 0; display: flex; align-items: baseline; gap: 12px; }
.page-identity h1 { color: var(--ink-950); font-size: 18px; font-weight: 740; }
.page-identity span { color: var(--ink-500); font-size: 12px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.global-search, .search-control { display: flex; align-items: center; gap: 8px; color: var(--ink-500); background: var(--white); border: 1px solid var(--ink-200); border-radius: 5px; }
.global-search { width: 252px; height: 36px; padding: 0 9px; }
.global-search svg, .search-control svg { width: 16px; }
.global-search input, .search-control input { min-width: 0; flex: 1; height: 100%; padding: 0; color: var(--ink-900); background: transparent; border: 0; outline: 0; }
.global-search kbd { padding: 0 5px; color: var(--ink-400); background: var(--ink-50); border: 1px solid var(--ink-200); border-radius: 3px; font-family: inherit; font-size: 10px; }
.environment { display: flex; align-items: center; gap: 6px; padding: 6px 9px; color: var(--ink-600); border: 1px solid var(--ink-200); border-radius: 5px; font-size: 11px; }
.environment > span { width: 7px; height: 7px; background: #1e9e58; border-radius: 50%; box-shadow: 0 0 0 3px var(--green-100); }
.icon-button { width: 36px; height: 36px; display: inline-grid; place-items: center; padding: 0; color: var(--ink-600); background: transparent; border: 1px solid var(--ink-200); border-radius: 5px; }
.icon-button:hover { color: var(--ink-950); background: var(--ink-50); }
.icon-button.compact { width: 30px; height: 30px; border-color: transparent; }
.notification-button { position: relative; }
.notification-button > span { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; display: grid; place-items: center; padding: 0 4px; color: var(--white); background: var(--red-700); border: 2px solid var(--white); border-radius: 10px; font-size: 8px; font-weight: 750; }

.content-shell { width: min(1600px, 100%); margin: 0 auto; padding: 24px 28px 44px; }
.impersonation-banner { position: sticky; top: var(--topbar-height); z-index: 29; min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 7px 28px; color: var(--amber-800); background: #fffbeb; border-bottom: 1px solid #edcf82; }
.impersonation-banner[hidden] { display: none; }
.impersonation-icon { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; color: var(--amber-800); background: var(--amber-100); border-radius: 5px; }
.impersonation-icon svg { width: 16px; }
.impersonation-banner > div { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.impersonation-banner strong { font-size: 11px; }
.impersonation-banner small { font-size: 9px; }
.impersonation-banner .button { min-height: 31px; color: var(--amber-800); border-color: #dfbd64; }
.view { display: none; }
.view.active { display: block; animation: view-in .16s ease-out; }
@keyframes view-in { from { opacity: .6; transform: translateY(2px); } to { opacity: 1; transform: none; } }
.view-toolbar { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }
.segmented { display: inline-flex; align-items: center; padding: 3px; background: var(--ink-100); border-radius: 6px; }
.segmented button { min-height: 30px; padding: 4px 12px; color: var(--ink-600); background: transparent; border: 0; border-radius: 4px; font-size: 12px; }
.segmented button.active { color: var(--ink-950); background: var(--white); box-shadow: 0 1px 3px rgba(16,24,40,.12); font-weight: 650; }
.compact-segment { padding: 2px; }
.compact-segment button { min-height: 29px; padding-inline: 10px; }
.select-control { height: 36px; display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; color: var(--ink-500); background: var(--white); border: 1px solid var(--ink-200); border-radius: 5px; }
.select-control svg { width: 15px; }
.select-control select { min-width: 120px; padding-right: 20px; color: var(--ink-700); background: transparent; border: 0; outline: 0; }
.button { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 12px; border: 1px solid transparent; border-radius: 5px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.button svg { width: 15px; }
.button.primary { color: var(--white); background: var(--teal-700); border-color: var(--teal-700); }
.button.primary:hover { background: #09594f; }
.button.secondary { color: var(--ink-700); background: var(--white); border-color: var(--ink-200); }
.button.secondary:hover { background: var(--ink-50); border-color: var(--ink-300); }
.button.text-button { padding-inline: 4px; color: var(--teal-700); background: transparent; border: 0; }
.button.mini { min-height: 28px; padding: 4px 9px; color: var(--ink-700); background: var(--white); border-color: var(--ink-200); font-size: 11px; }

.metric-grid { display: grid; grid-template-columns: 1.25fr repeat(4, 1fr); margin-bottom: 18px; background: var(--white); border: 1px solid var(--ink-200); border-radius: var(--radius); overflow: hidden; }
.metric { min-width: 0; padding: 17px 18px; border-right: 1px solid var(--ink-200); }
.metric:last-child { border-right: 0; }
.metric-label { display: flex; justify-content: space-between; align-items: center; color: var(--ink-600); font-size: 11px; }
.metric-label svg { width: 17px; color: var(--ink-400); }
.metric strong { display: block; margin-top: 10px; color: var(--ink-950); font-size: 24px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.primary-metric { border-top: 3px solid var(--teal-600); }
.primary-metric strong { font-size: 27px; }
.metric-foot { min-height: 18px; display: flex; align-items: center; gap: 3px; margin-top: 7px; color: var(--ink-500); font-size: 10px; }
.metric-foot svg { width: 12px; }
.metric-foot.positive { color: var(--green-700); }
.alert-metric { background: #fffdf8; }
.alert-metric .metric-label svg, .alert-metric strong { color: var(--amber-800); }
.metric-link { display: flex; align-items: center; gap: 3px; margin-top: 5px; padding: 0; color: var(--amber-800); background: transparent; border: 0; font-size: 10px; }
.metric-link svg { width: 12px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(300px, .8fr); gap: 18px; margin-bottom: 18px; }
.panel { background: var(--white); border: 1px solid var(--ink-200); border-radius: var(--radius); }
.panel-heading { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--ink-100); }
.panel-heading h2, .provider-head h2 { color: var(--ink-950); font-size: 13px; font-weight: 700; }
.panel-heading p, .provider-head p { margin-top: 2px; color: var(--ink-500); font-size: 10px; }
.chart-legend { display: flex; align-items: center; gap: 6px; color: var(--ink-500); font-size: 10px; }
.chart-legend span { width: 8px; height: 8px; margin-left: 7px; border-radius: 2px; }
.chart-legend span.success { background: var(--teal-600); }
.chart-legend span.muted { background: var(--ink-300); }
.chart-wrap { position: relative; height: 240px; padding: 18px 18px 28px 54px; }
.line-chart { width: 100%; height: 190px; overflow: visible; }
.line-chart .grid-lines line { stroke: var(--ink-100); stroke-width: 1; }
.line-chart .area { fill: rgba(15,130,114,.08); }
.line-chart .line { fill: none; stroke: var(--teal-600); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.line-chart .points circle { fill: var(--white); stroke: var(--teal-600); stroke-width: 2.5; }
.y-labels { position: absolute; inset: 17px auto 27px 14px; display: flex; flex-direction: column; justify-content: space-between; color: var(--ink-400); font-size: 9px; }
.x-labels { position: absolute; inset: auto 18px 10px 54px; display: flex; justify-content: space-between; color: var(--ink-400); font-size: 9px; }

.channel-list { padding: 5px 16px; }
.channel-row { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--ink-100); }
.channel-row:last-child { border-bottom: 0; }
.channel-row > div { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.channel-row strong { font-size: 11px; }
.channel-row small { color: var(--ink-500); font-size: 9px; }
.provider-logo, .method-mark { display: grid; place-items: center; flex: 0 0 auto; font-weight: 800; }
.provider-logo { width: 31px; height: 31px; border-radius: 6px; }
.provider-logo.large { width: 40px; height: 40px; font-size: 16px; }
.provider-logo.paypal { color: #144a9a; background: #e6effc; }
.provider-logo.stripe { color: #5546c8; background: #efedff; }
.provider-logo.adyen { color: #087a45; background: #e1f5e9; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-600); font-size: 10px; white-space: nowrap; }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-400); }
.status-dot.healthy { color: var(--green-700); }
.status-dot.healthy::before { background: #20a45b; box-shadow: 0 0 0 3px var(--green-100); }
.status-dot.degraded { color: var(--amber-800); }
.status-dot.degraded::before { background: #e79a16; box-shadow: 0 0 0 3px var(--amber-100); }
.status-dot.neutral::before { background: var(--ink-500); box-shadow: 0 0 0 3px var(--ink-100); }
.channel-summary { display: grid; grid-template-columns: 1fr 1fr; margin: 0 16px 14px; background: var(--ink-50); border: 1px solid var(--ink-100); border-radius: 5px; }
.channel-summary > div { padding: 9px 10px; }
.channel-summary > div + div { border-left: 1px solid var(--ink-200); }
.channel-summary span { display: block; color: var(--ink-500); font-size: 9px; }
.channel-summary strong { display: block; margin-top: 2px; font-size: 13px; }

.table-panel { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 9px 14px; color: var(--ink-500); background: #fafbfc; border-bottom: 1px solid var(--ink-200); font-size: 10px; font-weight: 650; white-space: nowrap; }
td { padding: 11px 14px; color: var(--ink-700); border-bottom: 1px solid var(--ink-100); font-size: 11px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfd; }
td strong { color: var(--ink-900); font-size: 11px; }
td > small, td > strong + small { display: block; margin-top: 2px; color: var(--ink-500); font-size: 9px; }
.clickable-row { cursor: pointer; }
.method { display: inline-flex; align-items: center; gap: 7px; }
.method-mark { width: 22px; height: 22px; border-radius: 4px; font-size: 9px; }
.method-mark.paypal { color: #144a9a; background: #e6effc; }
.method-mark.card { color: #5849b8; background: #efedff; }
.badge { display: inline-flex; align-items: center; padding: 3px 7px; border-radius: 4px; font-size: 9px; font-weight: 650; white-space: nowrap; }
.badge.success { color: var(--green-700); background: var(--green-100); }
.badge.processing { color: var(--blue-700); background: var(--blue-100); }
.badge.failed { color: var(--red-700); background: var(--red-100); }
.badge.warning, .badge.unknown { color: var(--amber-800); background: var(--amber-100); }
.row-action { color: var(--ink-400); }
.attention-row { background: #fffdf7; }

.page-actions { margin-bottom: 14px; }
.summary-line { min-height: 36px; display: flex; align-items: center; gap: 7px; color: var(--ink-600); font-size: 11px; }
.summary-line strong { color: var(--ink-950); font-size: 17px; }
.summary-line .divider { width: 1px; height: 20px; margin: 0 7px; background: var(--ink-200); }
.filter-bar { min-height: 54px; display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--ink-200); overflow-x: auto; }
.search-control { width: 260px; min-width: 200px; height: 34px; padding: 0 9px; }
.filter-bar .select-control { height: 34px; }
.filter-more { margin-left: auto; }
.table-footer { min-height: 50px; display: flex; align-items: center; justify-content: space-between; padding: 8px 14px; color: var(--ink-500); border-top: 1px solid var(--ink-100); font-size: 10px; }
.pagination { display: flex; gap: 3px; }
.pagination button { min-width: 28px; height: 28px; display: grid; place-items: center; padding: 0 7px; color: var(--ink-600); background: var(--white); border: 1px solid var(--ink-200); border-radius: 4px; font-size: 10px; }
.pagination button.active { color: var(--white); background: var(--ink-900); border-color: var(--ink-900); }
.pagination button:disabled { color: var(--ink-300); }
.pagination svg { width: 13px; }

.notice { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding: 10px 12px; border: 1px solid; border-radius: var(--radius); }
.notice > svg { width: 18px; }
.notice > div { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.notice strong { font-size: 11px; }
.notice span { font-size: 10px; }
.warning-notice { color: var(--amber-800); background: #fffbeb; border-color: #f3d78f; }
.stacked-badges { display: flex; flex-wrap: wrap; gap: 3px; }
.stacked-badges span { padding: 2px 5px; color: var(--ink-600); background: var(--ink-100); border-radius: 3px; font-size: 9px; }
.site-cell, .user-cell { display: flex; align-items: center; gap: 8px; }
.site-cell > span:last-child, .user-cell > span:last-child { display: flex; flex-direction: column; }
.site-icon { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; color: var(--teal-700); background: var(--teal-100); border-radius: 5px; font-size: 9px; font-weight: 750; }
.site-icon.sandbox { color: var(--amber-800); background: var(--amber-100); }

.provider-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.provider-card { padding: 16px; background: var(--white); border: 1px solid var(--ink-200); border-radius: var(--radius); }
.provider-card.degraded-card { border-top: 3px solid #e79a16; }
.provider-head { display: flex; align-items: center; gap: 10px; }
.provider-head > div { min-width: 0; flex: 1; }
.provider-head > .icon-button { margin-left: auto; }
.provider-status { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 14px 0; padding: 8px 10px; background: var(--ink-50); border-radius: 5px; color: var(--ink-500); font-size: 9px; }
.provider-metrics { display: grid; grid-template-columns: repeat(3, 1fr); border-block: 1px solid var(--ink-100); }
.provider-metrics > div { padding: 11px 8px; border-right: 1px solid var(--ink-100); }
.provider-metrics > div:last-child { border: 0; }
.provider-metrics span, .provider-sites span { display: block; color: var(--ink-500); font-size: 9px; }
.provider-metrics strong { display: block; margin-top: 4px; color: var(--ink-950); font-size: 14px; }
.provider-sites { margin-top: 12px; }
.provider-sites strong { display: block; margin-top: 3px; overflow: hidden; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.priority-number { width: 24px; height: 24px; display: grid; place-items: center; color: var(--ink-700); background: var(--ink-100); border-radius: 4px; font-weight: 700; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ink-200); }
.tabs button { position: relative; min-height: 38px; padding: 7px 12px; color: var(--ink-500); background: transparent; border: 0; }
.tabs button.active { color: var(--ink-950); font-weight: 650; }
.tabs button.active::after { content: ""; position: absolute; inset: auto 8px -1px; height: 2px; background: var(--teal-600); }
.tabs button span { display: inline-grid; min-width: 16px; height: 16px; place-items: center; margin-left: 3px; color: var(--red-700); background: var(--red-100); border-radius: 8px; font-size: 8px; }
.webhook-panel { display: none; }
.webhook-panel.active { display: block; }

.case-list { background: var(--white); border: 1px solid var(--ink-200); border-radius: var(--radius); overflow: hidden; }
.case-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) 170px auto; align-items: center; gap: 12px; min-height: 82px; padding: 12px 15px; border-bottom: 1px solid var(--ink-100); }
.case-row:last-child { border-bottom: 0; }
.case-row.critical { border-left: 3px solid var(--red-700); }
.case-icon { width: 36px; height: 36px; display: grid; place-items: center; color: var(--amber-800); background: var(--amber-100); border-radius: 5px; }
.case-row.critical .case-icon { color: var(--red-700); background: var(--red-100); }
.case-main > div { display: flex; align-items: center; gap: 8px; }
.case-main strong { font-size: 11px; }
.case-main p { margin-top: 4px; color: var(--ink-500); font-size: 10px; }
.case-meta { display: flex; flex-direction: column; color: var(--ink-500); font-size: 9px; }
.case-meta strong { margin-top: 3px; color: var(--ink-700); font-size: 10px; }

.health-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.health-item { padding: 14px; background: var(--white); border: 1px solid var(--ink-200); border-radius: var(--radius); }
.health-item.warning { border-top: 3px solid #e79a16; }
.health-item > div:first-child { display: flex; align-items: center; gap: 9px; }
.health-item > div:first-child > span:nth-child(2) { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.health-item > div:first-child strong { font-size: 11px; }
.health-item > div:first-child small { color: var(--ink-500); font-size: 9px; }
.health-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 5px; }
.health-icon.healthy { color: var(--green-700); background: var(--green-100); }
.health-icon.warning { color: var(--amber-800); background: var(--amber-100); }
.health-icon svg { width: 16px; }
.health-item dl { display: grid; grid-template-columns: 1fr 1fr; margin: 13px 0 0; padding-top: 11px; border-top: 1px solid var(--ink-100); }
.health-item dl > div + div { padding-left: 12px; border-left: 1px solid var(--ink-100); }
.health-item dt { color: var(--ink-500); font-size: 9px; }
.health-item dd { margin: 3px 0 0; color: var(--ink-900); font-size: 12px; font-weight: 700; }

.mobile-bottom-nav { display: none; }
.sidebar-scrim, .drawer-scrim, .modal-scrim { position: fixed; inset: 0; z-index: 44; display: none; background: rgba(17,24,39,.48); }
.detail-drawer { position: fixed; inset: 0 0 0 auto; z-index: 50; width: min(520px, 100vw); display: flex; flex-direction: column; background: var(--white); box-shadow: var(--shadow-lg); transform: translateX(105%); transition: transform .2s ease; }
.detail-drawer.open { transform: translateX(0); }
.drawer-scrim.open, .modal-scrim.open { display: block; }
.drawer-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 18px 20px 12px; border-bottom: 1px solid var(--ink-100); }
.eyebrow { display: block; margin-bottom: 3px; color: var(--ink-500); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.drawer-header h2, .modal-header h2 { font-size: 19px; }
.copy-id { display: inline-flex; align-items: center; gap: 4px; margin-top: 3px; padding: 0; color: var(--ink-500); background: transparent; border: 0; font-size: 9px; }
.copy-id svg { width: 11px; }
.drawer-status { display: flex; align-items: center; justify-content: space-between; padding: 11px 20px; background: var(--ink-50); }
.drawer-status strong { font-size: 17px; }
.drawer-tabs { display: flex; padding: 0 12px; border-bottom: 1px solid var(--ink-200); overflow-x: auto; }
.drawer-tabs button { position: relative; min-width: max-content; padding: 12px 10px; color: var(--ink-500); background: transparent; border: 0; font-size: 11px; }
.drawer-tabs button.active { color: var(--ink-950); font-weight: 650; }
.drawer-tabs button.active::after { content: ""; position: absolute; inset: auto 8px -1px; height: 2px; background: var(--teal-600); }
.drawer-body { display: none; min-height: 0; flex: 1; overflow-y: auto; padding: 18px 20px; }
.drawer-body.active { display: block; }
.detail-section { margin-bottom: 20px; }
.detail-section h3 { margin-bottom: 10px; font-size: 12px; }
.detail-list { display: grid; grid-template-columns: 1fr 1fr; margin: 0; border: 1px solid var(--ink-200); border-radius: 5px; }
.detail-list > div { padding: 10px 11px; border-bottom: 1px solid var(--ink-100); }
.detail-list > div:nth-child(odd) { border-right: 1px solid var(--ink-100); }
.detail-list > div:nth-last-child(-n+2) { border-bottom: 0; }
.detail-list dt { color: var(--ink-500); font-size: 9px; }
.detail-list dd { margin: 2px 0 0; color: var(--ink-900); font-size: 10px; font-weight: 650; overflow-wrap: anywhere; }
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { position: relative; display: flex; gap: 10px; min-height: 48px; }
.timeline li > span { position: relative; z-index: 1; width: 12px; height: 12px; margin-top: 3px; background: var(--white); border: 2px solid var(--ink-300); border-radius: 50%; }
.timeline li.done > span { background: var(--teal-600); border-color: var(--teal-600); box-shadow: 0 0 0 3px var(--teal-100); }
.timeline li:not(:last-child)::after { content: ""; position: absolute; top: 15px; bottom: -1px; left: 5px; width: 1px; background: var(--ink-200); }
.timeline li > div { display: flex; flex-direction: column; }
.timeline strong { font-size: 10px; }
.timeline small { margin-top: 2px; color: var(--ink-500); font-size: 9px; }
.attempt-card { padding: 12px; border: 1px solid var(--ink-200); border-radius: 5px; }
.attempt-card > div { display: flex; align-items: center; gap: 8px; }
.attempt-card > div > span:nth-child(2) { display: flex; flex: 1; flex-direction: column; }
.attempt-card small { color: var(--ink-500); font-size: 9px; }
.attempt-card dl { display: grid; grid-template-columns: 1fr 1fr; margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--ink-100); }
.attempt-card dt { color: var(--ink-500); font-size: 9px; }
.attempt-card dd { margin: 2px 0 0; font-size: 10px; font-weight: 650; }
.delivery-item { display: flex; align-items: center; gap: 9px; padding: 10px; background: var(--ink-50); border: 1px solid var(--ink-100); border-radius: 5px; }
.delivery-item > div { display: flex; flex: 1; flex-direction: column; }
.delivery-item strong { font-size: 10px; }
.delivery-item small, .delivery-item time { color: var(--ink-500); font-size: 9px; }
.empty-state { padding: 30px; color: var(--ink-500); background: var(--ink-50); border: 1px dashed var(--ink-300); border-radius: 5px; text-align: center; font-size: 11px; }
.drawer-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--ink-200); }

.modal { position: fixed; z-index: 55; top: 50%; left: 50%; width: min(540px, calc(100vw - 28px)); max-height: calc(100vh - 28px); overflow-y: auto; background: var(--white); border-radius: 7px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transform: translate(-50%, -48%); transition: .18s ease; }
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 17px 18px; border-bottom: 1px solid var(--ink-200); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 18px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; color: var(--ink-700); font-size: 10px; font-weight: 650; }
.form-grid label.full { grid-column: 1 / -1; }
.form-grid input, .form-grid select { width: 100%; height: 38px; padding: 0 10px; color: var(--ink-900); background: var(--white); border: 1px solid var(--ink-200); border-radius: 5px; outline: 0; }
.form-grid textarea { width: 100%; min-height: 84px; padding: 9px 10px; color: var(--ink-900); background: var(--white); border: 1px solid var(--ink-200); border-radius: 5px; outline: 0; resize: vertical; }
.form-grid input:focus, .form-grid select:focus { border-color: var(--teal-600); box-shadow: 0 0 0 3px var(--teal-100); }
.form-grid textarea:focus { border-color: var(--teal-600); box-shadow: 0 0 0 3px var(--teal-100); }
.form-error { grid-column: 1 / -1; margin: -4px 0 0; color: var(--red-700); font-size: 10px; }
.date-range-modal { width: min(460px, calc(100vw - 28px)); }
.impersonation-modal { width: min(500px, calc(100vw - 28px)); }
.impersonation-target { display: flex; align-items: center; gap: 9px; margin: 16px 18px 0; padding: 11px; background: var(--ink-50); border: 1px solid var(--ink-100); border-radius: 5px; }
.impersonation-target > div { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.impersonation-target strong { font-size: 11px; }
.impersonation-target small { color: var(--ink-500); font-size: 9px; }
.impersonation-scope { display: grid; grid-template-columns: repeat(3, 1fr); margin: 12px 18px 0; border: 1px solid var(--ink-200); border-radius: 5px; }
.impersonation-scope > div { padding: 9px 10px; border-right: 1px solid var(--ink-100); }
.impersonation-scope > div:last-child { border-right: 0; }
.impersonation-scope dt { color: var(--ink-500); font-size: 9px; }
.impersonation-scope dd { margin: 2px 0 0; color: var(--ink-900); font-size: 10px; font-weight: 650; }
.impersonation-notice { margin: 12px 18px 0; color: var(--amber-800); background: #fffbeb; border-color: #edcf82; }
.impersonation-form-grid { grid-template-columns: 1fr; padding-top: 12px; }
.confirmation-label { flex-direction: row !important; align-items: flex-start; gap: 8px !important; font-weight: 500 !important; }
.confirmation-label input { width: 16px; height: 16px; margin: 1px 0 0; padding: 0; flex: 0 0 auto; accent-color: var(--teal-700); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; background: var(--ink-50); border-top: 1px solid var(--ink-200); }
.toast { position: fixed; z-index: 80; right: 24px; bottom: 24px; min-width: 220px; display: flex; align-items: center; gap: 8px; padding: 11px 13px; color: var(--white); background: var(--ink-950); border-radius: 5px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transform: translateY(10px); transition: .18s ease; font-size: 11px; }
.toast svg { width: 16px; color: #42d3a7; }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .metric:nth-child(3) { border-right: 0; }
  .metric:nth-child(-n+3) { border-bottom: 1px solid var(--ink-200); }
  .provider-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .health-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .global-search { width: 205px; }
}

@media (max-width: 920px) {
  .sidebar { transform: translateX(-102%); box-shadow: var(--shadow-lg); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim.open { display: block; z-index: 35; }
  .sidebar-close { display: inline-grid !important; }
  .main-shell { margin-left: 0; }
  .mobile-menu { display: inline-grid !important; }
  .topbar { padding-inline: 18px; }
  .content-shell { padding-inline: 18px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .global-search { display: none; }
  .case-row { grid-template-columns: 42px minmax(0, 1fr) auto; }
  .case-meta { display: none; }
}

@media (max-width: 680px) {
  body { padding-bottom: 62px; }
  .topbar { height: 60px; gap: 10px; padding: 0 12px; }
  .impersonation-banner { top: 60px; align-items: flex-start; padding: 8px 12px; }
  .impersonation-banner .button { flex: 0 0 auto; }
  .impersonation-banner .button span { display: none; }
  .page-identity { display: block; }
  .page-identity h1 { font-size: 16px; }
  .page-identity span, .environment { display: none; }
  .topbar-actions { gap: 5px; }
  .topbar-actions .icon-button { width: 34px; height: 34px; }
  .content-shell { padding: 14px 12px 28px; }
  .view-toolbar { align-items: flex-start; margin-bottom: 12px; overflow-x: auto; }
  .view-toolbar .segmented { flex: 0 0 auto; }
  .toolbar-right { flex: 0 0 auto; }
  .toolbar-right .select-control { max-width: 150px; }
  .toolbar-right .select-control select { min-width: 95px; }
  .toolbar-right .button span { display: none; }
  .view[data-view="dashboard"] > .view-toolbar { flex-direction: column; align-items: stretch; overflow: visible; }
  .view[data-view="dashboard"] > .view-toolbar > .segmented { width: 100%; overflow-x: auto; }
  .view[data-view="dashboard"] > .view-toolbar > .toolbar-right { width: 100%; overflow-x: auto; }
  .view[data-view="dashboard"] > .view-toolbar .select-control { min-width: 138px; max-width: none; flex: 1; }
  .view[data-view="dashboard"] > .view-toolbar .select-control select { min-width: 100px; width: 100%; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 114px; padding: 14px; }
  .metric:nth-child(n) { border-right: 1px solid var(--ink-200); border-bottom: 1px solid var(--ink-200); }
  .metric:nth-child(even) { border-right: 0; }
  .metric:last-child { grid-column: 1 / -1; min-height: 96px; border-right: 0; border-bottom: 0; }
  .metric:nth-last-child(2) { border-bottom: 0; }
  .metric strong, .primary-metric strong { font-size: 21px; }
  .chart-legend { display: none; }
  .chart-wrap { height: 210px; padding-left: 48px; }
  .line-chart { height: 160px; }
  .x-labels span:nth-child(even) { display: none; }
  .panel-heading { padding-inline: 12px; }
  th, td { padding: 10px 11px; }
  .table-panel table { min-width: 680px; }
  .table-panel th:nth-child(7), .table-panel td:nth-child(7), .table-panel th:nth-child(8), .table-panel td:nth-child(8) { display: none; }
  .orders-table { min-width: 780px !important; }
  .orders-table th:nth-child(3), .orders-table td:nth-child(3), .orders-table th:nth-child(4), .orders-table td:nth-child(4), .orders-table th:nth-child(5), .orders-table td:nth-child(5), .orders-table th:nth-child(9), .orders-table td:nth-child(9), .orders-table th:nth-child(10), .orders-table td:nth-child(10) { display: none; }
  .orders-table th:nth-child(7), .orders-table td:nth-child(7), .orders-table th:nth-child(8), .orders-table td:nth-child(8), .orders-table th:nth-child(11), .orders-table td:nth-child(11) { display: table-cell; }
  .users-table { min-width: 520px !important; }
  .users-table th:nth-child(3), .users-table td:nth-child(3), .users-table th:nth-child(4), .users-table td:nth-child(4), .users-table th:nth-child(5), .users-table td:nth-child(5), .users-table th:nth-child(6), .users-table td:nth-child(6), .users-table th:nth-child(7), .users-table td:nth-child(7) { display: none; }
  .users-table th:nth-child(8), .users-table td:nth-child(8) { display: table-cell; }
  .users-table th:last-child, .users-table td:last-child { position: sticky; right: 0; z-index: 1; background: var(--white); box-shadow: -1px 0 0 var(--ink-100); }
  .users-table th:last-child { background: #fafbfc; }
  .users-table th:last-child, .users-table td:last-child { width: 54px; min-width: 54px; padding: 8px; text-align: center; }
  .users-table .impersonate-action { width: 30px; padding: 0; }
  .users-table .impersonate-action span { display: none; }
  .filter-bar { padding: 8px; }
  .search-control { width: 220px; }
  .summary-line { flex: 0 0 auto; }
  .summary-line strong { font-size: 14px; }
  .page-actions > .button span { display: none; }
  .provider-grid, .health-grid { grid-template-columns: 1fr; }
  .case-row { grid-template-columns: 36px minmax(0, 1fr); min-height: 98px; padding: 12px; }
  .case-row > .button { grid-column: 2; justify-self: start; min-height: 30px; }
  .case-main > div { align-items: flex-start; flex-direction: column; gap: 4px; }
  .notice { align-items: flex-start; }
  .notice .button { display: none; }
  .mobile-bottom-nav { position: fixed; inset: auto 0 0; z-index: 34; width: 100%; height: 62px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding-bottom: env(safe-area-inset-bottom); background: rgba(255,255,255,.98); border-top: 1px solid var(--ink-200); box-shadow: 0 -8px 24px rgba(16,24,40,.06); }
  .mobile-bottom-nav a, .mobile-bottom-nav button { position: relative; min-width: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 2px; color: var(--ink-500); background: transparent; border: 0; font-size: 9px; }
  .mobile-bottom-nav a.active { color: var(--teal-700); font-weight: 700; }
  .mobile-bottom-nav svg { width: 19px; height: 19px; }
  .mobile-bottom-nav b { position: absolute; top: 5px; left: calc(50% + 7px); min-width: 15px; height: 15px; display: grid; place-items: center; color: var(--white); background: var(--red-700); border: 2px solid var(--white); border-radius: 8px; font-size: 7px; }
  .detail-drawer { inset: 0; width: 100%; }
  .drawer-header { padding: 14px; }
  .drawer-body { padding: 14px; }
  .drawer-footer { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .drawer-footer .button { flex: 1; }
  .detail-list { grid-template-columns: 1fr; }
  .detail-list > div:nth-child(odd) { border-right: 0; }
  .detail-list > div:nth-last-child(2) { border-bottom: 1px solid var(--ink-100); }
  .form-grid { grid-template-columns: 1fr; padding: 14px; }
  .form-grid label.full { grid-column: auto; }
  .form-error { grid-column: auto; }
  .modal { width: calc(100vw - 20px); }
  .impersonation-scope { grid-template-columns: 1fr; }
  .impersonation-scope > div { border-right: 0; border-bottom: 1px solid var(--ink-100); }
  .impersonation-scope > div:last-child { border-bottom: 0; }
  .toast { right: 12px; bottom: 76px; left: 12px; min-width: 0; }
}

@media (max-width: 390px) {
  .metric { padding: 12px; }
  .metric strong, .primary-metric strong { font-size: 18px; }
  .metric-label span { max-width: 92px; white-space: normal; }
  .button { padding-inline: 10px; }
  .select-control select { min-width: 100px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.auth-page, .sandbox-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #eef1f4; }
.auth-shell { width: min(420px, 100%); }
.auth-brand, .sandbox-shell > header { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 18px; }
.auth-brand > div, .sandbox-shell > header > div { display: flex; flex-direction: column; line-height: 1.1; }
.auth-brand strong, .sandbox-shell > header strong { color: var(--ink-950); font-size: 18px; }
.auth-brand small, .sandbox-shell > header small { margin-top: 3px; color: var(--ink-500); font-size: 9px; font-weight: 750; letter-spacing: 1.4px; }
.auth-panel, .sandbox-shell { background: var(--white); border: 1px solid var(--ink-200); border-radius: 7px; box-shadow: 0 14px 36px rgba(16, 24, 40, .1); }
.auth-panel { padding: 28px; }
.auth-heading { margin-bottom: 24px; }
.auth-heading > span { color: var(--teal-700); font-size: 10px; font-weight: 750; }
.auth-heading h1 { margin-top: 4px; font-size: 24px; }
.auth-heading p { margin-top: 7px; color: var(--ink-500); font-size: 12px; }
.auth-panel form > label:not(.auth-check) { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; color: var(--ink-700); font-size: 11px; font-weight: 650; }
.auth-panel input[type="email"], .auth-panel input[type="password"] { height: 42px; padding: 0 11px; border: 1px solid var(--ink-200); border-radius: 5px; outline: 0; }
.auth-panel input:focus { border-color: var(--teal-600); box-shadow: 0 0 0 3px var(--teal-100); }
.auth-check { display: flex; align-items: center; gap: 7px; margin: 15px 0; color: var(--ink-600); font-size: 11px; }
.auth-check input { accent-color: var(--teal-700); }
.auth-error { margin: 12px 0; padding: 9px 10px; color: var(--red-700); background: var(--red-100); border-radius: 5px; font-size: 11px; }
.auth-submit { width: 100%; justify-content: center; height: 42px; }
.auth-shell footer { margin-top: 14px; color: var(--ink-500); text-align: center; font-size: 10px; }
.sandbox-shell { width: min(540px, 100%); padding: 24px; }
.sandbox-summary { text-align: center; }
.sandbox-summary h1 { margin-top: 16px; font-size: 34px; }
.sandbox-summary > p { margin-top: 4px; color: var(--ink-500); }
.sandbox-summary dl { margin: 24px 0 0; border: 1px solid var(--ink-200); border-radius: 6px; text-align: left; }
.sandbox-summary dl > div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--ink-100); }
.sandbox-summary dl > div:last-child { border-bottom: 0; }
.sandbox-summary dt { color: var(--ink-500); font-size: 11px; }
.sandbox-summary dd { min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: 11px; font-weight: 650; }
.sandbox-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.sandbox-actions .button { justify-content: center; height: 42px; }
.sandbox-result { margin-top: 20px; padding: 12px; border-radius: 5px; text-align: center; font-weight: 650; }
.sandbox-result.success { color: var(--green-700); background: var(--green-100); }
.sandbox-result.failed { color: var(--red-700); background: var(--red-100); }
.sandbox-note { margin-top: 16px; color: var(--ink-500); text-align: center; font-size: 10px; }
@media (max-width: 480px) {
  .auth-page, .sandbox-page { align-items: start; padding: 16px 12px; }
  .auth-panel, .sandbox-shell { padding: 20px 16px; }
  .sandbox-summary dl > div { grid-template-columns: 92px minmax(0, 1fr); }
  .sandbox-actions { grid-template-columns: 1fr; }
}
