/* Ignyte AppHub design system: dense, quiet admin. Black primary actions, hairline borders,
   orange accent for the current location, color for status and chart series, purple reserved for sandbox.
   Every spacing, radius and type size below comes from the token scale so surfaces line up. */
:root {
    --canvas: #fafafa;
    --panel: #ffffff;
    --card: #ffffff;
    --text: #0a0a0a;
    --ink: #0a0a0a;
    --secondary: #404040;
    --tertiary: #525252;
    --muted: #737373;
    --faint: #71717a;
    --label: #b4b4b8;
    --border: #ededed;
    --border-input: #e7e7e7;
    --row: #f1f1f1;
    --row-soft: #f6f6f6;
    --surface-inset: #f6f6f7;
    --surface-active: #f1f1f2;
    --surface-code: #0c0c0d;
    --accent: #ea580c;
    --accent-text: #c2410c;
    --accent-bg: #fff3eb;
    --primary: #0a0a0a;
    --primary-hover: #262626;
    --green: #16a34a;
    --green-text: #15803d;
    --green-bg: #effdf3;
    --green-border: #bbf7d0;
    --blue: #2563eb;
    --blue-text: #1d4ed8;
    --blue-bg: #eef3ff;
    --amber: #d97706;
    --amber-text: #b45309;
    --amber-bg: #fff7ea;
    --amber-border: #f4d29b;
    --red: #dc2626;
    --red-text: #b91c1c;
    --red-bg: #fef1f1;
    --red-border: #f4b4b4;
    --purple: #7c3aed;
    --purple-bg: #f5f0ff;
    --purple-border: #e4d3fb;
    --chart-neutral: #a1a1aa;
    --chart-email: #2563eb;
    --chart-sms: #0d9488;
    --chart-push: #9333ea;
    --chart-line: #0a0a0a;
    --chart-area: rgba(10, 10, 10, 0.06);

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --page-gap: var(--space-4);
    --card-pad: var(--space-4);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --text-xs: 11px;
    --text-sm: 12px;
    --text-md: 13px;
    --text-lg: 15px;
    --text-xl: 18px;
    --text-2xl: 26px;

    --sidebar-width: 236px;
    --topbar-height: 56px;
    --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
    --motion-fast: 160ms;
    --motion-base: 320ms;
    --motion-slow: 700ms;

    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* ---- Base ---- */

* {
    box-sizing: border-box;
}

html,
body {
    background: var(--canvas);
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--text-md);
    margin: 0;
}

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

a {
    color: inherit;
}

/* Bootstrap paints code pink; the console keeps it in the text color. */
code,
pre {
    color: inherit;
    font-family: var(--font-mono);
}

code {
    font-size: 0.92em;
}

pre {
    overflow-x: auto;
}

h1:focus {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

/* ---- Shell: sidebar, topbar, mobile bar ---- */

.app-shell {
    background: var(--canvas);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    width: var(--sidebar-width);
}

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

.mobile-bar,
.nav-backdrop,
.sidebar-close {
    display: none;
}

.app-topbar {
    align-items: center;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: var(--space-4);
    justify-content: space-between;
    min-height: var(--topbar-height);
    padding: var(--space-2) var(--space-6);
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar-heading {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--space-3);
}

.topbar-heading h1 {
    color: var(--text);
    font-size: var(--text-lg);
    font-weight: 680;
    letter-spacing: -0.01em;
    line-height: 1.2;
    margin: 0;
}

.topbar-heading p {
    color: var(--muted);
    font-size: var(--text-md);
    margin: 0;
}

.topbar-actions {
    align-items: center;
    display: flex;
    flex-shrink: 0;
    gap: var(--space-2);
}

.app-content {
    padding: var(--space-5) var(--space-6) var(--space-8);
}

/* Application pages draw their own header and section menu edge to edge. */
.app-content.app-content-flush {
    padding: 0;
}

.brand-row {
    align-items: center;
    display: flex;
    gap: var(--space-3);
    min-height: var(--topbar-height);
    padding: 0 var(--space-4);
}

.app-sidebar .brand-row {
    border-bottom: 1px solid var(--border);
}

.brand-mark {
    align-items: center;
    background: linear-gradient(135deg, #f97316, #db2777);
    border-radius: 7px;
    display: flex;
    flex-shrink: 0;
    height: 26px;
    justify-content: center;
    width: 26px;
}

.brand-mark-gem {
    background: #fff;
    border-radius: 2px;
    display: block;
    height: 11px;
    transform: rotate(45deg);
    width: 11px;
}

.brand-name {
    color: var(--text);
    font-size: var(--text-md);
    font-weight: 650;
    letter-spacing: -0.01em;
    line-height: 1.1;
}

.brand-domain {
    color: var(--faint);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    line-height: 1.35;
    margin-top: 2px;
}

/* ---- Navigation ---- */

.nav-stack {
    display: grid;
    gap: var(--space-5);
    min-height: 0;
    overflow-y: auto;
    padding: var(--space-4) var(--space-3);
}

.nav-section {
    display: grid;
    gap: 2px;
}


.nav-link {
    align-items: center;
    border-radius: var(--radius-md);
    color: var(--tertiary);
    display: flex;
    font-size: var(--text-md);
    font-weight: 500;
    gap: var(--space-3);
    min-height: 34px;
    padding: var(--space-2) var(--space-3);
    text-decoration: none;
    transition: background var(--motion-fast) ease, color var(--motion-fast) ease;
}

.nav-link:hover {
    background: var(--surface-inset);
    color: var(--text);
}

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

.nav-section-label {
    color: var(--faint);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    padding: 0 var(--space-3) var(--space-1);
    text-transform: uppercase;
}

.nav-icon {
    flex-shrink: 0;
    height: 16px;
    width: 16px;
}




.sidebar-footer {
    border-top: 1px solid var(--border);
    display: grid;
    gap: var(--space-2);
    margin-top: auto;
    padding: var(--space-3);
}

.account-anchor {
    position: relative;
}

.current-user-card {
    align-items: center;
    border: 0;
    cursor: pointer;
    font: inherit;
    text-align: left;
    width: 100%;
    background: var(--row-soft);
    border-radius: var(--radius-md);
    display: grid;
    gap: var(--space-2);
    grid-template-columns: 28px minmax(0, 1fr) auto;
    padding: var(--space-2) var(--space-3);
}

.current-user-avatar {
    align-items: center;
    background: var(--ink);
    border-radius: 999px;
    color: #fff;
    display: flex;
    font-size: var(--text-xs);
    font-weight: 650;
    height: 28px;
    justify-content: center;
    width: 28px;
}

.current-user-card:hover {
    background: var(--surface-active);
}

.current-user-text {
    min-width: 0;
}

.account-caret {
    color: var(--muted);
    font-size: var(--text-xs);
}

.account-menu {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    bottom: calc(100% + var(--space-2));
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    display: grid;
    gap: 2px;
    left: 0;
    padding: var(--space-1);
    position: absolute;
    right: 0;
    z-index: 20;
}

.account-signout {
    background: none;
    border: 0;
    cursor: pointer;
    font: inherit;
    font-size: var(--text-md);
    text-align: left;
    width: 100%;
}

.guide-cards {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    list-style: none;
    margin: 0;
    padding: 0;
}

.guide-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text);
    display: grid;
    gap: var(--space-2);
    height: 100%;
    padding: var(--space-4);
    text-decoration: none;
}

