/*
  Sistema visual do APS Monitor, portado do protótipo estático em /prototipo
  (mesma paleta, tipografia e componentes: sidebar, cards, grid, tabelas, login).
*/

:root {
    --bg: #f5f7fb;
    --card: #fff;
    --ink: #172033;
    --muted: #6d778b;
    --line: #e5e9f1;
    --primary: #2563eb;
    --primary2: #eaf1ff;
    --good: #16a36a;
    --warn: #f59e0b;
    --bad: #e5484d;
    --purple: #7c3aed;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--ink);
}

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

select, input, textarea {
    border: 1px solid #d9deea;
    background: #fff;
    border-radius: 9px;
    padding: 10px 12px;
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
}

button {
    font: inherit;
}

/* ===== Shell do aplicativo (pós-login) ===== */

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

aside {
    width: 258px;
    background: #101828;
    color: #fff;
    position: fixed;
    inset: 0 auto 0 0;
    padding: 22px 14px;
    display: flex;
    flex-direction: column;
    z-index: 20;
    transition: transform 0.2s ease-in-out;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 22px;
}

.logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #14b8a6);
    display: grid;
    place-items: center;
    font-weight: 800;
    flex-shrink: 0;
}

.brand b {
    display: block;
    font-size: 17px;
}

.brand small, .user small {
    display: block;
    color: #9ca9bd;
    margin-top: 2px;
}

nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: auto;
}

.nav-section {
    font-size: 10px;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: .12em;
    padding: 18px 12px 7px;
}

.nav-item {
    display: block;
    border: 0;
    background: transparent;
    color: #c9d2e2;
    text-align: left;
    padding: 10px 12px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
}

    .nav-item:hover, .nav-item.active {
        background: #1d2939;
        color: #fff;
    }

.user {
    margin-top: auto;
    border-top: 1px solid #27364b;
    padding: 16px 8px 0;
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 12px;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #344054;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.logout-btn {
    margin-left: auto;
    border: 0;
    background: transparent;
    color: #9ca9bd;
    cursor: pointer;
    font-size: 16px;
}

.app-main {
    margin-left: 258px;
    width: calc(100% - 258px);
}

header {
    min-height: 88px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 18px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 5;
}

h1 {
    font-size: 22px;
}

header p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
}

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

.icon {
    position: relative;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 9px;
    padding: 9px 11px;
}

.dot {
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--bad);
    right: 7px;
    top: 6px;
}

.menu-toggle {
    display: none;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 9px;
    padding: 9px 11px;
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
}

#app-content {
    padding: 24px 28px 42px;
}

/* ===== Componentes de conteúdo ===== */

.toolbar {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

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

.btn {
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 10px 14px;
    cursor: pointer;
    background: #fff;
    color: var(--ink);
    text-decoration: none;
    display: inline-block;
}

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

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

.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 1px 2px #10182808;
}

.span3 { grid-column: span 3; }
.span4 { grid-column: span 4; }
.span5 { grid-column: span 5; }
.span6 { grid-column: span 6; }
.span7 { grid-column: span 7; }
.span8 { grid-column: span 8; }
.span12 { grid-column: span 12; }

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

.kpi strong {
    display: block;
    font-size: 27px;
    margin: 9px 0 4px;
}

.trend {
    font-size: 12px;
}

.good { color: var(--good); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

.card h3 {
    font-size: 15px;
    margin: 0 0 15px;
}

.progress {
    height: 8px;
    background: #eef1f6;
    border-radius: 99px;
    overflow: hidden;
}

    .progress span {
        display: block;
        height: 100%;
        background: var(--primary);
        border-radius: 99px;
    }

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 11px 0;
}

.pill {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 99px;
    background: #eef2f7;
    color: #566176;
}

