:root {
    color-scheme: light;
    font-family: Inter, Segoe UI, Arial, sans-serif;

    /* ─── Design tokens (shared with WPF) ─── */
    --color-primary:        #2563eb;
    --color-primary-dark:   #1d4ed8;
    --color-primary-light:  #dbeafe;
    --color-sidebar-start:  #0f172a;
    --color-sidebar-end:    #1e293b;
    --color-bg:             #f8fafc;
    --color-surface:        #ffffff;
    --color-border:         #e2e8f0;
    --color-border-hover:   #94a3b8;
    --color-text:           #0f172a;
    --color-text-muted:     #475569;
    --color-text-faint:     #64748b;
    --color-success-bg:     #dcfce7;
    --color-success-fg:     #166534;
    --color-success-bd:     #86efac;
    --color-warning-bg:     #fef3c7;
    --color-warning-fg:     #b45309;
    --color-warning-bd:     #fde68a;
    --color-error-bg:       #fee2e2;
    --color-error-fg:       #b91c1c;
    --color-error-bd:       #fca5a5;
    --color-running-bg:     #dbeafe;
    --color-running-fg:     #1d4ed8;
    --radius-card:          1rem;
    --radius-btn:           0.75rem;
    --radius-input:         0.75rem;
    --shadow-card:          0 10px 30px rgba(15, 23, 42, 0.06);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    background: #f8fafc;
    color: #0f172a;
}

body,
.mud-typography,
.mud-button-root,
.mud-input-slot,
.mud-nav-link,
.mud-list-item,
.mud-popover,
.mud-table,
.mud-chip {
    font-family: Inter, Segoe UI, Arial, sans-serif;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.95rem; }

.page-copy {
    color: #475569;
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    max-width: 70ch;
}

.eyebrow {
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
}

.card-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 1rem;
}

.metric-card,
.panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    min-width: 0;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.metric-card:hover {
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.1);
    transform: translateY(-2px);
}

.metric-card {
    align-content: start;
    display: grid;
    gap: 0.25rem;
    min-height: 100%;
    padding: 0.85rem 1rem;
}

.metric-card span,
.metric-label {
    color: #64748b;
    font-weight: 600;
}

.metric-label {
    font-size: 0.82rem;
    line-height: 1.4;
}

.metric-card strong {
    font-size: 1.4rem;
}

.metric-card-detailed {
    align-items: flex-start;
}

.metric-card-detailed strong {
    font-size: 1.1rem;
}

.metric-card-detailed p {
    margin-bottom: 0;
}

.panel {
    overflow-x: auto;
    padding: 1.1rem 1.25rem;
    -webkit-overflow-scrolling: touch;
}

.feature-list {
    display: grid;
    gap: 0.75rem;
    margin: 0;
    padding-left: 1.1rem;
}

.data-table {
    border-collapse: collapse;
    min-width: 42rem;
    width: 100%;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid #e2e8f0;
    padding: 0.5rem 0.65rem;
    text-align: left;
    vertical-align: top;
}

.data-table th {
    background: #f8fafc;
    color: #334155;
    font-size: 0.78rem;
    text-transform: uppercase;
}

.data-table tr.history-row-success td:first-child  { border-left: 3px solid var(--color-success-fg); }
.data-table tr.history-row-info td:first-child     { border-left: 3px solid var(--color-primary); }
.data-table tr.history-row-internal td:first-child { border-left: 3px solid var(--color-warning-fg); }
.data-table tr.history-row-error td:first-child    { border-left: 3px solid var(--color-error-fg); }

.data-table tbody tr:hover {
    background: #f8fafc;
}

.state-pill {
    border-radius: 999px;
    display: inline-flex;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.3rem 0.7rem;
}

.state-running {
    background: #dbeafe;
    color: #1d4ed8;
}

.state-success {
    background: #dcfce7;
    color: #15803d;
}

.state-warning {
    background: #fef3c7;
    color: #b45309;
}

.state-failed {
    background: #fee2e2;
    color: #b91c1c;
}

.markdown-panel {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 1rem 1.25rem;
}

.markdown-panel h1,
.markdown-panel h2,
.markdown-panel h3,
.markdown-panel h4,
.markdown-panel h5,
.markdown-panel h6 {
    margin-top: 0;
}

.shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 1.25rem 1rem;
}

.brand-panel {
    margin-bottom: 1rem;
}

.tagline {
    color: #cbd5e1;
    line-height: 1.5;
}

.main-content {
    background: #f8fafc;
    color: #0f172a;
}

.mud-shell {
    min-height: 100vh;
}

.shell-drawer.mud-drawer {
    background: transparent !important;
    border-right: 0 !important;
    box-shadow: none !important;
}

.shell-drawer .mud-drawer-content {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.shell-drawer .sidebar {
    box-sizing: border-box;
    display: flex;
    flex: 1;
    flex-direction: column;
}

.shell-main.mud-main-content {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.topbar {
    align-items: center;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    padding: 0.9rem 1.5rem;
}

.shell-appbar.mud-appbar {
    color: #0f172a !important;
    position: static;
}

.shell-appbar .mud-toolbar-appbar {
    min-height: auto;
    padding: 0;
    width: 100%;
}

.topbar-inner {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    width: 100%;
}

.topbar-heading-group {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    min-width: 0;
}

.topbar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.drawer-toggle {
    color: #0f172a !important;
    display: none;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.topbar-actions {
    align-items: center;
    display: flex;
    gap: 1rem;
}

.user-summary {
    display: grid;
    gap: 0.25rem;
    text-align: right;
}

.user-summary span {
    color: #64748b;
    font-size: 0.85rem;
}

.page-body {
    padding: 1.25rem 1.5rem;
}

/* ── App footer (version display) ── */

.app-footer {
    padding: 1.25rem 1.5rem 1rem;
    text-align: center;
    font-size: 0.75rem;
    color: #94a3b8;
    letter-spacing: 0.025em;
}

.nav-menu {
    display: grid;
    gap: 0.15rem;
}

/* Prevent MudBlazor surface/paper white from bleeding into the dark sidebar */
.shell-drawer .mud-navmenu,
.shell-drawer .mud-nav-group,
.shell-drawer .mud-nav-group-items,
.shell-drawer .mud-collapse-container,
.shell-drawer .mud-collapse-entering,
.shell-drawer .mud-collapse-exiting {
    background: transparent !important;
    color: inherit;
}

/* MudNavGroup header button inherits sidebar text colour */
.shell-drawer .mud-nav-group > .mud-nav-link {
    color: #cbd5e1;
    font-weight: 600;
}

/* Indent child links to show hierarchy */
.shell-drawer .mud-nav-group-items .mud-nav-link {
    padding-left: 2rem;
}

.nav-menu a,
.nav-menu .mud-nav-link {
    border-radius: 0.5rem;
    color: #cbd5e1;
    display: block;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
}

.nav-menu .mud-nav-link-text {
    color: inherit;
    font-weight: inherit;
}

.nav-menu a.active,
.nav-menu .mud-nav-link.active,
.nav-menu .mud-nav-link.mud-nav-link-active {
    background: rgba(59, 130, 246, 0.2);
    color: #ffffff;
}

.nav-menu a:hover,
.nav-menu .mud-nav-link:hover {
    background: rgba(148, 163, 184, 0.18);
}

.primary-button,
.secondary-button,
.danger-button,
.secondary-link {
    border-radius: 0.75rem;
    display: inline-flex;
    font-weight: 700;
    justify-content: center;
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
}

.primary-button,
.secondary-button,
.danger-button {
    align-items: center;
    border: 0;
    cursor: pointer;
    line-height: 1.2;
    padding: 0.5rem 0.75rem;
}

.primary-button {
    background: #2563eb;
    color: #ffffff;
}

.primary-button:hover:not(:disabled) {
    background: #1d4ed8;
}

.secondary-button {
    background: #e2e8f0;
    color: #0f172a;
}

.secondary-button:hover:not(:disabled) {
    background: #cbd5e1;
}

.danger-button {
    background: #dc2626;
    color: #ffffff;
}

.danger-button:hover:not(:disabled) {
    background: #b91c1c;
}

.secondary-link {
    color: #2563eb;
    display: inline-flex;
    text-underline-offset: 0.2rem;
}

.secondary-link:hover {
    color: #1d4ed8;
}

.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.danger-button:focus-visible,
.secret-toggle-button:focus-visible,
.secondary-link:focus-visible,
.selector-button:focus-visible,
.nav-menu a:focus-visible,
.text-input:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.25);
    outline-offset: 2px;
}

.login-panel {
    max-width: 460px;
}

.login-form {
    display: grid;
    gap: 0.85rem;
}

.field-label {
    color: #334155;
    font-weight: 700;
}

.text-input {
    border: 1px solid #cbd5e1;
    border-radius: 0.75rem;
    background: #ffffff;
    font-size: 0.9rem;
    line-height: 1.4;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    width: 100%;
}

.text-input:hover {
    border-color: #94a3b8;
}

.text-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
    outline: none;
}