.guide-card:hover {
    border-color: var(--accent);
}

.guide-card span {
    color: var(--muted);
    font-size: var(--text-md);
}

.current-user-text strong,
.current-user-text span {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.current-user-text strong {
    color: var(--text);
    font-size: var(--text-sm);
    font-weight: 650;
}

.current-user-text span {
    color: var(--muted);
    font-size: var(--text-xs);
}



/* ---- Page structure ---- */

.page-stack {
    display: grid;
    gap: var(--page-gap);
}

.kpi-grid {
    display: grid;
    gap: var(--page-gap);
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.chart-row {
    display: grid;
    gap: var(--page-gap);
    grid-template-columns: minmax(0, 1.8fr) minmax(280px, 1fr);
}

.kpi-grid > *,
.chart-row > *,
.page-stack > .ui-card {
    animation: ah-rise var(--motion-base) var(--ease-out) both;
}

.kpi-grid > :nth-child(2) { animation-delay: 50ms; }
.kpi-grid > :nth-child(3) { animation-delay: 100ms; }
.kpi-grid > :nth-child(4) { animation-delay: 150ms; }
.chart-row > :nth-child(2) { animation-delay: 80ms; }

@keyframes ah-rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.loading-text,
.help-text {
    color: var(--muted);
    font-size: var(--text-sm);
    margin: 0;
}

.help-text {
    line-height: 1.55;
}

.back-link {
    color: var(--muted);
    font-size: var(--text-sm);
    font-weight: 650;
    text-decoration: none;
    width: fit-content;
}

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

.ml-2 {
    margin-left: var(--space-2);
}

/* ---- Cards ---- */

.ui-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    min-width: 0;
    overflow: hidden;
}

.ui-card-header {
    align-items: center;
    border-bottom: 1px solid var(--row);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    justify-content: space-between;
    min-height: 48px;
    padding: var(--space-3) var(--card-pad);
}

.ui-card-header h2 {
    color: var(--text);
    font-size: var(--text-md);
    font-weight: 620;
    line-height: 1.2;
    margin: 0;
}

.ui-card-header p {
    color: var(--faint);
    font-size: var(--text-sm);
    margin: var(--space-1) 0 0;
}

.ui-card-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.ui-card-body {
    padding: var(--card-pad);
}

.ui-card-body > p:first-child,
.ui-card-body > h3:first-child {
    margin-top: 0;
}

.ui-card-body h3 {
    color: var(--text);
    font-size: var(--text-lg);
    font-weight: 650;
    margin: var(--space-5) 0 var(--space-2);
}

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

.ui-card-body p {
    color: var(--secondary);
    font-size: var(--text-md);
    line-height: 1.55;
}

.ui-card-body ul {
    color: var(--secondary);
    font-size: var(--text-md);
    line-height: 1.55;
    margin: 0;
    padding-left: var(--space-5);
}

.ui-card-body li + li {
    margin-top: var(--space-1);
}

.ui-card-body pre {
    background: var(--surface-code);
    border-radius: var(--radius-md);
    color: #d4d4d8;
    font-size: var(--text-sm);
    line-height: 1.5;
    margin: var(--space-3) 0;
    padding: var(--space-3);
}

.ui-card-body pre code {
    color: inherit;
    font-size: inherit;
}

/* ---- Buttons ---- */

.ui-button {
    align-items: center;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: inline-flex;
    font-size: var(--text-md);
    font-weight: 600;
    gap: var(--space-2);
    justify-content: center;
    line-height: 1;
    min-height: 34px;
    padding: 0 var(--space-3);
    text-decoration: none;
    transition: background var(--motion-fast) ease, border-color var(--motion-fast) ease, color var(--motion-fast) ease;
    white-space: nowrap;
}

.ui-button-sm {
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    min-height: 28px;
    padding: 0 var(--space-2);
}

.ui-button-primary {
    background: var(--primary);
    color: #fff;
}

.ui-button-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.ui-button-secondary {
    background: #fff;
    border-color: var(--border-input);
    color: var(--secondary);
}

.ui-button-secondary:hover:not(:disabled) {
    border-color: #d4d4d4;
    color: var(--text);
}

.ui-button-ghost {
    background: transparent;
    color: var(--secondary);
}

.ui-button-ghost:hover:not(:disabled) {
    background: var(--surface-inset);
    color: var(--text);
}

.ui-button-danger {
    background: var(--red-bg);
    border-color: var(--red-border);
    color: var(--red-text);
}

.ui-button-danger:hover:not(:disabled) {
    background: #fde2e2;
}

.ui-button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.ui-button-icon {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 700;
}

.row-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
}

/* ---- Status pills ---- */

.status-pill {
    align-items: center;
    border-radius: var(--radius-sm);
    display: inline-flex;
    font-size: var(--text-xs);
    font-weight: 600;
    gap: 5px;
    line-height: 1;
    padding: 5px var(--space-2);
    text-transform: capitalize;
    vertical-align: middle;
}

