:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #667085;
    --line: #dfe6ef;
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --success: #159947;
    --warning: #d97706;
    --danger: #dc2626;
    --sidebar: #0f172a;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a {
    text-decoration: none;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    width: 272px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--sidebar);
    color: #e5edf8;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-brand:hover {
    color: #fff;
}

.sidebar-brand-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #2563eb;
    box-shadow: 0 10px 24px rgba(37, 99, 235, .35);
}

.sidebar-brand strong,
.user-mini strong {
    display: block;
    font-size: .98rem;
    line-height: 1.2;
}

.sidebar-brand small,
.user-mini small {
    display: block;
    margin-top: 3px;
    color: #93a4bb;
    font-size: .78rem;
}

.sidebar-nav {
    flex: 1;
    padding: 14px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    margin-bottom: 4px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #a8b3c4;
    font-size: .94rem;
    font-weight: 600;
}

.sidebar-nav .nav-link i {
    width: 22px;
    font-size: 1.08rem;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    box-shadow: inset 3px 0 0 #60a5fa;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.user-mini {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.avatar {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e0f2fe;
    color: #075985;
    font-weight: 800;
}

.logout-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #cbd5e1;
    font-weight: 600;
}

.logout-link:hover {
    color: #fff;
}

.main {
    flex: 1;
    min-width: 0;
    width: 100%;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 84px;
    padding: 18px 28px;
    background: rgba(255, 255, 255, .92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.topbar h1 {
    margin: 0;
    font-size: 1.38rem;
    font-weight: 800;
    letter-spacing: 0;
}

.topbar p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: .92rem;
}

.main-content {
    width: 100%;
    max-width: none;
    padding: 28px;
}

.flash-stack {
    margin-bottom: 18px;
}

.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.section-head h2 {
    margin: 0;
    font-size: 1.16rem;
    font-weight: 800;
}

.section-head p {
    margin: 4px 0 0;
    color: var(--muted);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card,
.page-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 12px 30px rgba(15, 23, 42, .05);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
}

.stat-icon {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #eff6ff;
    color: var(--brand);
    font-size: 1.25rem;
}

.stat-card strong {
    display: block;
    font-size: 1.58rem;
    line-height: 1;
}

.stat-card span {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: .85rem;
}

.page-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}

.table {
    margin-bottom: 0;
}

.table thead th {
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    color: #667085;
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.table tbody td {
    padding: 14px 16px;
    border-color: #edf1f6;
    vertical-align: middle;
    font-size: .92rem;
}

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

.badge-soft {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 5px 10px;
    border-radius: 999px;
    font-weight: 800;
    font-size: .76rem;
}

.badge-status-pendente,
.badge-urgencia-media {
    background: #fff7ed;
    color: #b45309;
}

.badge-status-em-andamento {
    background: #eff6ff;
    color: #1d4ed8;
}

.badge-status-concluida,
.badge-situacao-aberto,
.badge-urgencia-baixa {
    background: #ecfdf3;
    color: #047857;
}

.badge-situacao-fechado {
    background: #f1f5f9;
    color: #475569;
}

.badge-urgencia-alta,
.badge-overdue {
    background: #fef2f2;
    color: #b91c1c;
}

.form-control,
.form-select,
.input-group-text {
    min-height: 44px;
    border-color: #d8e0ea;
    border-radius: 8px;
}

.input-group .form-control {
    border-radius: 0 8px 8px 0;
}

.input-group-text {
    border-radius: 8px 0 0 8px;
    background: #f8fafc;
    color: #64748b;
}

.form-label {
    color: #344054;
    font-weight: 700;
    font-size: .9rem;
}

.btn {
    min-height: 40px;
    border-radius: 8px;
    font-weight: 700;
}

.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
}

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

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

.empty-state i {
    display: block;
    margin-bottom: 12px;
    color: #94a3b8;
    font-size: 2.1rem;
}

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

.system-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
}

.system-option:hover {
    border-color: #93c5fd;
    background: #f8fbff;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px;
    background:
        linear-gradient(135deg, rgba(11, 18, 32, .94), rgba(20, 32, 51, .90)),
        url("https://images.unsplash.com/photo-1515879218367-8466d910aaa4?auto=format&fit=crop&w=1800&q=80") center/cover;
}

.login-shell {
    width: min(1080px, 100%);
    min-height: 640px;
    display: grid;
    grid-template-columns: minmax(360px, .92fr) minmax(420px, 1.08fr);
    overflow: hidden;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid rgba(226, 232, 240, .62);
    box-shadow: 0 28px 80px rgba(2, 6, 23, .42);
}

.login-aside {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 28px;
    padding: 38px;
    background:
        linear-gradient(180deg, rgba(15, 23, 42, .96), rgba(17, 24, 39, .98)),
        repeating-linear-gradient(0deg, rgba(148, 163, 184, .06) 0, rgba(148, 163, 184, .06) 1px, transparent 1px, transparent 34px),
        repeating-linear-gradient(90deg, rgba(148, 163, 184, .05) 0, rgba(148, 163, 184, .05) 1px, transparent 1px, transparent 34px);
    color: #f8fafc;
}