.text-input:disabled {
    background: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
    opacity: 0.7;
}

.text-input::placeholder {
    color: #94a3b8;
    font-style: italic;
    font-weight: 400;
}

.secret-textarea {
    font-family: Consolas, "Courier New", monospace;
}

.text-input.invalid,
.text-input:invalid:not(:placeholder-shown) {
    border-color: #dc2626;
}

.field-validation {
    color: #dc2626;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.validation-message {
    background: #fee2e2;
    border: 1px solid #fecaca;
    border-radius: 0.75rem;
    color: #b91c1c;
    padding: 0.9rem 1rem;
}
.customer-registry-grid {
    align-items: start;
    display: grid;
    gap: 1.5rem;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
}

.detail-stack {
    display: grid;
    gap: 1.5rem;
}

.detail-stack > * {
    min-width: 0;
}

.panel-header {
    align-items: start;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.panel-copy {
    color: #64748b;
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 0;
    max-width: 72ch;
}

.panel-subheading {
    margin: 0.75rem 0 0.5rem;
}

.status-message {
    border: 1px solid transparent;
    border-radius: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
}

.status-success {
    background: #dcfce7;
    color: #166534;
    border-color: #86efac;
}

.status-error {
    background: #fee2e2;
    color: #7f1d1d;
    border-color: #fca5a5;
}

.selector-button {
    align-items: flex-start;
    background: transparent;
    border: 0;
    color: #2563eb;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 700;
    padding: 0;
    text-align: left;
}

.selector-button:hover {
    text-decoration: underline;
}

.selector-button-selected {
    color: #1d4ed8;
    text-decoration: underline;
}

.editor-form {
    display: grid;
    gap: 1rem;
}

.form-grid {
    display: grid;
    gap: 0.75rem;
}

.form-grid > div,
.filter-grid-5col > div,
.form-field {
    display: grid;
    gap: 0.45rem;
    min-width: 0;
}

.two-column-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.three-column-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.checkbox-row {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    line-height: 1.5;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.field-validation {
    color: #b91c1c;
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.35rem;
}

.empty-state {
    color: #475569;
    line-height: 1.6;
    margin-bottom: 0;
}

.environment-form {
    border-top: 1px solid #e2e8f0;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
}

.text-area-input {
    min-height: 5.5rem;
    resize: vertical;
}

.section-spacing {
    margin-bottom: 1rem;
}

.conversation-message {
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    padding: 0.65rem 0.9rem;
}

.conversation-message-internal {
    background: var(--color-warning-bg);
    border-color: var(--color-warning-bd);
    border-left: 4px solid var(--color-warning-fg);
}

.conversation-message-support {
    border-left: 4px solid var(--color-primary);
}

.conversation-message-customer {
    border-left: 4px solid var(--color-success-fg);
}

.conversation-message-body {
    white-space: pre-wrap;
}

.conversation-legend {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    font-size: 0.8rem;
    gap: 1rem;
    margin-bottom: 1rem;
}

.conversation-legend-item {
    align-items: center;
    display: flex;
    gap: 0.4rem;
}

.legend-swatch {
    border-radius: 0.2rem;
    display: inline-block;
    height: 0.75rem;
    width: 0.75rem;
}

.legend-swatch-public {
    background: var(--color-border);
    border: 1px solid var(--color-border-hover);
}

.legend-swatch-internal {
    background: var(--color-warning-fg);
}

.legend-swatch-support {
    background: var(--color-primary);
}

.legend-swatch-customer {
    background: var(--color-success-fg);
}

.legend-swatch-success {
    background: var(--color-success-fg);
}

.legend-swatch-info {
    background: var(--color-primary);
}

.legend-swatch-error {
    background: var(--color-error-fg);
}

.quick-actions-bar {
    align-items: center;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
}

.quick-actions-label {
    color: var(--color-text-muted);
    font-size: 0.8125rem;
    margin-right: 0.25rem;
}

.assignment-row {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.assignment-row .field-label {
    margin-bottom: 0;
    min-width: 6rem;
    white-space: nowrap;
}

.assignment-row .assignment-select {
    flex: 1;
    min-width: 12rem;
}

.metric-grid-4col {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-grid-auto {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
}

.metric-detail-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-detail-grid > div {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.85rem;
    display: grid;
    gap: 0.35rem;
    min-width: 0;
    padding: 0.9rem 1rem;
}

.filter-grid-5col {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(5, minmax(0, 1fr));
}


.inline-link-row {
    margin: 1rem 0 0;
}

.checkbox-list-panel {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.9rem;
    display: grid;
    gap: 0.75rem;
    margin-top: 0.5rem;
    max-height: 18rem;
    overflow-y: auto;
    padding: 1rem;
}


/* ─── Nav section labels ─── */

.nav-section-label {
    color: #64748b;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    margin-bottom: 0.15rem;
    margin-top: 0.85rem;
    padding: 0 0.25rem;
    text-transform: uppercase;
}

.nav-section-label:first-child {
    margin-top: 0;
}

/* ─── Alert / inline notification ─── */

.alert {
    border: 1px solid transparent;
    border-radius: 0.9rem;
    padding: 0.9rem 1rem;
    margin-bottom: 1rem;
    font-weight: 600;
    line-height: 1.5;
}

.alert-info {
    background: var(--color-running-bg);
    border-color: #93c5fd;
    color: var(--color-running-fg);
}

.alert-success {
    background: var(--color-success-bg);
    border-color: var(--color-success-bd);
    color: var(--color-success-fg);
}

.alert-warning {
    background: var(--color-warning-bg);
    border-color: var(--color-warning-bd);
    color: var(--color-warning-fg);
}

.alert-error {
    background: var(--color-error-bg);
    border-color: var(--color-error-bd);
    color: var(--color-error-fg);
}

/* ─── Loading skeleton ─── */

@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.45; }
}

.skeleton {
    animation: skeleton-pulse 1.4s ease-in-out infinite;
    background: #e2e8f0;
    border-radius: 0.5rem;
    display: block;
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
    width: 80%;
}

.skeleton-text-sm {
    height: 0.75rem;
    margin-bottom: 0.4rem;
    width: 55%;
}

.skeleton-card-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 1.5rem;
}

.skeleton-card {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    min-height: 6rem;
    padding: 1.25rem;
}

/* ─── Table pager ─── */

.table-pager {
    align-items: center;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-wrap: wrap;
    font-size: 0.875rem;
    gap: 0.75rem;
    justify-content: space-between;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
}

.table-pager-info {
    color: var(--color-text-muted);
}

.table-pager-controls {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.table-pager-size-label {
    align-items: center;
    display: flex;
    gap: 0.4rem;
    margin-right: 0.25rem;
}

.table-pager-select {
    padding: 0.25rem 0.4rem;
    width: auto;
}

.table-pager-page {
    color: var(--color-text-muted);
    min-width: 7rem;
    text-align: center;
    white-space: nowrap;
}

/* ─── Page header with optional back navigation ─── */

.page-header {
    align-items: flex-start;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.page-header-back {
    align-items: center;
    color: var(--color-primary);
    display: inline-flex;
    font-size: 0.9rem;
    font-weight: 700;
    gap: 0.35rem;
    margin-bottom: 0.4rem;
    text-decoration: none;
}

.page-header-back:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

/* ─── Login page: brand-accented card ─── */

.login-shell {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 80vh;
    padding: 2rem;
}

.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 1.25rem;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.1);
    max-width: 440px;
    overflow: hidden;
    width: 100%;
}

.login-card-brand {
    background: linear-gradient(135deg, var(--color-sidebar-start) 0%, var(--color-sidebar-end) 100%);
    padding: 1.75rem 2rem;
}

.login-card-brand-eyebrow {
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
}

.login-card-brand-title {
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.login-card-body {
    padding: 1.75rem 2rem;
}

/* ─── Metric card accent variants ─── */

.metric-card-blue  { border-top: 3px solid var(--color-primary); }
.metric-card-green { border-top: 3px solid #16a34a; }
.metric-card-amber { border-top: 3px solid #d97706; }
.metric-card-red   { border-top: 3px solid #dc2626; }

/* ─── Custom scrollbar (webkit) ─── */

::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ─── Metric detail grid field label ─── */

.metric-detail-grid > div small {
    color: var(--color-text-faint);
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

/* ─── Help page: accordion ─── */

.help-accordion {
    border: 1px solid var(--color-border);
    border-radius: 1rem;
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.help-accordion[open] {
    box-shadow: var(--shadow-card);
}

.help-accordion-header {
    align-items: center;
    cursor: pointer;
    display: flex;
    font-size: 1rem;
    font-weight: 700;
    gap: 0.75rem;
    list-style: none;
    padding: 1rem 1.25rem;
    user-select: none;
}

.help-accordion-header::-webkit-details-marker {
    display: none;
}

.help-accordion-header::after {
    content: '+';
    color: var(--color-text-faint);
    font-size: 1.2rem;
    font-weight: 400;
    margin-left: auto;
    transition: transform 0.2s ease;
}

.help-accordion[open] > .help-accordion-header::after {
    content: '−';
}

.help-accordion-header:hover {
    background: #f8fafc;
}

.help-accordion-body {
    border-top: 1px solid var(--color-border);
    padding: 1.25rem 1.5rem 1.5rem;
}

.help-accordion-body h4 {
    color: var(--color-text);
    font-size: 0.95rem;
    font-weight: 700;
    margin: 1.25rem 0 0.5rem;
}

.help-accordion-body h4:first-child {
    margin-top: 0.25rem;
}

.help-accordion-body p {
    color: var(--color-text-muted);
    line-height: 1.65;
    margin-bottom: 0.75rem;
}

/* ─── Publish release: numbered steps ─── */

.publish-steps {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 0.5rem 0;
}

.publish-step {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.publish-step-number {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    margin-top: 1.5rem;
}

.publish-step-content {
    flex: 1;
    min-width: 0;
}

.publish-step-content .text-input {
    width: 100%;
}

.publish-step-content .text-area-input {
    min-height: 6rem;
    resize: vertical;
}

.field-hint {
    color: var(--color-text-faint);
    font-size: 0.82rem;
    margin: 0.25rem 0 0;
    line-height: 1.45;
}

.field-hint.upload-selected {
    color: var(--color-success-fg);
}

.publish-button {
    font-size: 1rem;
    padding: 0.75rem 2rem;
}

.publish-checklist {
    line-height: 1.8;
}

.manifest-helper {
    background: var(--color-primary-light);
    border: 1px solid var(--color-border);
    border-radius: 1rem;
    padding: 1rem 1.1rem;
}

.manifest-helper h3 {
    color: var(--color-text);
    font-size: 1rem;
    margin: 0 0 0.5rem;
}

.manifest-helper .panel-copy {
    margin-bottom: 0.75rem;
}

.manifest-helper code {
    background: rgba(15, 23, 42, 0.06);
    border-radius: 0.4rem;
    color: var(--color-text);
    padding: 0.1rem 0.35rem;
}

.manifest-helper-actions {
    margin-bottom: 0.75rem;
}

/* ─── Help page: step list ─── */

.help-steps {
    color: var(--color-text-muted);
    display: grid;
    gap: 0.55rem;
    line-height: 1.6;
    margin: 0 0 0.75rem;
    padding-left: 1.5rem;
}

.help-steps li {
    padding-left: 0.25rem;
}

.help-steps li strong {
    color: var(--color-text);
}

/* ─── Help page: bullet list ─── */

.help-list {
    color: var(--color-text-muted);
    display: grid;
    gap: 0.5rem;
    line-height: 1.6;
    margin: 0 0 0.75rem;
    padding-left: 1.25rem;
}

.help-list li {
    padding-left: 0.2rem;
}

.help-list li strong {
    color: var(--color-text);
}

/* ─── Help page: section heading ─── */

.help-section-heading {
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    text-transform: uppercase;
}

/* ─── Help page: architecture component cards ─── */

.help-component-card {
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: 0.85rem;
    display: grid;
    gap: 0.5rem;
    padding: 1rem 1.1rem;
}

.help-component-card strong {
    color: var(--color-text);
    display: block;
    font-size: 0.95rem;
}

.help-component-card p {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    line-height: 1.55;
    margin: 0;
}

@media (max-width: 900px) {
    .help-accordion-header {
        padding: 0.85rem 1rem;
    }

    .help-accordion-body {
        padding: 1rem 1.1rem 1.25rem;
    }
}

@media (max-width: 1200px) {
    .customer-registry-grid {
        grid-template-columns: 1fr;
    }

    .filter-grid-5col {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .metric-detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .drawer-toggle {
        display: inline-flex !important;
    }

    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        padding: 1rem 0.75rem;
    }

    .brand-panel {
        margin-bottom: 0.5rem;
    }

    .tagline {
        display: none;
    }

    .shell-drawer .nav-menu {
        gap: 0.15rem;
        grid-auto-columns: initial;
        grid-auto-flow: row;
        overflow-x: visible;
        padding-bottom: 0;
    }

    .nav-menu a,
    .nav-menu .mud-nav-link {
        align-items: center;
        display: flex;
        min-height: 2.75rem;
    }

    .topbar {
        padding: 1.25rem 1rem;
    }

    .page-body {
        padding: 1.25rem 1rem;
    }

    .metric-grid-4col,
    .card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    /* ── Topbar: compact two-row layout ── */
    .topbar {
        align-items: stretch;
        flex-direction: column;
        gap: 0.4rem;
        padding: 0.75rem 1rem;
    }

    .topbar-inner {
        flex-direction: column;
        gap: 0.4rem;
        width: 100%;
    }

    /* Row 1: hamburger toggle + brand label, side-by-side */
    .topbar-heading-group {
        align-items: center;
        flex-direction: row;
        min-width: 0;
        width: 100%;
    }

    /* Row 2: user name + sign-out, compact horizontal row */
    .topbar-actions {
        align-items: center;
        flex-direction: row;
        gap: 0.5rem;
        justify-content: space-between;
        width: 100%;
    }

    /* Sign-out form must not stretch to fill the row */
    .topbar-actions form {
        flex-shrink: 0;
    }

    .user-summary {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-align: left;
    }

    /* Hide role label on mobile to keep topbar compact */
    .user-summary-role {
        display: none;
    }

    /* ── Panel header ── */
    .panel-header {
        align-items: stretch;
        flex-direction: column;
    }

    /* Panel-header action buttons stay auto-width (not full-width) */
    .panel-header .button-row a,
    .panel-header .button-row button {
        width: auto;
    }

    /* ── Grids: 2-column for metric tiles, 2-column for filter bars ── */
    .metric-grid-4col,
    .metric-detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-grid-5col {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .two-column-grid,
    .three-column-grid {
        grid-template-columns: 1fr;
    }

    /* ── Buttons in form/list contexts ── */
    .button-row {
        flex-direction: column;
    }

    /* Only expand buttons to full width when inside a .button-row */
    .button-row .primary-button,
    .button-row .secondary-button {
        width: 100%;
    }

    /* ── Touch targets: ≥44px (2.75rem) on all interactive elements ── */
    .primary-button,
    .secondary-button,
    .danger-button {
        min-height: 2.75rem;
    }

    .icon-button {
        height: 2.75rem;
        width: 2.75rem;
    }

    .secret-toggle-button {
        height: 2.75rem;
    }

    /* ── iOS: prevent viewport zoom on input focus (requires font-size ≥ 16px) ── */
    .text-input,
    .hd-input,
    .hd-select,
    .catalog-add-input {
        font-size: 1rem;
    }

    /* Remove 300ms tap delay on interactive elements */
    button,
    a,
    input,
    select,
    textarea {
        touch-action: manipulation;
    }

    /* ── Tables: tighter min-width for small phones ── */
    .data-table {
        min-width: 22rem;
    }
}

/* Table row selection highlight */
.data-table tbody tr.table-row-selected {
    background-color: #eff6ff;
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
}

/* Compact action button inside table cells */
.button-compact {
    padding: 0.2rem 0.6rem;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Stacked checkbox list for multi-environment selection */
.checkbox-stack {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Scrollable multi-environment checkbox list in dialog */
.environment-checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 14rem;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    padding: 0.5rem;
    background: #f9fafb;
}

/* Full-span column in two-column and three-column grids */
.two-column-grid .form-grid-full-span,
.three-column-grid .form-grid-full-span {
    grid-column: 1 / -1;
}

/* File input styling */
.file-input {
    display: block;
    font-size: 0.875rem;
    color: #374151;
}

/* Panel subheading inside forms */
.panel-subheading {
    margin-top: 0.25rem;
}

.panel-subheading h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #374151;
    margin: 0 0 0.25rem 0;
}

.field-label-row,
.panel-heading-row,
.checkbox-label-row {
    align-items: center;
    display: flex;
    gap: 0.4rem;
}

.panel-heading-row h3 {
    margin: 0;
}

.checkbox-row {
    align-items: flex-start;
}

.checkbox-row input[type="checkbox"] {
    margin-top: 0.2rem;
}

.checkbox-label-row {
    flex: 1 1 auto;
    flex-wrap: wrap;
    line-height: 1.5;
}

.checkbox-label {
    margin: 0;
}

.secret-label-row {
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.secret-toggle-button {
    align-items: center;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 0.75rem;
    color: #475569;
    cursor: pointer;
    display: inline-flex;
    height: 2.25rem;
    justify-content: center;
    padding: 0 0.7rem;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.secret-toggle-button:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a;
}

.secret-toggle-button[aria-pressed="true"] {
    color: #2563eb;
}

.secret-toggle-button svg {
    height: 1rem;
    width: 1rem;
}

.info-icon-button {
    align-items: center;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    color: #1d4ed8;
    cursor: help;
    display: inline-flex;
    font-size: 0.72rem;
    font-weight: 700;
    height: 1.2rem;
    justify-content: center;
    line-height: 1;
    padding: 0;
    width: 1.2rem;
}

.info-icon-button:hover {
    background: #dbeafe;
    border-color: #93c5fd;
}

.info-icon-button:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   HELPDESK CONFIG — CATALOG EDITOR
   ═══════════════════════════════════════════════════════════════ */
.catalog-editor {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.catalog-item-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    overflow: hidden;
}

.catalog-empty-state {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    color: var(--color-text-faint);
    font-size: 0.9rem;
    font-style: italic;
}

.catalog-empty-icon {
    font-size: 1.1rem;
    opacity: 0.5;
}

.catalog-item-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    transition: background 0.12s;
}

.catalog-item-row:last-child {
    border-bottom: none;
}

.catalog-item-row:hover {
    background: #f8fafc;
}

.catalog-item-index {
    flex: 0 0 1.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text-faint);
    text-align: right;
    user-select: none;
}

.catalog-item-name {
    flex: 1;
    font-size: 0.925rem;
    color: var(--color-text);
    word-break: break-word;
}

.catalog-item-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border: 1px solid var(--color-border);
    border-radius: 0.4rem;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    padding: 0;
    line-height: 1;
}

.icon-button:hover:not(:disabled) {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    color: var(--color-primary-dark);
}

.icon-button:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

.icon-button-danger:hover:not(:disabled) {
    background: var(--color-error-bg);
    border-color: var(--color-error-bd);
    color: var(--color-error-fg);
}

.catalog-add-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.catalog-add-input {
    flex: 1;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    font-size: 0.9rem;
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.catalog-add-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.catalog-add-input--error {
    border-color: var(--color-error-fg);
}

.catalog-add-btn {
    white-space: nowrap;
    flex-shrink: 0;
}

.catalog-add-error {
    display: block;
    margin-top: 0.2rem;
}

/* ═══════════════════════════════════════════════════════════════
   HELPDESK CONFIG — PAGE SHELL & SHARED
   ═══════════════════════════════════════════════════════════════ */
.hd-catalog-page {
    max-width: 680px;
}

.hd-catalog-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.hd-catalog-icon {
    font-size: 2rem;
    line-height: 1;
    flex-shrink: 0;
}

.hd-catalog-title {
    margin: 0 0 0.2rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-text);
}

.hd-catalog-desc {
    margin: 0;
}

.hd-catalog-error {
    margin-bottom: 1rem;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-input);
    background: var(--color-error-bg);
    border: 1px solid var(--color-error-bd);
}

.hd-catalog-loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem;
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

.hd-catalog-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
}

.hd-btn-spinner {
    margin-right: 0.4rem;
}

.hd-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 1rem;
    color: var(--color-text);
}

.hd-section-divider {
    height: 1px;
    background: var(--color-border);
    margin: 1.25rem 0;
}

.hd-select {
    display: block;
    width: 100%;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    font-size: 0.9rem;
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
}

.hd-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.hd-input {
    display: block;
    width: 100%;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    font-size: 0.9rem;
    background: var(--color-surface);
    color: var(--color-text);
}

.hd-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.hd-input--wide {
    max-width: 600px;
}

/* ═══════════════════════════════════════════════════════════════
   HELPDESK CONFIG — EMAIL TEMPLATES PAGE
   ═══════════════════════════════════════════════════════════════ */
.email-token-shelf {
    margin-bottom: 1.5rem;
}

.email-token-shelf-header {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    margin-bottom: 0;
}

.email-token-shelf-icon {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
}

.email-token-shelf-title {
    display: block;
    font-size: 0.95rem;
    color: var(--color-text);
    margin-bottom: 0.15rem;
}

.email-token-shelf-hint {
    display: block;
}

.email-token-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
}

.email-token-list li {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
    max-width: 22rem;
}

.email-token-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 0.4rem;
    background: var(--color-primary-light);
    border: 1px solid #bfdbfe;
    color: var(--color-primary-dark);
    font-family: 'Consolas', 'Fira Mono', monospace;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    white-space: nowrap;
    user-select: all;
}

.email-token-badge:hover {
    background: #bfdbfe;
    border-color: var(--color-primary);
}

.email-token-desc {
    font-size: 0.78rem;
    color: var(--color-text-faint);
    line-height: 1.35;
}

.email-token-example {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    line-height: 1.35;
    word-break: break-word;
}

.email-template-card {
    margin-bottom: 1.25rem;
}

.email-template-card-header {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--color-border);
}

.email-event-icon {
    font-size: 1.6rem;
    line-height: 1;
    flex-shrink: 0;
}

.email-event-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.email-event-title {
    font-size: 1rem;
    color: var(--color-text);
}

.email-event-description {
    display: block;
    font-size: 0.865rem;
}

.email-template-card-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ── Email template card tabs ─────────────────────────────────── */
.email-card-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 1rem;
}

