:root {
    --bg: #eef2f7;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --ink: #172033;
    --muted: #64748b;
    --line: #dbe3ee;
    --primary: #1e5eff;
    --primary-dark: #1745bd;
    --accent: #16a085;
    --warning: #d97706;
    --danger-soft: #fff1f2;
    --danger: #be123c;
    --shadow: 0 20px 45px rgba(23, 32, 51, 0.1);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(180deg, #ffffff 0, #f6f8fc 330px, var(--bg) 100%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px clamp(18px, 4vw, 42px);
    border-bottom: 1px solid rgba(219, 227, 238, 0.9);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: var(--radius);
    color: #fff;
    background: #172033;
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: var(--muted);
    font-size: 0.8rem;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.main-nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: var(--radius);
    color: #526174;
    font-weight: 650;
}

.main-nav a:hover,
.main-nav a.active {
    color: var(--ink);
    background: #edf3ff;
}

.nav-icon {
    display: grid;
    width: 26px;
    height: 26px;
    place-items: center;
    border-radius: 6px;
    color: var(--primary-dark);
    background: #ffffff;
    font-size: 0.9rem;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: auto;
    color: #aab7ca;
    font-size: 0.9rem;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 5px rgba(22, 160, 133, 0.14);
}

.main-panel {
    min-width: 0;
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 30px clamp(18px, 4vw, 42px) 52px;
}

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

.eyebrow,
.section-kicker,
.metric-label {
    color: var(--primary-dark);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.topbar h1,
.hero-copy h2,
.section-heading h2,
.auth-intro h2,
.form-heading h2 {
    margin: 0;
    color: var(--ink);
    letter-spacing: 0;
}

.topbar h1 {
    font-size: clamp(1.65rem, 3vw, 2.65rem);
}

.topbar-actions,
.hero-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.user-chip {
    max-width: 260px;
    overflow: hidden;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #f8fafc;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    color: var(--ink);
    border-color: var(--line);
    background: var(--surface);
}

.btn-danger {
    color: #fff;
    background: var(--danger);
}

.btn-sm {
    min-height: 34px;
    padding: 7px 11px;
    font-size: 0.88rem;
}

.hero-section,
.auth-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 28px;
    align-items: stretch;
    margin-bottom: 28px;
}

.hero-copy,
.auth-intro {
    padding: clamp(28px, 5vw, 58px);
    border: 1px solid rgba(219, 227, 238, 0.9);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.hero-copy h2,
.auth-intro h2 {
    max-width: 760px;
    margin-top: 10px;
    font-size: clamp(2rem, 4.7vw, 4rem);
    line-height: 1.05;
}

.hero-copy p,
.auth-intro p,
.info-card p,
.form-heading p {
    color: var(--muted);
}

.hero-copy p,
.auth-intro p {
    max-width: 640px;
    font-size: 1.05rem;
}

.hero-visual {
    display: grid;
    min-height: 420px;
    place-items: center;
    border-radius: var(--radius);
    background: #172033;
    box-shadow: var(--shadow);
}

.contract-preview {
    width: min(82%, 420px);
    padding: 24px;
    border-radius: var(--radius);
    background: #fff;
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.22);
}

.preview-header {
    display: flex;
    gap: 7px;
    margin-bottom: 26px;
}

.preview-header span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--line);
}

.preview-line {
    height: 12px;
    margin-bottom: 14px;
    border-radius: 6px;
    background: #d9e2ef;
}

.preview-line.strong {
    width: 78%;
    height: 18px;
    background: #223251;
}

.preview-line.short {
    width: 52%;
}

.signature-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 42px;
}

.signature-grid span {
    height: 54px;
    border: 1px dashed #9aa8bd;
    border-radius: var(--radius);
}

.quick-grid,
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.info-card,
.metric-card,
.auth-card,
.table-section {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 12px 34px rgba(23, 32, 51, 0.07);
}

.info-card {
    padding: 24px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

a.info-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 42px rgba(23, 32, 51, 0.1);
}

.action-card {
    display: flex;
    min-height: 220px;
    flex-direction: column;
    align-items: flex-start;
}

