:root {
    color-scheme: light;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    --canvas: #f4f7fb;
    --surface: #ffffff;
    --surface-subtle: #f8fafc;
    --surface-muted: #eef2f7;
    --text: #182230;
    --text-soft: #344054;
    --muted: #526077;
    --muted-strong: #475467;
    --border: #d8e0ea;
    --border-soft: #e8edf3;
    --primary: #155eef;
    --primary-hover: #004eeb;
    --primary-active: #0040c1;
    --primary-soft: #eff4ff;
    --success: #067647;
    --success-soft: #ecfdf3;
    --warning: #93470b;
    --warning-soft: #fffaeb;
    --danger: #b42318;
    --danger-hover: #912018;
    --danger-soft: #fef3f2;
    --info: #175cd3;
    --info-soft: #eff8ff;
    --sidebar: #101828;
    --sidebar-soft: #1d2939;
    --sidebar-text: #d0d5dd;
    --focus: #84adff;
    --focus-ring: #155eef;
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 2px 8px rgba(16, 24, 40, .07);
    --shadow-md: 0 12px 28px rgba(16, 24, 40, .12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --sidebar-width: 248px;
    --content-width: 1240px;
    --control-height: 44px;
}

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

* {
    margin: 0;
    padding: 0;
}

html {
    min-width: 320px;
    background: var(--canvas);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    min-height: 100svh;
    background: var(--canvas);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img, svg {
    display: block;
    max-width: 100%;
}

button, input, textarea, select {
    color: inherit;
    font: inherit;
}

button, [role="button"] {
    touch-action: manipulation;
}

button {
    border: 0;
}

a {
    color: var(--primary);
    text-decoration: none;
    text-underline-offset: 3px;
}

a:hover {
    text-decoration: underline;
}

:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

::selection {
    background: #c7d7fe;
    color: #102a56;
}

[hidden] {
    display: none !important;
}

.sr-only,
.app-live-region {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.clipboard-fallback {
    position: fixed !important;
    top: 0 !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 120;
    padding: 9px 13px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #ffffff;
    font-weight: 650;
    transform: translateY(calc(-100% - 16px));
}

.skip-link:focus,
.skip-link:focus-visible {
    color: #ffffff;
    text-decoration: none;
    transform: translateY(0);
}

h1, h2, h3 {
    color: var(--text);
    font-weight: 650;
    letter-spacing: -.018em;
    line-height: 1.3;
}

p + p {
    margin-top: 10px;
}

small {
    color: var(--muted);
    font-size: 12px;
}

code, pre, .mono {
    font-family: var(--font-mono);
}

code {
    padding: 2px 6px;
    border-radius: 5px;
    background: var(--surface-muted);
    color: var(--text-soft);
    font-size: 13px;
}

/* Application shell */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
    min-height: 100svh;
}

.app-main {
    min-width: 0;
}

.app-content {
    min-width: 0;
}

.container {
    width: min(100%, var(--content-width));
    margin-inline: auto;
    padding: 28px 28px 72px;
}

.sidebar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    height: 100vh;
    height: 100svh;
    padding: 20px 14px;
    overflow-y: auto;
    background: var(--sidebar);
    color: var(--sidebar-text);
}

.sidebar-brand {
    display: flex;
    min-height: 48px;
    align-items: center;
    gap: 11px;
    padding: 6px 10px 18px;
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.sidebar-brand:hover {
    text-decoration: none;
}

.sidebar-brand strong,
.sidebar-brand small {
    display: block;
}

.sidebar-brand small {
    margin-top: 1px;
    color: #98a2b3;
    font-size: 11px;
    font-weight: 500;
}

.sidebar-brand-mark {
    display: inline-grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 10px;
    background: rgba(255, 255, 255, .1);
}

.sidebar nav,
.sidebar-nav {
    display: grid;
    gap: 5px;
}

.nav-link {
    display: flex;
    min-height: var(--control-height);
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 14px;
    font-weight: 550;
    transition: background-color .16s ease, color .16s ease;
}

.nav-link:hover {
    background: rgba(255, 255, 255, .08);
    color: #ffffff;
    text-decoration: none;
}

.nav-link.active,
.nav-link[aria-current="page"] {
    background: #344054;
    color: #ffffff;
}

.nav-link-icon {
    display: inline-grid;
    width: 20px;
    flex: 0 0 20px;
    place-items: center;
}

.sidebar-footer {
    display: grid;
    gap: 6px;
    margin-top: auto;
    padding-top: 20px;
}

.nav-button {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
}

.sidebar-backdrop {
    display: none;
}

/* Existing header and compact page header */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    border-bottom: 1px solid var(--border-soft);
    background: rgba(255, 255, 255, .94);
    box-shadow: var(--shadow-xs);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.topbar-inner {
    display: flex;
    width: min(100%, var(--content-width));
    min-height: 64px;
    margin-inline: auto;
    padding: 8px 28px;
    align-items: center;
    gap: 20px;
}

.topbar-status {
    display: flex;
    min-width: 0;
    flex: 1;
    align-items: center;
    gap: 12px;
}

.topbar-health {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
}

.health-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border-radius: 50%;
    background: var(--warning);
}

.health-dot.ok {
    background: var(--success);
}

.brand {
    flex: 0 0 auto;
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
}

.topbar nav {
    display: flex;
    min-width: 0;
    flex: 1;
    align-items: center;
    gap: 4px;
}

.topbar nav a,
.logout {
    display: inline-flex;
    min-height: var(--control-height);
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--muted-strong);
    font-size: 14px;
    font-weight: 550;
}