.status-dot {
    border-radius: 999px;
    height: 6px;
    width: 6px;
}

.status-green { background: var(--green-bg); color: var(--green-text); }
.status-green .status-dot { background: var(--green); }
.status-blue { background: var(--blue-bg); color: var(--blue-text); }
.status-blue .status-dot { background: var(--blue); }
.status-amber { background: var(--amber-bg); color: var(--amber-text); }
.status-amber .status-dot { background: var(--amber); }
.status-red { background: var(--red-bg); color: var(--red-text); }
.status-red .status-dot { background: var(--red); }
.status-purple { background: var(--purple-bg); color: var(--purple); }
.status-purple .status-dot { background: var(--purple); }
.status-gray { background: var(--row-soft); color: var(--muted); }
.status-gray .status-dot { background: var(--faint); }

/* ---- Metric cards ---- */

.metric-card .ui-card-body {
    padding: var(--card-pad);
}

.metric-card-grid {
    align-items: center;
    display: grid;
    gap: var(--space-3);
    grid-template-columns: minmax(0, 1fr) auto;
}

.ui-card-body .metric-label {
    color: var(--muted);
    font-size: var(--text-sm);
    margin: 0 0 var(--space-2);
}

.ui-card-body .metric-value {
    color: var(--text);
    font-size: var(--text-2xl);
    font-variant-numeric: tabular-nums;
    font-weight: 680;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 0;
    overflow-wrap: anywhere;
}

.ui-card-body .metric-delta {
    color: var(--muted);
    font-size: var(--text-sm);
    margin: var(--space-2) 0 0;
}

.metric-delta.positive { color: var(--green-text); }
.metric-delta.negative { color: var(--red-text); }

.metric-delta span {
    color: var(--faint);
}

.metric-delta:empty {
    display: none;
}

/* ---- Tables ---- */

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

.data-table {
    border-collapse: collapse;
    min-width: 720px;
    width: 100%;
}

.data-table th {
    color: var(--faint);
    font-size: var(--text-xs);
    font-weight: 650;
    letter-spacing: 0.02em;
    padding: 0 var(--space-3) var(--space-2);
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table td {
    border-top: 1px solid var(--row-soft);
    color: var(--secondary);
    font-size: var(--text-md);
    padding: var(--space-3);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--motion-fast) ease;
}

.data-table tbody tr:hover {
    background: var(--row-soft);
}

.data-table th.num,
.data-table td.num {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.data-table details summary {
    color: var(--muted);
    cursor: pointer;
    font-size: var(--text-xs);
    margin-top: var(--space-1);
}

.app-cell {
    align-items: center;
    display: grid;
    gap: var(--space-2);
    grid-template-columns: 30px 1fr;
}

.app-avatar {
    align-items: center;
    background: var(--surface-active);
    border-radius: var(--radius-sm);
    color: var(--text);
    display: flex;
    font-size: var(--text-xs);
    font-weight: 680;
    height: 30px;
    justify-content: center;
    width: 30px;
}

.row-title {
    color: var(--text);
    display: block;
    font-size: var(--text-md);
    font-weight: 650;
}

.table-sub {
    color: var(--faint);
    display: block;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    margin-top: 2px;
}

.table-sub-wrap {
    font-family: var(--font-body);
    max-width: 420px;
    white-space: normal;
}

.nuget-key-groups {
    display: grid;
    gap: var(--space-6);
}

.nuget-key-group {
    border-top: 1px solid var(--border);
    padding-top: var(--space-5);
}

.nuget-key-group:first-child {
    border-top: 0;
    padding-top: 0;
}

.nuget-key-group-header {
    align-items: flex-start;
    display: flex;
    gap: var(--space-4);
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.nuget-key-group-header h3 {
    margin: 0;
}

.nuget-key-group-header p {
    color: var(--muted);
    margin: var(--space-1) 0 0;
}

/* ---- Forms ---- */

.form-grid {
    display: grid;
    gap: var(--space-3);
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.one {
    grid-template-columns: 1fr;
}

.form-field {
    color: var(--secondary);
    display: grid;
    font-size: var(--text-sm);
    font-weight: 650;
    gap: var(--space-1);
}

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

.form-field > span,
.form-field legend {
    color: var(--muted);
    font-size: var(--text-sm);
    font-weight: 650;
}

.form-field input,
.form-field select,
.form-field textarea {
    background: #fff;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    color: var(--text);
    font-weight: 450;
    min-height: 36px;
    outline: none;
    padding: var(--space-2) var(--space-3);
    transition: border-color var(--motion-fast) ease;
    width: 100%;
}

.form-field textarea {
    min-height: 96px;
    resize: vertical;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: var(--text);
}

.form-field small {
    color: var(--faint);
    font-size: var(--text-xs);
    font-weight: 450;
}

.form-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    justify-content: flex-end;
    margin-top: var(--space-4);
}

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

.form-actions > span {
    color: var(--muted);
}

.form-actions span {
    font-size: var(--text-sm);
}

.passkey-actions {
    align-items: flex-end;
}

.passkey-actions > .ui-button {
    min-height: 36px;
}

.check-row {
    align-items: center;
    color: var(--secondary);
    display: inline-flex;
    font-size: var(--text-md);
    font-weight: 500;
    gap: var(--space-2);
}

.check-row input {
    width: auto;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--green);
}

.invalid {
    outline: 1px solid var(--red);
}

.validation-message {
    color: var(--red);
}

/* ---- Notices ---- */

.notice {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    line-height: 1.5;
    margin: 0;
    padding: var(--space-2) var(--space-3);
}

.notice strong {
    font-weight: 650;
}

.notice-amber { background: var(--amber-bg); border-color: var(--amber-border); color: var(--amber-text); }
.notice-purple { background: var(--purple-bg); border-color: var(--purple-border); color: var(--purple); }
.notice-red { background: var(--red-bg); border-color: var(--red-border); color: var(--red-text); }
.notice-green { background: var(--green-bg); border-color: var(--green-border); color: var(--green-text); }

.auth-error {
    background: var(--red-bg);
    border: 1px solid var(--red-border);
    border-radius: var(--radius-md);
    color: var(--red-text);
    font-size: var(--text-md);
    margin: 0 0 var(--space-3);
    padding: var(--space-2) var(--space-3);
}

/* ---- Secret display ---- */

.secret-display,
.feed-url {
    align-items: center;
    background: var(--row-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    display: flex;
    gap: var(--space-2);
    min-width: 0;
    padding: var(--space-2);
}

.secret-display code,
.feed-url code {
    color: var(--text);
    flex: 1;
    font-size: var(--text-sm);
    min-width: 0;
    overflow: hidden;
    padding-left: var(--space-1);
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Empty state ---- */

.empty-state {
    align-items: center;
    color: var(--muted);
    display: grid;
    justify-items: center;
    padding: var(--space-8) var(--space-4);
    text-align: center;
}

.empty-state-icon {
    align-items: center;
    background: var(--row-soft);
    border-radius: 999px;
    color: var(--secondary);
    display: flex;
    font-size: var(--text-lg);
    font-weight: 700;
    height: 38px;
    justify-content: center;
    margin-bottom: var(--space-3);
    width: 38px;
}

.empty-state h3 {
    color: var(--text);
    font-size: var(--text-md);
    margin: 0 0 var(--space-1);
}

.empty-state p {
    font-size: var(--text-sm);
    margin: 0;
    max-width: 340px;
}

.empty-state-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-4);
}

/* ---- Modal ---- */

.modal-backdrop {
    align-items: center;
    animation: ah-fade var(--motion-fast) ease;
    background: rgba(0, 0, 0, 0.34);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: var(--space-4);
    position: fixed;
    z-index: 40;
}

.modal-panel {
    animation: ah-rise var(--motion-base) var(--ease-out);
    background: #fff;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-xl);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
    max-width: 560px;
    overflow: hidden;
    width: 100%;
}

.modal-panel.application-key-editor-modal {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 2 * var(--space-4));
}

