:root {
    --bg: #f5f7fa;
    --panel: #ffffff;
    --panel-soft: #f9fbfd;
    --text: #101828;
    --muted: #667085;
    --line: #d9e0ea;
    --line-strong: #c7d0dd;
    --primary: #0f766e;
    --primary-dark: #0b5f59;
    --blue: #2563eb;
    --green: #16803c;
    --yellow: #9a6a00;
    --orange: #c2410c;
    --red: #b42318;
    --gray: #667085;
    --shadow: 0 10px 28px rgba(16, 24, 40, 0.08);
    --radius: 8px;
    --sidebar: 278px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

[hidden] {
    display: none !important;
}

.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(180deg, rgba(245, 247, 250, 0.94), rgba(235, 240, 247, 0.96)),
        url("data:image/svg+xml,%3Csvg width='1200' height='700' viewBox='0 0 1200 700' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23c8d3e1' stroke-width='1'%3E%3Cpath d='M0 84h1200M0 168h1200M0 252h1200M0 336h1200M0 420h1200M0 504h1200M0 588h1200M120 0v700M240 0v700M360 0v700M480 0v700M600 0v700M720 0v700M840 0v700M960 0v700M1080 0v700'/%3E%3C/g%3E%3Cg fill='%230f766e' fill-opacity='.12'%3E%3Crect x='180' y='118' width='160' height='74' rx='6'/%3E%3Crect x='422' y='260' width='240' height='96' rx='6'/%3E%3Crect x='782' y='146' width='190' height='84' rx='6'/%3E%3Crect x='826' y='420' width='220' height='90' rx='6'/%3E%3C/g%3E%3C/svg%3E");
    background-size: cover;
}

.login-panel {
    width: min(438px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px;
}

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

.brand-mark.small {
    width: 40px;
    height: 40px;
    font-size: 14px;
}

.eyebrow {
    margin: 20px 0 6px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    font-size: 30px;
    line-height: 1.15;
    margin-bottom: 12px;
}

h2 {
    font-size: 22px;
    margin-bottom: 8px;
}

h3 {
    font-size: 16px;
    margin-bottom: 8px;
}

.login-copy {
    color: var(--muted);
    line-height: 1.55;
    margin-bottom: 24px;
}

.form-stack {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    color: #344054;
    font-size: 13px;
    font-weight: 650;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--text);
    background: #fff;
    padding: 10px 11px;
    outline: none;
}

textarea {
    min-height: 90px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 9px 13px;
    font-weight: 750;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

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

.secondary-button {
    background: #fff;
    border-color: var(--line-strong);
    color: var(--text);
}

.ghost-button {
    background: transparent;
    color: var(--muted);
}

.danger-button {
    background: #fff1f0;
    color: var(--red);
    border-color: #ffd1cc;
}

.form-error {
    min-height: 18px;
    color: var(--red);
    font-size: 13px;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar) 1fr;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    background: #ffffff;
    padding: 18px 14px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 6px 18px;
    border-bottom: 1px solid var(--line);
}

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

.sidebar-brand span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.sidebar-nav {
    display: grid;
    gap: 4px;
    padding: 14px 0 30px;
}

.nav-group {
    padding: 14px 10px 5px;
    color: #98a2b3;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.nav-button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #344054;
    padding: 9px 10px;
    text-align: left;
    font-weight: 650;
}

.nav-button .nav-icon {
    width: 22px;
    color: var(--muted);
    text-align: center;
}

.nav-button:hover,
.nav-button.active {
    background: #edf7f5;
    color: var(--primary-dark);
}

.main-shell {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 66px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 22px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.search-wrap {
    position: relative;
    flex: 1;
    min-width: 180px;
}

.search-wrap input {
    padding-left: 36px;
    background: #f8fafc;
}

.search-wrap::before {
    content: "";
    position: absolute;
    left: 13px;
    top: 50%;
    width: 13px;
    height: 13px;
    border: 2px solid #98a2b3;
    border-radius: 50%;
    transform: translateY(-58%);
    z-index: 1;
}

.search-wrap::after {
    content: "";
    position: absolute;
    left: 25px;
    top: 34px;
    width: 7px;
    height: 2px;
    background: #98a2b3;
    transform: rotate(45deg);
    z-index: 1;
}

.search-results {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 8px);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-height: 360px;
    overflow-y: auto;
    padding: 8px;
}

.search-result {
    border-radius: 6px;
    padding: 10px;
}

.search-result:hover {
    background: var(--panel-soft);
}

.search-result strong,
.search-result span {
    display: block;
}

.search-result span {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.alert-button {
    position: relative;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: #fff;
}

.alert-button strong {
    position: absolute;
    right: -5px;
    top: -6px;
    min-width: 19px;
    height: 19px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
    font-size: 11px;
}

.bell-shape {
    width: 16px;
    height: 17px;
    display: inline-block;
    border: 2px solid #344054;
    border-bottom: 0;
    border-radius: 10px 10px 4px 4px;
    position: relative;
    margin-top: 4px;
}

.bell-shape::after {
    content: "";
    position: absolute;
    left: 3px;
    bottom: -5px;
    width: 8px;
    height: 2px;
    background: #344054;
    border-radius: 3px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
}

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

.user-chip button {
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 8px 10px;
    font-weight: 700;
}

.global-filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    padding: 16px 22px 0;
}

.global-filters label {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 9px 10px;
}

.global-filters select {
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    padding: 7px 0 0;
    box-shadow: none;
}

.view-root {
    padding: 22px;
}

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

.view-head p {
    color: var(--muted);
    margin-bottom: 0;
    max-width: 840px;
}

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

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