.action-card .btn,
.action-card .form-control {
    margin-top: auto;
}

.action-card .form-control + .btn {
    margin-top: 14px;
}

.card-icon {
    display: inline-flex;
    margin-bottom: 18px;
    color: var(--primary-dark);
    font-weight: 900;
}

.info-card h3 {
    margin: 0 0 8px;
    font-size: 1.05rem;
}

.info-card p {
    margin: 0;
}

.metric-card {
    padding: 22px;
    border-top: 4px solid var(--primary);
}

.metric-card strong {
    display: block;
    margin-top: 8px;
    font-size: 2.4rem;
    line-height: 1;
}

.metric-card small {
    color: var(--muted);
}

.metric-card.urgent .metric-label {
    color: var(--warning);
}

.metric-card.danger {
    border-top-color: var(--danger);
}

.metric-card.danger .metric-label {
    color: var(--danger);
}

.dashboard-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
    gap: 18px;
    align-items: stretch;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
    box-shadow: 0 16px 42px rgba(23, 32, 51, 0.08);
    overflow: hidden;
}

.dashboard-hero-copy {
    padding: clamp(24px, 4vw, 42px);
}

.dashboard-hero-copy h2 {
    max-width: 780px;
    margin: 8px 0 10px;
    color: var(--ink);
    font-size: clamp(1.9rem, 3.4vw, 3.2rem);
    line-height: 1.05;
}

.dashboard-hero-copy p {
    max-width: 720px;
    margin: 0;
    color: var(--muted);
    font-size: 1.02rem;
}

.deadline-panel {
    display: flex;
    min-height: 210px;
    flex-direction: column;
    justify-content: center;
    padding: 28px;
    color: #ffffff;
    background: #172033;
}

.panel-label {
    color: #b7c4d7;
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.deadline-panel strong {
    display: block;
    margin-top: 10px;
    font-size: 4rem;
    line-height: 0.95;
}

.deadline-panel small {
    margin-top: 12px;
    color: #dce6f5;
}

.dashboard-metrics {
    grid-template-columns: repeat(5, minmax(170px, 1fr));
    gap: 12px;
}

.alerts-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.work-panel {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 12px 34px rgba(23, 32, 51, 0.07);
}

.section-heading.compact {
    padding: 18px 20px;
}

.alert-list {
    display: grid;
    gap: 10px;
    padding: 16px;
}

.deadline-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border: 1px solid #e2e8f0;
    border-left-width: 4px;
    border-radius: var(--radius);
    background: #fbfdff;
}

.deadline-item strong,
.deadline-item span {
    display: block;
}

.deadline-item strong {
    overflow-wrap: anywhere;
    font-size: 0.98rem;
}

.deadline-item div > span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.88rem;
}

.deadline-item.warning {
    border-left-color: var(--warning);
}

.deadline-item.danger {
    border-left-color: var(--danger);
    background: #fff8fa;
}

.deadline-badge,
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 900;
    white-space: nowrap;
}

.deadline-badge.warning,
.status-badge.warning {
    color: #92400e;
    background: #ffedd5;
}

.deadline-badge.danger,
.status-badge.danger {
    color: #be123c;
    background: #ffe4e6;
}

.status-badge.success {
    color: #166534;
    background: #dcfce7;
}

.status-badge.info {
    color: #1d4ed8;
    background: #dbeafe;
}

.status-badge.muted {
    color: #475569;
    background: #eef2f7;
}

.portfolio-section .data-table {
    min-width: 0;
}