.email-card-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.45rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.email-card-tab:hover {
    color: var(--color-primary);
}

.email-card-tab--active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* ── Email preview ────────────────────────────────────────────── */
.email-preview-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0 0 0.5rem;
}

.email-preview-frame {
    width: 100%;
    height: 520px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input, 6px);
    background: #fff;
}

.email-preview-text {
    background: var(--color-surface-secondary, #f4f5f6);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input, 6px);
    padding: 1rem;
    font-size: 0.83rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
}

.email-preview-empty {
    margin: 0.5rem 0 0;
}

.email-preview-notice {
    margin: 0;
    font-size: 0.78rem;
}

/* ── Test email row ───────────────────────────────────────────── */
.email-test-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 0.25rem;
    border-top: 1px solid var(--color-border);
}

.email-test-trigger {
    align-self: flex-start;
}

.email-test-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.email-test-input {
    flex: 1 1 220px;
    min-width: 180px;
}

.email-test-result {
    font-size: 0.82rem;
    padding: 0.35rem 0.6rem;
    border-radius: 4px;
    font-weight: 500;
}

.email-test-result--success {
    color: #15692a;
    background: #d1fae5;
}

.email-test-result--error {
    color: #991b1b;
    background: #fee2e2;
}

.email-template-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.email-template-textarea {
    width: 100%;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
    resize: vertical;
    line-height: 1.5;
    box-sizing: border-box;
}

