:root {
    --bg: #f5f7fa;
    --panel: #ffffff;
    --ink: #17202a;
    --muted: #667085;
    --line: #e3e8ef;
    --line-strong: #cdd5df;
    --nav: #ffffff;
    --accent: #155e75;
    --accent-dark: #0f4659;
    --accent-soft: #e6f3f7;
    --danger: #b42318;
    --danger-soft: #fee4e2;
    --warn: #b54708;
    --warn-soft: #fff4df;
    --ok: #067647;
    --ok-soft: #dcfae6;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

a {
    color: var(--accent);
    text-decoration: none;
}

code {
    background: #f2f4f7;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: #344054;
    font-size: 12px;
    padding: 2px 5px;
}

button,
.button {
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: 13px;
    font-weight: 650;
    min-height: 36px;
    padding: 0 12px;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

button:hover,
.button:hover {
    border-color: var(--line-strong);
}

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

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

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

.link-danger,
a.button,
button {
    white-space: nowrap;
}

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

.sidebar {
    background: var(--nav);
    border-right: 1px solid var(--line);
    color: var(--ink);
    display: flex;
    flex-direction: column;
    flex: 0 0 252px;
    padding: 20px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    align-items: center;
    display: flex;
    gap: 12px;
    margin-bottom: 28px;
    padding: 0 6px;
}

.brand-mark {
    align-items: center;
    background: var(--accent);
    border-radius: 6px;
    color: #fff;
    display: inline-flex;
    font-weight: 900;
    height: 40px;
    justify-content: center;
    width: 54px;
}

.brand strong {
    display: block;
    font-size: 15px;
}

.brand small {
    color: var(--muted);
    display: block;
    margin-top: 3px;
}

.nav {
    display: grid;
    gap: 4px;
}

.nav-section {
    color: #98a2b3;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    margin: 14px 10px 5px;
    text-transform: uppercase;
}

.nav a {
    border-radius: 6px;
    color: #344054;
    font-weight: 650;
    padding: 10px 12px;
}

.nav a:hover,
.nav a.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.logout {
    margin-top: auto;
}

.logout button {
    width: 100%;
    color: var(--muted);
}

.content {
    flex: 1;
    max-width: 100%;
    padding: 28px 32px;
}

.content > * {
    max-width: 1480px;
}

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

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

.eyebrow {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    margin: 0 0 4px;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
}

h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0;
}

h2 {
    font-size: 17px;
    font-weight: 700;
}

.user-chip {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: #344054;
    font-size: 13px;
    font-weight: 650;
    padding: 8px 12px;
}

.alert {
    border-radius: 6px;
    border: 1px solid transparent;
    font-weight: 650;
    margin-bottom: 16px;
    padding: 11px 13px;
}

.alert-success {
    background: var(--ok-soft);
    border-color: #abefc6;
    color: #1f6846;
}

.alert-error {
    background: var(--danger-soft);
    border-color: #fecdca;
    color: #8d2d20;
}

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

.metrics-grid.compact .metric strong {
    font-size: 22px;
}

.metric,
.panel,
.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric {
    overflow: hidden;
    padding: 16px;
    position: relative;
}

.metric::before {
    background: var(--accent);
    content: "";
    height: 3px;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
}

.metric.danger::before {
    background: var(--danger);
}

.metric span {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 700;
}

.metric strong {
    display: block;
    font-size: 28px;
    font-weight: 750;
    margin-top: 6px;
    word-break: break-word;
}

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

.panel {
    margin-bottom: 18px;
    padding: 0;
}

.panel-heading {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 0;
    padding: 18px 18px 14px;
}

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

.toolbar {
    border-top: 1px solid var(--line);
    display: flex;
    gap: 10px;
    margin-bottom: 0;
    padding: 14px 18px;
}

input,
select,
textarea {
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--ink);
    font: inherit;
    min-height: 38px;
    padding: 8px 10px;
    width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(21, 94, 117, 0.12);
    outline: 0;
}