.portfolio-section .table-wrapper {
    max-height: none;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.portfolio-section .col-toggle {
    width: 44px;
}

.portfolio-section .col-contract {
    width: 28%;
}

.portfolio-section .col-funding {
    width: 15%;
}

.portfolio-section .col-number {
    width: 15%;
}

.portfolio-section .col-date {
    width: 9%;
}

.portfolio-section .col-status {
    width: 15%;
}

.portfolio-section .data-table th,
.portfolio-section .data-table td {
    overflow-wrap: anywhere;
    line-height: 1.35;
}

.portfolio-section .data-table th,
.portfolio-section .data-table td {
    padding: 12px 10px;
}

.portfolio-section .data-table td:nth-child(5),
.portfolio-section .data-table td:nth-child(6),
.portfolio-section .data-table td:nth-child(7) {
    white-space: nowrap;
}

.portfolio-section .primary-cell {
    max-width: none;
}

.portfolio-section .table-code {
    display: inline-block;
    max-width: 100%;
    font-weight: 800;
    color: #334155;
    overflow-wrap: anywhere;
}

.portfolio-section .status-badge {
    max-width: 100%;
    white-space: normal;
    text-align: center;
}

.portfolio-section .avenant-row {
    background: #f8fafc;
}

.portfolio-section .avenant-row td {
    color: #475569;
}

.portfolio-section .avenant-label {
    position: relative;
    padding-left: 28px;
}

.portfolio-section .avenant-label::before {
    content: "";
    position: absolute;
    top: 21px;
    left: 12px;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #94a3b8;
}

@media (max-width: 1100px) {
    .portfolio-section .data-table {
        min-width: 980px;
    }
}

.primary-cell small {
    display: block;
    max-width: 420px;
    margin-top: 4px;
    color: var(--muted);
    font-weight: 500;
}

.nowrap {
    white-space: nowrap;
}

.empty-state.compact {
    padding: 18px;
    border: 1px dashed #cbd5e1;
    border-radius: var(--radius);
    background: #f8fafc;
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 22px;
    border-top: 1px solid var(--line);
    background: #fbfdff;
}

.pagination-pages {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.pagination-link {
    display: inline-flex;
    min-width: 38px;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    padding: 8px 11px;
    border: 1px solid #dbe3ee;
    border-radius: 8px;
    color: #475569;
    background: #ffffff;
    font-weight: 850;
}

.pagination-link:hover {
    border-color: #b9c8dd;
    color: var(--ink);
    background: #f1f5f9;
}

.pagination-link.active {
    border-color: var(--primary);
    color: #ffffff;
    background: var(--primary);
}

.pagination-link.disabled {
    pointer-events: none;
    opacity: 0.48;
}

.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 18px;
}

.confirm-modal[hidden] {
    display: none;
}

.confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(6px);
}

.confirm-dialog {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    width: min(460px, 100%);
    padding: 22px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: var(--radius);
    background: #ffffff;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.26);
}

.confirm-icon {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 8px;
    color: #be123c;
    background: #ffe4e6;
    font-size: 1.25rem;
    font-weight: 950;
}

.confirm-dialog h2 {
    margin: 0;
    color: var(--ink);
    font-size: 1.15rem;
}

.confirm-dialog p {
    margin: 6px 0 0;
    color: var(--muted);
}

.confirm-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.table-section {
    overflow: hidden;
    border-top: 4px solid #172033;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 22px;
    border-bottom: 1px solid var(--line);
}

.section-heading h2 {
    margin-top: 4px;
    font-size: 1.25rem;
}

.section-note {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-weight: 650;
}

.section-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(220px, 300px) auto;
    gap: 14px;
    align-items: end;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
    background: #fbfdff;
}

.filter-bar label {
    margin: 0;
}

.filter-bar label > span {
    display: block;
    margin-bottom: 7px;
    color: #334155;
    font-size: 0.82rem;
    font-weight: 850;
}

.search-field,
.filter-field {
    min-width: 0;
}

.filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    min-width: 1120px;
    border-collapse: collapse;
    table-layout: fixed;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.data-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    color: #475569;
    background: var(--surface-soft);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: #f8fbff;
}

.toggle-column {
    width: 54px;
}

.text-center {
    text-align: center;
}

.icon-button {
    display: inline-grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border: 1px solid #bfcef5;
    border-radius: 6px;
    color: var(--primary-dark);
    background: #edf3ff;
    font-weight: 900;
    cursor: pointer;
}

.row-index {
    display: inline-grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 6px;
    background: #edf3ff;
    color: var(--primary-dark);
    font-weight: 800;
}

