/* Pulse Monitor — Design moderno e elegante */
/* Tokens de cor (claro / escuro) */

:root {
    --bg: #f2f4f7;
    --surface: #ffffff;
    --surface-2: #f4f6f9;
    --border: #e2e6ea;
    --text: #17202c;
    --muted: #5c6876;
    --quiet: #8b97a5;
    --accent: #3e63dd;
    --accent-600: #2c4ec2;
    --accent-bg: #eef2ff;
    --success: #2b8a78;
    --success-bg: #e8f4f0;
    --danger: #d34848;
    --danger-bg: #fbecec;
    --shadow: 0 6px 24px rgba(23, 32, 44, 0.06);
    --shadow-sm: 0 2px 8px rgba(23, 32, 44, 0.04);
    --radius: 14px;
    --radius-sm: 10px;
    --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color-scheme: light
}

:root[data-theme=dark] {
    --bg: #131821;
    --surface: #1b212c;
    --surface-2: #232a36;
    --border: #2e3744;
    --text: #e9edf1;
    --muted: #9aa5b2;
    --quiet: #6c7785;
    --accent: #6b8cff;
    --accent-600: #5a77e6;
    --accent-bg: #263154;
    --success: #56b8a0;
    --success-bg: #1e3a33;
    --danger: #e37777;
    --danger-bg: #3d2a2a;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    color-scheme: dark
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme=light]) {
        --bg: #131821;
        --surface: #1b212c;
        --surface-2: #232a36;
        --border: #2e3744;
        --text: #e9edf1;
        --muted: #9aa5b2;
        --quiet: #6c7785;
        --accent: #6b8cff;
        --accent-600: #5a77e6;
        --accent-bg: #263154;
        --success: #56b8a0;
        --success-bg: #1e3a33;
        --danger: #e37777;
        --danger-bg: #3d2a2a;
        --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
        --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
        color-scheme: dark
    }
}

*,
*::before,
*::after {
    box-sizing: border-box
}

html,
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    font-feature-settings: "tnum";
    -webkit-font-smoothing: antialiased
}

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

a {
    color: inherit;
    text-decoration: none
}

button {
    cursor: pointer;
    border: none;
    background: transparent
}

::selection {
    background: var(--accent);
    color: #fff
}

/* ---------- Login ---------- */

.login-page {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at top, var(--accent-bg), var(--bg) 40%)
}

.login-card {
    width: min(390px, calc(100% - 32px));
    padding: 40px 32px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow)
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
    font-size: 22px;
    margin-bottom: 24px
}

.eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.4px;
    color: var(--quiet);
    margin: 0 0 6px;
    text-transform: uppercase
}

.login-card h1 {
    font-size: 27px;
    letter-spacing: -0.8px;
    margin: 0 0 8px;
    color: var(--text)
}

.muted {
    color: var(--muted);
    margin: 0 0 28px;
    font-size: 15px
}

.login-card label,
.field {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    margin: 0 0 8px;
    letter-spacing: 0.2px
}

.login-card input,
.field input {
    display: block;
    width: 100%;
    height: 46px;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-top: 6px;
    padding: 0 14px;
    background: var(--surface-2);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s
}

.login-card input:focus,
.field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent)
}

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    padding: 0 16px;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s, border-color 0.2s
}

.button:hover {
    background: var(--surface-2)
}

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

.button.primary:hover {
    background: var(--accent-600);
    border-color: var(--accent-600)
}

.button.full {
    width: 100%;
    justify-content: space-between
}

.button.small {
    min-height: 34px;
    padding: 0 10px;
    font-size: 12.5px
}

.button.danger {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 35%, var(--border))
}

.button.danger:hover {
    background: var(--danger-bg)
}

.form-error {
    font-size: 12px;
    color: var(--danger);
    text-align: center;
    margin: 16px 0 0;
    min-height: 18px
}

.form-success {
    font-size: 12px;
    color: var(--success);
    text-align: center;
    margin: 16px 0 0;
    min-height: 18px
}

/* ---------- App shell ---------- */

.app-shell {
    display: grid;
    grid-template-columns: 230px 1fr;
    min-height: 100dvh
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: 28px 16px 24px;
    border-right: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    z-index: 10
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 17px;
    font-weight: 700;
    padding: 0 6px 30px;
    color: var(--text)
}

.logo-symbol {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    background: var(--accent-bg);
    color: var(--accent-600);
    border-radius: 11px;
    font-weight: 800
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 5px
}

.nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: var(--muted);
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s, color 0.2s
}

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

.sidebar-foot {
    margin-top: auto;
    padding: 16px 6px 0;
    font-size: 12px;
    color: var(--quiet)
}