.login-brand,
.login-form-head,
.login-metrics {
    display: flex;
    align-items: center;
}

.login-brand {
    gap: 12px;
}

.brand-mark,
.form-icon {
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.login-aside .brand-mark {
    background: #22c55e;
    color: #052e16;
    font-size: 1.35rem;
    box-shadow: 0 14px 34px rgba(34, 197, 94, .28);
}

.login-brand strong {
    display: block;
    font-size: 1.02rem;
    line-height: 1.2;
}

.login-brand small {
    display: block;
    margin-top: 3px;
    color: #93c5fd;
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.login-aside-content {
    max-width: 390px;
}

.login-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 30px;
    padding: 5px 10px;
    border: 1px solid rgba(125, 211, 252, .24);
    border-radius: 999px;
    background: rgba(14, 165, 233, .10);
    color: #bae6fd;
    font-size: .78rem;
    font-weight: 800;
}

.login-aside h1 {
    margin: 20px 0 12px;
    font-size: clamp(2rem, 3vw, 3.08rem);
    line-height: 1.02;
    font-weight: 900;
    letter-spacing: 0;
}

.login-aside p {
    margin: 0;
    color: #cbd5e1;
    font-size: 1.02rem;
    line-height: 1.65;
}

.login-terminal {
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, .22);
    border-radius: 8px;
    background: rgba(2, 6, 23, .72);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
}

.terminal-bar {
    display: flex;
    align-items: center;
    gap: 7px;
    height: 36px;
    padding: 0 14px;
    border-bottom: 1px solid rgba(148, 163, 184, .15);
}

.terminal-bar span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
}

.terminal-bar span:nth-child(2) {
    background: #f59e0b;
}

.terminal-bar span:nth-child(3) {
    background: #22c55e;
}

.login-terminal pre {
    margin: 0;
    padding: 18px;
    color: #d1fae5;
    font-family: "Cascadia Mono", "Fira Code", Consolas, monospace;
    font-size: .92rem;
    line-height: 1.7;
    white-space: pre-wrap;
}

.login-metrics {
    justify-content: space-between;
    gap: 10px;
}

.login-metrics span {
    min-width: 0;
    color: #cbd5e1;
    font-size: .78rem;
}

.login-metrics strong {
    display: block;
    color: #f8fafc;
    font-size: 1rem;
}

.login-form-side {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 56px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(248, 250, 252, .98));
}

.login-form-head {
    gap: 14px;
    margin-bottom: 30px;
}

.form-icon {
    flex: 0 0 auto;
    background: #e0f2fe;
    color: #0369a1;
    font-size: 1.3rem;
}

.login-form-side h2 {
    margin: 0 0 6px;
    font-size: 1.72rem;
    line-height: 1.1;
    font-weight: 900;
    color: #111827;
}

.login-form-side p {
    margin: 0;
    color: var(--muted);
}

.login-field {
    margin-bottom: 18px;
}

.login-input .input-group-text,
.login-input .form-control {
    min-height: 52px;
    border-color: #cbd5e1;
    background: #fff;
}

.login-input .input-group-text {
    width: 52px;
    justify-content: center;
    color: #0f766e;
}

.login-input .form-control {
    font-weight: 650;
}

.login-input .form-control::placeholder {
    color: #94a3b8;
    font-weight: 500;
}

.login-input .form-control:focus {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 .22rem rgba(14, 165, 233, .16);
}

.login-submit {
    width: 100%;
    min-height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    margin-top: 4px;
    background: #111827;
    border-color: #111827;
    box-shadow: 0 14px 28px rgba(17, 24, 39, .18);
}

.login-submit:hover,
.login-submit:focus {
    background: #0f766e;
    border-color: #0f766e;
}

@media (max-width: 1100px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: static;
        width: 100%;
        height: auto;
    }

    .sidebar-brand,
    .sidebar-footer {
        display: none;
    }

    .sidebar-nav {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding: 10px;
    }

    .sidebar-nav .nav-link {
        flex: 0 0 auto;
        margin-bottom: 0;
        white-space: nowrap;
    }

    .topbar {
        position: static;
        align-items: flex-start;
        padding: 18px;
    }

    .main-content {
        padding: 18px;
    }

    .system-list,
    .login-shell {
        grid-template-columns: 1fr;
    }

    .login-aside {
        min-height: auto;
        padding: 32px;
    }
}

@media (max-width: 620px) {
    .topbar,
    .section-head {
        flex-direction: column;
    }

    .topbar .btn,
    .section-head .btn {
        width: 100%;
    }

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

    .login-page {
        padding: 0;
    }

    .login-shell {
        min-height: 100vh;
        border-radius: 0;
        border: 0;
    }

    .login-form-side,
    .login-aside {
        padding: 28px 20px;
    }

    .login-metrics {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .login-form-head {
        align-items: flex-start;
    }
}
