:root {
    --orange: #ff7900;
    --orange-dark: #d65f00;
    --ink: #18202a;
    --muted: #6f7a88;
    --line: #e6e9ee;
    --surface: #ffffff;
    --page: #f5f7fa;
    --sidebar: #171b22;
    --sidebar-soft: #222834;
    --success: #14845a;
    --warning: #b96b00;
    --danger: #b42318;
    --info: #0a6680;
}

* {
    letter-spacing: 0;
}

body {
    background: var(--page);
    color: var(--ink);
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

body.sidebar-open {
    overflow: hidden;
}

a {
    color: var(--orange-dark);
    text-decoration: none;
}

.btn-orange {
    --bs-btn-bg: var(--orange);
    --bs-btn-border-color: var(--orange);
    --bs-btn-hover-bg: var(--orange-dark);
    --bs-btn-hover-border-color: var(--orange-dark);
    --bs-btn-color: #111;
    --bs-btn-hover-color: #fff;
    font-weight: 700;
}

.app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
    transition: grid-template-columns 180ms ease;
}

body.sidebar-collapsed .app-shell {
    grid-template-columns: 82px minmax(0, 1fr);
}

.sidebar {
    background: linear-gradient(180deg, var(--sidebar), #101318);
    color: #fff;
    padding: 18px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    scrollbar-color: #3a4250 transparent;
    scrollbar-width: thin;
    transition: width 180ms ease, transform 180ms ease;
}

.sidebar-backdrop {
    display: none;
}

.sidebar-close {
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    display: none;
    height: 38px;
    justify-content: center;
    position: absolute;
    right: 14px;
    top: 22px;
    width: 38px;
}

.sidebar-close span {
    background: #fff;
    border-radius: 999px;
    height: 2px;
    position: absolute;
    width: 17px;
}

.sidebar-close span:first-child {
    transform: rotate(45deg);
}

.sidebar-close span:last-child {
    transform: rotate(-45deg);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    min-height: 42px;
}

.brand:hover {
    color: inherit;
}

.brand-mark {
    align-items: center;
    background: var(--orange);
    color: #111;
    display: inline-flex;
    font-weight: 900;
    height: 42px;
    justify-content: center;
    min-width: 42px;
    border-radius: 8px;
}

.brand strong,
.brand small {
    display: block;
    line-height: 1.1;
}

.brand small {
    color: #aeb7c3;
    font-size: 12px;
    margin-top: 4px;
}

.sidebar .nav {
    margin-top: 18px;
    gap: 8px;
}

.nav-section {
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    padding-bottom: 7px;
}

.nav-section:last-child {
    border-bottom: 0;
}

.nav-section-title {
    align-items: center;
    color: #8792a2;
    cursor: pointer;
    display: flex;
    font-size: 11px;
    font-weight: 800;
    justify-content: space-between;
    list-style: none;
    min-height: 28px;
    padding: 2px 10px 4px;
    text-transform: uppercase;
}

.nav-section-title::-webkit-details-marker {
    display: none;
}

.nav-section-title::after {
    border-color: currentColor;
    border-style: solid;
    border-width: 0 1.5px 1.5px 0;
    content: "";
    height: 7px;
    transform: rotate(45deg) translateY(-2px);
    transition: transform 150ms ease;
    width: 7px;
}

.nav-section[open] .nav-section-title::after {
    transform: rotate(225deg) translateY(-1px);
}

.nav-section-links {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sidebar .nav-link {
    align-items: center;
    border-radius: 8px;
    color: #c5cbd4;
    display: flex;
    font-size: 13px;
    gap: 9px;
    min-height: 36px;
    padding: 7px 9px;
}

body.sidebar-collapsed .sidebar {
    padding-left: 12px;
    padding-right: 12px;
}

body.sidebar-collapsed .brand {
    justify-content: center;
}

body.sidebar-collapsed .brand > span:last-child,
body.sidebar-collapsed .sidebar .nav-link > span:last-child,
body.sidebar-collapsed .nav-section-title {
    opacity: 0;
    pointer-events: none;
    position: absolute;
    width: 0;
}

body.sidebar-collapsed .sidebar .nav {
    gap: 4px;
    margin-top: 16px;
}

body.sidebar-collapsed .nav-section {
    border-bottom: 0;
    padding-bottom: 0;
}

body.sidebar-collapsed .nav-section:not([open]) {
    display: none;
}

body.sidebar-collapsed .nav-section-links {
    gap: 4px;
}

body.sidebar-collapsed .sidebar .nav-link {
    justify-content: center;
    padding-left: 8px;
    padding-right: 8px;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: var(--sidebar-soft);
    color: #fff;
}

.nav-icon {
    align-items: center;
    border: 1px solid #3a4250;
    border-radius: 6px;
    color: var(--orange);
    display: inline-flex;
    font-size: 11px;
    font-weight: 800;
    height: 26px;
    justify-content: center;
    min-width: 30px;
}

.main-panel {
    min-width: 0;
    padding: 24px;
}

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

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

.quick-actions {
    align-items: center;
    display: flex;
    gap: 7px;
}

.shell-icon-button {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    display: inline-flex;
    gap: 5px;
    height: 42px;
    justify-content: center;
    min-width: 42px;
    padding: 0 10px;
}

.shell-icon-button:hover {
    border-color: #ffc28a;
    color: var(--orange-dark);
}

.shell-icon-button svg {
    fill: none;
    height: 17px;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
    width: 17px;
}

.shell-icon-button strong {
    font-size: 11px;
    line-height: 1;
}

.shell-icon-button-danger {
    color: var(--danger);
}

.topbar h1 {
    font-size: 26px;
    font-weight: 800;
    margin: 0;
}

.topbar p {
    align-items: center;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 0;
}

.role-pill {
    background: #fff4e9;
    border: 1px solid #ffd4ad;
    border-radius: 999px;
    color: var(--orange-dark);
    display: inline-block;
    font-size: 12px;
    font-weight: 800;
    padding: 2px 8px;
}

.knowledge-search,
.knowledge-assistant-form {
    display: grid;
    gap: 10px;
}

.knowledge-search {
    grid-template-columns: minmax(0, 1fr) auto auto;
}

.knowledge-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}

.knowledge-suggestions a,
.knowledge-score,
.knowledge-confidence {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    padding: 5px 9px;
}

.knowledge-results {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.knowledge-result {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 14px;
}

.knowledge-result h3 {
    font-size: 16px;
    font-weight: 800;
    margin: 8px 0 6px;
}

.knowledge-result p {
    color: var(--muted);
    margin: 0;
}

.knowledge-actions {
    align-content: start;
    display: grid;
    gap: 7px;
    min-width: 210px;
}

.knowledge-sources {
    border-top: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
}

.knowledge-sources span {
    color: var(--muted);
    font-size: 12px;
}

.knowledge-assistant-layout {
    display: grid;
    gap: 16px;
    grid-template-columns: 280px minmax(0, 1fr) 300px;
}

.knowledge-history-list,
.knowledge-source-list,
.knowledge-answer {
    display: grid;
    gap: 10px;
}

.knowledge-history-list div,
.knowledge-source-list a,
.knowledge-answer article,
.knowledge-answer-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.knowledge-history-list strong,
.knowledge-history-list span,
.knowledge-history-list small,
.knowledge-source-list strong,
.knowledge-source-list span {
    display: block;
}

.knowledge-history-list span,
.knowledge-history-list small,
.knowledge-source-list span,
.knowledge-answer p,
.knowledge-answer-item p {
    color: var(--muted);
}

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

.knowledge-assistant-form button {
    justify-self: end;
}

.knowledge-answer {
    margin-top: 16px;
}

.knowledge-answer h3 {
    font-size: 16px;
    font-weight: 800;
}

.knowledge-usage-stats {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.knowledge-usage-stats div,
.knowledge-domain-list span {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
}

.knowledge-usage-stats span,
.knowledge-domain-list strong {
    color: var(--muted);
    display: block;
    font-size: 12px;
}

.knowledge-usage-stats strong {
    font-size: 24px;
}

.knowledge-domain-list {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.mobile-menu-button {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(19, 27, 40, 0.08);
    color: var(--ink);
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    height: 42px;
    justify-content: center;
    min-width: 42px;
    padding: 8px;
}

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

.mobile-menu-button strong {
    display: none;
}

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

.tenant-switch {
    min-width: 210px;
}

.dashboard-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.metric-card,
.panel,
.report-tile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 14px 35px rgba(19, 27, 40, 0.06);
}

.metric-card {
    min-height: 118px;
    padding: 18px;
}

.metric-card span {
    color: var(--muted);
    display: block;
    font-size: 13px;
    min-height: 34px;
}

.metric-card strong {
    display: block;
    font-size: 34px;
    line-height: 1;
    margin-top: 14px;
}

.content-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 1.15fr 1fr 0.85fr;
    margin-top: 16px;
}

.panel {
    padding: 18px;
}

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

.panel-heading h2 {
    font-size: 18px;
    font-weight: 800;
    margin: 0;
}

.panel-heading span,
.panel-heading small {
    color: var(--muted);
    font-size: 13px;
}

.heatmap {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(5, minmax(46px, 1fr));
}

.heat-panel {
    grid-column: 1 / -1;
}

.heatmap-filters {
    align-items: end;
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(4, minmax(150px, 1fr)) auto auto;
    margin-bottom: 14px;
}

.heatmap-filters label {
    display: grid;
    gap: 5px;
}

.heatmap-filters label span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.heatmap-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-bottom: 14px;
}

.heatmap-legend span {
    align-items: center;
    color: #4d5866;
    display: inline-flex;
    font-size: 12px;
    gap: 6px;
}

.legend-dot {
    border-radius: 999px;
    display: inline-block;
    height: 10px;
    width: 10px;
}

.band-green,
.risk-band-green {
    background: #12805c;
}

.band-yellow,
.risk-band-yellow {
    background: #f7c948;
}

.band-orange,
.risk-band-orange {
    background: #f97316;
}

.band-red,
.risk-band-red {
    background: #dc2626;
}

.band-dark-red,
.risk-band-dark-red {
    background: #7f1d1d;
}

.heatmap-shell {
    display: grid;
    gap: 8px;
    grid-template-columns: auto minmax(0, 1fr);
}

.heatmap-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: 28px repeat(5, minmax(118px, 1fr));
}