.topbar nav a:hover,
.logout:hover {
    background: var(--surface-muted);
    color: var(--text);
    text-decoration: none;
}

.topbar nav a.active,
.topbar nav a[aria-current="page"] {
    background: var(--primary-soft);
    color: #1849a9;
}

.nav-toggle,
[data-nav-toggle] {
    display: none;
}

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

.page-title {
    font-size: clamp(24px, 2.2vw, 30px);
}

.eyebrow {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.page-subtitle {
    max-width: 720px;
    margin-top: 6px;
    color: var(--muted);
    font-size: 14px;
}

.page-actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* Buttons */
.btn,
.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-danger,
.btn-icon {
    display: inline-flex;
    min-height: var(--control-height);
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 15px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, transform .08s ease;
}

.btn:hover,
.btn-primary:hover,
.btn-secondary:hover,
.btn-ghost:hover,
.btn-danger:hover,
.btn-icon:hover {
    text-decoration: none;
}

.btn-primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
    box-shadow: var(--shadow-xs);
}

.btn-primary:hover {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
}

.btn-primary:active {
    border-color: var(--primary-active);
    background: var(--primary-active);
}

.btn-secondary,
.btn-ghost,
.btn {
    border-color: #c8d1dc;
    background: var(--surface);
    color: var(--text-soft);
    box-shadow: var(--shadow-xs);
}

.btn-secondary:hover,
.btn-ghost:hover,
.btn:hover {
    border-color: #aeb9c8;
    background: var(--surface-subtle);
    color: var(--text);
}

.btn-danger {
    border-color: var(--danger);
    background: var(--danger);
    color: #ffffff;
    box-shadow: var(--shadow-xs);
}

.btn-danger:hover {
    border-color: var(--danger-hover);
    background: var(--danger-hover);
}

.btn-icon {
    width: var(--control-height);
    flex: 0 0 var(--control-height);
    padding: 0;
    border-color: #c8d1dc;
    background: var(--surface);
    color: var(--text-soft);
}