textarea {
    resize: vertical;
}

.toolbar input {
    max-width: 420px;
}

.table-wrap {
    background: #fff;
    border: 1px solid var(--line);
    border-left: 0;
    border-radius: 0 0 8px 8px;
    border-right: 0;
    border-bottom: 0;
    overflow-x: auto;
}

.compact-table {
    border: 1px solid var(--line);
    border-radius: 8px;
}

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

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

th {
    background: #f8fafc;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    white-space: nowrap;
}

tbody tr:hover {
    background: #fbfcfe;
}

td:first-child,
th:first-child {
    padding-left: 18px;
}

td:last-child,
th:last-child {
    padding-right: 18px;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.badge {
    border-radius: 999px;
    display: inline-block;
    font-size: 12px;
    font-size: 11px;
    font-weight: 800;
    padding: 4px 8px;
    text-transform: uppercase;
}

.badge-baixa {
    background: var(--ok-soft);
    color: var(--ok);
}

.badge-media {
    background: var(--warn-soft);
    color: var(--warn);
}

.badge-alta,
.badge-critica {
    background: var(--danger-soft);
    color: var(--danger);
}

.actions {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    white-space: nowrap;
}

.actions a {
    border: 1px solid var(--line);
    border-radius: 5px;
    color: #344054;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 8px;
}

.actions a:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.inline-form {
    align-items: center;
    display: flex;
    gap: 8px;
}

.inline-form select {
    min-width: 150px;
    width: auto;
}

.inline-form button {
    min-height: 34px;
}

.actions form {
    display: inline;
}

.link-danger {
    background: none;
    border: 0;
    color: var(--danger);
    min-height: auto;
    padding: 0;
}

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

.form-grid {
    border-top: 1px solid var(--line);
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 18px;
}

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

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

.auth-content {
    background: linear-gradient(180deg, #f8fafc 0%, #eef3f7 100%);
    display: grid;
    min-height: 100vh;
    place-items: center;
    width: 100%;
}

.login-panel {
    display: grid;
    gap: 30px;
    grid-template-columns: 1fr 360px;
    max-width: 860px;
    padding: 32px;
    width: calc(100% - 36px);
}

.login-panel .brand-mark {
    box-shadow: 0 10px 24px rgba(21, 94, 117, .16);
}

.login-copy h1 {
    font-size: 32px;
    font-weight: 750;
    margin: 18px 0 10px;
}

.login-copy p {
    color: var(--muted);
    font-size: 16px;
    line-height: 1.5;
    max-width: 470px;
}

.auth-form {
    align-content: center;
    display: grid;
    gap: 14px;
}

.form-actions {
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: flex-end;
    margin-top: 0;
    padding: 14px 18px 18px;
}

.login-actions {
    display: flex;
    justify-content: flex-end;
}

.help-text {
    color: var(--muted);
    line-height: 1.5;
}

.two-columns {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 18px;
}

.mini-table {
    margin-top: 12px;
    min-width: 100%;
}

.two-columns > div {
    min-width: 0;
}

.two-columns h2 {
    margin-bottom: 12px;
}

.panel > h2,
.panel > .help-text {
    padding-left: 18px;
    padding-right: 18px;
}

.panel > h2:first-child {
    padding-top: 18px;
}

.panel > .help-text:last-child {
    padding-bottom: 18px;
}

@media (max-width: 900px) {
    .app-shell,
    .topbar,
    .panel-heading,
    .login-panel {
        display: block;
    }

    .sidebar {
        display: block;
        flex: none;
        height: auto;
        padding: 16px;
        position: static;
    }

    .nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-bottom: 12px;
    }

    .content {
        padding: 16px;
    }

    .topbar-actions {
        margin-top: 12px;
    }

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

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

    .panel-heading .button,
    .panel-heading button {
        margin-top: 12px;
    }

    .toolbar {
        display: grid;
    }
}