.email-template-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

/* ── Page header ──────────────────────────────────────────────── */
.email-page-header {
    margin-bottom: 1.5rem;
}

.email-page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 0.35rem;
    line-height: 1.25;
}

.email-page-subtitle {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin: 0;
    max-width: 680px;
    line-height: 1.55;
}

/* ── Token shelf collapse ─────────────────────────────────────── */
.email-token-shelf-header {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    margin-bottom: 0;
}

.email-token-shelf-info {
    flex: 1;
}

.email-token-shelf-toggle {
    flex-shrink: 0;
    align-self: flex-start;
    font-size: 0.75rem;
    margin-left: auto;
}

.email-token-shelf .email-token-list {
    margin-top: 1rem;
}

/* ── Themes section header ────────────────────────────────────── */
.hd-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

/* ── Inset panel ──────────────────────────────────────────────── */
.panel--inset {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    padding: 1.25rem;
}

/* ── Inline actions row ───────────────────────────────────────── */
.hd-catalog-actions--inline {
    margin-top: 1rem;
    display: flex;
    gap: 0.75rem;
}

/* ── Code/monospace textarea ──────────────────────────────────── */
.email-template-textarea--code {
    font-family: 'Consolas', 'Fira Code', 'Monaco', 'Courier New', monospace;
    font-size: 0.83rem;
    line-height: 1.6;
    tab-size: 2;
}