.kpi-card,
.panel,
.mini-card,
.tool-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.kpi-card {
    min-height: 124px;
    padding: 16px;
    display: grid;
    align-content: space-between;
}

.kpi-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.kpi-card strong {
    font-size: 25px;
    line-height: 1.15;
}

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

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.55fr 1fr;
    gap: 16px;
}

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

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.panel-head p {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 0;
}

.chart-wrap {
    height: 310px;
    position: relative;
}

.chart-wrap canvas {
    width: 100%;
    height: 100%;
}

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

.rank-item {
    display: grid;
    gap: 6px;
}

.rank-line {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
}

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

.bar-fill {
    height: 100%;
    width: var(--value);
    background: var(--primary);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 24px;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 750;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: currentColor;
}

.badge.active,
.badge.paid,
.badge.success,
.badge.confirmed,
.badge.healthy,
.badge.Saudável {
    color: var(--green);
    background: #edfdf3;
    border-color: #c8f2d8;
}

.badge.warning,
.badge.open,
.badge.requested,
.badge.imported,
.badge.alto {
    color: var(--yellow);
    background: #fff8e6;
    border-color: #ffe6a3;
}

.badge.high,
.badge.risk,
.badge.manual,
.badge.baixa,
.badge.baixa-utilização {
    color: var(--orange);
    background: #fff3ea;
    border-color: #ffd8bf;
}

.badge.critical,
.badge.overdue,
.badge.expired,
.badge.terminated,
.badge.crítico,
.badge.excedido {
    color: var(--red);
    background: #fff1f0;
    border-color: #ffd1cc;
}

.badge.inactive,
.badge.draft,
.badge.revoked,
.badge.suspended,
.badge.estimated {
    color: var(--gray);
    background: #f2f4f7;
    border-color: #e4e7ec;
}

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

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

.mini-card {
    padding: 14px;
}

.mini-card strong {
    display: block;
    font-size: 22px;
    margin-top: 6px;
}

.mini-card span,
.muted {
    color: var(--muted);
}

.table-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
}

.table-toolbar input {
    max-width: 320px;
    background: #f8fafc;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
    font-size: 13px;
}

th {
    color: #475467;
    background: #f8fafc;
    font-weight: 800;
    user-select: none;
}

th.sortable {
    cursor: pointer;
}

tr:hover td {
    background: #fbfcfe;
}

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 12px;
    color: var(--muted);
    font-size: 13px;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pagination button {
    width: 34px;
    height: 32px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: #fff;
}

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

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

.tool-card {
    padding: 15px;
    display: grid;
    gap: 13px;
}

.tool-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.tool-logo {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: #fff;
    background: #334155;
    font-weight: 800;
}

.tool-card h3 {
    margin: 0;
}

.tool-card dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
}

.tool-card dt {
    color: var(--muted);
    font-size: 12px;
}

.tool-card dd {
    margin: 3px 0 0;
    font-weight: 750;
}

.progress {
    display: grid;
    gap: 7px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 12px;
}

.matrix-panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: auto;
}

.matrix-panel table {
    min-width: 900px;
}

.matrix-cell {
    min-width: 96px;
    text-align: center;
}

.access-dot {
    width: 28px;
    height: 28px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: #eef4ff;
    color: var(--blue);
    font-weight: 900;
    border: 1px solid #c7d7fe;
}

.access-dot.empty {
    background: #f2f4f7;
    color: #98a2b3;
    border-color: #e4e7ec;
}

.modal-root,
.drawer-root {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(16, 24, 40, 0.36);
}

.modal-card {
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(720px, calc(100vw - 30px));
    max-height: calc(100vh - 44px);
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.modal-head,
.modal-foot,
.drawer-head {
    padding: 16px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-foot {
    border-top: 1px solid var(--line);
    border-bottom: 0;
}

.modal-body {
    padding: 16px;
    overflow-y: auto;
}

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

.form-grid label.full {
    grid-column: 1 / -1;
}

.close-button,
.icon-button {
    width: 36px;
    height: 36px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
}

.drawer-card {
    position: absolute;
    right: 0;
    top: 0;
    width: min(520px, 100vw);
    height: 100%;
    background: #fff;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-rows: auto 1fr;
}

.drawer-body {
    overflow-y: auto;
    padding: 16px;
}

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

.detail-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.detail-row span {
    color: var(--muted);
}

.toast-root {
    position: fixed;
    right: 18px;
    bottom: 18px;
    display: grid;
    gap: 10px;
    z-index: 80;
}

.toast {
    width: min(360px, calc(100vw - 36px));
    background: #101828;
    color: #fff;
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: var(--shadow);
}

.tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 16px;
    overflow-x: auto;
}

.tab-button {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 10px 8px;
    font-weight: 750;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.tab-button.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.mobile-only {
    display: none;
}

.mobile-only span {
    display: block;
    width: 18px;
    height: 2px;
    margin: 3px auto;
    background: #344054;
}

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

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

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

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

    .sidebar {
        position: fixed;
        left: -290px;
        top: 0;
        z-index: 60;
        width: 280px;
        transition: left 180ms ease;
    }

    body.sidebar-open .sidebar {
        left: 0;
    }

    .mobile-only {
        display: inline-block;
        flex: 0 0 auto;
    }

    .topbar {
        padding: 10px 14px;
        flex-wrap: wrap;
    }

    .user-chip span {
        display: none;
    }

    .global-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 14px;
    }

    .view-root {
        padding: 14px;
    }

    .tool-grid,
    .kpi-grid {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 560px) {
    .login-panel {
        padding: 22px;
    }

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

    .view-head {
        display: grid;
    }

    .table-toolbar,
    .table-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .table-toolbar input {
        max-width: none;
    }
}