.sidebar-foot {
    margin-top: auto;
    padding: 14px 6px 0;
    font-size: 12px;
    color: var(--quiet);
    display: flex;
    align-items: center;
    gap: 10px
}
.sidebar-version {
    color: var(--quiet);
    font-weight: 700;
    font-size: 12px
}
.sidebar-version span {
    font-weight: 500;
    opacity: 0.8
}
.sidebar-account {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1
}
.account-avatar,
.topbar-avatar {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--accent-bg);
    color: var(--accent-600);
    font-weight: 700
}
.account-name {
    display: flex;
    flex-direction: column;
    min-width: 0;
    color: var(--text);
    font-size: 11px
}
.account-name small {
    color: var(--quiet);
    font-size: 10px
}
.account-settings {
    color: var(--muted);
    padding: 6px;
    border-radius: 7px
}
.account-settings:hover {
    color: var(--text);
    background: var(--surface-2)
}
.logout-link {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap
}
.logout-link span {
    opacity: 0.7
}
.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 12px
}
.topbar-avatar {
    width: 30px;
    height: 30px
}
.main {
    min-width: 0;
    display: flex;
    flex-direction: column
}

.topbar {
    height: 74px;
    border-bottom: 1px solid var(--border);
    padding: 0 clamp(24px, 4vw, 72px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 20
}

.topbar .updated {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500
}

.topbar .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success)
}

.content {
    max-width: 1440px;
    margin: 0 auto;
    padding: clamp(28px, 4vw, 60px) clamp(24px, 4vw, 72px) 72px;
    width: 100%
}

.content-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px
}

.content-head h1 {
    font-size: 26px;
    letter-spacing: -0.8px;
    margin: 0 0 6px
}

.content-head p {
    margin: 0;
    color: var(--muted);
    font-size: 14.5px
}

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

/* ---------- KPI cards ---------- */

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

.kpi {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    padding: 20px 20px 16px;
    box-shadow: var(--shadow-sm)
}

.kpi-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 16px;
    letter-spacing: 0.2px
}

.kpi-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    background: var(--surface-2);
    border-radius: 10px;
    color: var(--quiet)
}

.kpi-value {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 6px
}

.kpi-foot {
    display: flex;
    gap: 16px;
    color: var(--quiet);
    font-size: 12px;
    font-weight: 500
}

.kpi-foot .success {
    color: var(--success)
}

.kpi-foot .danger {
    color: var(--danger)
}

/* ---------- Panels ---------- */

.panel {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border)
}

.panel-head h2 {
    font-size: 15px;
    margin: 0;
    font-weight: 650;
    color: var(--text)
}

.panel-body {
    padding: 22px
}

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

canvas {
    width: 100% !important;
    height: 100% !important
}

.table-wrap {
    overflow: auto
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left
}

th {
    color: var(--quiet);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: var(--surface-2);
    padding: 14px 18px
}

th,
td {
    border-bottom: 1px solid var(--border);
    white-space: nowrap
}

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

td {
    font-size: 13px;
    padding: 13px 18px;
    color: var(--text)
}

td:last-child,
th:last-child {
    text-align: right
}

.site-cell {
    display: flex;
    gap: 12px;
    align-items: center
}

.avatar {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--accent-bg);
    color: var(--accent-600);
    font-weight: 700;
    font-size: 15px
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 5px 11px;
    font-size: 11.5px;
    font-weight: 700;
    background: var(--surface-2);
    color: var(--muted)
}

.status.up {
    color: var(--success);
    background: var(--success-bg)
}

.status.down {
    color: var(--danger);
    background: var(--danger-bg)
}

.status.wait {
    color: var(--quiet)
}

.status .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor
}

.bar {
    width: 86px;
    height: 5px;
    border-radius: 99px;
    background: var(--surface-2);
    overflow: hidden;
    margin-left: auto
}

.bar i {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: inherit
}

/* ---------- Empty / states ---------- */

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

.empty strong {
    display: block;
    color: var(--text);
    font-size: 15px;
    margin-bottom: 6px
}

/* ---------- Page grid ---------- */

.page-grid {
    display: grid;
    grid-template-columns: 1.5fr 0.9fr;
    gap: 24px;
    align-items: start
}

.split-head {
    display: flex;
    justify-content: space-between;
    gap: 10px
}

.chip-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px
}

.chip {
    padding: 5px 10px;
    border-radius: 8px;
    background: var(--surface-2);
    font-size: 11.5px;
    color: var(--muted)
}

.danger-chip {
    background: var(--danger-bg);
    color: var(--danger)
}

.token-code {
    display: block;
    width: 100%;
    padding: 12px;
    background: var(--surface-2);
    border-radius: 10px;
    color: var(--text);
    font: 13px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
    overflow-wrap: anywhere
}

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

.api-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    background: var(--surface)
}

.api-card code {
    color: var(--accent-600);
    font-size: 12px
}