/* ═══════════════════════════════════════════════════════════════
   DRAWER — BRAND PANEL HEADER & MOBILE CLOSE BUTTON
   ═══════════════════════════════════════════════════════════════ */

.brand-panel-header {
    align-items: flex-start;
    display: flex;
    justify-content: space-between;
}

/* Hidden by default; shown only when drawer is in overlay (mobile) mode */
.drawer-close-btn {
    align-items: center;
    background: transparent;
    border: 1px solid rgba(248, 250, 252, 0.2);
    border-radius: 0.5rem;
    color: #cbd5e1;
    cursor: pointer;
    display: none;
    flex-shrink: 0;
    font-size: 1.1rem;
    height: 2.75rem;
    justify-content: center;
    line-height: 1;
    margin-top: 0.1rem;
    padding: 0;
    touch-action: manipulation;
    width: 2.75rem;
}

.drawer-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(248, 250, 252, 0.4);
    color: #ffffff;
}

@media (max-width: 900px) {
    .drawer-close-btn {
        display: flex;
    }
}

/* ═══════════════════════════════════════════════════════════════
   MUDBLAZOR DIALOG — MOBILE RESPONSIVE OVERRIDES
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
    .mud-dialog {
        max-height: calc(100vh - 3rem);
        max-width: calc(100vw - 1.5rem) !important;
        overflow-y: auto;
        width: calc(100vw - 1.5rem) !important;
    }
}

/* Bottom-sheet style on very small phones */
@media (max-width: 480px) {
    .mud-dialog-container {
        align-items: flex-end;
        padding-bottom: 0;
    }

    .mud-dialog {
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        margin-bottom: 0;
        max-height: 90vh;
        max-width: 100% !important;
        width: 100% !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   VERY SMALL SCREENS (≤480px) — TIGHTER SPACING
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    .page-body {
        padding: 1rem 0.75rem;
    }

    .panel {
        padding: 0.85rem 0.9rem;
    }

    .login-card-body,
    .login-card-brand {
        padding: 1.25rem;
    }
}

/* ── Tall textarea ────────────────────────────────────────────── */
.email-template-textarea--tall {
    min-height: 280px;
}

/* ── Card title row with meta badges ─────────────────────────── */
.email-card-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.15rem;
}

/* ── Format / theme badges ────────────────────────────────────── */
.email-format-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.email-format-badge--html {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    border: 1px solid #bfdbfe;
}

.email-format-badge--text {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid var(--color-border);
}

.email-format-badge--theme {
    background: var(--color-warning-bg);
    color: var(--color-warning-fg);
    border: 1px solid var(--color-warning-bd);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Format + Theme 2-col grid ────────────────────────────────── */
.email-template-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 640px) {
    .email-template-row-2col {
        grid-template-columns: 1fr;
    }
}

/* ── Test email panel ─────────────────────────────────────────── */
.email-test-panel {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input, 0.75rem);
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.email-test-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.email-test-panel-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

/* ── Sticky save bar ──────────────────────────────────────────── */
.email-save-bar {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 1rem 0;
    margin-top: 1.5rem;
    display: flex;
    justify-content: flex-end;
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.07);
}

/* ═══════════════════════════════════════════════════════════════
   HELPDESK SETUP — SHARED PAGE CHROME
   ═══════════════════════════════════════════════════════════════ */

/* Page header: breadcrumb + title + subtitle */
.hd-page-header {
    margin-bottom: 1.25rem;
}

.hd-page-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--color-text-faint);
    margin-bottom: 0.4rem;
}

.hd-page-breadcrumb a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
}

.hd-page-breadcrumb a:hover {
    text-decoration: underline;
}

.hd-page-breadcrumb-sep {
    color: var(--color-border-hover);
}

.hd-page-title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.hd-page-title-icon {
    font-size: 1.75rem;
    line-height: 1;
    flex-shrink: 0;
}

.hd-page-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--color-text);
    margin: 0;
    line-height: 1.2;
}