.btn-sm {
    min-height: var(--control-height);
    padding: 7px 11px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

:where(.btn, .btn-primary, .btn-secondary, .btn-ghost, .btn-danger, .btn-icon):disabled,
:where(.btn, .btn-primary, .btn-secondary, .btn-ghost, .btn-danger, .btn-icon)[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: .58;
}

.btn-copy {
    white-space: nowrap;
}

.btn-copy.is-success,
[data-copy].is-success {
    border-color: #6ce9a6;
    background: var(--success-soft);
    color: var(--success);
}

.btn-copy.is-error,
[data-copy].is-error {
    border-color: #fda29b;
    background: var(--danger-soft);
    color: var(--danger);
}

form.inline {
    display: inline-flex;
}

.choice-fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

/* Summary cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    min-width: 0;
    padding: 17px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.stat-card-primary {
    border-color: #b2ccff;
    background: linear-gradient(145deg, #ffffff, var(--primary-soft));
}

.stat-card-warning {
    border-color: #fedf89;
    background: var(--warning-soft);
}

.stat-label {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 550;
}

.stat-value {
    display: block;
    margin-top: 7px;
    color: var(--text);
    font-size: clamp(22px, 2vw, 28px);
    font-weight: 700;
    letter-spacing: -.025em;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.stat-meta {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    font-size: 12px;
}

.stat-value-badge {
    min-height: 34px;
    font-size: 16px;
}

/* Panels, alerts and status */
.card {
    margin-bottom: 20px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.card > :last-child {
    margin-bottom: 0;
}

.card h2,
.card-title {
    margin-bottom: 16px;
    font-size: 17px;
}

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

.card-header h2,
.card-header .card-title {
    margin-bottom: 0;
}

.card-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.alert {
    display: block;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.55;
}

.alert-icon {
    display: inline-flex;
    margin-right: 7px;
    vertical-align: -.1em;
}

.alert a {
    color: inherit;
    font-weight: 650;
    text-decoration: underline;
}

form > :where(button, .form-actions) + .alert {
    margin-top: 14px;
}

.alert-error,
.alert-danger {
    border-color: #fecdca;
    background: var(--danger-soft);
    color: #912018;
}

.alert-warn,
.alert-warning {
    border-color: #fedf89;
    background: var(--warning-soft);
    color: #7a2e0e;
}

.alert-ok,
.alert-success {
    border-color: #abefc6;
    background: var(--success-soft);
    color: #05603a;
}

.alert-info,
.notice {
    border-color: #b2ddff;
    background: var(--info-soft);
    color: #1849a9;
}

.notice {
    margin-top: 16px;
    padding: 13px 14px;
    border-style: solid;
    border-radius: var(--radius-sm);
}

.badge {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    gap: 6px;
    padding: 2px 9px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 650;
    line-height: 1.35;
    white-space: nowrap;
}

.badge::before {
    width: 6px;
    height: 6px;
    flex: 0 0 6px;
    border-radius: 50%;
    background: currentColor;
    content: "";
    opacity: .82;
}

.badge-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.text-error {
    color: var(--danger);
}

.text-warn {
    color: var(--warning);
}

.badge-pending,
.badge-warning,
.badge-sandbox {
    border-color: #fedf89;
    background: var(--warning-soft);
    color: #854a0e;
}

.badge-paid,
.badge-success,
.badge-live,
.badge-available {
    border-color: #abefc6;
    background: var(--success-soft);
    color: #05603a;
}

.badge-refunded,
.badge-neutral,
.badge-assigned {
    border-color: #d0d5dd;
    background: var(--surface-muted);
    color: #475467;
}

.badge-error,
.badge-danger,
.badge-failed {
    border-color: #fecdca;
    background: var(--danger-soft);
    color: #912018;
}

.badge-info,
.badge-processing {
    border-color: #b2ddff;
    background: var(--info-soft);
    color: #1849a9;
}

.checks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.check {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--muted-strong);
    font-size: 12px;
}

/* Forms and filters */
label,
.field-label {
    display: block;
    margin-bottom: 13px;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 550;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="date"],
input[type="datetime-local"],
textarea,
select,
.input {
    width: 100%;
    min-height: var(--control-height);
    margin-top: 5px;
    padding: 9px 11px;
    border: 1px solid #b8c2cf;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .03);
    transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}

textarea {
    min-height: 104px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: #667085;
    opacity: 1;
}

:where(input, textarea, select):hover:not(:disabled) {
    border-color: #8f9cad;
}

:where(input, textarea, select):focus {
    border-color: var(--primary);
    outline: 0;
    box-shadow: 0 0 0 4px var(--focus-ring);
}

:where(input, textarea, select):disabled {
    cursor: not-allowed;
    border-color: #d0d5dd;
    background: #f2f4f7;
    color: #667085;
    opacity: 1;
}

input[type="radio"],
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    margin: 0;
    accent-color: var(--primary);
}