.modal-panel.application-key-editor-modal .modal-body {
    min-height: 0;
    overflow-y: auto;
}

.modal-header,
.modal-footer {
    align-items: center;
    display: flex;
    gap: var(--space-3);
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
}

.modal-header {
    border-bottom: 1px solid var(--row);
}

.modal-footer {
    border-top: 1px solid var(--row);
}

.modal-header h2 {
    font-size: var(--text-lg);
    margin: 0;
}

.modal-header p {
    color: var(--faint);
    font-size: var(--text-sm);
    margin: var(--space-1) 0 0;
}

.modal-body {
    display: grid;
    gap: var(--space-3);
    padding: var(--space-4);
}

.modal-body .auth-error {
    margin: 0;
}

@keyframes ah-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ---- Toasts ---- */

.toast-host {
    bottom: var(--space-4);
    display: grid;
    gap: var(--space-2);
    position: fixed;
    right: var(--space-4);
    width: min(360px, calc(100vw - 32px));
    z-index: 50;
}

.toast {
    animation: ah-rise var(--motion-base) var(--ease-out);
    background: var(--ink);
    border-radius: var(--radius-lg);
    color: #fff;
    padding: var(--space-3) var(--space-4) var(--space-3) 28px;
    position: relative;
}

.toast::before {
    background: var(--green);
    border-radius: 999px;
    content: "";
    height: 7px;
    left: 13px;
    position: absolute;
    top: 17px;
    width: 7px;
}

.toast h3 {
    font-size: var(--text-md);
    font-weight: 550;
    margin: 0 0 var(--space-1);
}

.toast p {
    color: #d4d4d8;
    font-size: var(--text-sm);
    margin: 0;
}

.toast-info::before { background: var(--blue); }
.toast-warning::before { background: var(--amber); }
.toast-danger::before,
.toast-error::before { background: var(--red); }
.toast-purple::before { background: var(--purple); }

/* ---- Charts: shared anatomy ---- */

.chart {
    display: grid;
    gap: var(--space-3);
}

.chart-legend {
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    font-size: var(--text-sm);
    gap: var(--space-4);
    list-style: none;
    margin: 0;
    padding: 0;
}

.chart-legend li {
    align-items: center;
    display: flex;
    gap: var(--space-2);
}

.chart-swatch {
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
    height: 10px;
    width: 10px;
}

.chart-plot {
    height: 160px;
    position: relative;
}

.chart-grid {
    display: flex;
    flex-direction: column;
    inset: 0;
    justify-content: space-between;
    pointer-events: none;
    position: absolute;
}

.chart-grid span {
    border-top: 1px solid var(--row);
    display: block;
    position: relative;
}

.chart-grid span:last-child {
    border-top-color: var(--label);
}

.chart-grid span::after {
    color: var(--faint);
    content: attr(data-label);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    position: absolute;
    right: 0;
    top: -14px;
}

.chart-columns {
    align-items: end;
    display: flex;
    gap: 2px;
    height: 100%;
    padding-right: 40px;
    position: relative;
}

.chart-column {
    align-items: end;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    display: flex;
    flex: 1;
    height: 100%;
    min-width: 0;
    position: relative;
    transition: background var(--motion-fast) ease;
}

.chart-column:hover,
.chart-column:focus-within {
    background: var(--row-soft);
}

.chart-column.is-selected {
    background: var(--surface-active);
}

.chart-hit {
    background: transparent;
    border: 0;
    cursor: pointer;
    inset: 0;
    padding: 0;
    position: absolute;
    z-index: 2;
}

.chart-hit:focus-visible {
    border-radius: var(--radius-sm);
    outline: 2px solid var(--text);
    outline-offset: -2px;
}

.chart-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0 auto;
    max-width: 18px;
    min-height: 4px;
    transform-origin: bottom;
    transition: height var(--motion-base) var(--ease-out);
    width: 62%;
}

.stacked-chart .chart-stack {
    animation: ah-grow var(--motion-slow) var(--ease-out) both;
    animation-delay: calc(var(--i, 0) * 14ms);
}

.chart-stack span {
    border-radius: 2px;
    display: block;
    min-height: 2px;
}

.chart-stack span:first-child {
    border-radius: 4px 4px 2px 2px;
}

@keyframes ah-grow {
    from { transform: scaleY(0); }
    to { transform: scaleY(1); }
}

