/* The application palette follows ShadCn.Blazor's default theme in both modes.
   Legacy dashboard tokens use a pg prefix so they cannot replace the theme's HSL variables. */
:root .shell {
    --bg: hsl(var(--background));
    --workspace-bg: hsl(var(--muted) / .35);
    --surface: hsl(var(--card));
    --surface-raised: hsl(var(--muted));
    --surface-input: hsl(var(--background));
    --surface-sunken: hsl(var(--background));
    --row-hover: hsl(var(--accent));
    --pg-border: hsl(var(--border));
    --pg-border-strong: hsl(var(--input));
    --text: hsl(var(--foreground));
    --pg-muted: hsl(var(--muted-foreground));
    --pg-muted-strong: hsl(var(--foreground));
    --pg-accent: hsl(var(--primary));
    --pg-accent-hover: hsl(var(--primary) / .86);
    --pg-accent-soft: hsl(var(--accent));
    --pg-accent-text: hsl(var(--accent-foreground));
    --success: #15803d;
    --success-soft: #f0fdf4;
    --success-text: #15803d;
    --warning: #a16207;
    --warning-soft: #fffbeb;
    --warning-text: #92400e;
    --danger: hsl(var(--destructive));
    --danger-soft: #fef2f2;
    --danger-text: #b91c1c;
    --sidebar-width: 252px;
    background: var(--workspace-bg);
    color: var(--text);
    font-family: "Roboto", system-ui, sans-serif;
}
.dark .shell {
    --workspace-bg: hsl(var(--background));
    --success: #4ade80;
    --success-soft: #052e16;
    --success-text: #86efac;
    --warning: #fbbf24;
    --warning-soft: #422006;
    --warning-text: #fde68a;
    --danger-soft: #450a0a;
    --danger-text: #fca5a5;
}