.hd-page-subtitle {
    margin: 0.35rem 0 0;
    color: var(--color-text-muted);
    font-size: 0.88rem;
    line-height: 1.55;
    max-width: 72ch;
}

/* Unsaved changes indicator */
.hd-unsaved-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: var(--color-warning-bg);
    border: 1px solid var(--color-warning-bd);
    color: var(--color-warning-fg);
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    animation: hd-pulse-badge 2s ease-in-out infinite;
}

@keyframes hd-pulse-badge {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.7; }
}

/* Item count chip in catalog pages */
.hd-item-count {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: var(--color-primary-light);
    border: 1px solid #bfdbfe;
    color: var(--color-primary-dark);
    font-size: 0.78rem;
    font-weight: 700;
}

/* ── Horizontal setup navigation strip ─────────────────────── */
.hd-setup-nav {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    padding: 0.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-card);
}

.hd-setup-nav-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    border-radius: 0.6rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    border: 1px solid transparent;
    cursor: pointer;
    background: none;
}

.hd-setup-nav-item:hover {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    border-color: #bfdbfe;
}

.hd-setup-nav-item--active {
    background: var(--color-primary);
    color: #ffffff !important;
    border-color: var(--color-primary-dark);
}

.hd-setup-nav-item--active:hover {
    background: var(--color-primary-dark);
    color: #ffffff;
    border-color: var(--color-primary-dark);
}

.hd-setup-nav-icon {
    font-size: 1rem;
    line-height: 1;
}

/* ── Settings page toggle rows ──────────────────────────────── */
.hd-toggle-group {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    overflow: hidden;
}

.hd-toggle-row {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.9rem 1rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    transition: background 0.12s;
}

.hd-toggle-row:last-child {
    border-bottom: none;
}

.hd-toggle-row:hover {
    background: #f8fafc;
}

.hd-toggle-checkbox {
    flex-shrink: 0;
    width: 1.1rem;
    height: 1.1rem;
    margin-top: 0.15rem;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.hd-toggle-body {
    flex: 1;
    min-width: 0;
}

.hd-toggle-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-text);
    cursor: pointer;
    line-height: 1.4;
    margin-bottom: 0.2rem;
}

.hd-toggle-hint {
    display: block;
    font-size: 0.82rem;
    color: var(--color-text-faint);
    line-height: 1.5;
}

/* ── Notification user list ─────────────────────────────────── */
.hd-notify-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    overflow: hidden;
}

.hd-notify-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.9rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    transition: background 0.12s;
    cursor: pointer;
}

.hd-notify-row:hover {
    background: var(--color-primary-light);
}

.hd-notify-row--selected {
    background: #eff6ff;
}

.hd-notify-row--selected:hover {
    background: var(--color-primary-light);
}

.hd-notify-row:last-child {
    border-bottom: none;
}