.field-help,
.muted {
    color: var(--muted);
    font-size: 13px;
}

.muted {
    margin-top: 12px;
}

.field-help {
    display: block;
    margin-top: 5px;
    font-weight: 400;
}

.field-error {
    display: block;
    margin-top: 5px;
    color: var(--danger);
    font-size: 13px;
    font-weight: 550;
}

.form-grid,
.row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-grid > label,
.row > label {
    min-width: 0;
}

.form-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
}

.delivery-options {
    margin: 4px 0 16px;
}

.delivery-options label,
.check-label,
.radio-label {
    display: flex;
    min-height: var(--control-height);
    align-items: center;
    gap: 9px;
    margin-bottom: 4px;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
}

.delivery-options textarea {
    margin: 5px 0 13px;
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.choice-card {
    position: relative;
    display: grid;
    min-width: 0;
    min-height: 104px;
    align-content: start;
    gap: 6px;
    margin: 0;
    padding: 15px 15px 15px 45px;
    border: 1px solid #c8d1dc;
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: border-color .16s ease, background-color .16s ease, box-shadow .16s ease;
}

.choice-card:hover {
    border-color: #84adff;
    background: #fbfcff;
}

.choice-card.is-selected {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 0 0 1px var(--primary);
}

.choice-card.is-focused {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

.choice-card input[type="radio"],
.choice-card input[type="checkbox"] {
    position: absolute;
    top: 16px;
    left: 15px;
}

.choice-title {
    font-size: 14px;
    font-weight: 650;
}

.choice-description {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
}

.choice-card.is-disabled {
    cursor: not-allowed;
    background: #f2f4f7;
    color: #667085;
    opacity: .7;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.filters {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
}

.filters label {
    min-width: 150px;
    flex: 0 1 210px;
    margin-bottom: 0;
}

.filters .filter-search {
    flex: 1 1 260px;
}

.filters-card {
    padding: 16px;
}

.filters-compact {
    max-width: 760px;
}

.filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.toolbar-actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* Tables */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    -webkit-overflow-scrolling: touch;
}

table,
.data-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text-soft);
    font-size: 14px;
}

th, td,
.data-table th,
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-soft);
    text-align: left;
    vertical-align: middle;
}

th,
.data-table th {
    background: var(--surface-subtle);
    color: var(--muted-strong);
    font-size: 12px;
    font-weight: 650;
    letter-spacing: .01em;
    white-space: nowrap;
}

tbody tr {
    transition: background-color .14s ease;
}

tbody tr:hover {
    background: #fafcff;
}

tr:last-child td,
.data-table tr:last-child td {
    border-bottom: 0;
}

.table-wrap > table {
    min-width: 720px;
}

.table-wrap > table.data-table[data-mobile-cards] {
    min-width: 0;
}

.numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.table-primary {
    color: var(--text);
    font-weight: 600;
}

.data-table td > small {
    display: block;
    margin-top: 2px;
}

.table-secondary {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.table-actions {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 7px;
    white-space: nowrap;
}

.mobile-card-list {
    display: none;
}

.mobile-card {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.mobile-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.mobile-card-grid {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 7px 14px;
    font-size: 13px;
}

.mobile-card-grid dt {
    color: var(--muted);
}

.mobile-card-grid dd {
    min-width: 0;
    color: var(--text-soft);
    text-align: right;
    overflow-wrap: anywhere;
}

.mobile-card-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-soft);
}

/* Detail and workflow patterns */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-top: 1px solid var(--border-soft);
    border-left: 1px solid var(--border-soft);
}

.detail-grid > div,
.detail-item {
    min-width: 0;
    padding: 14px 16px;
    border-right: 1px solid var(--border-soft);
    border-bottom: 1px solid var(--border-soft);
}

