/* Shared responsive patterns; loaded after legacy and scoped styles. */
html, body { max-width: 100%; }
body { overflow-x: clip; }
.app-shell, .app-main, .app-content, .page-shell, .container,
.surface-card, .card, .dashboard-grid, .dashboard-main, .dashboard-side,
.kpi-stack, .detail-grid, .module-dashboard-grid, .empty-state-card {
    min-width: 0; max-width: 100%; box-sizing: border-box;
}
:is(.dashboard-grid, .dashboard-main, .dashboard-side, .kpi-stack, .detail-grid,
.module-dashboard-grid, .row, .section-header, .page-header) > * { min-width: 0; }
.text-preline, .timeline-text, .task-card-text { white-space: pre-line; overflow-wrap: anywhere; }
.table-responsive, .table-scroll {
    width: 100%; max-width: 100%; min-width: 0; overflow-x: auto;
    overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch;
}
.table-responsive > table, .table-scroll > table {
    display: table; width: max-content; min-width: 100%; max-width: none; table-layout: auto;
}
td, th { white-space: nowrap; word-break: normal; overflow-wrap: normal; }
td.text-preline, td:has(.text-preline), .text-cell {
    white-space: normal; overflow-wrap: anywhere; min-width: 160px; max-width: 320px;
}
td :is(input, select, textarea) { max-width: 100%; }
td .btn { white-space: nowrap; }
.status-badge, .badge {
    display: inline-flex; align-items: center; white-space: nowrap;
    word-break: normal; overflow-wrap: normal; width: fit-content; flex-shrink: 0;
}
.dashboard-grid { grid-template-columns: minmax(0, 1.5fr) minmax(0, .9fr); gap: 16px; }
.dashboard-main, .dashboard-side { gap: 16px; }
.kpi-stack { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi-card { align-self: start; width: 100%; box-shadow: 0 3px 12px #0f172a08; }
.kpi-label { line-height: 1.25; text-transform: none; letter-spacing: normal; margin-bottom: 3px; }
.kpi-trend { margin-top: 3px; line-height: 1.25; }
.empty-state-card, .empty-state-card.empty-state-card-compact {
    padding: 24px; border-radius: 16px; overflow-wrap: anywhere;
}
.empty-state-card > * { min-width: 0; max-width: 100%; }
.live-feed-mobile { display: none; }
:where(h1, h2, main, section, div)[tabindex="-1"]:focus { outline: none; }
:where(a, button, input, select, textarea, [tabindex="0"]):focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }
.login-card { width: min(100%, 460px); margin: clamp(1rem, 5vh, 4rem) auto; padding: clamp(1.25rem, 4vw, 2.25rem); background: var(--bg-surface, #fff); border: 1px solid #e2e8f0; border-radius: 20px; box-shadow: 0 12px 36px #0f172a0d; }
.login-card h1 { font-size: clamp(1.5rem, 5vw, 2rem); }
.login-form input { min-height: 44px; }
.login-form button[type="submit"], .signup-cta { width: 100%; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.login-signup { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid #e2e8f0; text-align: center; }
.login-signup p { margin-bottom: .65rem; color: #475569; }
.kpi-card { min-height: 0; padding: 1rem; gap: .75rem; align-items: center; }
.kpi-icon { width: 42px; height: 42px; min-width: 42px; font-size: 1.15rem; }
.kpi-value { font-size: 1.5rem; line-height: 1.2; overflow-wrap: anywhere; }
.module-summary-card, .workspace-overview-grid-compact .module-summary-card { min-height: 0; padding: 1rem; gap: .5rem; }
.module-summary-icon-wrap { width: 32px; height: 32px; font-size: 1rem; }
.topbar-tenant-summary { min-width: 0; }
.topbar-tenant-summary strong, .topbar-user-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.topbar-tenant-summary > span { white-space: nowrap; font-size: .75rem; }
.topbar-user-inline { min-width: 0; }
@media (max-width: 991.98px) {
    .app-shell { grid-template-columns: minmax(0, 1fr); }
    .app-sidebar { z-index: 1060; height: 100dvh; overscroll-behavior: contain; padding: 16px; }
    .app-sidebar-backdrop { z-index: 1050; position: fixed; inset: 0; width: 100%; height: 100dvh; }
    .app-shell.sidebar-open .app-sidebar-backdrop { display: block; opacity: 1; pointer-events: auto; }
    .app-topbar.compact-topbar.compact-topbar-glass { display: block; min-height: 0; padding: 8px 12px; }
    .topbar-row.topbar-row-unified { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; width: 100%; }
    .topbar-meta.topbar-meta-compact { width: auto; min-width: 0; gap: 6px; flex-wrap: nowrap; }
    .topbar-actions.topbar-actions-header { grid-column: 2; grid-row: 1; width: auto; gap: 4px; flex-wrap: nowrap; }
    .topbar-tenant-shell-inline, .topbar-tenant-brand-inline { width: auto; min-width: 0; gap: 6px; align-items: center; }
    .topbar-tenant-logo-frame.topbar-tenant-logo-frame-inline { flex: 0 0 32px; width: 32px; height: 32px; min-height: 32px; padding: 3px; border-radius: 8px; }
    .topbar-tenant-logo { max-height: 26px; max-width: 26px; object-fit: contain; }
    .topbar-tenant-summary strong { max-width: 180px; font-size: .875rem; }
    .topbar-user-copy { display: none; }
    .topbar-user-inline .user-avatar { width: 30px; height: 30px; font-size: .7rem; }
    .app-topbar .icon-btn { width: 34px; height: 34px; min-width: 34px; }
    .topbar-time-cluster.topbar-time-cluster-inline { grid-row: 2; grid-column: 1 / -1; width: 100%; min-width: 0; }
    .topbar-time-cluster-inline .topbar-time-cluster-glass { display: flex; flex-direction: row; justify-content: space-between; align-items: center; width: 100%; min-width: 0; min-height: 0; padding: 0; gap: 6px; border: 0; box-shadow: none; background: transparent; }
    .topbar-time-overview.topbar-time-overview-inline, .topbar-time-command.topbar-time-command-inline { display: flex; flex-direction: row; align-items: center; width: auto; min-width: 0; gap: 6px; }
    .topbar-time-overview-inline strong { font-size: 1rem; line-height: 1.2; white-space: nowrap; }
    .topbar-time-copy { display: none; }
    .topbar-time-actions.topbar-time-actions-inline { display: flex; flex-wrap: nowrap; gap: 4px; }
    .topbar-time-actions-inline .btn { width: auto; min-height: 30px; padding: 4px 7px; font-size: .75rem; }
    .topbar-time-actions-inline .topbar-open-icon { width: 30px; height: 30px; min-width: 30px; }
}
@media (max-width: 768px) {
    .app-content { padding: 12px; }
    .kpi-stack, .workspace-overview-grid, .workspace-overview-grid-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .kpi-card, .module-summary-card, .workspace-overview-grid-compact .module-summary-card { min-height: 0; padding: 10px; gap: 6px; }
    .kpi-icon { width: 36px; height: 36px; min-width: 36px; font-size: 1rem; }
    .kpi-value, .module-summary-metric { font-size: 1.25rem; }
    .module-summary-head { margin-bottom: 6px; }
    .kpi-card > div { min-width: 0; }
    .page-header { gap: 12px; }
    table td, table th { padding: .55rem; }
}
@media (max-width: 640px) {
    .app-topbar .app-environment-badge { display: none; }
    .topbar-tenant-summary strong { max-width: 140px; }
    .topbar-time-command-inline .status-badge { font-size: .65rem; padding: 3px 5px; }

    .login-card { margin: 12px auto; }
}
@media (max-width: 480px) {
    .topbar-tenant-summary strong { max-width: 115px; }
    .topbar-time-command-inline .status-badge { display: none; }
    .app-topbar .topbar-shortcut-btn { width: 30px; min-width: 30px; }
    .login-card { padding: 20px; border-radius: 14px; }
    .kpi-label { font-size: .75rem; }
    .module-summary-card strong { overflow-wrap: anywhere; }
}
@media (prefers-reduced-motion: reduce) { .app-sidebar { transition: none; } }

@media (max-width: 991.98px) {
    .dashboard-grid, .report-hero-grid { grid-template-columns: minmax(0, 1fr); }
    .dashboard-hero-bar, .dashboard-hero-time { min-width: 0; max-width: 100%; flex-wrap: wrap; }
    .topbar-tenant-summary { overflow: hidden; }
}
@media (max-width: 768px) {
    .surface-card { padding: 16px; border-radius: 16px; }
    .dashboard-main, .dashboard-side, .page-shell { gap: 12px; }
    .detail-grid, .support-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .detail-item { padding: 12px; overflow-wrap: anywhere; }
    .section-header, .page-header { flex-wrap: wrap; gap: 10px; }
    .section-header > div, .section-actions, .page-actions { min-width: 0; max-width: 100%; flex-wrap: wrap; }
    .page-header { margin-bottom: 12px; padding-bottom: 12px; }
    h1, .page-header .page-title { font-size: 1.625rem; }
    h2 { font-size: 1.375rem; }
    .section-header h3 { font-size: 1.125rem; line-height: 1.35; }
    .status-badge, .badge, .section-kicker, .page-kicker, .detail-item span, .table thead th {
        text-transform: none; letter-spacing: normal;
    }
    .kpi-stack { grid-template-columns: minmax(0, 1fr); }
    .kpi-card { min-height: 76px; padding: 14px 16px; gap: 12px; align-items: center; border-radius: 16px; }
    .kpi-label { font-size: .75rem; }
    .kpi-value { font-size: 1.375rem; line-height: 1.1; }
    .kpi-trend { font-size: .75rem; }
    .module-summary-card, .workspace-overview-grid-compact .module-summary-card { padding: 12px; }
    .module-summary-main { min-width: 0; flex-wrap: wrap; gap: 6px; }
    .module-summary-summary, .module-summary-list { overflow-wrap: anywhere; }
    .empty-state-card, .empty-state-card.empty-state-card-compact { padding: 18px 14px; gap: 8px; }
    .empty-state-card i { font-size: 1.25rem; }
    .empty-state-card span { font-size: .875rem; line-height: 1.5; }
    .chart-placeholder-bars { min-width: 0; max-width: 100%; overflow-x: auto; }
}
@media (max-width: 640px) {
    .live-feed-desktop { display: none; }
    .live-feed-mobile { display: grid; gap: 10px; margin-top: 12px; }
    .live-feed-item { min-width: 0; padding: 14px; border: 1px solid #e2e8f0; border-radius: 14px; background: var(--bg-surface-muted); }
    .live-feed-item > a { display: block; font-weight: 600; overflow-wrap: anywhere; margin-bottom: 8px; }
    .live-feed-item dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; margin: 10px 0 0; font-size: .8125rem; }
    .live-feed-item dt { font-weight: 400; color: var(--text-muted); }
    .live-feed-item dd { margin: 0; }
}