.heatmap-axis {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.heatmap-y-axis {
    align-self: center;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

.heatmap-x-axis {
    grid-column: 2;
    justify-self: center;
}

.heatmap-axis-label,
.heatmap-corner {
    align-items: center;
    color: #6f7a88;
    display: flex;
    font-size: 12px;
    font-weight: 900;
    justify-content: center;
    min-height: 24px;
}

.heat-cell {
    border-radius: 8px;
    color: #111;
    min-height: 112px;
    padding: 9px;
}

.heat-band-green {
    background: #dcfce7;
}

.heat-band-yellow {
    background: #fef3c7;
}

.heat-band-orange {
    background: #fed7aa;
}

.heat-band-red {
    background: #fecaca;
}

.heat-band-dark-red {
    background: #fecdd3;
    box-shadow: inset 0 0 0 2px rgba(127, 29, 29, 0.2);
}

.heat-cell-top {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.heat-cell-top span,
.heat-cell-top small {
    color: #4d5866;
    font-size: 11px;
    font-weight: 900;
}

.risk-cell-count {
    align-items: center;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(24, 32, 42, 0.16);
    border-radius: 999px;
    color: var(--ink);
    display: inline-flex;
    font-size: 12px;
    font-weight: 900;
    height: 24px;
    justify-content: center;
    min-width: 28px;
    padding: 0 8px;
}

.risk-cell-count:hover {
    border-color: var(--orange);
    color: var(--orange-dark);
}

.risk-marker-list {
    align-content: start;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.risk-marker {
    border: 2px solid rgba(255, 255, 255, 0.82);
    border-radius: 999px;
    box-shadow: 0 6px 14px rgba(24, 32, 42, 0.16);
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    max-width: 74px;
    min-height: 24px;
    overflow: hidden;
    padding: 5px 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.risk-marker:hover {
    filter: brightness(0.94);
    transform: translateY(-1px);
}

.risk-band-yellow,
.risk-band-green {
    color: #17202a;
}

.modal-subtitle {
    color: var(--muted);
    font-size: 13px;
}

.risk-detail-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
}

.risk-detail-grid div,
.risk-drilldown-item {
    background: #f8f9fb;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
}

.risk-detail-grid dt {
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.risk-detail-grid dd {
    font-weight: 800;
    margin: 0;
}

.modal-body h3 {
    font-size: 14px;
    font-weight: 900;
    margin: 16px 0 6px;
}

.risk-drilldown-list {
    display: grid;
    gap: 10px;
}

.risk-drilldown-item {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr auto;
    text-align: left;
    width: 100%;
}

.risk-drilldown-item strong,
.risk-drilldown-item span,
.risk-drilldown-item small {
    display: block;
}

.risk-drilldown-item small {
    color: var(--muted);
}

.heat-cell strong,
.heat-cell small {
    display: block;
}

.heat-cell small {
    opacity: 0.8;
}

.level-low {
    background: #dff7ea;
}

.level-medium {
    background: #fff1c7;
}

.level-high {
    background: #ffd5a8;
}

.level-critical {
    background: #ffd5d2;
}

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

.bar-row {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(110px, 1fr) 2fr 30px;
    font-size: 13px;
}

.bar-track {
    background: #edf0f4;
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
}

.bar-track div {
    background: linear-gradient(90deg, var(--orange), #f2b705);
    height: 100%;
}

.progress-stack {
    display: grid;
    gap: 10px;
}

.progress-stack div,
.compliance-score {
    align-items: center;
    background: #f7f8fa;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    padding: 11px 12px;
}

.compliance-score {
    margin-top: 16px;
}

.compliance-score strong {
    color: var(--success);
    font-size: 26px;
}

.search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.data-table {
    font-size: 14px;
}

.data-table thead th {
    background: #f8f9fb;
    border-bottom: 1px solid var(--line);
    color: #4d5866;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.data-table td,
.data-table th {
    white-space: nowrap;
}

.table-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.table-actions form {
    display: inline;
}

.form-panel {
    max-width: 1180px;
}

.module-form .form-label {
    color: #4d5866;
    font-size: 13px;
    font-weight: 800;
}

.form-actions {
    border-top: 1px solid var(--line);
    display: flex;
    gap: 10px;
    margin-top: 22px;
    padding-top: 18px;
}

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

.report-tile {
    color: var(--ink);
    min-height: 160px;
    padding: 20px;
}

.report-tile:hover {
    border-color: var(--orange);
    color: var(--ink);
}

.report-tile span,
.report-tile small {
    color: var(--muted);
    display: block;
}

.report-tile strong {
    display: block;
    font-size: 20px;
    margin: 16px 0 24px;
}

.guest-shell {
    background: radial-gradient(circle at 15% 20%, rgba(255, 121, 0, 0.18), transparent 35%), #11161d;
}

.login-wrap {
    align-items: center;
    display: flex;
    min-height: 100vh;
    padding: 28px;
}

.login-card {
    background: #fff;
    border-radius: 8px;
    display: grid;
    grid-template-columns: 1.25fr 0.9fr;
    margin: 0 auto;
    max-width: 1040px;
    min-height: 540px;
    overflow: hidden;
    width: 100%;
}

.login-copy {
    background: linear-gradient(145deg, #171b22, #252c36);
    color: #fff;
    padding: 44px;
}

.login-copy h1 {
    font-size: 40px;
    font-weight: 900;
    line-height: 1.08;
    margin: 90px 0 18px;
    max-width: 540px;
}

.login-copy p {
    color: #c7d0dc;
    font-size: 17px;
    max-width: 560px;
}

.login-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 34px;
}

.login-stats span {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    padding: 10px 14px;
}

.login-form {
    padding: 44px;
}

.login-form h2 {
    font-size: 28px;
    font-weight: 900;
    margin-bottom: 28px;
}

.credentials {
    color: var(--muted);
    font-size: 13px;
    margin-top: 18px;
}

.print-body {
    background: #fff;
    padding: 30px;
}

.print-toolbar {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.print-report {
    margin: 0 auto;
    max-width: 1120px;
}

.print-report header {
    border-bottom: 3px solid var(--orange);
    margin-bottom: 22px;
    padding-bottom: 18px;
}

.print-report h1 {
    font-size: 28px;
    font-weight: 900;
    margin-top: 24px;
}

[dir="rtl"] .sidebar .nav-link,
[dir="rtl"] .brand {
    flex-direction: row-reverse;
}

[dir="rtl"] .topbar-actions {
    justify-content: flex-start;
}

@media (max-width: 1180px) {
    .dashboard-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .content-grid,
    .report-grid {
        grid-template-columns: 1fr;
    }

    .heatmap-filters {
        grid-template-columns: repeat(2, minmax(150px, 1fr)) auto auto;
    }
}

@media (max-width: 860px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    body.sidebar-collapsed .app-shell {
        grid-template-columns: 1fr;
    }

    body.sidebar-collapsed .brand > span:last-child,
    body.sidebar-collapsed .sidebar .nav-link > span:last-child {
        opacity: 1;
        pointer-events: auto;
        position: static;
        width: auto;
    }

    body.sidebar-collapsed .brand,
    body.sidebar-collapsed .sidebar .nav-link {
        justify-content: flex-start;
    }

    .sidebar {
        box-shadow: 24px 0 60px rgba(0, 0, 0, 0.34);
        height: 100vh;
        left: 0;
        max-width: min(86vw, 320px);
        position: fixed;
        top: 0;
        transform: translateX(-105%);
        transition: transform 180ms ease;
        width: 320px;
        z-index: 1040;
    }

    .sidebar-close {
        display: inline-flex;
    }

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

    [dir="rtl"] .sidebar {
        left: auto;
        right: 0;
        transform: translateX(105%);
    }

    [dir="rtl"] .sidebar-close {
        left: 14px;
        right: auto;
    }

    [dir="rtl"] .sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        background: rgba(13, 18, 25, 0.56);
        display: block;
        inset: 0;
        opacity: 0;
        pointer-events: none;
        position: fixed;
        transition: opacity 180ms ease;
        z-index: 1030;
    }

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

    .sidebar .nav {
        display: flex;
        flex-direction: column;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        background: rgba(245, 247, 250, 0.94);
        margin: -10px -10px 18px;
        padding: 10px;
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .topbar-actions {
        justify-content: flex-start;
        width: 100%;
    }

    .topbar-title {
        width: 100%;
    }

    .quick-actions {
        flex-shrink: 0;
    }

    .topbar-title h1 {
        font-size: 22px;
    }

    .mobile-menu-button {
        min-width: 50px;
    }

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

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

    .login-copy h1 {
        margin-top: 48px;
    }
}

@media (max-width: 560px) {
    .main-panel,
    .login-copy,
    .login-form {
        padding: 14px;
    }

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

    .search-row,
    .form-actions {
        flex-direction: column;
    }

    .tenant-switch {
        min-width: 0;
        width: 100%;
    }

    .metric-card {
        min-height: 92px;
    }

    .metric-card span {
        min-height: 0;
    }

    .metric-card strong {
        font-size: 30px;
        margin-top: 10px;
    }

    .panel {
        padding: 14px;
    }

    .panel-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .heatmap {
        gap: 6px;
        grid-template-columns: repeat(5, minmax(44px, 1fr));
        overflow-x: auto;
    }

    .heatmap-filters {
        grid-template-columns: 1fr;
    }

    .heatmap-shell {
        grid-template-columns: 1fr;
        overflow-x: auto;
    }

    .heatmap-y-axis,
    .heatmap-x-axis {
        display: none;
    }

    .heatmap-grid {
        min-width: 660px;
    }

    .heat-cell {
        min-height: 54px;
        min-width: 44px;
        padding: 8px;
    }

    .heatmap-grid .heat-cell {
        min-height: 105px;
    }

    .risk-detail-grid {
        grid-template-columns: 1fr 1fr;
    }

    .table-responsive {
        overflow: visible;
    }

    .data-table thead {
        display: none;
    }

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

    .data-table tr {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 8px;
        margin-bottom: 10px;
        padding: 10px;
    }

    .data-table td {
        align-items: flex-start;
        border: 0;
        display: flex;
        gap: 12px;
        justify-content: space-between;
        padding: 7px 0;
        white-space: normal;
    }

    .data-table td::before {
        color: var(--muted);
        content: attr(data-label);
        flex: 0 0 42%;
        font-size: 11px;
        font-weight: 800;
        text-transform: uppercase;
    }

    .table-actions {
        justify-content: space-between;
    }

    .knowledge-search,
    .knowledge-result,
    .knowledge-usage-stats {
        grid-template-columns: 1fr;
    }

    .knowledge-actions {
        min-width: 0;
    }

    .knowledge-assistant-form button {
        justify-self: stretch;
    }
}

@media (max-width: 1180px) {
    .knowledge-assistant-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .knowledge-result {
        grid-template-columns: 1fr;
    }

    .knowledge-actions {
        grid-template-columns: 1fr;
        min-width: 0;
    }
}

@media print {
    .print-toolbar {
        display: none;
    }

    .print-body {
        padding: 0;
    }
}