.detail-grid dt,
.detail-label {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 550;
}

.detail-grid dd,
.detail-value {
    min-width: 0;
    color: var(--text);
    font-size: 14px;
    overflow-wrap: anywhere;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.settings-grid > .card {
    min-width: 0;
}

.definition-list {
    display: grid;
    gap: 0;
    border-top: 1px solid var(--border-soft);
}

.definition-list > div {
    display: grid;
    grid-template-columns: minmax(110px, .7fr) minmax(0, 1.3fr);
    gap: 14px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border-soft);
}

.definition-list dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.definition-list dd {
    min-width: 0;
    color: var(--text);
    font-size: 13px;
    text-align: right;
    overflow-wrap: anywhere;
}

.definition-list dd code {
    white-space: normal;
    overflow-wrap: anywhere;
}

.definition-list-wide > div {
    grid-template-columns: minmax(150px, .35fr) minmax(0, 1.65fr);
}

.definition-list-wide dd {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.timeline {
    position: relative;
    display: grid;
    gap: 0;
    padding: 2px 0;
    list-style: none;
}

.check-list {
    display: grid;
    gap: 9px;
    padding-left: 20px;
    color: var(--text-soft);
    font-size: 14px;
}

.event-summary {
    color: var(--muted);
    font-size: 12px;
}

.timeline-item {
    position: relative;
    min-height: 58px;
    padding: 0 0 20px 30px;
}

.timeline-item::before {
    position: absolute;
    top: 5px;
    left: 7px;
    width: 1px;
    height: 100%;
    background: var(--border);
    content: "";
}

.timeline-item::after {
    position: absolute;
    top: 5px;
    left: 2px;
    width: 11px;
    height: 11px;
    border: 3px solid var(--surface);
    border-radius: 50%;
    background: #98a2b3;
    box-shadow: 0 0 0 1px #98a2b3;
    content: "";
}

.timeline-item:last-child {
    min-height: 0;
    padding-bottom: 0;
}

.timeline-item:last-child::before {
    display: none;
}

.timeline-item.is-current::after,
.timeline-item.is-success::after {
    background: var(--success);
    box-shadow: 0 0 0 1px var(--success);
}

.timeline-title {
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}

.timeline-meta {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.danger-zone {
    margin-top: 22px;
    padding: 18px;
    border: 1px solid #fda29b;
    border-radius: var(--radius-md);
    background: var(--danger-soft);
}

.danger-zone h2,
.danger-zone h3,
.danger-zone .card-title {
    margin-bottom: 6px;
    color: #912018;
}

.danger-zone p {
    color: #7a271a;
    font-size: 13px;
}

.danger-zone-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.link-box {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 8px;
    padding: 11px 12px;
    border: 1px dashed #98a2b3;
    border-radius: var(--radius-sm);
    background: var(--surface-subtle);
    font-family: var(--font-mono);
    font-size: 13px;
    word-break: break-all;
}

.link-box .link {
    min-width: 0;
    flex: 1;
}

.delivery-box {
    margin-top: 16px;
    padding: 15px;
    border: 1px solid #abefc6;
    border-radius: var(--radius-sm);
    background: var(--success-soft);
    text-align: left;
}

.delivery-label {
    margin-bottom: 8px;
    color: #05603a;
    font-size: 13px;
    font-weight: 650;
}

.delivery-box pre {
    color: #074d31;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.secret {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 8px;
}

.secret-value,
.secret-mask {
    min-width: 0;
    font-family: var(--font-mono);
    overflow-wrap: anywhere;
}

.secret:not(.is-revealed) .secret-value,
.secret[data-revealed="false"] .secret-value {
    display: none;
}

.secret.is-revealed .secret-mask,
.secret[data-revealed="true"] .secret-mask {
    display: none;
}

.secret-toggle {
    flex: 0 0 auto;
}

/* Pagination and empty states */
.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
}

.pagination-info {
    color: var(--muted);
    font-size: 13px;
}

.pagination-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
}

