:root {
    --navy: #0f2f57;
    --navy-2: #123d70;
    --blue: #1f6fbf;
    --green: #23866a;
    --gold: #b88418;
    --red: #b74444;
    --ink: #243447;
    --muted: #6c7a89;
    --line: #dfe6ee;
    --surface: #ffffff;
    --background: #f3f6fa;
}

* {
    letter-spacing: 0;
}

body {
    color: var(--ink);
    font-size: 13px;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    text-decoration: none;
}

.btn,
.form-control,
.form-select,
.input-group-text {
    font-size: 13px;
}

.btn-primary {
    --bs-btn-bg: var(--blue);
    --bs-btn-border-color: var(--blue);
    --bs-btn-hover-bg: #195fA5;
    --bs-btn-hover-border-color: #195fA5;
    border-radius: 8px;
}

.btn-outline-primary {
    --bs-btn-color: var(--blue);
    --bs-btn-border-color: var(--blue);
    --bs-btn-hover-bg: var(--blue);
    --bs-btn-hover-border-color: var(--blue);
    border-radius: 8px;
}

.public-page {
    background: linear-gradient(135deg, #eef4f9 0%, #ffffff 48%, #eaf1f7 100%);
    min-height: 100vh;
}

.public-hero h1 {
    color: var(--navy);
    font-size: clamp(2.2rem, 5vw, 4.8rem);
    font-weight: 800;
    line-height: 1.02;
    margin: 1rem 0 1.25rem;
    max-width: 900px;
}

.public-hero .lead {
    color: #526475;
    font-size: 1.2rem;
    max-width: 720px;
}

.public-badge {
    align-items: center;
    background: #e6eff8;
    border: 1px solid #c7d8ea;
    border-radius: 999px;
    color: var(--navy);
    display: inline-flex;
    font-size: .88rem;
    font-weight: 700;
    gap: .5rem;
    padding: .45rem .85rem;
}

.public-panel {
    background: rgba(255, 255, 255, .9);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 60px rgba(15, 47, 87, .14);
    padding: 1.25rem;
}

.public-panel-top {
    background: var(--navy);
    border-radius: 6px;
    height: 64px;
    margin-bottom: 1rem;
}

.public-stat {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 1rem;
    margin-top: .85rem;
    padding: 1rem;
}

.public-stat i {
    align-items: center;
    background: #eaf3fb;
    border-radius: 8px;
    color: var(--blue);
    display: inline-flex;
    flex: 0 0 42px;
    height: 42px;
    justify-content: center;
}

.public-stat strong,
.public-stat span {
    display: block;
}

.public-stat span {
    color: var(--muted);
    font-size: .9rem;
}

.login-page {
    background: radial-gradient(circle at top left, #dbe8f4, transparent 38%), var(--background);
    min-height: 100vh;
}

.login-shell {
    align-items: center;
    display: grid;
    gap: 2rem;
    grid-template-columns: 1.1fr .9fr;
    min-height: 100vh;
    padding: 2rem 0;
}

.login-brand h1 {
    color: var(--navy);
    font-size: clamp(2rem, 4vw, 4rem);
    font-weight: 800;
    line-height: 1.05;
    margin: 1rem 0;
}

.login-brand p {
    color: #526475;
    font-size: 1.08rem;
    max-width: 680px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 22px 55px rgba(15, 47, 87, .14);
    padding: 2rem;
}

.login-icon {
    align-items: center;
    background: var(--navy);
    border-radius: 8px;
    color: #fff;
    display: inline-flex;
    height: 56px;
    justify-content: center;
    margin-bottom: 1rem;
    width: 56px;
}

.input-group-text {
    background: #eef4f9;
    border-color: #d7e1ec;
    color: var(--navy);
}

.form-control {
    border-color: #d7e1ec;
    min-height: 44px;
}

.app-page {
    background: var(--background);
    min-height: 100vh;
}

.topbar {
    align-items: center;
    background: var(--navy);
    box-shadow: 0 8px 26px rgba(15, 47, 87, .18);
    color: #fff;
    display: flex;
    justify-content: space-between;
    min-height: 72px;
    padding: .75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-brand,
.topbar-actions {
    align-items: center;
    display: flex;
    gap: .9rem;
}

.topbar-brand strong,
.topbar-brand span {
    display: block;
}

.topbar-brand strong {
    font-size: .95rem;
}

.topbar-brand span {
    color: #cbd9e8;
    font-size: .78rem;
}

.brand-mark,
.menu-toggle {
    align-items: center;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 8px;
    color: #fff;
    display: inline-flex;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.menu-toggle {
    display: none;
}

.user-chip {
    align-items: center;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 999px;
    display: flex;
    gap: .5rem;
    max-width: 280px;
    padding: .45rem .8rem;
}

.user-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-body {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: calc(100vh - 72px);
}

.sidebar {
    background: #e8eef5;
    border-right: 1px solid #d5dfeb;
    padding: 1.25rem;
}

.sidebar-title {
    color: var(--navy);
    font-size: .82rem;
    font-weight: 800;
    margin-bottom: .85rem;
    text-transform: uppercase;
}

.sidebar-nav {
    display: grid;
    gap: .72rem;
}

.sidebar-card {
    align-items: center;
    background: var(--surface);
    border: 1px solid #dce5ef;
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(15, 47, 87, .06);
    color: var(--ink);
    display: grid;
    gap: .1rem .75rem;
    grid-template-columns: 38px 1fr;
    min-height: 64px;
    padding: .75rem;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.sidebar-card i {
    align-items: center;
    background: #edf4fb;
    border-radius: 8px;
    color: var(--blue);
    display: inline-flex;
    height: 38px;
    justify-content: center;
    width: 38px;
}

.sidebar-card span {
    font-size: .9rem;
    font-weight: 700;
}

.sidebar-card small {
    color: var(--muted);
    font-size: .75rem;
    grid-column: 2;
}

.sidebar-card:hover,
.sidebar-card.active {
    border-color: #9fc0e2;
    box-shadow: 0 12px 28px rgba(15, 47, 87, .1);
    color: var(--navy);
    transform: translateY(-1px);
}

.sidebar-card.active {
    background: #f7fbff;
}

.main-content {
    padding: 1.5rem;
}

.dashboard-header {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.dashboard-header h1,
.module-placeholder h1 {
    color: var(--navy);
    font-size: 1.45rem;
    font-weight: 800;
    margin: .15rem 0;
}

.dashboard-header p,
.module-placeholder p {
    color: var(--muted);
    font-size: .9rem;
    margin: 0;
}

.section-kicker {
    color: var(--blue);
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.dashboard-user-card {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: .75rem;
    min-width: 240px;
    padding: .9rem;
}

.dashboard-user-card i {
    color: var(--gold);
    font-size: 1.35rem;
}

.dashboard-user-card strong,
.dashboard-user-card span {
    display: block;
}

.dashboard-user-card span {
    color: var(--muted);
    font-size: .82rem;
}

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

.info-card,
.content-panel,
.module-placeholder {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(15, 47, 87, .06);
}

.info-card {
    align-items: center;
    display: flex;
    gap: .85rem;
    min-height: 104px;
    padding: 1rem;
}

.info-card span,
.info-card strong {
    display: block;
}

.info-card span {
    color: var(--muted);
    font-size: .84rem;
}

.info-card strong {
    color: var(--navy);
    font-size: .98rem;
}

.info-icon {
    align-items: center;
    border-radius: 8px;
    color: #fff;
    display: inline-flex;
    flex: 0 0 48px;
    height: 48px;
    justify-content: center;
}

.bg-blue { background: var(--blue); }
.bg-green { background: var(--green); }
.bg-gold { background: var(--gold); }
.bg-red { background: var(--red); }

.content-panel {
    margin-bottom: 1.25rem;
    padding: 1.25rem;
}

.panel-heading {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.panel-heading h2 {
    color: var(--navy);
    font-size: 1.05rem;
    font-weight: 800;
    margin: .15rem 0 0;
}

.panel-heading > i {
    color: #9aaabd;
    font-size: 1.4rem;
}

.planned-grid {
    display: grid;
    gap: .85rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.planned-item {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    display: flex;
    gap: .8rem;
    min-height: 82px;
    padding: .9rem;
    transition: background .18s ease, border-color .18s ease;
}

.planned-item:hover {
    background: #f7fbff;
    border-color: #b7d0ea;
}

.planned-item i {
    color: var(--blue);
    font-size: 1.2rem;
}

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

.planned-item span {
    color: var(--muted);
    font-size: .84rem;
}

.chart-panel {
    min-height: 280px;
}

.reports-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 1.25rem;
}

.chart-card {
    min-height: 0;
    padding: 1rem;
}

.chart-card canvas {
    display: block;
    height: 210px !important;
    max-height: 210px;
    width: 100% !important;
}

.chart-card h2 {
    color: var(--navy);
    font-size: .98rem;
    font-weight: 800;
    margin: 0 0 .75rem;
}

.chart-card .panel-heading {
    margin-bottom: .75rem;
}

.module-placeholder {
    margin: 2rem auto;
    max-width: 760px;
    padding: 2.5rem;
    text-align: center;
}

.placeholder-icon {
    align-items: center;
    background: #eaf3fb;
    border-radius: 8px;
    color: var(--blue);
    display: inline-flex;
    font-size: 1.5rem;
    height: 62px;
    justify-content: center;
    margin-bottom: 1rem;
    width: 62px;
}

.app-footer {
    align-items: center;
    background: #13283f;
    color: #cbd9e8;
    display: flex;
    font-size: .86rem;
    gap: 1rem;
    justify-content: space-between;
    padding: .85rem 1.5rem;
}

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

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

    .login-shell {
        min-height: auto;
        padding: 2rem 0;
    }

    .topbar {
        align-items: flex-start;
        gap: .75rem;
        padding: .85rem;
    }

    .topbar-actions {
        align-items: flex-end;
        flex-direction: column;
        gap: .5rem;
    }

    .topbar-brand strong {
        font-size: .95rem;
    }

    .brand-mark {
        display: none;
    }

    .menu-toggle {
        display: inline-flex;
    }

    .sidebar {
        display: none;
        padding: .85rem;
    }

    .sidebar.open {
        display: block;
    }

    .main-content {
        padding: 1rem;
    }

    .dashboard-header {
        align-items: stretch;
        flex-direction: column;
    }

    .dashboard-user-card {
        min-width: 0;
        width: 100%;
    }
}

@media (max-width: 640px) {
    .stats-grid,
    .planned-grid,
    .reports-grid {
        grid-template-columns: 1fr;
    }

    .public-panel,
    .login-card,
    .content-panel,
    .module-placeholder {
        padding: 1rem;
    }

    .chart-card canvas {
        height: 180px !important;
        max-height: 180px;
    }

    .topbar {
        flex-direction: column;
    }

    .topbar-actions,
    .topbar-actions form,
    .topbar-actions .btn,
    .user-chip {
        width: 100%;
    }

    .topbar-actions .btn {
        min-height: 40px;
    }

    .app-footer {
        align-items: flex-start;
        flex-direction: column;
        gap: .25rem;
    }
}

/* Login inspirado no modelo corporativo solicitado */
.login-page {
    background: #f4f7fb;
    min-height: 100vh;
    overflow-x: hidden;
}

.login-stage {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    position: relative;
}

.login-diagonal {
    background: #174c7f;
    clip-path: polygon(0 0, 70% 0, 26% 100%, 0 100%);
    inset: 0;
    position: fixed;
    z-index: 0;
}

.login-stage .login-shell {
    display: block;
    min-height: 0;
    padding: 0;
    position: relative;
    width: min(440px, 100%);
    z-index: 1;
}

.login-stage .login-card {
    background: #fff;
    border: 1px solid #d8e1ea;
    border-radius: 7px;
    box-shadow: 0 24px 70px rgba(20, 52, 85, .18);
    padding: 1.9rem;
}

.login-card-header {
    align-items: center;
    display: flex;
    gap: 1rem;
    margin-bottom: 1.65rem;
}

.login-card-header h1 {
    color: #102f53;
    font-size: 1.28rem;
    font-weight: 800;
    line-height: 1.15;
    margin: 0 0 .25rem;
}

.login-card-header p {
    color: #66758a;
    margin: 0;
}

.login-stage .login-icon {
    align-items: center;
    background: #15558e;
    border-radius: 7px;
    color: #fff;
    display: inline-flex;
    flex: 0 0 58px;
    font-size: 1.55rem;
    height: 58px;
    justify-content: center;
    margin: 0;
    width: 58px;
}

.login-stage .form-label {
    color: #102f53;
    font-weight: 800;
    margin-bottom: .55rem;
}

.login-stage .input-group {
    border-radius: 6px;
}

.login-stage .input-group-text {
    background: #f8fafc;
    border-color: #d5e0eb;
    border-radius: 6px 0 0 6px;
    color: #17293d;
    justify-content: center;
    width: 40px;
}

.login-stage .form-control {
    border-color: #d5e0eb;
    border-radius: 0 6px 6px 0;
    min-height: 46px;
}

.login-stage .form-control:focus {
    border-color: #7da7cf;
    box-shadow: 0 0 0 .2rem rgba(21, 85, 142, .12);
}

.btn-login {
    --bs-btn-bg: #174c7f;
    --bs-btn-border-color: #174c7f;
    --bs-btn-hover-bg: #103c66;
    --bs-btn-hover-border-color: #103c66;
    --bs-btn-active-bg: #0e3458;
    --bs-btn-active-border-color: #0e3458;
    border-radius: 7px;
    color: #fff;
    font-weight: 800;
    min-height: 48px;
}

.login-stage .alert {
    border-radius: 7px;
    font-size: .92rem;
}

@media (max-width: 760px) {
    .login-stage {
        padding: 1rem;
    }

    .login-diagonal {
        clip-path: polygon(0 0, 100% 0, 100% 34%, 0 62%);
    }

    .login-stage .login-card {
        padding: 1.35rem;
    }

    .login-card-header h1 {
        font-size: 1.08rem;
    }
}

.companies-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.companies-search {
    align-items: end;
    display: grid;
    gap: .85rem;
    grid-template-columns: minmax(240px, 1fr) auto auto auto;
}

.users-search {
    align-items: end;
    display: grid;
    gap: .85rem;
    grid-template-columns: minmax(220px, 1.4fr) minmax(130px, .6fr) minmax(150px, .7fr) minmax(180px, 1fr) auto auto;
}

.users-stats {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

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

.companies-table {
    font-size: 13px;
}

.companies-table thead th {
    background: #f5f8fb;
    color: var(--navy);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    white-space: nowrap;
}

.companies-table td {
    vertical-align: middle;
}

.status-badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: .75rem;
    font-weight: 800;
    padding: .32rem .62rem;
}

.status-active {
    background: #e5f6ef;
    color: #17684f;
}

.status-inactive {
    background: #f1f3f5;
    color: #7b3333;
}

.status-warning {
    background: #fff5d8;
    color: #8a5b00;
}

.table-actions {
    display: flex;
    gap: .35rem;
    justify-content: flex-end;
}

.table-actions form {
    margin: 0;
}

.empty-state {
    align-items: center;
    display: flex;
    flex-direction: column;
    padding: 2rem 1rem;
    text-align: center;
}

.empty-state h3 {
    color: var(--navy);
    font-size: 1.25rem;
    font-weight: 800;
    margin: .5rem 0;
}

.empty-state p {
    color: var(--muted);
}

.company-form {
    margin-bottom: 1.25rem;
}

.form-section {
    margin-bottom: 1rem;
}

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

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

.form-actions {
    display: flex;
    gap: .75rem;
    justify-content: flex-end;
}

.company-detail .detail-grid {
    display: grid;
    gap: .85rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.detail-item {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: .85rem;
}

.detail-item span,
.detail-notes span {
    color: var(--muted);
    display: block;
    font-size: .78rem;
    font-weight: 800;
    margin-bottom: .25rem;
    text-transform: uppercase;
}

.detail-item strong {
    color: var(--ink);
    display: block;
    overflow-wrap: anywhere;
}

.detail-notes {
    border-top: 1px solid var(--line);
    margin-top: 1rem;
    padding-top: 1rem;
}

.detail-notes p {
    margin-bottom: 0;
    white-space: normal;
}

.permissions-table .form-check-input {
    cursor: pointer;
    height: 1.15rem;
    width: 1.15rem;
}

.permission-category {
    margin-bottom: 1rem;
}

@media (max-width: 1100px) {
    .companies-search,
    .users-search,
    .form-grid,
    .company-detail .detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .companies-stats,
    .companies-search,
    .users-search,
    .form-grid,
    .company-detail .detail-grid {
        grid-template-columns: 1fr;
    }

    .companies-search .btn,
    .users-search .btn,
    .form-actions .btn {
        width: 100%;
    }

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

    .form-actions,
    .table-actions {
        flex-wrap: wrap;
        justify-content: stretch;
    }

    .table-actions .btn {
        min-width: 42px;
    }
}