.chart-tip {
    background: var(--ink);
    border-radius: var(--radius-md);
    bottom: calc(100% + 6px);
    color: #fff;
    display: none;
    font-size: var(--text-xs);
    left: 50%;
    line-height: 1.5;
    padding: var(--space-2) var(--space-3);
    pointer-events: none;
    position: absolute;
    transform: translateX(-50%);
    white-space: nowrap;
    z-index: 3;
}

.chart-tip strong,
.chart-tip span {
    display: flex;
    gap: 6px;
    align-items: center;
}

.chart-tip strong {
    margin-bottom: 3px;
}

.chart-tip .chart-swatch {
    height: 8px;
    width: 8px;
}

.chart-column:hover .chart-tip,
.chart-column:focus-within .chart-tip {
    display: block;
}

.chart-column:first-child .chart-tip,
.chart-column:nth-child(2) .chart-tip,
.chart-column:nth-child(3) .chart-tip {
    left: 0;
    transform: none;
}

.chart-column:last-child .chart-tip,
.chart-column:nth-last-child(2) .chart-tip,
.chart-column:nth-last-child(3) .chart-tip {
    left: auto;
    right: 0;
    transform: none;
}

.chart-axis {
    color: var(--faint);
    display: flex;
    font-size: 10px;
    gap: 2px;
    padding-right: 40px;
}

.chart-axis span {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
}

.chart-date-picker {
    display: none;
}

/* ---- Charts: donut ---- */

.donut-chart {
    align-items: center;
    gap: var(--space-4);
    grid-template-columns: minmax(110px, 140px) minmax(0, 1fr);
}

.donut-chart svg {
    height: auto;
    transform: rotate(-90deg);
    width: 100%;
}

.donut-track {
    fill: none;
    stroke: var(--row);
    stroke-width: 12;
}

.donut-segment {
    fill: none;
    stroke-dasharray: var(--len) 100;
    stroke-dashoffset: var(--off);
    stroke-width: 12;
    animation: ah-donut var(--motion-slow) var(--ease-out) both;
    animation-delay: calc(var(--i, 0) * 90ms);
    transition: stroke-width var(--motion-fast) ease;
}

.donut-segment:hover {
    stroke-width: 16;
}

@keyframes ah-donut {
    from { stroke-dasharray: 0 100; }
    to { stroke-dasharray: var(--len) 100; }
}

.donut-value,
.donut-label {
    fill: var(--text);
    font-family: var(--font-body);
    transform: rotate(90deg);
    transform-origin: 60px 60px;
}

.donut-value {
    font-size: 17px;
    font-variant-numeric: tabular-nums;
    font-weight: 680;
    letter-spacing: -0.02em;
}

.donut-label {
    fill: var(--muted);
    font-size: 8px;
}

.donut-legend {
    display: grid;
    gap: var(--space-2);
    list-style: none;
    margin: 0;
    min-width: 0;
    padding: 0;
}

.donut-legend li {
    align-items: center;
    color: var(--secondary);
    display: grid;
    font-size: var(--text-sm);
    gap: var(--space-2);
    grid-template-columns: 10px minmax(0, 1fr) auto 36px;
}