.pagination a,
.pagination button,
.pagination-current {
    display: inline-flex;
    min-width: var(--control-height);
    min-height: var(--control-height);
    align-items: center;
    justify-content: center;
    padding: 8px 11px;
    border: 1px solid #c8d1dc;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 600;
}

.pagination a:hover,
.pagination button:hover {
    background: var(--surface-muted);
    text-decoration: none;
}

.pagination-current,
.pagination [aria-current="page"] {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: #1849a9;
}

.pagination [aria-disabled="true"] {
    cursor: not-allowed;
    opacity: .5;
}

.empty-state {
    display: grid;
    min-height: 210px;
    place-items: center;
    align-content: center;
    padding: 32px 20px;
    color: var(--muted);
    text-align: center;
}

.empty-state-icon {
    display: grid;
    width: 44px;
    height: 44px;
    margin-bottom: 12px;
    place-items: center;
    border-radius: 12px;
    background: var(--surface-muted);
    color: var(--muted-strong);
    font-size: 20px;
}

.empty-state h2,
.empty-state h3 {
    margin-bottom: 6px;
    color: var(--text);
    font-size: 16px;
}

.empty-state p {
    max-width: 440px;
    font-size: 13px;
}

.empty-state .btn,
.empty-state .btn-primary,
.empty-state .btn-ghost {
    margin-top: 16px;
}

/* Login and first-run setup */
.login-shell {
    display: grid;
    min-height: 100vh;
    min-height: 100svh;
    place-items: center;
    padding: 28px 16px;
    background:
        radial-gradient(circle at 15% 12%, rgba(21, 94, 239, .11), transparent 28rem),
        radial-gradient(circle at 88% 92%, rgba(23, 92, 211, .08), transparent 24rem),
        var(--canvas);
}

