:root {
    --sidebar-width: 268px;
    --navy: #102a43;
    --navy-2: #16324f;
    --accent: #1f7a8c;
    --bg: #f3f6fa;
    --text: #243044;
    --muted: #6b7c93;
    --card-shadow: 0 8px 24px rgba(16, 42, 67, 0.06);
}

* { box-sizing: border-box; }

body {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--navy) 0%, #0c1e32 100%);
    color: #fff;
    position: fixed;
    inset: 0 auto 0 0;
    flex-direction: column;
    z-index: 1030;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 1.1rem 0.85rem 1.5rem;
}

.sidebar-brand {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    color: #fff;
    text-decoration: none;
    padding: 0.35rem 0.5rem 1.2rem;
}
.sidebar-brand strong { display: block; font-size: 0.95rem; }
.sidebar-brand small { display: block; color: #9fb3c8; font-size: 0.72rem; }

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-section {
    color: #8aa0b5;
    font-size: 0.7rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 0.8rem 0.85rem 0.35rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: #d6e2ee;
    text-decoration: none;
    padding: 0.55rem 0.85rem;
    border-radius: 10px;
    margin-bottom: 0.15rem;
}
.sidebar-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-link.active { background: rgba(31, 122, 140, .35); color: #fff; }

.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    max-width: calc(100% - var(--sidebar-width));
}

.app-topbar {
    background: #fff;
    border-bottom: 1px solid #e6edf5;
    padding: 0.9rem 1.4rem;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 20;
}

.app-content {
    padding: 1.4rem;
    min-width: 0;
    max-width: 100%;
}

.card-soft {
    background: #fff;
    border: 0;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    min-width: 0;
    max-width: 100%;
}

.kpi-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    padding: 1rem 1.1rem;
    height: 100%;
}
.kpi-label { color: var(--muted); font-size: 0.82rem; margin-bottom: 0.25rem; }
.kpi-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.03em; }
.kpi-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e8f4f6;
    color: var(--accent);
}