/* Shell, navigation, and page heading */
.shell .sidebar {
    gap: 20px;
    padding: 24px 14px 18px;
    border-right: 1px solid hsl(var(--border));
    background: hsl(var(--background));
}
.shell .brand { padding: 0 10px 20px; border-bottom: 1px solid hsl(var(--border)); }
.shell .brand-mark {
    border: 1px solid hsl(var(--primary));
    border-radius: var(--radius-lg);
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    box-shadow: none;
}
.shell .brand span, .shell .nav-group-label { color: hsl(var(--muted-foreground)); }
.shell .brand strong { color: hsl(var(--foreground)); }
.shell .section-nav { gap: 20px; }
.shell .section-nav a {
    color: hsl(var(--muted-foreground));
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 13px;
}
.shell .section-nav a:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.shell .section-nav a.active {
    border-color: hsl(var(--border));
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
    box-shadow: none;
}
.shell .section-nav a.active::before { display: none; }
.shell .section-nav a.active .nav-icon { color: currentColor; }
.shell .sidebar-footer {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 8px;
    padding: 12px;
    border-color: hsl(var(--border));
    background: hsl(var(--card));
}
.shell .sidebar-footer .secure { min-width: 0; white-space: nowrap; font-size: 11px; }
.shell .sidebar-footer form { justify-self: end; }
.shell .secure { color: hsl(var(--muted-foreground)); }
.shell .secure i { background: #22c55e; box-shadow: 0 0 0 3px #22c55e20; }
.shell .workspace { max-width: 1720px; padding: 0 clamp(22px, 3vw, 52px) 72px; }
.shell .hero { margin-bottom: 24px; padding: 36px 0 24px; border-color: hsl(var(--border)); }
.shell .eyebrow { color: hsl(var(--muted-foreground)); letter-spacing: .12em; }
.shell .hero h1 { color: hsl(var(--foreground)); font-size: clamp(28px, 2.5vw, 36px); font-weight: 700; }
.shell .hero p { color: hsl(var(--muted-foreground)); }
.shell .mobile-toolbar { color: hsl(var(--foreground)); }
.shell .mobile-toolbar > span { color: hsl(var(--muted-foreground)); }

/* Surfaces and data */
.shell .panel, .shell .pricing-card, .shell .account-editor, .shell .test-payment-result,
.shell .queue-panel, .shell .provider-detail-section, .shell .provider-account-settings,
.shell .provider-account-detail, .shell .provider-balance-card, .shell .provider-grant-card,
.shell .provider-movement, .shell .entity-context {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-xl);
    background: hsl(var(--card));
    box-shadow: none;
}
.shell .panel { padding: 24px; }
.shell .pricing-card, .shell .account-editor, .shell .test-payment-result,
.shell .provider-balance-card, .shell .provider-grant-card { border-radius: var(--radius-lg); }
.shell .panel h2, .shell .panel h3 { color: hsl(var(--card-foreground)); }
.shell .panel-head { border-color: hsl(var(--border)); }
.shell .count-badge, .shell .version-badge, .shell .status, .shell .account-state,
.shell .source, .shell .audit-outcome {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-sm);
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}
.shell .cards { gap: 14px; }
.shell .cards .metric-card, .shell .provider-movement-cards .movement-card {
    --pg-border: hsl(var(--border));
    --pg-muted: hsl(var(--muted-foreground));
    min-height: 150px;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-lg);
    background: hsl(var(--card));
    color: hsl(var(--card-foreground));
    box-shadow: none;
}
.shell .cards .metric-card > span, .shell .cards .metric-card > small,
.shell .provider-movement-cards .movement-card small { color: hsl(var(--muted-foreground)); }
.shell .cards .metric-card > strong, .shell .provider-movement-cards .movement-card strong { color: hsl(var(--card-foreground)); }
.shell .cards .metric-card.profit {
    border-color: hsl(var(--primary));
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}
.shell .cards .metric-card.profit > span, .shell .cards .metric-card.profit > small,
.shell .cards .metric-card.profit > strong { color: hsl(var(--primary-foreground)); }
.shell .cards .metric-card.balance, .shell .cards#overview article:last-child {
    border-color: hsl(var(--border));
    background: hsl(var(--secondary));
}
.shell .cards .metric-card.balance > strong, .shell .cards#overview article:last-child > strong { color: hsl(var(--secondary-foreground)); }
.shell .cards .metric-card.attention { border-color: hsl(var(--border)); background: hsl(var(--secondary)); }
.shell .cards .metric-card.attention > strong { color: hsl(var(--secondary-foreground)); }
.shell .table-wrap, .shell .day-stats, .shell .queue-list a {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-lg);
    background: hsl(var(--card));
    box-shadow: none;
}
.shell .day-stats > div { background: hsl(var(--card)); }
.shell .queue-list a { border-radius: var(--radius-md); }
.shell .day-stats dd { color: hsl(var(--foreground)); }
.shell table { border-collapse: collapse; }
.shell.shell th { background: hsl(var(--muted) / .45); color: hsl(var(--muted-foreground)); }
.shell td, .shell td:first-child { color: hsl(var(--foreground)); }
.shell tbody tr:hover { background: hsl(var(--accent) / .6); }
.shell .queue-panel, .shell .queue-list a { background: hsl(var(--card)); }
.shell .queue-list a:hover { border-color: hsl(var(--ring)); background: hsl(var(--accent)); }
.shell .pricing-card-head { background: hsl(var(--muted) / .45); }
.shell .provider-subnav, .shell .provider-account-stats { background: hsl(var(--muted) / .4); }
.shell .action-block, .shell .action-block summary:hover, .shell .action-block[open] summary { background: hsl(var(--muted) / .45); }

/* Controls use the same surfaces and focus ring as ShadCn.Blazor. */
.shell.shell button:not(.theme-toggle), .shell.shell input, .shell.shell select, .shell.shell textarea {
    border-color: hsl(var(--input));
    border-radius: var(--radius-md);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    box-shadow: none;
}
.shell.shell button:not(.theme-toggle):hover { border-color: hsl(var(--ring)); background: hsl(var(--accent)); }
.shell.shell input[type="checkbox"] { border-radius: var(--radius-sm); }
.shell.shell button.primary, .shell.shell button.bg-primary, .shell.shell .link-button {
    border-color: hsl(var(--primary));
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}
.shell.shell button.primary:hover, .shell.shell button.bg-primary:hover, .shell.shell .link-button:hover { background: hsl(var(--primary) / .86); }
.shell.shell button.ghost, .shell.shell button.refresh, .shell.shell button.secondary-action,
.shell.shell .sidebar-footer button.ghost {
    border-color: hsl(var(--border));
    background: hsl(var(--background));
    color: hsl(var(--foreground));
}
.shell.shell button.ghost:hover, .shell.shell button.refresh:hover, .shell.shell button.secondary-action:hover,
.shell.shell .sidebar-footer button.ghost:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.shell.shell button.danger { border-color: var(--danger-text); background: transparent; color: var(--danger-text); }
.shell.shell button.danger:hover { background: hsl(var(--destructive) / .12); }
.shell.shell input:focus-visible, .shell.shell select:focus-visible, .shell.shell textarea:focus-visible,
.shell.shell button:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; box-shadow: none; }
.shell.shell input::placeholder, .shell.shell textarea::placeholder { color: hsl(var(--muted-foreground)); }
.shell.shell select option { background: hsl(var(--popover)); color: hsl(var(--popover-foreground)); }
.shell .client-tabs a.active, .shell .provider-tabs button[aria-pressed="true"],
.shell .provider-subnav button.active, .shell .entity-avatar, .shell .provider-account-mark {
    border-color: hsl(var(--border));
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}
.shell .secret code { background: hsl(var(--muted)); color: hsl(var(--foreground)); }
.shell .operational-alerts, .shell .alert.warning, .shell .test-production-notice { border-color: hsl(var(--border)); background: hsl(var(--secondary)); }
.shell .operational-alerts.error, .shell .alert.error { border-color: hsl(var(--destructive)); background: hsl(var(--destructive) / .08); color: hsl(var(--destructive)); }
.shell .alert.success { border-color: hsl(var(--border)); background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }

/* Theme switch is present in the dashboard and access screens. */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-md);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}
.theme-toggle:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.theme-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .theme-sun, .theme-toggle .theme-label-dark { display: none; }
.dark .theme-toggle .theme-moon, .dark .theme-toggle .theme-label-light { display: none; }
.dark .theme-toggle .theme-sun, .dark .theme-toggle .theme-label-dark { display: inline; }
.shell .sidebar-footer button.theme-toggle {
    grid-column: 1 / -1;
    width: 100%;
    margin: 0;
    border: 1px solid hsl(var(--border)) !important;
    background: hsl(var(--background)) !important;
    color: hsl(var(--foreground)) !important;
}
.shell .sidebar-footer button.theme-toggle:hover {
    background: hsl(var(--accent)) !important;
    color: hsl(var(--accent-foreground)) !important;
}

/* Client summary follows the current provider wallets; legacy figures stay available below. */
.shell .client-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.shell .client-title-row h1 { margin: 0 10px 0 0; }
.shell .client-title-row .env-badge { margin-left: 0; }
.shell .client-tabs { margin-top: 0; }
.shell .client-provider-overview { padding: 26px; }
.shell .client-overview-heading, .shell .client-legacy-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.shell .client-overview-heading { padding-bottom: 20px; border-bottom: 1px solid hsl(var(--border)); }
.shell .client-overview-kicker { display: block; margin-bottom: 7px; color: hsl(var(--muted-foreground)); font-size: 10px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.shell .client-overview-heading h2, .shell .client-legacy-heading h2 { margin: 0 0 5px; font-size: 19px; }
.shell .client-overview-heading p, .shell .client-legacy-heading p { max-width: 690px; margin: 0; color: hsl(var(--muted-foreground)); font-size: 12px; line-height: 1.5; }
.shell .client-overview-link { display: inline-flex; align-items: center; gap: 9px; flex: 0 0 auto; min-height: 38px; padding: 8px 12px; border: 1px solid hsl(var(--border)); border-radius: var(--radius-md); color: hsl(var(--foreground)); font-size: 12px; font-weight: 650; text-decoration: none; }
.shell .client-overview-link:hover { border-color: hsl(var(--ring)); background: hsl(var(--accent)); }
.shell .client-provider-overview .provider-balance-list { grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 12px; margin-top: 18px; }
.shell .client-provider-overview .provider-balance-card { min-width: 0; padding: 20px; background: hsl(var(--background)); }
.shell .client-provider-overview .provider-balance-name { padding-bottom: 15px; }
.shell .client-provider-overview .provider-balance-name strong { font-size: 15px; }
.shell .client-provider-overview .provider-balance-card dl { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 18px; padding-top: 15px; }
.shell .client-provider-overview .provider-balance-card dl > div { display: grid; gap: 3px; min-width: 0; }
.shell .client-provider-overview .provider-balance-card dl > div:first-child { grid-column: 1 / -1; padding-bottom: 12px; border-bottom: 1px solid hsl(var(--border)); }
.shell .client-provider-overview .provider-balance-card dt { color: hsl(var(--muted-foreground)); font-size: 11px; }
.shell .client-provider-overview .provider-balance-card dd { margin: 0; color: hsl(var(--foreground)); font-size: 15px; font-weight: 650; text-align: left; }
.shell .client-provider-overview .provider-balance-card dl > div:first-child dd { font-size: 27px; font-weight: 750; letter-spacing: -.035em; }
.shell .client-provider-overview .provider-empty { display: grid; justify-items: start; gap: 6px; margin-top: 18px; text-align: left; }
.shell .client-provider-overview .provider-empty p { margin: 0; }
.shell .client-provider-overview .provider-empty a { margin-top: 5px; color: hsl(var(--primary)); font-weight: 650; }
.shell .client-legacy-summary { padding: 21px 26px; background: hsl(var(--muted) / .18); }
.shell .client-legacy-totals { display: flex; flex-wrap: wrap; gap: 10px; }
.shell .client-legacy-totals > div { display: grid; gap: 3px; min-width: 120px; padding: 9px 13px; border: 1px solid hsl(var(--border)); border-radius: var(--radius-md); background: hsl(var(--card)); }
.shell .client-legacy-totals span { color: hsl(var(--muted-foreground)); font-size: 10px; }
.shell .client-legacy-totals strong { color: hsl(var(--foreground)); font-size: 16px; font-variant-numeric: tabular-nums; }
.shell .client-legacy-details { margin-top: 15px; border-top: 1px solid hsl(var(--border)); }
.shell .client-legacy-details summary { width: fit-content; padding: 12px 0 0; color: hsl(var(--foreground)); font-size: 12px; font-weight: 650; cursor: pointer; }
.shell .client-legacy-details .day-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 15px 0 0; }
.shell .client-legacy-details .day-stats > div { padding: 13px; }
.shell .client-legacy-details .day-stats dd { font-size: 17px; }
@media (max-width: 800px) {
    .shell .client-overview-heading, .shell .client-legacy-heading { align-items: flex-start; flex-direction: column; }
    .shell .client-legacy-details .day-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 500px) {
    .shell .client-provider-overview, .shell .client-legacy-summary { padding: 18px; }
    .shell .client-overview-link { width: 100%; justify-content: center; }
    .shell .client-legacy-totals { width: 100%; }
    .shell .client-legacy-totals > div { flex: 1 1 120px; }
    .shell .client-legacy-details .day-stats { grid-template-columns: 1fr; }
}