.pill.good { background: #e8f8f1; color: #087a4c; }
.pill.warn { background: #fff5dc; color: #a36200; }
.pill.bad { background: #ffeded; color: #bd2b31; }

.indicator {
    padding: 14px 0;
    border-bottom: 1px solid #edf0f5;
}

    .indicator:last-child {
        border: 0;
    }

.indicator-top {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 8px;
}

.indicator b {
    font-size: 13px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    text-align: left;
    color: #667085;
    font-weight: 600;
    background: #f8fafc;
}

th, td {
    padding: 12px;
    border-bottom: 1px solid #edf0f5;
}

tr:hover td {
    background: #fbfcff;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th.sortable:hover {
    color: var(--text, #1a1d29);
}

.name {
    font-weight: 650;
}

.sub {
    display: block;
    color: var(--muted);
    font-size: 11px;
    margin-top: 3px;
}

.bar-chart {
    height: 220px;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding-top: 20px;
}

.bar {
    flex: 1;
    background: #dbe7ff;
    border-radius: 6px 6px 0 0;
    position: relative;
    min-width: 18px;
}

    .bar.highlight {
        background: #4d7df3;
    }

    .bar label {
        position: absolute;
        bottom: -23px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 10px;
        color: #7a8495;
    }

    .bar em {
        position: absolute;
        top: -20px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 10px;
        font-style: normal;
    }

.alert {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    margin: 9px 0;
    display: flex;
    gap: 10px;
}

    .alert i {
        font-style: normal;
    }

.big-score {
    font-size: 48px;
    font-weight: 800;
}

.ring {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    position: relative;
    flex-shrink: 0;
}

    .ring:after {
        content: "";
        position: absolute;
        width: 88px;
        height: 88px;
        border-radius: 50%;
        background: #fff;
    }

    .ring span {
        z-index: 1;
        font-weight: 800;
        font-size: 22px;
    }

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

.field label {
    display: block;
    font-size: 12px;
    color: #667085;
    margin-bottom: 6px;
}

.field input, .field select, .field textarea {
    width: 100%;
}

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

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

.tab {
    padding: 10px 12px;
    border: 0;
    background: none;
    color: var(--muted);
}

    .tab.active {
        color: var(--primary);
        border-bottom: 2px solid var(--primary);
    }

@media (max-width: 1050px) {
    aside {
        width: 78px;
    }

    .brand div:not(.logo), .nav-item span, .nav-section, .user div:not(.avatar) {
        display: none;
    }

    .app-main {
        margin-left: 78px;
        width: calc(100% - 78px);
    }

    .span3, .span4 {
        grid-column: span 6;
    }
}

@media (max-width: 700px) {
    .menu-toggle {
        display: inline-block;
    }

    aside {
        transform: translateX(-100%);
        width: 258px;
    }

        aside.aberto {
            transform: translateX(0);
        }

            aside.aberto .brand div:not(.logo), aside.aberto .nav-item span, aside.aberto .nav-section, aside.aberto .user div:not(.avatar) {
                display: initial;
            }

    .sidebar-overlay.aberto {
        display: block;
        position: fixed;
        inset: 0;
        background: #10182880;
        z-index: 15;
    }

    .app-main {
        margin: 0;
        width: 100%;
    }

    header {
        padding: 14px 16px;
    }

        header select {
            display: none;
        }

    #app-content {
        padding: 16px;
    }

    .grid > * {
        grid-column: span 12 !important;
    }

    .toolbar {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* ===== Login / registro / landing (telas de tela cheia) ===== */

.login-page {
    min-height: 100vh;
    width: 100%;
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    background: #fff;
}

.login-hero {
    padding: 64px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: linear-gradient(145deg, #0f172a, #153e75 58%, #0f766e);
    color: #fff;
    position: relative;
    overflow: hidden;
}

    .login-hero:after {
        content: "";
        position: absolute;
        width: 420px;
        height: 420px;
        border-radius: 50%;
        background: #ffffff0b;
        right: -100px;
        bottom: -120px;
    }

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    z-index: 1;
}

    .login-brand .logo {
        width: 48px;
        height: 48px;
    }

    .login-brand b {
        font-size: 20px;
        display: block;
    }

    .login-brand small {
        color: #c7d2e3;
    }

.hero-copy {
    max-width: 620px;
    position: relative;
    z-index: 1;
}

    .hero-copy h2 {
        font-size: 42px;
        line-height: 1.12;
        margin: 0 0 18px;
    }

    .hero-copy p {
        font-size: 17px;
        line-height: 1.65;
        color: #d9e4f2;
        max-width: 560px;
    }

.hero-points {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 34px;
}

.hero-point {
    padding: 15px;
    border: 1px solid #ffffff22;
    background: #ffffff0d;
    border-radius: 14px;
}

    .hero-point b {
        display: block;
        font-size: 13px;
        margin-bottom: 4px;
    }

    .hero-point span {
        font-size: 11px;
        color: #d9e4f2;
    }

.login-foot {
    font-size: 11px;
    color: #bdcadb;
    position: relative;
    z-index: 1;
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    background: #f8fafc;
}

.login-box {
    width: 100%;
    max-width: 430px;
}

    .login-box h1 {
        font-size: 30px;
        margin-bottom: 8px;
    }

    .login-box > p {
        color: var(--muted);
        margin: 0 0 30px;
    }

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

    .login-field label {
        display: block;
        font-size: 12px;
        font-weight: 650;
        margin-bottom: 7px;
    }

    .login-field input {
        width: 100%;
        height: 46px;
    }

.login-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    margin: 2px 0 20px;
}

    .login-row label {
        display: flex;
        gap: 7px;
        align-items: center;
        color: #596579;
    }

    .login-row input {
        width: auto;
    }

.login-link {
    color: var(--primary);
    text-decoration: none;
}

.login-btn {
    width: 100%;
    height: 46px;
    font-weight: 600;
}

.login-demo {
    margin-top: 20px;
    padding: 13px 14px;
    border: 1px solid #dbe5f5;
    background: #f0f6ff;
    border-radius: 10px;
    font-size: 12px;
    color: #526177;
}

.login-error {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 9px;
    background: #ffeded;
    color: #bd2b31;
    font-size: 12px;
}

.login-security {
    text-align: center;
    color: #8490a3;
    font-size: 11px;
    margin-top: 26px;
}

@media (max-width: 850px) {
    .login-page {
        grid-template-columns: 1fr;
    }

    .login-hero {
        display: none;
    }

    .login-panel {
        min-height: 100vh;
        padding: 24px;
    }
}

.clickable {
    cursor: pointer;
}

.clickable:hover {
    background: var(--primary2);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(23, 32, 51, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    background: var(--card);
    border-radius: 12px;
    padding: 20px 24px;
    min-width: 360px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(23, 32, 51, 0.25);
}

.modal-box h3 {
    margin: 0 0 4px;
}

.modal-close {
    float: right;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 18px;
    color: var(--muted);
}