.badge-risk {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-risk-low { background: #e6f6ec; color: #157347; }
.badge-risk-medium { background: #fff6d9; color: #9a6b00; }
.badge-risk-high { background: #ffedd9; color: #c05600; }
.badge-risk-critical { background: #fde8ea; color: #b02a37; }

.table-soft { font-size: 0.9rem; }
.ostep-page .table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}
.ostep-cell { min-width: 0; }
.ostep-count { font-weight: 600; }
.ostep-names {
    margin: 0.4rem 0 0;
    padding-left: 1.15rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.4;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.ostep-names li { padding-left: 0.15rem; }
.ostep-ok { background: #e6f6ec; }
.ostep-low { background: #fde8ea; }
.table-ostep tr.ostep-ok > td { background: #e6f6ec; }
.table-ostep tr.ostep-low > td { background: #fde8ea; }
.table-ostep {
    border: 1px solid #6b8499;
    border-collapse: collapse;
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
}
.table-ostep > :not(caption) > * > * {
    border: 1px solid #6b8499;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    vertical-align: top;
}
.table-ostep th:first-child,
.table-ostep td:first-child {
    width: 16%;
}
.table-ostep th:nth-last-child(-n+2),
.table-ostep td:nth-last-child(-n+2) {
    width: 6.5rem;
}
.table-soft thead th {
    color: var(--muted);
    font-weight: 600;
    border-bottom-width: 1px;
    white-space: nowrap;
}
.table-ostep.table-soft thead th {
    white-space: normal;
    line-height: 1.25;
}

.risk-rule-table .form-control {
    max-width: 8rem;
}

.filter-bar .form-control, .filter-bar .form-select { min-width: 140px; }

.alert-signal {
    border: 0;
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--card-shadow);
    margin-bottom: 0.65rem;
}

.risk-panel {
    border-radius: 16px;
    padding: 1.2rem 1.3rem;
    color: #fff;
}
.risk-panel.low { background: linear-gradient(135deg, #198754, #146c43); }
.risk-panel.medium { background: linear-gradient(135deg, #d39e00, #b8860b); }
.risk-panel.high { background: linear-gradient(135deg, #fd7e14, #d9480f); }
.risk-panel.critical { background: linear-gradient(135deg, #dc3545, #a71d2a); }

.chat-wrap {
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    min-height: 62vh;
    display: flex;
    flex-direction: column;
}
.chat-log {
    flex: 1;
    padding: 1.2rem;
    overflow-y: auto;
    max-height: 58vh;
}
.bubble {
    max-width: 78%;
    padding: 0.75rem 0.95rem;
    border-radius: 14px;
    white-space: pre-wrap;
    margin-bottom: 0.75rem;
}
.bubble-user { margin-left: auto; background: #1f7a8c; color: #fff; }
.bubble-ai { background: #eef3f8; color: var(--text); }
.ai-suggestions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.ai-chip {
    border: 1px solid #d7e8ee;
    background: #f7fbfc;
    color: #14515c;
    border-radius: 999px;
    padding: 0.25rem 0.7rem;
    font-size: 0.8rem;
    line-height: 1.3;
}
.ai-chip:hover { background: #e8f4f6; border-color: #1f7a8c; }

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, #102a43 0%, #1f7a8c 100%);
}
.login-card {
    width: min(420px, 92vw);
    background: #fff;
    border-radius: 18px;
    padding: 2rem;
    box-shadow: 0 20px 50px rgba(0,0,0,.18);
}

.app-offcanvas { background: var(--navy); color: #fff; width: var(--sidebar-width); }

@media (max-width: 991.98px) {
    .app-main { margin-left: 0; max-width: 100%; }
}

.report-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.85rem;
}
.report-type-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    border: 1px solid #e6edf5;
    border-radius: 14px;
    padding: 1rem;
    cursor: pointer;
    background: #fbfcfe;
    height: 100%;
    position: relative;
}
.report-type-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.report-type-card:hover { border-color: #b9c9d8; }
.report-type-card:has(input:checked) {
    border-color: #1f7a8c;
    background: #f3fafb;
    box-shadow: 0 0 0 3px rgba(31, 122, 140, 0.12);
}
.report-type-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: #e8f4f6;
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.2rem;
}
.report-type-title { font-weight: 600; }
.report-type-desc { color: var(--muted); font-size: 0.82rem; line-height: 1.35; }

.report-conclusions {
    background: #f7fbfc;
    border: 1px solid #d7e8ee;
    border-radius: 14px;
    padding: 1.1rem 1.25rem;
}
.report-briefing {
    background: #f4fafb;
    border: 1px solid #c5e0e6;
    border-radius: 14px;
    padding: 1.15rem 1.3rem;
}
.report-briefing-kicker {
    color: #1f7a8c;
    font-size: 0.78rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.transfer-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    font-size: 0.82rem;
}
.transfer-legend-item {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    border: 1px solid transparent;
}
.transfer-faculty-block { margin-bottom: 1.75rem; }
.transfer-faculty {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 0.75rem;
    padding: 0.55rem 0.85rem;
    background: #1f7a8c;
    color: #fff;
    border-radius: 8px;
}
.transfer-cafedra {
    font-size: 1rem;
    font-weight: 650;
    margin: 0.9rem 0 0.5rem;
    padding: 0.4rem 0.75rem;
    background: #d7eef2;
    color: #14515c;
    border-radius: 6px;
}
.transfer-group {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0.85rem 0 0.4rem;
    color: #334155;
}
.transfer-table tbody td { border-color: #e2e8f0; }
.table.transfer-table > tbody > tr.transfer-row-ok > * {
    background-color: #b7ebc3 !important;
}
.table.transfer-table > tbody > tr.transfer-row-warn > * {
    background-color: #ffe08a !important;
}
.table.transfer-table > tbody > tr.transfer-row-no > * {
    background-color: #f5a9b0 !important;
}
.transfer-legend-item.transfer-row-ok { background-color: #b7ebc3; }
.transfer-legend-item.transfer-row-warn { background-color: #ffe08a; }
.transfer-legend-item.transfer-row-no { background-color: #f5a9b0; }
.transfer-detail {
    margin-top: 0.25rem;
    font-size: 0.8rem;
    line-height: 1.35;
    color: #334155;
}

@media print {
    .app-sidebar, .app-topbar, .no-print { display: none !important; }
    .app-main { margin-left: 0; }
    .app-content { padding: 0; }
    .card-soft { box-shadow: none; }
    .transfer-row-ok,
    .transfer-row-warn,
    .transfer-row-no,
    .table.transfer-table > tbody > tr.transfer-row-ok > *,
    .table.transfer-table > tbody > tr.transfer-row-warn > *,
    .table.transfer-table > tbody > tr.transfer-row-no > *,
    .transfer-faculty,
    .transfer-cafedra {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .transfer-faculty-block { break-inside: avoid; }
}

.report-schedule-tabs {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}
.report-schedule-tab {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.8rem;
    border: 1px solid #e6edf5;
    border-radius: 999px;
    color: #334155;
    text-decoration: none;
    background: #fbfcfe;
    font-size: 0.86rem;
    white-space: nowrap;
}
.report-schedule-tab:hover { border-color: #1f7a8c; color: #14515c; }
.report-schedule-tab.active {
    background: #1f7a8c;
    border-color: #1f7a8c;
    color: #fff;
}
.report-cal-weekdays,
.report-cal-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.35rem;
}
.report-cal-weekdays {
    margin-bottom: 0.4rem;
    color: var(--muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: center;
}
.report-cal-day {
    min-height: 4.4rem;
    border: 1px solid #e6edf5;
    border-radius: 10px;
    background: #fff;
    padding: 0.35rem;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    cursor: pointer;
}
.report-cal-day.is-empty {
    border-color: transparent;
    background: transparent;
    cursor: default;
}
.report-cal-day.is-today { box-shadow: 0 0 0 2px rgba(31, 122, 140, 0.35); }
.report-cal-day.has-jobs { background: #f3fafb; border-color: #c5e0e6; }
.report-cal-day:not(.is-empty):hover { border-color: #1f7a8c; }
.report-cal-num { font-weight: 600; font-size: 0.9rem; }
.report-cal-dot {
    display: inline-block;
    width: 0.48rem;
    height: 0.48rem;
    border-radius: 50%;
    background: #94a3b8;
    margin-right: 0.15rem;
}
.report-cal-dot.status-pending { background: #64748b; }
.report-cal-dot.status-done { background: #16a34a; }
.report-cal-dot.status-error { background: #dc2626; }
.report-cal-dot.status-running { background: #0284c7; }
.report-cal-legend { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.report-cal-legend .report-cal-dot { vertical-align: middle; }