.api-card p {
    color: var(--muted);
    margin: 10px 0 16px;
    font-size: 13px;
    line-height: 1.6
}

.api-card pre {
    margin: 0;
    padding: 14px;
    border-radius: 10px;
    background: var(--surface-2);
    overflow: auto;
    font-size: 12px;
    line-height: 1.55
}

.form-panel {
    max-width: 560px
}

/* ---------- API docs ---------- */

.api-docs .content {
    max-width: 1180px
}

.api-docs .content-head {
    margin-bottom: 28px
}

.api-docs .content-head h1 {
    letter-spacing: -1.1px
}

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

.api-docs .api-card {
    padding: 22px;
    border-radius: 14px;
    transition: border-color 0.2s, box-shadow 0.2s
}

.api-docs .api-card:hover {
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03)
}

.api-docs .api-card h3 {
    margin: 0 0 10px;
    font-size: 15px;
    letter-spacing: -0.2px
}

.api-docs .api-card p code {
    padding: 2px 6px;
    border-radius: 5px;
    background: var(--accent-bg)
}

.api-docs pre {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre;
    tab-size: 2
}

.api-docs .method {
    display: inline-flex;
    align-items: center;
    min-width: 44px;
    justify-content: center;
    margin-right: 10px;
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--success-bg);
    color: var(--success);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 0.4px;
    text-transform: uppercase
}

.api-docs .auth-note {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55
}

@media (max-width: 760px) {
    .api-docs .api-grid {
        grid-template-columns: 1fr;
        gap: 12px
    }
    .api-docs .api-card {
        padding: 18px
    }
}

/* ---------- Forms ---------- */

.field-hint {
    font-size: 11px;
    color: var(--quiet);
    margin-top: 6px
}

.field label {
    display: block
}

.field input {
    margin-bottom: 4px
}

.field label,
.field input {
    font-size: 13px
}

.badge {
    font-size: 10.5px;
    font-weight: 750;
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--accent-bg);
    color: var(--accent-600)
}

/* ---------- Modal ---------- */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 40;
    place-items: center
}

.modal.open {
    display: grid
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--text) 30%, transparent);
    backdrop-filter: blur(4px)
}

.modal-card {
    position: relative;
    width: min(520px, calc(100% - 32px));
    max-height: 90dvh;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 26px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18);
    overflow-y: auto
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px
}

.modal-head h3 {
    margin: 0;
    font-size: 19px;
    font-weight: 700
}

.modal-close {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: var(--muted);
    font-size: 24px;
    line-height: 1
}

.modal-close:hover {
    background: var(--surface-2);
    color: var(--text)
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px
}

.field label {
    display: block
}

.field input {
    margin-bottom: 4px
}

/* ---------- Toast ---------- */

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 18px;
    border-radius: 10px;
    background: var(--text);
    color: var(--surface);
    z-index: 50;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    transform: translateY(20px)
}

.toast.show {
    opacity: 1;
    transform: translateY(0)
}

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr)
    }
    .page-grid {
        grid-template-columns: 1fr
    }
}

@media (max-width: 760px) {
    .app-shell {
        display: block
    }
    .sidebar {
        position: relative;
        width: auto;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding: 16px
    }
    .logo {
        padding-bottom: 18px
    }
    .nav {
        flex-direction: row;
        overflow: auto;
        gap: 10px;
        padding-bottom: 6px
    }
    .nav a {
        white-space: nowrap;
        padding: 10px 14px
    }
    .topbar {
        padding: 0 20px;
        height: 64px
    }
    .content {
        padding: 24px 20px 48px
    }
    .content-head {
        align-items: flex-start;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px
    }
    .content-head h1 {
        font-size: 22px
    }
    .updated {
        display: none
    }
    .head-actions {
        width: 100%;
        justify-content: space-between;
        margin-top: 10px
    }
    .panel-head {
        padding: 14px
    }
    .panel-body {
        padding: 16px
    }
    .login-card {
        padding: 32px 24px
    }
    .api-grid {
        grid-template-columns: 1fr
    }
    .kpi-grid {
        grid-template-columns: 1fr 1fr
    }
    .kpi-value {
        font-size: 26px
    }
}

@media (max-width: 420px) {
    .kpi-grid {
        grid-template-columns: 1fr
    }
    .kpi-value {
        font-size: 24px
    }
    .content-head {
        flex-direction: column;
        align-items: flex-start
    }
    .head-actions {
        margin-top: 12px;
        justify-content: flex-start
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        scroll-behavior: auto !important;
        transition: none !important
    }
}

/* ---------- Password modal extras ---------- */

.form-success {
    min-height: 18px
}

.password-hint {
    font-size: 11px;
    color: var(--quiet);
    margin-top: 6px
}