.hd-notify-checkbox {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.hd-notify-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hd-notify-username {
    font-size: 0.78rem;
    color: var(--color-text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════════════════════════
   NEW TICKET — FORM LAYOUT
   ═══════════════════════════════════════════════════════════════ */

/* Taller textarea for the description field */
.text-area-description {
    min-height: 9rem;
}

/* Action bar anchored to the bottom of the form panel */
.form-actions-bar {
    align-items: center;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-top: 1.25rem;
}

@media (max-width: 640px) {
    .form-actions-bar {
        flex-direction: column;
    }

    .form-actions-bar .primary-button,
    .form-actions-bar .secondary-button {
        text-align: center;
        width: 100%;
    }
}

/* ── Info callout (neutral, informational) ──────────────────── */
.hd-info-callout {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius-input);
    background: var(--color-running-bg);
    border: 1px solid #93c5fd;
    color: var(--color-running-fg);
    font-size: 0.83rem;
    line-height: 1.5;
}

.hd-info-callout-icon {
    flex-shrink: 0;
    font-size: 1rem;
    line-height: 1.4;
}

/* ── Section header with inline action ─────────────────────── */
.hd-section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.hd-section-header-row .hd-section-title {
    margin-bottom: 0;
}

/* Responsive: collapse nav strip to 2 cols on narrow screens */
@media (max-width: 640px) {
    .hd-setup-nav {
        gap: 0.25rem;
    }

    .hd-setup-nav-item {
        flex: 1 0 auto;
        justify-content: center;
    }

    .hd-catalog-page {
        max-width: 100%;
    }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE POLISH — Cross-device UX refinements
   Ensures a professional, robust experience on mobile, tablet,
   and desktop across every page, dialog, and interactive element.
   ═══════════════════════════════════════════════════════════════ */

/* ── Base: text overflow protection ──
   Prevent long URLs, GUIDs, file paths, and user-generated text
   from causing horizontal overflow on any screen size.           */

.conversation-message-body,
.catalog-item-name,
.hd-notify-name,
.alert,
.status-message,
.field-hint,
.panel-copy,
.page-copy,
.email-event-description,
.metric-label,
.metric-card-detailed strong,
.hd-toggle-hint {
    overflow-wrap: break-word;
    word-break: break-word;
}

.data-table td {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Scrollable checkbox & environment lists (momentum on iOS) */
.checkbox-list-panel,
.environment-checkbox-list {
    -webkit-overflow-scrolling: touch;
}

/* ── Tablet (≤900px) ──────────────────────────────────────── */

@media (max-width: 900px) {
    /* Reduce table min-width so they fit on tablet-portrait without scroll */
    .data-table {
        min-width: 30rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.45rem 0.5rem;
    }

    /* Touch-friendly accordion headers */
    .help-accordion-header {
        align-items: center;
        min-height: 2.75rem;
    }

    /* Tighter table pager */
    .table-pager {
        gap: 0.5rem;
    }

    /* Email preview: less tall on tablet */
    .email-preview-frame {
        height: 380px;
    }
}

/* ── Phone (≤640px) ───────────────────────────────────────── */

@media (max-width: 640px) {
    /* ─ Touch targets: remaining interactive elements → 44px ─ */

    .selector-button {
        min-height: 2.75rem;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .email-card-tab {
        min-height: 2.75rem;
    }

    .catalog-item-row {
        min-height: 2.75rem;
    }

    .hd-toggle-row {
        min-height: 2.75rem;
    }

    .hd-notify-row {
        min-height: 2.75rem;
    }

    .help-accordion-header {
        min-height: 2.75rem;
    }

    .quick-actions-bar .secondary-button,
    .quick-actions-bar .secondary-link {
        min-height: 2.75rem;
    }

    .page-header-back {
        min-height: 2.75rem;
        display: inline-flex;
        align-items: center;
    }

    /* ─ Email preview: shorter on phones ─ */
    .email-preview-frame {
        height: 280px;
    }

    /* ─ Login shell: tighter padding ─ */
    .login-shell {
        padding: 1.25rem;
    }

    /* ─ Table pager: compact layout ─ */
    .table-pager {
        font-size: 0.8rem;
    }

    .table-pager-page {
        min-width: auto;
    }

    .table-pager-select {
        font-size: 1rem;
    }

    /* ─ Assignment row: stack vertically ─ */
    .assignment-row {
        flex-direction: column;
        align-items: stretch;
    }

    .assignment-row .field-label {
        min-width: auto;
    }

    .assignment-row .assignment-select {
        min-width: auto;
        width: 100%;
    }

    /* ─ Publish wizard: tighter ─ */
    .publish-step {
        gap: 0.65rem;
    }

    .publish-step-number {
        margin-top: 1rem;
    }

    /* ─ iOS zoom prevention: remaining inputs ─ */
    textarea,
    select,
    .email-template-textarea {
        font-size: 1rem;
    }

    /* ─ Data table cells: tighter for phones ─ */
    .data-table th,
    .data-table td {
        padding: 0.35rem 0.4rem;
        font-size: 0.8rem;
    }

    .data-table th {
        font-size: 0.72rem;
    }

    /* ─ MudDialog content: momentum scrolling ─ */
    .mud-dialog-content {
        -webkit-overflow-scrolling: touch;
    }

    /* ─ Page headings: slightly smaller on mobile ─ */
    .hd-page-title {
        font-size: 1.15rem;
    }

    .email-page-title {
        font-size: 1.2rem;
    }

    /* ─ Section header rows: stack for space ─ */
    .hd-section-header-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    /* ─ Email template card header: stack icon + text ─ */
    .email-template-card-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    /* ─ Email test form: full-width input on mobile ─ */
    .email-test-form {
        flex-direction: column;
    }

    .email-test-input {
        flex: 1 1 auto;
        min-width: auto;
        width: 100%;
    }

    /* ─ Helpdesk catalog actions: wrap buttons ─ */
    .hd-catalog-actions,
    .hd-catalog-actions--inline {
        flex-wrap: wrap;
    }

    /* ─ Conversation legend: compact ─ */
    .conversation-legend {
        font-size: 0.75rem;
        gap: 0.5rem;
    }

    /* ─ Secret toggle row: allow wrapping ─ */
    .secret-label-row {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* ─ Page header: tighter gap ─ */
    .page-header {
        gap: 0.5rem;
    }

    /* ─ Metric cards: slightly smaller values ─ */
    .metric-card strong {
        font-size: 1.2rem;
    }

    .metric-card-detailed strong {
        font-size: 1rem;
    }

    /* ─ Quick actions: compact ─ */
    .quick-actions-bar {
        gap: 0.35rem;
    }

    .quick-actions-label {
        width: 100%;
        margin-bottom: 0.15rem;
    }

    /* ─ Helpdesk catalog header: stack icon + text ─ */
    .hd-catalog-header {
        flex-direction: column;
        gap: 0.65rem;
    }

    /* ─ Email token list: tighter on mobile ─ */
    .email-token-list {
        gap: 0.35rem 0.5rem;
    }

    .email-token-shelf-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    /* ─ Inline link rows: allow wrapping ─ */
    .inline-link-row {
        word-break: break-word;
    }
}

/* ── Very small phones (≤480px) ───────────────────────────── */

@media (max-width: 480px) {
    .login-shell {
        padding: 0.75rem;
    }

    /* Single-column cards to prevent cramping */
    .card-grid {
        grid-template-columns: 1fr;
    }

    /* Smaller headings for space */
    h1 { font-size: 1.2rem; }
    h2 { font-size: 1rem; }

    /* Tighter conversation messages */
    .conversation-message {
        padding: 0.5rem 0.65rem;
    }

    /* Tighter metric cards */
    .metric-card {
        padding: 0.65rem 0.75rem;
    }

    /* Help accordion compact */
    .help-accordion-header {
        font-size: 0.9rem;
    }

    .help-accordion-body {
        padding: 0.75rem 0.85rem 1rem;
    }

    /* Email save bar: tighter */
    .email-save-bar {
        padding: 0.65rem 0;
    }

    /* Publish step: even tighter */
    .publish-step-number {
        height: 1.75rem;
        margin-top: 0.75rem;
        width: 1.75rem;
    }

    /* Page description text: slightly smaller */
    .page-copy {
        font-size: 0.82rem;
    }
}

/* ── iPhone safe area insets (notch / home indicator) ─────── */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .page-body {
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
    }

    .email-save-bar {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }

    @media (max-width: 480px) {
        .page-body {
            padding-bottom: calc(1rem + env(safe-area-inset-bottom));
        }

        .mud-dialog {
            padding-bottom: env(safe-area-inset-bottom);
        }
    }
}

/* ── Touch device refinements ─────────────────────────────── */

/* Active tap feedback — gives immediate tactile response on touch */
@media (hover: none) and (pointer: coarse) {
    .primary-button:active,
    .secondary-button:active,
    .danger-button:active {
        transform: scale(0.97);
        opacity: 0.85;
    }

    .nav-menu a:active,
    .nav-menu .mud-nav-link:active {
        background: rgba(148, 163, 184, 0.28);
    }

    .metric-card:active {
        transform: scale(0.98);
    }

    .help-accordion-header:active {
        background: #f1f5f9;
    }

    .catalog-item-row:active {
        background: #f1f5f9;
    }

    .hd-notify-row:active {
        background: #dbeafe;
    }

    .hd-setup-nav-item:active {
        opacity: 0.8;
    }

    .icon-button:active:not(:disabled) {
        transform: scale(0.9);
    }

    .drawer-close-btn:active {
        background: rgba(255, 255, 255, 0.18);
    }
}

/* Prevent "sticky hover" effects on pure touch devices */
@media (hover: none) and (pointer: coarse) {
    .metric-card:hover {
        box-shadow: var(--shadow-card);
        transform: none;
    }

    .data-table tbody tr:hover {
        background: inherit;
    }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE PHASE 3 — Final audit hardening
   Addresses remaining gaps found during cross-device QA pass:
   touch table hover, enrollment key row, monospace inputs,
   metric grid sizing, panel tightening, 480px edge cases.
   ═══════════════════════════════════════════════════════════════ */

/* ── Enrollment key row (CustomerEditorDialog) ── */

.enrollment-key-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.enrollment-key-input {
    flex: 1;
    font-family: monospace;
    font-size: 0.85rem;
    min-width: 0;
}

/* Monospace read-only hash inputs */
.mono-input {
    font-family: monospace;
    font-size: 0.85rem;
}

/* ── Tablet (≤900px) — Phase 3 additions ── */

@media (max-width: 900px) {
    /* Inputs at 1rem to prevent iOS zoom on tablets too */
    .text-input,
    .hd-input,
    .hd-select,
    .catalog-add-input {
        font-size: 1rem;
    }

    .mono-input,
    .enrollment-key-input {
        font-size: 1rem;
    }
}

/* ── Phone (≤640px) — Phase 3 additions ── */

@media (max-width: 640px) {
    /* Enrollment key row stacks vertically */
    .enrollment-key-row {
        flex-direction: column;
    }

    /* Monospace inputs: iOS zoom prevention */
    .mono-input,
    .enrollment-key-input {
        font-size: 1rem;
    }

    /* Metric grid auto: tighter minmax for better 2-col fit */
    .metric-grid-auto {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

    /* Panel: consistent tighter padding */
    .panel {
        padding: 1rem;
    }

    /* hd-table action column: allow shrink */
    .hd-table th:last-child,
    .hd-table td:last-child {
        width: auto;
        min-width: 0;
        white-space: nowrap;
    }
}

/* ── Very small phones (≤480px) — Phase 3 additions ── */

@media (max-width: 480px) {
    /* Data table: even smaller min-width for narrow phones */
    .data-table {
        min-width: 18rem;
    }

    /* Metric grid auto: force 2-column to prevent single-column waste */
    .metric-grid-auto {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Button rows: distribute buttons evenly */
    .button-row {
        flex-wrap: wrap;
    }

    .button-row > button,
    .button-row > a {
        flex: 1 1 auto;
        min-width: 0;
        text-align: center;
    }

    /* Quick actions: fill available space */
    .quick-actions-bar .secondary-button,
    .quick-actions-bar .secondary-link {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 0.78rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        text-align: center;
    }

    /* Environment checkbox list: shorter on tiny screens */
    .environment-checkbox-list {
        max-height: 10rem;
    }

    .checkbox-row {
        font-size: 0.88rem;
    }

    /* Assignment row: also remove min-widths at 480 */
    .assignment-row .assignment-select {
        min-width: 0;
    }

    /* Panel header: stack heading + actions vertically */
    .panel-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }

    /* State pills: slightly smaller */
    .state-pill {
        font-size: 0.72rem;
        padding: 0.15rem 0.5rem;
    }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE PHASE 4 — Helpdesk settings polish, error table
   text overflow, and cross-page mobile hardening.
   ═══════════════════════════════════════════════════════════════ */

/* ── Utility: truncated table cell (single-line ellipsis) ── */

.cell-truncate {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Utility: line-clamped cell (2 lines max, then fade) ── */

.cell-clamp {
    max-width: 320px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Utility: monospace truncated cell (GUIDs, correlation IDs) ── */

.cell-mono {
    font-family: monospace;
    font-size: 0.82rem;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── hd-table base styles (Email themes table) ── */

.hd-table {
    width: 100%;
    border-collapse: collapse;
}

.hd-table th,
.hd-table td {
    border-bottom: 1px solid var(--color-border);
    padding: 0.5rem 0.65rem;
    text-align: left;
    vertical-align: middle;
}

.hd-table th {
    background: #f8fafc;
    color: #334155;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
}

.hd-table tbody tr:hover {
    background: #f8fafc;
}

.hd-table-actions {
    display: flex;
    gap: 0.35rem;
    white-space: nowrap;
}

.hd-table-actions-col {
    width: 130px;
}

/* Helpdesk config accordion header (inline style replacement) */
.hd-config-accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Email body header row (Configuration page inline style replacement) */
.email-body-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.email-body-header-label {
    margin-bottom: 0;
}

/* ── Tablet (≤900px) — Phase 4 ── */

@media (max-width: 900px) {
    .cell-truncate {
        max-width: 180px;
    }

    .cell-clamp {
        max-width: 220px;
    }

    .cell-mono {
        max-width: 150px;
    }
}

/* ── Phone (≤640px) — Phase 4 ── */

@media (max-width: 640px) {
    /* ─ Catalog add row: stack input + button vertically ─ */
    .catalog-add-row {
        flex-direction: column;
    }

    .catalog-add-btn {
        width: 100%;
        justify-content: center;
    }

    /* ─ Panel header: stack heading + actions at phone size ─ */
    .panel-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }

    /* ─ Helpdesk toggle hints: smaller on phones ─ */
    .hd-toggle-hint {
        font-size: 0.78rem;
    }

    /* ─ Helpdesk page subtitle: smaller ─ */
    .hd-page-subtitle {
        font-size: 0.82rem;
    }

    /* ─ Helpdesk section title: slightly smaller ─ */
    .hd-section-title {
        font-size: 0.95rem;
    }

    /* ─ hd-table: compact cells on phones ─ */
    .hd-table th,
    .hd-table td {
        padding: 0.4rem 0.5rem;
        font-size: 0.82rem;
    }

    .hd-table-actions {
        flex-direction: column;
        gap: 0.25rem;
    }

    /* ─ Cell utilities: tighter on phones ─ */
    .cell-truncate {
        max-width: 140px;
    }

    .cell-clamp {
        max-width: 180px;
        -webkit-line-clamp: 1;
    }

    .cell-mono {
        max-width: 110px;
        font-size: 0.75rem;
    }

    /* ─ Filter grid: force single column on phones ─ */
    .filter-grid-5col {
        grid-template-columns: 1fr;
    }

    /* ─ Data table headers: compact ─ */
    .data-table th {
        white-space: nowrap;
        font-size: 0.7rem;
    }

    .data-table td {
        font-size: 0.8rem;
    }

    /* ─ Helpdesk notify grid: single column ─ */
    .hd-notify-grid {
        grid-template-columns: 1fr;
    }

    /* ─ Inline style overrides for tables ─ */
    .hd-table th[style],
    .hd-table td[style] {
        width: auto !important;
        min-width: auto !important;
    }
}

/* ── Very small phones (≤480px) — Phase 4 ── */

@media (max-width: 480px) {
    .cell-truncate {
        max-width: 100px;
    }

    .cell-clamp {
        max-width: 120px;
    }

    .cell-mono {
        max-width: 80px;
        font-size: 0.7rem;
    }

    /* ─ Helpdesk toggle: tighter text ─ */
    .hd-toggle-label {
        font-size: 0.85rem;
    }

    .hd-toggle-hint {
        font-size: 0.75rem;
    }

    /* ─ Data table: even tighter cells ─ */
    .data-table th {
        font-size: 0.65rem;
        padding: 0.35rem 0.4rem;
    }

    .data-table td {
        font-size: 0.75rem;
        padding: 0.35rem 0.4rem;
    }

    /* ─ hd-table: ultra compact ─ */
    .hd-table th,
    .hd-table td {
        padding: 0.3rem 0.4rem;
        font-size: 0.75rem;
    }
}

/* ─── MY-TICKETS MOBILE CARD LAYOUT ───────────────────────────────────────── */
@media (max-width: 640px) {
    .my-tickets-table,
    .my-tickets-table tbody {
        display: block;
        width: 100%;
    }

    .my-tickets-table thead {
        display: none;
    }

    .my-tickets-table tr {
        display: block;
        border: 1px solid #e2e8f0;
        border-radius: 0.5rem;
        margin-bottom: 0.75rem;
        padding: 0.625rem 0.75rem;
        background: #fff;
    }

    .my-tickets-table td {
        display: flex;
        align-items: flex-start;
        gap: 0.5rem;
        border: none;
        padding: 0.2rem 0;
        font-size: 0.85rem;
        min-width: 0;
    }

    .my-tickets-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.72rem;
        color: #64748b;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        min-width: 5.5rem;
        flex-shrink: 0;
        padding-top: 0.15rem;
    }

    /* Action cell: no label, full-width button at bottom */
    .my-tickets-table td:last-child {
        padding-top: 0.5rem;
        margin-top: 0.25rem;
        border-top: 1px solid #f1f5f9;
        justify-content: flex-end;
    }

    .my-tickets-table td:last-child::before {
        display: none;
    }

    .my-tickets-table td:last-child .secondary-button {
        width: 100%;
        text-align: center;
    }
}

/* ─── ACCOUNT DIRECTORY MOBILE CARD LAYOUT ─────────────────────────────────── */
@media (max-width: 640px) {
    .account-directory-table,
    .account-directory-table tbody {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .account-directory-table thead {
        display: none;
    }

    .account-directory-table tr {
        display: block;
        border: 1px solid #e2e8f0;
        border-radius: 0.5rem;
        margin-bottom: 0.75rem;
        padding: 0.625rem 0.75rem;
        background: #fff;
    }

    /* Standard label-value layout for all cells */
    .account-directory-table td {
        display: flex;
        align-items: flex-start;
        gap: 0.5rem;
        border: none;
        padding: 0.2rem 0;
        font-size: 0.85rem;
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .account-directory-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.72rem;
        color: #64748b;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        min-width: 5.5rem;
        flex-shrink: 0;
        padding-top: 0.15rem;
    }

    /* First td: display name — card title, no label */
    .account-directory-table td:first-child {
        display: block;
        font-weight: 600;
        font-size: 1rem;
        color: #1e293b;
        padding: 0 0 0.5rem 0;
        border-bottom: 1px solid #e2e8f0;
        margin-bottom: 0.25rem;
        overflow-wrap: anywhere;
    }

    .account-directory-table td:first-child::before {
        display: none;
    }

    /* Actions cell — stacked full-width buttons, no label */
    .account-directory-table td.actions-cell {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        padding-top: 0.5rem;
        border-top: 1px solid #e2e8f0;
        margin-top: 0.25rem;
    }

    .account-directory-table td.actions-cell::before {
        display: none;
    }

    .account-directory-table td.actions-cell .secondary-button {
        width: 100%;
        text-align: center;
    }
}