.primary-cell {
    max-width: 280px;
    font-weight: 800;
}

.pill {
    display: inline-flex;
    max-width: 180px;
    overflow-wrap: anywhere;
    padding: 5px 9px;
    border-radius: 999px;
    color: #0f766e;
    background: #dff7ef;
    font-size: 0.84rem;
    font-weight: 800;
}

.pill-muted {
    color: #475569;
    background: #eef2f7;
}

.avenant-row {
    color: #475569;
    background: #fbfdff;
}

.avenant-label {
    color: var(--primary-dark);
}

.empty-state {
    padding: 36px;
    color: var(--muted);
    text-align: center;
}

.auth-layout {
    grid-template-columns: minmax(0, 0.95fr) minmax(320px, 460px);
}

.auth-card {
    align-self: start;
    padding: 28px;
}

.form-section {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(23, 32, 51, 0.06);
}

.management-form {
    padding: 24px;
}

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

.span-2 {
    grid-column: span 2;
}

.role-options {
    display: grid;
    gap: 12px;
    margin: 24px 0 0;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.role-options legend {
    padding: 0 8px;
    font-weight: 850;
}

.check-option {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    margin: 0;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.check-option input {
    grid-row: span 2;
    margin-top: 4px;
}

.check-option span {
    font-weight: 850;
}

.check-option small {
    color: var(--muted);
}

.form-actions,
.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.form-actions {
    justify-content: flex-end;
    margin-top: 24px;
}

.row-actions {
    align-items: center;
}

.row-actions form {
    margin: 0;
}

.form-heading {
    margin-bottom: 22px;
}

.form-heading h2 {
    font-size: 1.5rem;
}

label {
    display: block;
    margin: 16px 0 7px;
    color: #334155;
    font-weight: 800;
}

.form-control {
    width: 100%;
    min-height: 46px;
    padding: 11px 12px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius);
    color: var(--ink);
    background: #fff;
    font: inherit;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(30, 94, 255, 0.12);
    outline: none;
}

.auth-card .btn {
    width: 100%;
    margin-top: 20px;
}

.alert {
    padding: 12px 14px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-weight: 700;
}

.alert-danger {
    border: 1px solid #fecdd3;
    color: var(--danger);
    background: var(--danger-soft);
}

.alert-success {
    border: 1px solid #bbf7d0;
    color: #166534;
    background: #f0fdf4;
}

.alert-warning {
    border: 1px solid #fed7aa;
    color: #9a3412;
    background: #fff7ed;
}

.alert-info {
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
    background: #eff6ff;
}

@media (max-width: 980px) {
    .app-header {
        position: static;
        align-items: flex-start;
        flex-direction: column;
    }

    .main-nav,
    .topbar-actions {
        width: 100%;
    }

    .hero-section,
    .auth-layout,
    .quick-grid,
    .metrics-grid,
    .dashboard-hero,
    .alerts-layout {
        grid-template-columns: 1fr;
    }

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

    .hero-visual {
        min-height: 320px;
    }
}

@media (max-width: 640px) {
    .main-panel {
        padding: 18px;
    }

    .topbar,
    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions,
    .topbar-actions .btn,
    .section-actions,
    .section-actions .btn,
    .section-heading .btn,
    .hero-actions,
    .hero-actions .btn {
        width: 100%;
    }

    .filter-bar {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    .filter-actions,
    .filter-actions .btn {
        width: 100%;
    }

    .pagination-bar {
        align-items: stretch;
        flex-direction: column;
        padding: 16px;
    }

    .pagination-link {
        flex: 1;
    }

    .confirm-dialog {
        grid-template-columns: 1fr;
    }

    .confirm-actions,
    .confirm-actions .btn {
        width: 100%;
    }

    .main-nav a {
        flex: 1 1 100%;
    }

    .hero-copy,
    .auth-intro,
    .auth-card {
        padding: 22px;
    }

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

    .deadline-item {
        grid-template-columns: 1fr;
    }

    .form-grid,
    .span-2 {
        grid-template-columns: 1fr;
        grid-column: span 1;
    }
}