.login-card {
    width: min(100%, 430px);
    margin: 0;
    padding: 28px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.login-header {
    margin-bottom: 22px;
    text-align: center;
}

.login-header h1 {
    margin-top: 12px;
    font-size: 22px;
}

.login-header p {
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
}

.login-mark {
    display: inline-grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border-radius: 13px;
    background: var(--primary);
    color: #fff;
    font-size: 20px;
    font-weight: 750;
    box-shadow: 0 8px 18px rgba(21, 94, 239, .2);
}

.login-form {
    margin-top: 20px;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 72px;
}

.password-toggle {
    position: absolute;
    right: 5px;
    bottom: 5px;
    min-width: 58px;
    min-height: 34px;
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text-soft);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.setup-checks {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 14px 0;
}

.setup-checks-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.setup-check {
    display: flex;
    min-width: 0;
    align-items: flex-start;
    gap: 9px;
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.setup-check > span {
    display: inline-grid;
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    place-items: center;
    border-radius: 50%;
    background: var(--surface-muted);
    font-size: 12px;
    font-weight: 700;
}

.setup-check strong,
.setup-check small {
    display: block;
}

.setup-check.ok > span {
    background: var(--success-soft);
    color: var(--success);
}

.setup-check.blocked > span {
    background: var(--danger-soft);
    color: var(--danger);
}

.setup-check.warn > span {
    background: var(--warning-soft);
    color: var(--warning);
}

.setup-panel {
    margin: 18px 0 20px;
    padding: 14px;
    border: 1px solid #fedf89;
    border-radius: var(--radius-sm);
    background: var(--warning-soft);
    color: #7a2e0e;
    font-size: 13px;
}

.setup-panel h2,
.setup-panel h3 {
    margin-bottom: 6px;
    color: #7a2e0e;
    font-size: 14px;
}

.setup-panel code {
    display: block;
    margin-top: 8px;
    padding: 9px 10px;
    overflow-x: auto;
    border: 1px solid #fedf89;
    background: rgba(255, 255, 255, .68);
    color: #652b0e;
    white-space: nowrap;
}

/* Loading */
.loading,
[aria-busy="true"] {
    cursor: wait;
}

button.loading,
a.loading,
.btn.loading,
.btn-primary.loading,
.btn-ghost.loading,
.btn-danger.loading {
    pointer-events: none;
}

button.loading::before,
a.loading::before,
.btn.loading::before,
.btn-primary.loading::before,
.btn-ghost.loading::before,
.btn-danger.loading::before {
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    content: "";
    opacity: .85;
    animation: app-spin .65s linear infinite;
}

form[data-submitting="true"] :where(button[type="submit"], input[type="submit"]) {
    pointer-events: none;
}

@keyframes app-spin {
    to { transform: rotate(360deg); }
}

/* Customer-facing page kept compatible */
body.customer {
    display: flex;
    min-height: 100vh;
    min-height: 100svh;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.customer-card {
    width: min(100%, 560px);
    padding: 40px 36px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    text-align: center;
}

.customer-card h1 {
    margin: 10px 0 8px;
    font-size: 23px;
}

.result-icon {
    font-size: 44px;
    line-height: 1;
}

footer.muted {
    margin-top: 24px;
}

/* Responsive shell */
@media (max-width: 1100px) {
    :root {
        --sidebar-width: 224px;
    }

    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 80;
        width: min(84vw, 288px);
        transform: translateX(-105%);
        box-shadow: var(--shadow-md);
        transition: transform .22s ease;
    }

    body.nav-open {
        overflow: hidden;
    }

    body.nav-open .sidebar,
    .sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: min(84vw, 288px);
        z-index: 70;
        display: block;
        visibility: hidden;
        border: 0;
        background: rgba(16, 24, 40, .54);
        opacity: 0;
        pointer-events: none;
        transition: opacity .22s ease, visibility .22s ease;
    }

    body.nav-open .sidebar-backdrop,
    .sidebar-backdrop.is-visible {
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
    }

    .nav-toggle,
    [data-nav-toggle] {
        display: inline-flex;
    }

    .container,
    .topbar-inner {
        padding-right: 20px;
        padding-left: 20px;
    }

    .page-header {
        gap: 16px;
    }

    .choice-grid {
        grid-template-columns: 1fr;
    }

    .setup-checks-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 700px) {
    .container {
        padding: 22px 16px 56px;
    }

    .topbar-inner {
        min-height: 60px;
        padding: 8px 16px;
        gap: 8px;
        flex-wrap: wrap;
    }

    .topbar nav {
        order: 3;
        width: 100%;
        flex-basis: 100%;
        overflow-x: auto;
        scrollbar-width: none;
    }

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

    .topbar nav a {
        flex: 0 0 auto;
    }

    .logout {
        margin-left: auto;
    }

    .page-header {
        align-items: stretch;
        flex-direction: column;
        margin-bottom: 20px;
    }

    .page-actions {
        justify-content: flex-start;
    }

    .page-actions > :where(a, button, form) {
        flex: 1 1 auto;
    }

    .page-actions form > button {
        width: 100%;
    }

    .stat-grid,
    .form-grid,
    .form-grid-3,
    .row,
    .detail-grid,
    .settings-grid,
    .setup-checks,
    .setup-checks-grid {
        grid-template-columns: 1fr;
    }

    .definition-list > div,
    .definition-list-wide > div {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .definition-list dd,
    .definition-list-wide dd {
        justify-content: flex-start;
        text-align: left;
    }

    .detail-grid {
        border-right: 1px solid var(--border-soft);
    }

    .detail-grid > div,
    .detail-item {
        border-right: 0;
    }

    .card {
        padding: 18px 16px;
        border-radius: 10px;
    }

    .card-header {
        align-items: stretch;
        flex-direction: column;
    }

    .filters,
    .filters label,
    .filters .filter-search {
        width: 100%;
        flex-basis: 100%;
    }

    .toolbar-actions > :where(a, button, form) {
        flex: 1 1 auto;
    }

    .toolbar-actions form > button {
        width: 100%;
    }

    .table-wrap > table:not([data-mobile-cards]) {
        min-width: 700px;
    }

    .data-table[data-mobile-cards],
    .data-table[data-mobile-cards] tbody,
    .data-table[data-mobile-cards] tr,
    .data-table[data-mobile-cards] td {
        display: block;
        width: 100%;
    }

    .data-table[data-mobile-cards] thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
    }

    .data-table[data-mobile-cards] tbody {
        display: grid;
        gap: 12px;
        padding: 1px;
    }

    .data-table[data-mobile-cards] tr {
        overflow: hidden;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--surface);
        box-shadow: var(--shadow-xs);
    }

    .data-table[data-mobile-cards] td {
        display: grid;
        grid-template-columns: minmax(88px, .38fr) minmax(0, 1fr);
        gap: 12px;
        padding: 10px 13px;
        text-align: right;
    }

    .data-table[data-mobile-cards] td::before {
        color: var(--muted);
        content: attr(data-label);
        font-size: 12px;
        font-weight: 550;
        text-align: left;
    }

    .data-table[data-mobile-cards] td > :where(a, button, strong, small, span, div, time, code) {
        min-width: 0;
        max-width: 100%;
        grid-column: 2;
        justify-self: end;
    }

    .data-table[data-mobile-cards] td > small {
        display: block;
        margin-top: 2px;
    }

    .data-table[data-mobile-cards] td[data-label=""],
    .data-table[data-mobile-cards] td.table-actions-cell {
        display: block;
        text-align: left;
    }

    .data-table[data-mobile-cards] td[colspan]::before,
    .data-table[data-mobile-cards] td[data-label=""]::before,
    .data-table[data-mobile-cards] td.table-actions-cell::before {
        display: none;
    }

    .data-table[data-mobile-cards] td.table-actions {
        display: grid;
        grid-template-columns: minmax(88px, .38fr) minmax(0, 1fr);
        justify-content: stretch;
    }

    .data-table[data-mobile-cards] td.table-actions > * {
        grid-column: 2;
        width: 100%;
    }

    .desktop-table {
        display: none;
    }

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

    .link-box {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .link-box .link {
        width: 100%;
        flex-basis: 100%;
        padding-bottom: 4px;
    }

    .link-box :where(.btn, .btn-primary, .btn-ghost, .btn-copy) {
        flex: 1 1 auto;
    }

    .pagination {
        align-items: stretch;
        flex-direction: column;
    }

    .pagination-links {
        width: 100%;
        justify-content: space-between;
    }

    .danger-zone-actions > :where(a, button, form) {
        width: 100%;
    }

    .danger-zone-actions form > button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .topbar-health {
        display: none;
    }

    .topbar-status {
        flex: 0 1 auto;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 15px 16px;
    }

    .page-actions,
    .form-actions,
    .toolbar-actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .page-actions > *,
    .form-actions > *,
    .toolbar-actions > * {
        width: 100%;
    }

    .page-actions button,
    .form-actions button,
    .toolbar-actions button {
        width: 100%;
    }

    .login-card,
    .customer-card {
        padding: 24px 18px;
    }

    .mobile-card-actions {
        grid-template-columns: 1fr;
    }
}

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

@page {
    margin: 14mm;
}

@media print {
    :root {
        --canvas: #ffffff;
        --surface: #ffffff;
        --text: #000000;
        --text-soft: #1f2937;
        --muted: #475467;
        --border: #c7c7c7;
        --border-soft: #dddddd;
    }

    body {
        background: #ffffff;
        color: #000000;
        font-size: 11pt;
    }

    .app-shell {
        display: block;
    }

    .sidebar,
    .topbar,
    .sidebar-backdrop,
    .page-actions,
    .toolbar,
    .pagination,
    .danger-zone,
    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-ghost,
    .btn-danger,
    .btn-icon,
    button {
        display: none !important;
    }

    .container {
        width: 100%;
        max-width: none;
        padding: 0;
    }

    .card,
    .stat-card,
    .table-wrap,
    .mobile-card {
        break-inside: avoid;
        border-color: #c7c7c7;
        box-shadow: none;
    }

    .table-wrap {
        overflow: visible;
    }

    .table-wrap > table {
        min-width: 0;
    }

    th, td {
        padding: 7px 8px;
    }

    a {
        color: #000000;
        text-decoration: underline;
    }
}