/* Access screens use the same theme tokens. Keep the 2FA QR background white. */
.auth-shell, .invite-shell, .setup-shell {
    --bg: hsl(var(--background));
    --surface: hsl(var(--card));
    --surface-raised: hsl(var(--secondary));
    --surface-input: hsl(var(--background));
    --pg-border: hsl(var(--border));
    --pg-border-strong: hsl(var(--input));
    --text: hsl(var(--foreground));
    --pg-muted: hsl(var(--muted-foreground));
    --pg-muted-strong: hsl(var(--foreground));
    --pg-accent: hsl(var(--primary));
    --pg-accent-hover: hsl(var(--primary) / .86);
    color: var(--text);
}
.auth-shell .login-card, .invite-shell .invite-card, .setup-shell .setup-card {
    border-color: hsl(var(--border));
    border-radius: var(--radius-xl);
    background: hsl(var(--card));
    box-shadow: 0 10px 35px hsl(var(--foreground) / .04);
}
.auth-shell .login-card button.login-button, .invite-shell .invite-card button.invite-button,
.setup-shell .setup-card button {
    border-color: hsl(var(--primary)) !important;
    background: hsl(var(--primary)) !important;
    color: hsl(var(--primary-foreground)) !important;
}
.auth-shell .login-card label.remember { display: flex !important; align-items: center; gap: 8px; }
.auth-shell .login-card input[type="checkbox"] {
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    min-height: 16px;
    padding: 0;
    border-radius: var(--radius-sm);
    accent-color: hsl(var(--primary));
}
.auth-shell .auth-error, .invite-shell .invite-error, .setup-shell .setup-error {
    border-color: hsl(var(--destructive));
    background: hsl(var(--destructive) / .08);
    color: hsl(var(--destructive));
}
.auth-shell .theme-toggle, .invite-shell .theme-toggle, .setup-shell .theme-toggle {
    border-color: hsl(var(--border));
    background: hsl(var(--background));
    color: hsl(var(--foreground));
}

@media (max-width: 960px) {
    .shell .sidebar { background: hsl(var(--background) / .96); }
}