.donut-legend-label {
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.donut-legend strong {
    color: var(--text);
    font-variant-numeric: tabular-nums;
    font-weight: 650;
}

.donut-legend-pct {
    color: var(--faint);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* ---- Charts: trend line ---- */

.trend-chart .chart-plot {
    height: 140px;
}

.trend-svg {
    display: block;
    height: 100%;
    left: 0;
    overflow: visible;
    position: absolute;
    top: 0;
    width: calc(100% - 40px);
}

.trend-line {
    fill: none;
    stroke: var(--chart-line);
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2px;
    vector-effect: non-scaling-stroke;
    animation: ah-draw 1.1s var(--ease-out) forwards;
}

.trend-area {
    fill: var(--chart-area);
    animation: ah-fade var(--motion-slow) ease 400ms both;
}

@keyframes ah-draw {
    to { stroke-dashoffset: 0; }
}

.trend-columns .chart-column {
    border-radius: 0;
}

.trend-columns .chart-column:hover,
.trend-columns .chart-column:focus-within {
    background: linear-gradient(to right, transparent calc(50% - 1px), var(--label) calc(50% - 1px), var(--label) calc(50% + 1px), transparent calc(50% + 1px));
}

.trend-marker {
    background: #fff;
    border: 2px solid var(--chart-line);
    border-radius: 999px;
    height: 9px;
    left: 50%;
    opacity: 0;
    position: absolute;
    transform: translate(-50%, 50%);
    transition: opacity var(--motion-fast) ease;
    width: 9px;
}

.chart-column:hover .trend-marker,
.chart-column:focus-within .trend-marker {
    opacity: 1;
}

/* ---- Charts: ranked bars ---- */

.ranked-bars {
    display: grid;
    gap: var(--space-3);
    list-style: none;
    margin: 0;
    padding: 0;
}

.ranked-bars li {
    animation: ah-rise var(--motion-base) var(--ease-out) both;
    animation-delay: calc(var(--i, 0) * 60ms);
    display: grid;
    gap: var(--space-1);
    grid-template-columns: minmax(0, 1fr);
    min-width: 0;
}

.ranked-head {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    justify-content: space-between;
    min-width: 0;
}

.ranked-label {
    color: var(--text);
    font-size: var(--text-md);
    font-weight: 600;
    min-width: 0;
    overflow: hidden;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

a.ranked-label:hover {
    text-decoration: underline;
}

.ranked-value {
    color: var(--text);
    font-size: var(--text-md);
    font-variant-numeric: tabular-nums;
    font-weight: 650;
}

.ranked-track {
    background: var(--row-soft);
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
}

.ranked-fill {
    background: var(--ink);
    border-radius: inherit;
    display: block;
    height: 100%;
    transform-origin: left;
    animation: ah-fill var(--motion-slow) var(--ease-out) both;
    animation-delay: calc(var(--i, 0) * 60ms + 100ms);
    transition: width var(--motion-base) var(--ease-out);
}

@keyframes ah-fill {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

.ranked-detail {
    color: var(--faint);
    font-size: var(--text-xs);
}

/* ---- Charts: sparkline ---- */

.sparkline {
    display: block;
    height: 28px;
    overflow: visible;
    width: 100px;
}

.sparkline-line {
    fill: none;
    stroke: var(--chart-line);
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.5px;
    vector-effect: non-scaling-stroke;
    animation: ah-draw 0.9s var(--ease-out) forwards;
}

.sparkline-area {
    fill: var(--chart-area);
}

/* ---- Package uploads ---- */

.upload-zone {
    align-items: center;
    border: 1.5px dashed var(--border-input);
    border-radius: var(--radius-lg);
    color: var(--muted);
    cursor: pointer;
    display: grid;
    font-size: var(--text-sm);
    gap: var(--space-1);
    justify-items: center;
    padding: var(--space-6);
    position: relative;
    text-align: center;
    transition: border-color var(--motion-fast) ease, background var(--motion-fast) ease;
}

.upload-zone:hover,
.upload-zone:focus-within {
    background: var(--row-soft);
    border-color: var(--text);
}

.upload-zone.is-busy {
    cursor: progress;
    opacity: 0.7;
}

.upload-zone input {
    cursor: inherit;
    inset: 0;
    opacity: 0;
    position: absolute;
    width: 100%;
}

.upload-zone strong {
    color: var(--text);
    font-size: var(--text-md);
}

.upload-zone-icon {
    align-items: center;
    background: var(--ink);
    border-radius: 999px;
    color: #fff;
    display: flex;
    font-size: var(--text-lg);
    font-weight: 700;
    height: 34px;
    justify-content: center;
    margin-bottom: var(--space-1);
    width: 34px;
}

/* Typed with the element so the generic .ui-card-body ul indent does not win. */
ul.upload-results {
    display: grid;
    gap: var(--space-2);
    list-style: none;
    margin: var(--space-4) 0 0;
    padding: 0;
}

ul.upload-results li {
    align-items: center;
    animation: ah-rise var(--motion-base) var(--ease-out) both;
    border: 1px solid var(--row);
    border-radius: var(--radius-md);
    display: grid;
    gap: var(--space-3);
    grid-template-columns: auto minmax(0, 1fr) auto;
    margin: 0;
    padding: var(--space-2) var(--space-3);
}

.upload-result-name {
    color: var(--text);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-result-detail {
    color: var(--muted);
    font-size: var(--text-sm);
    text-align: right;
}

/* ---- Notification detail and item cards ---- */

.fact-grid {
    border: 1px solid var(--row);
    border-radius: var(--radius-md);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    overflow: hidden;
}

.fact {
    background: #fff;
    /* The shadow draws the inner hairlines; the outer edge is clipped so partial rows stay clean. */
    box-shadow: 1px 1px 0 0 var(--row);
    display: grid;
    gap: var(--space-1);
    min-width: 0;
    padding: var(--space-3);
}

.fact span {
    color: var(--muted);
    font-size: var(--text-xs);
    font-weight: 650;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.fact strong {
    color: var(--text);
    font-size: var(--text-md);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.fact code {
    font-size: var(--text-sm);
}

.item-card-list {
    display: grid;
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.item-card {
    border: 1px solid var(--row);
    border-radius: var(--radius-lg);
    display: grid;
    gap: var(--space-3);
    margin: 0;
    min-width: 0;
    padding: var(--space-4);
}

.item-card-body {
    display: grid;
    gap: var(--space-3);
}

.item-card .form-actions {
    margin-top: 0;
}

.item-card-head {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    justify-content: space-between;
}

.item-card-head h3,
.item-card-head legend {
    color: var(--text);
    float: left;
    font-size: var(--text-md);
    font-weight: 650;
    margin: 0;
    padding: 0;
}

.issued-secret {
    margin: var(--space-3) 0 var(--space-4);
}

.item-card p {
    margin: 0;
}

.item-card details {
    border-top: 1px solid var(--row);
    padding-top: var(--space-3);
}

.item-card summary {
    color: var(--secondary);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 650;
    width: fit-content;
}

.item-card details[open] summary {
    margin-bottom: var(--space-2);
}

.item-card pre {
    background: var(--row-soft);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: var(--text-sm);
    margin: var(--space-2) 0 0;
    padding: var(--space-3);
    white-space: pre-wrap;
}

.item-card-archived {
    opacity: 0.6;
}

.quota-usage {
    font-weight: 600;
}

.attempt-list {
    display: grid;
    gap: var(--space-1);
    list-style: none;
    margin: 0;
    padding: 0;
}

.attempt-list li {
    color: var(--secondary);
    font-size: var(--text-sm);
}

/* ---- Delivery history list ---- */

.delivery-list {
    display: grid;
    list-style: none;
    margin: 0;
    padding: 0;
}

.delivery-row {
    border-top: 1px solid var(--row-soft);
}

.delivery-row:first-child {
    border-top: 0;
}

.delivery-summary {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: var(--radius-md);
    color: var(--text);
    cursor: pointer;
    display: grid;
    gap: var(--space-3);
    grid-template-columns: 88px auto minmax(0, 1fr) auto 14px;
    min-height: 48px;
    padding: var(--space-2) var(--space-2);
    text-align: left;
    transition: background var(--motion-fast) ease;
    width: 100%;
}

.delivery-summary:hover,
.delivery-row.is-open .delivery-summary {
    background: var(--row-soft);
}

.delivery-time {
    color: var(--muted);
    font-size: var(--text-sm);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.channel-chip {
    background: var(--row-soft);
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1;
    padding: 5px 6px;
    text-transform: uppercase;
}

.channel-email { background: var(--blue-bg); color: var(--blue-text); }
.channel-sms { background: #e6f7f5; color: #0f766e; }
.channel-push { background: var(--purple-bg); color: var(--purple); }

.delivery-main {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.delivery-main strong {
    font-size: var(--text-md);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.delivery-main span {
    color: var(--muted);
    font-size: var(--text-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.delivery-caret {
    border-color: var(--faint);
    border-style: solid;
    border-width: 0 1.5px 1.5px 0;
    height: 7px;
    justify-self: center;
    transform: rotate(45deg) translateY(-2px);
    transition: transform var(--motion-fast) ease;
    width: 7px;
}

.delivery-row.is-open .delivery-caret {
    transform: rotate(225deg) translateY(-2px);
}

.delivery-details {
    animation: ah-rise var(--motion-fast) var(--ease-out);
    display: grid;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-2) var(--space-4) 112px;
}

.delivery-facts {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-6);
    margin: 0;
}

.delivery-facts dt {
    color: var(--muted);
    font-size: var(--text-xs);
}

.delivery-facts dd {
    font-size: var(--text-md);
    margin: 2px 0 0;
    overflow-wrap: anywhere;
}

.delivery-facts .delivery-problem dd {
    color: var(--red-text);
}

.delivery-links {
    align-items: center;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    font-size: var(--text-sm);
    gap: var(--space-3);
}

/* ---- Recent deliveries feed (dashboard) ---- */

/* The feed sits in the narrow column, so the time column shrinks to fit and the caret goes. */
.feed-card .delivery-summary {
    gap: var(--space-2);
    grid-template-columns: auto auto minmax(0, 1fr) auto;
}

.feed-card .delivery-caret {
    display: none;
}

.feed-card .delivery-details {
    padding-left: var(--space-2);
}

.usage-stack {
    display: grid;
    gap: var(--space-2);
}

/* ---- Modules and planned features (dashboard) ---- */





.module-stat-value {
    font-size: var(--text-2xl);
    font-variant-numeric: tabular-nums;
    font-weight: 680;
    letter-spacing: -0.02em;
    line-height: 1;
    margin-top: var(--space-1);
}

.module-stat-detail {
    color: var(--muted);
    font-size: var(--text-sm);
}

.ui-card-body ul.planned-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    list-style: none;
    margin: 0;
    padding: 0;
}

.ui-card-body .planned-list li {
    background: var(--surface-active);
    border-radius: 999px;
    color: var(--secondary);
    font-size: var(--text-sm);
    margin: 0;
    padding: 3px 10px;
}



/* ---- Packages page ---- */

.package-search {
    margin-bottom: var(--space-3);
    max-width: 420px;
}

.delivery-summary.package-summary {
    grid-template-columns: minmax(0, 1fr) auto auto 14px;
}

.package-summary code {
    color: var(--text);
    font-size: var(--text-sm);
}

.package-count {
    color: var(--muted);
    font-size: var(--text-sm);
    white-space: nowrap;
}

.package-details {
    padding-left: var(--space-2);
}

/* The extra class outranks CopyableCode's own scoped rules, which otherwise tie on
   specificity and win on source order. */
.delivery-details.package-details .copyable-code {
    align-items: center;
    margin: 0;
}

.delivery-details.package-details .copyable-code pre {
    padding: var(--space-2) var(--space-3);
}

/* ---- Chip lists (templates, tags) ---- */

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.chip {
    background: var(--row-soft);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--secondary);
    cursor: pointer;
    display: inline-flex;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 650;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
}

.chip:hover {
    border-color: var(--border);
    color: var(--text);
}

.chip span {
    color: var(--faint);
    font-weight: 500;
}

/* ---- Error UI ---- */

.blazor-error-boundary {
    background: var(--red-bg);
    border: 1px solid var(--red-border);
    border-radius: var(--radius-md);
    color: var(--red-text);
    padding: var(--space-4);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

#blazor-error-ui {
    background: var(--red-bg);
    border-top: 1px solid var(--red-border);
    bottom: 0;
    box-sizing: border-box;
    color: var(--red-text);
    display: none;
    font-size: var(--text-md);
    left: 0;
    padding: var(--space-3) 48px var(--space-3) var(--space-4);
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    background: none;
    border: 0;
    color: inherit;
    cursor: pointer;
    font: inherit;
    position: absolute;
    right: 14px;
    top: 10px;
}

/* ---- Auth pages ---- */

.auth-shell {
    align-items: center;
    background: var(--canvas);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-6);
}

.auth-card {
    animation: ah-rise var(--motion-base) var(--ease-out);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    max-width: 380px;
    padding: var(--space-8);
    width: 100%;
}

.auth-brand {
    margin-bottom: var(--space-1);
    min-height: 0;
    padding: 0;
}

.auth-title {
    font-size: 20px;
    font-weight: 680;
    letter-spacing: -0.01em;
    margin: 0;
}

.auth-subtitle {
    color: var(--secondary);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.auth-field span {
    color: var(--muted);
    font-size: var(--text-sm);
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.auth-field input {
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    font-size: var(--text-lg);
    padding: var(--space-2) var(--space-3);
}

.auth-field input:focus {
    border-color: var(--primary);
    outline: none;
}

.auth-primary,
.auth-secondary {
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    padding: var(--space-2) var(--space-4);
}

.auth-primary {
    background: var(--primary);
    border: 1px solid var(--primary);
    color: #fff;
    display: block;
    text-align: center;
    text-decoration: none;
}

.auth-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.auth-secondary {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
}

a.auth-secondary {
    display: block;
    text-align: center;
    text-decoration: none;
}

.auth-secondary:hover:not(:disabled) {
    background: var(--row-soft);
}

.auth-primary:disabled,
.auth-secondary:disabled {
    cursor: default;
    opacity: 0.6;
}

.auth-divider {
    align-items: center;
    color: var(--faint);
    display: flex;
    font-size: var(--text-sm);
    gap: var(--space-3);
}

.auth-divider::before,
.auth-divider::after {
    background: var(--border);
    content: "";
    flex: 1;
    height: 1px;
}

.auth-link {
    background: none;
    border: none;
    color: var(--blue-text);
    cursor: pointer;
    font-size: var(--text-md);
    padding: 0;
    text-align: left;
    text-decoration: none;
}

.auth-link:hover {
    text-decoration: underline;
}

.auth-qr {
    display: flex;
    justify-content: center;
}

.auth-qr img {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.auth-hint {
    color: var(--muted);
    font-size: var(--text-sm);
    margin: 0;
    word-break: break-all;
}

/* ---- Responsive ---- */

@media (max-width: 1120px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .chart-row {
        grid-template-columns: 1fr;
    }

    .chart-row > :nth-child(2) {
        animation-delay: 0ms;
    }
}

@media (max-width: 860px) {
    .nuget-key-group-header {
        flex-direction: column;
    }

    .app-shell {
        display: block;
    }

    .mobile-bar {
        align-items: center;
        background: var(--card);
        border-bottom: 1px solid var(--border);
        display: flex;
        gap: var(--space-2);
        min-height: var(--topbar-height);
        padding: 0 var(--space-3);
        position: sticky;
        top: 0;
        z-index: 20;
    }

    .brand-row-compact {
        min-height: 0;
        padding: 0;
    }

    .menu-button {
        align-items: center;
        background: transparent;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        cursor: pointer;
        display: flex;
        flex-direction: column;
        gap: 4px;
        height: 36px;
        justify-content: center;
        padding: 0 9px;
    }

    .menu-button span {
        background: var(--text);
        border-radius: 1px;
        display: block;
        height: 2px;
        width: 16px;
    }

    .app-sidebar {
        box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
        height: 100dvh;
        left: 0;
        max-width: 320px;
        position: fixed;
        top: 0;
        transform: translateX(-100%);
        transition: transform var(--motion-base) var(--ease-out), visibility 0s linear var(--motion-base);
        visibility: hidden;
        width: 84vw;
        z-index: 40;
    }

    .nav-open .app-sidebar {
        transform: none;
        transition-delay: 0s;
        visibility: visible;
    }

    .nav-backdrop {
        background: rgba(0, 0, 0, 0.36);
        border: 0;
        display: block;
        inset: 0;
        opacity: 0;
        padding: 0;
        pointer-events: none;
        position: fixed;
        transition: opacity var(--motion-base) ease;
        z-index: 30;
    }

    .nav-open .nav-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    body:has(.nav-open) {
        overflow: hidden;
    }

    .sidebar-close {
        background: transparent;
        border: 0;
        border-radius: var(--radius-sm);
        color: var(--muted);
        cursor: pointer;
        display: block;
        font-size: 22px;
        line-height: 1;
        margin-left: auto;
        padding: var(--space-1) var(--space-2);
    }

    .sidebar-close:hover {
        background: var(--row-soft);
        color: var(--text);
    }

    .nav-link {
        min-height: 44px;
    }

    .app-topbar {
        min-height: 0;
        padding: var(--space-3) var(--space-4);
        position: static;
    }

    .topbar-heading h1 {
        font-size: 17px;
    }

    .topbar-heading p {
        display: none;
    }

    .app-content {
        padding: var(--space-4) var(--space-4) var(--space-8);
    }

    .ui-card-header,
    .ui-card-body {
        padding-left: var(--space-3);
        padding-right: var(--space-3);
    }

    .chart-date-picker {
        display: grid;
    }

    .chart-tip {
        display: none !important;
    }

    .delivery-summary {
        grid-template-columns: auto minmax(0, 1fr) auto;
        row-gap: var(--space-1);
    }

    .delivery-summary.package-summary {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .package-summary .package-count {
        grid-column: 1 / -1;
    }

    /* Undo the .delivery-main placement below; the package row keeps the name first. */
    .package-summary .delivery-main {
        grid-column: 1;
        grid-row: 1;
    }

    .delivery-time {
        grid-column: 1;
        grid-row: 2;
    }

    .channel-chip {
        grid-column: 1;
        grid-row: 1;
        justify-self: start;
    }

    .delivery-main {
        grid-column: 2;
        grid-row: 1 / 3;
    }

    .delivery-summary .status-pill {
        grid-column: 3;
        grid-row: 1;
    }

    .delivery-caret {
        display: none;
    }

    .delivery-details {
        padding-left: var(--space-2);
    }

    .feed-card .delivery-summary {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    ul.upload-results li {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .upload-result-detail {
        grid-column: 1 / -1;
        text-align: left;
    }
}

@media (max-width: 640px) {
    .kpi-grid,
    .kpi-grid-3 {
        gap: var(--space-2);
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .metric-card .sparkline {
        display: none;
    }

    .donut-chart {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .donut-chart svg {
        max-width: 180px;
    }

    .donut-legend {
        width: 100%;
    }

    .form-actions {
        justify-content: stretch;
    }

    .form-actions > .ui-button {
        flex: 1;
    }
}

/* Inbox filters row */
.inbox-filters {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    align-items: end;
}

.inbox-filters .form-field {
    min-width: 140px;
    flex: 0 1 auto;
}

/* HTML preview iframe */
.html-preview-frame {
    width: 100%;
    min-height: 320px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    margin-top: var(--space-2);
}

.html-source-toggle {
    margin-top: var(--space-2);
}

/* Push metadata in notification detail */
.push-meta {
    margin-bottom: var(--space-3);
}

/* Template context */
.template-context {
    margin: var(--space-2) 0;
}

/* ---- Sandbox mode theming ---- */

.sandbox-mode .app-topbar {
    border-bottom-color: var(--purple-border);
}

.sandbox-mode .app-content .ui-card {
    border-color: var(--purple-border);
}

/* A Live key stays green in sandbox mode, because its colour says which environment it sends to. */
.sandbox-mode .status-green:not(.status-fixed) {
    background: var(--purple-bg);
    color: var(--purple);
}

.sandbox-mode .status-green .status-dot {
    background: var(--purple);
}

.sandbox-indicator {
    background: var(--purple-bg);
    border: 1px solid var(--purple-border);
    border-radius: var(--radius-sm);
    color: var(--purple);
    font-size: var(--text-sm);
    font-weight: 650;
    padding: var(--space-1) var(--space-3);
}

/* ---- Config snippet ---- */

.config-snippet {
    margin-top: var(--space-3);
}

.snippet-tabs {
    display: flex;
    gap: var(--space-1);
    margin-bottom: var(--space-2);
}

.snippet-tabs button {
    background: transparent;
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-size: var(--text-sm);
    padding: var(--space-2) var(--space-3);
}

.snippet-tabs button[aria-selected="true"] {
    background: var(--row-soft);
    color: var(--text);
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0ms !important;
        transition-duration: 0.01ms !important;
    }
}
