:root {
    --bg: #000000;
    --bg-panel: #0d0d0d;
    --surface: #1a1a1a;
    --surface-2: #222222;
    --surface-hover: #282828;
    --border: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.22);
    --text: #f5f5f5;
    --text-secondary: #b8b8b8;
    --text-muted: #8a8a8a;
    --teal: #2dd4bf;
    --teal-dim: rgba(45, 212, 191, 0.12);
    --teal-glow: rgba(45, 212, 191, 0.25);
    --orange: #f59e0b;
    --orange-dim: rgba(245, 158, 11, 0.12);
    --ok: #2dd4bf;
    --danger: #f87171;
    --danger-dim: rgba(248, 113, 113, 0.12);
    --font-sans: "Inter", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", "SF Mono", Consolas, monospace;
    --sidebar-w: 240px;
    --radius: 10px;
    --radius-sm: 6px;
    --transition: 0.15s ease;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Shell ── */
.app-shell {
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    overflow-x: hidden;
}

/* ── Sidebar ── */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 1px solid var(--border);
    background: var(--bg-panel);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.brand__logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 11px;
    color: var(--teal);
    background: var(--teal-dim);
    border: 1px solid rgba(45, 212, 191, 0.25);
    flex-shrink: 0;
}

.brand strong {
    display: block;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.brand span {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10px;
}

.menu-label {
    padding: 0 16px 8px;
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0 8px;
    margin-bottom: 16px;
}

.menu__item {
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    text-align: left;
    font-size: 13px;
    font-weight: 400;
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
    width: 100%;
}

.menu__item::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
    opacity: 0;
    background: var(--teal);
    box-shadow: 0 0 6px var(--teal-glow);
}

.menu__item:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.menu__item.is-active {
    color: var(--text);
    font-weight: 500;
    background: rgba(45, 212, 191, 0.06);
}

.menu__item.is-active::before {
    opacity: 1;
}

.sidebar__foot {
    margin-top: auto;
    padding: 14px 16px 0;
    border-top: 1px solid var(--border);
}

.sidebar__foot span {
    display: block;
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
}

.status-pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-pill--ok::before {
    background: var(--teal);
    box-shadow: 0 0 6px var(--teal-glow);
}

.status-pill--warn::before {
    background: var(--orange);
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
    animation: blink 2s ease infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.sidebar__logout {
    display: inline-block;
    margin-top: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
}

.sidebar__logout:hover { color: var(--teal); }

/* ── Content ── */
.content {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: clamp(20px, 2.5vw, 32px) clamp(16px, 2.5vw, 36px) 40px;
    box-sizing: border-box;
    overflow-x: hidden;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    width: 100%;
    flex-wrap: wrap;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: lowercase;
}

.breadcrumb__sep { opacity: 0.5; color: var(--text-muted); }

.topbar h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.topbar p {
    margin: 6px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.topbar__actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    padding: 8px 14px;
    cursor: pointer;
    color: var(--text);
    background: transparent;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
    white-space: nowrap;
}

.btn--ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn--primary {
    background: var(--teal);
    border-color: var(--teal);
    color: #000;
    font-weight: 600;
}

.btn--primary:hover {
    background: #5eead4;
    border-color: #5eead4;
}

.btn--primary:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.btn--danger {
    background: transparent;
    border-color: rgba(248, 113, 113, 0.4);
    color: var(--danger);
}

.btn--danger:hover {
    background: var(--danger-dim);
}

.btn--subtle {
    padding: 6px 10px;
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

.btn--subtle:hover {
    color: var(--teal);
    border-color: rgba(45, 212, 191, 0.45);
    background: rgba(45, 212, 191, 0.08);
}

.btn--xs {
    padding: 4px 8px;
    font-size: 10px;
    display: inline-flex;
}

.btn--sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn--block { width: 100%; }

/* ── Cards ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

/* ── KPIs ── */
.kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
    width: 100%;
}

.kpi {
    padding: 16px 18px;
    position: relative;
}

.kpi__label {
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 10px;
}

.kpi__head {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 4px;
    min-height: 18px;
}

.kpi strong {
    display: block;
    font-size: 32px;
    font-weight: 600;
    letter-spacing: -0.04em;
    line-height: 1;
    color: var(--text);
}

.kpi small {
    display: block;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.kpi__badge {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: lowercase;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--teal-dim);
    color: var(--teal);
    border: 1px solid rgba(45, 212, 191, 0.2);
}

/* ── Dashboard grid ── */
.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    width: 100%;
    max-width: 100%;
    margin-bottom: 14px;
}

.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.quick-action {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    cursor: pointer;
    text-align: left;
    color: var(--text);
    font-family: inherit;
    transition: border-color var(--transition), background var(--transition);
}

.quick-action:hover {
    border-color: rgba(45, 212, 191, 0.25);
    background: var(--surface-hover);
}

.quick-action strong {
    font-size: 13px;
    font-weight: 500;
}

.quick-action span {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Setup ── */
.setup-card {
    border-color: rgba(245, 158, 11, 0.2);
}

.setup-steps {
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.setup-steps li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    font-size: 12px;
    color: var(--text-secondary);
}

.setup-steps__num {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-top: 1px;
}

.setup-steps li.is-done .setup-steps__num { color: var(--teal); }

/* ── Panels ── */
.layout-two-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    width: 100%;
    max-width: 100%;
}

.layout-two-col--clients { align-items: start; }

.panel {
    padding: 18px 20px;
    min-width: 0;
    max-width: 100%;
}

.panel__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.panel h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.panel__desc {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.panel p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.pill {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: lowercase;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    padding: 3px 9px;
    color: var(--text-muted);
    white-space: nowrap;
}

.pill--warn {
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--orange);
    background: var(--orange-dim);
}

.pill--teal {
    border-color: rgba(45, 212, 191, 0.25);
    color: var(--teal);
    background: var(--teal-dim);
}

/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
    max-width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    font-size: 12px;
    table-layout: auto;
}

.table th,
.table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    word-break: break-word;
}

.table td code {
    word-break: break-all;
    white-space: normal;
}

.table--clients { min-width: 0; }

.table-wrap--clients {
    border-radius: var(--radius-sm);
}

.table-wrap--clients .table--clients thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.table--clients {
    width: 100%;
    min-width: 920px;
    table-layout: auto;
}

.table--clients th,
.table--clients td {
    padding: 12px 14px;
    vertical-align: middle;
    word-break: normal;
    overflow-wrap: normal;
}

.table--clients th {
    white-space: nowrap;
    font-size: 10px;
    letter-spacing: 0.06em;
}

.table--clients .col-client { width: 22%; min-width: 200px; }
.table--clients .col-model { width: 10%; min-width: 108px; white-space: nowrap; }
.table--clients .col-consumo { width: 12%; min-width: 110px; white-space: nowrap; }
.table--clients .col-tokens { width: 7%; min-width: 64px; text-align: center; white-space: nowrap; }
.table--clients th.col-tokens { text-align: center; }
.table--clients .col-lastreq { width: 12%; min-width: 128px; white-space: nowrap; }
.table--clients .col-status { width: 9%; min-width: 92px; white-space: nowrap; }
.table--clients .col-actions { width: 18%; min-width: 220px; white-space: nowrap; }
.table--clients th.col-actions { text-align: right; }
.table--clients td.col-actions { text-align: right; }

.client-cell {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.client-cell__name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.client-cell__code {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.client-cell__meta,
.client-cell__link {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.client-cell__link {
    color: var(--teal);
    text-decoration: none;
}

.client-cell__link:hover {
    text-decoration: underline;
}

.client-cell__empresa {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.4;
}

.client-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: nowrap;
}

.client-actions--stack {
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.client-actions__quick {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
}

.client-actions .inline-form {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.table--clients .col-actions .btn,
.table--clients .col-actions .input--sm {
    width: auto;
}

.clients-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.panel--client-list {
    min-width: 0;
    width: 100%;
}

.client-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.client-form__nome {
    margin: 0;
}

.client-form__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 16px;
    align-items: end;
}

.client-form__submit {
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
}

.client-form__submit .btn {
    min-width: 140px;
    white-space: nowrap;
}

.client-form__obs {
    margin: 0;
}

.client-form__obs .input--area {
    min-height: 64px;
}

@media (max-width: 900px) {
    .client-form__grid {
        grid-template-columns: 1fr 1fr;
    }

    .client-form__submit {
        grid-column: 1 / -1;
        justify-content: stretch;
    }

    .client-form__submit .btn {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .client-form__grid {
        grid-template-columns: 1fr;
    }
}

.table-wrap--tokens {
    border-radius: var(--radius-sm);
}

.table-wrap--tokens .table--tokens thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.table--tokens {
    width: 100%;
    min-width: 960px;
    table-layout: auto;
}

.table--tokens th,
.table--tokens td {
    padding: 12px 14px;
    vertical-align: middle;
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
}

.table--tokens th {
    white-space: nowrap;
    font-size: 10px;
    letter-spacing: 0.06em;
}

.table--tokens .col-client { width: 14%; min-width: 140px; }
.table--tokens .col-token { width: auto; min-width: 280px; }
.table--tokens .col-scopes { width: 10%; min-width: 90px; }
.table--tokens .col-date { width: 12%; min-width: 130px; white-space: nowrap; }
.table--tokens .col-stats { width: 8%; min-width: 72px; white-space: nowrap; text-align: center; }
.table--tokens th.col-stats { text-align: center; }
.table--tokens .col-status { width: 8%; min-width: 84px; white-space: nowrap; }
.table--tokens .col-actions { width: 12%; min-width: 148px; white-space: nowrap; }
.table--tokens th.col-actions { text-align: right; }
.table--tokens td.col-actions { text-align: right; }

.table--tokens .col-revoked-at {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}

.mono-stat {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
}

.mono-stat-sep {
    margin: 0 2px;
    color: var(--text-muted);
    font-size: 10px;
}

.badge--nowrap {
    white-space: nowrap;
}

.token-client {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.token-client__name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.token-client__code {
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.token-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.token-row--muted {
    opacity: 0.85;
}

.token-row__value {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    background: #000;
    border: 1px solid rgba(45, 212, 191, 0.28);
    font-family: var(--font-mono);
    font-size: 11px;
    color: #6ee7d6;
    line-height: 1.35;
}

.token-row__value--prefix {
    color: var(--text-muted);
    border-style: dashed;
    border-color: var(--border-strong);
    background: rgba(255, 255, 255, 0.02);
}

.token-row__btns {
    display: flex;
    flex-shrink: 0;
    gap: 6px;
    align-items: center;
}

.token-row__hint {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--orange);
    white-space: nowrap;
}

.token-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.token-actions .inline-form {
    display: inline-flex;
    margin: 0;
}

.token-actions {
    justify-content: flex-end;
}

/* ── Tokens agrupados por cliente ── */
.token-groups {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.token-groups__head {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) 88px 128px 72px 84px 148px;
    gap: 12px 16px;
    padding: 0 14px 8px;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.token-group {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    overflow: hidden;
}

.token-group__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.token-group__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.token-group__body {
    display: flex;
    flex-direction: column;
}

.token-entry {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) 88px 128px 72px 84px 148px;
    gap: 12px 16px;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.token-entry:last-child {
    border-bottom: 0;
}

.token-entry--primary {
    background: rgba(45, 212, 191, 0.04);
}

.token-entry--history {
    background: rgba(255, 255, 255, 0.02);
}

.token-entry--history .token-row__value {
    font-size: 10px;
    padding: 5px 8px;
}

.token-entry__stats {
    text-align: center;
    white-space: nowrap;
}

.token-entry__status {
    white-space: nowrap;
}

.token-entry__actions {
    text-align: right;
    white-space: nowrap;
}

.token-entry__date {
    white-space: nowrap;
    font-size: 12px;
    color: var(--text-secondary);
}

.token-group__history {
    border-top: 1px dashed var(--border);
}

.token-group__history summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    user-select: none;
    transition: color var(--transition), background var(--transition);
}

.token-group__history summary::-webkit-details-marker {
    display: none;
}

.token-group__history summary::before {
    content: "▸";
    font-size: 10px;
    color: var(--text-muted);
    transition: transform var(--transition);
}

.token-group__history[open] summary::before {
    transform: rotate(90deg);
}

.token-group__history summary:hover {
    color: var(--teal);
    background: rgba(255, 255, 255, 0.02);
}

.token-group__history-count {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.token-group__history-list .token-entry {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

.token-group__empty {
    margin: 0;
    padding: 14px;
    font-size: 12px;
    color: var(--text-muted);
}

@media (max-width: 1100px) {
    .token-groups__head {
        display: none;
    }

    .token-entry {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "key key"
            "scopes status"
            "date stats"
            "actions actions";
    }

    .token-entry__key { grid-area: key; }
    .token-entry__scopes { grid-area: scopes; }
    .token-entry__date { grid-area: date; }
    .token-entry__stats { grid-area: stats; text-align: right; }
    .token-entry__status { grid-area: status; text-align: right; }
    .token-entry__actions { grid-area: actions; text-align: left; }
}

.table--tokens .col-actions .btn {
    width: auto;
}

.table--ledger { min-width: 0; }

/* ── Planos e cotas ── */
.cotas-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.cotas-forms {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.panel--quota-form,
.panel--credit-form,
.panel--cotas-ledger {
    min-width: 0;
}

.quota-form,
.credit-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quota-form__client,
.credit-form__client {
    margin: 0;
}

.quota-form__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 16px;
}

.credit-form__grid {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 12px 16px;
}

.quota-form__submit,
.credit-form__submit {
    display: flex;
    justify-content: flex-end;
}

.quota-form__submit .btn,
.credit-form__submit .btn {
    min-width: 160px;
    white-space: nowrap;
}

.table-wrap--ledger {
    border-radius: var(--radius-sm);
}

.table-wrap--ledger .table--ledger thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.table--ledger {
    width: 100%;
    min-width: 880px;
    table-layout: auto;
}

.table--ledger th,
.table--ledger td {
    padding: 12px 14px;
    vertical-align: middle;
    word-break: normal;
    overflow-wrap: normal;
}

.table--ledger th {
    white-space: nowrap;
    font-size: 10px;
    letter-spacing: 0.06em;
}

.table--ledger .col-date { width: 14%; min-width: 130px; white-space: nowrap; }
.table--ledger .col-client { width: 18%; min-width: 160px; }
.table--ledger .col-type { width: 12%; min-width: 108px; white-space: nowrap; }
.table--ledger .col-qty { width: 8%; min-width: 72px; text-align: right; white-space: nowrap; }
.table--ledger th.col-qty { text-align: right; }
.table--ledger .col-balance { width: 10%; min-width: 88px; text-align: right; white-space: nowrap; }
.table--ledger th.col-balance { text-align: right; }
.table--ledger .col-obs { width: auto; min-width: 200px; }

.ledger-badge {
    border-color: var(--border-strong);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
}

.ledger-obs {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
}

.table--ledger td.col-qty .mono-stat,
.table--ledger td.col-balance .mono-stat {
    font-weight: 600;
}

@media (max-width: 1100px) {
    .cotas-forms {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .quota-form__grid,
    .credit-form__grid {
        grid-template-columns: 1fr;
    }

    .quota-form__submit,
    .credit-form__submit {
        justify-content: stretch;
    }

    .quota-form__submit .btn,
    .credit-form__submit .btn {
        width: 100%;
    }
}

/* ── Aprovações ── */
.aprovacoes-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.panel--approval-queue,
.panel--approval-history {
    min-width: 0;
    width: 100%;
}

.table-wrap--approvals,
.table-wrap--activations {
    border-radius: var(--radius-sm);
}

.table-wrap--approvals .table--approvals thead th,
.table-wrap--activations .table--activations thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.table--approvals,
.table--activations {
    width: 100%;
    table-layout: auto;
}

.table--approvals {
    min-width: 720px;
}

.table--activations {
    min-width: 560px;
}

.table--approvals th,
.table--approvals td,
.table--activations th,
.table--activations td {
    padding: 12px 14px;
    vertical-align: middle;
    word-break: normal;
    overflow-wrap: normal;
}

.table--approvals th,
.table--activations th {
    white-space: nowrap;
    font-size: 10px;
    letter-spacing: 0.06em;
}

.table--approvals .col-client,
.table--activations .col-client { width: 28%; min-width: 180px; }
.table--approvals .col-date,
.table--activations .col-date { width: 18%; min-width: 130px; white-space: nowrap; }
.table--approvals .col-ip,
.table--activations .col-ip { width: 20%; min-width: 140px; }
.table--approvals .col-actions { width: 16%; min-width: 180px; white-space: nowrap; }
.table--approvals th.col-actions { text-align: right; }
.table--approvals td.col-actions { text-align: right; }

.table--approvals .col-ip .mono-stat,
.table--activations .col-ip .mono-stat {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
}

.approval-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: nowrap;
}

.approval-actions .inline-form {
    display: inline-flex;
    margin: 0;
}

.table--approvals .col-actions .btn {
    width: auto;
}

.empty-state--ok .empty-state__icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 12px;
    color: var(--teal);
    opacity: 0.85;
}

.empty-state--ok .empty-state__icon svg {
    width: 100%;
    height: 100%;
}

.col-actions {
    min-width: 120px;
}

.col-actions--row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.col-actions--row .inline-form {
    display: inline-flex;
    margin: 0;
}

.col-actions .inline-form {
    flex-direction: column;
    align-items: stretch;
}

.col-actions .btn,
.col-actions .input--sm {
    width: 100%;
}

.table th {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--surface);
    border-bottom: 1px solid var(--border-strong);
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.04); }

.table td small {
    display: block;
    margin-top: 2px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-secondary);
    word-break: break-all;
}

.cell-avatar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cell-avatar__icon {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: var(--teal-dim);
    color: var(--teal);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid rgba(45, 212, 191, 0.15);
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: lowercase;
    border-radius: 999px;
    padding: 2px 8px;
    border: 1px solid transparent;
}

.badge--pending { color: var(--orange); background: var(--orange-dim); border-color: rgba(245, 158, 11, 0.2); }
.badge--active { color: var(--teal); background: var(--teal-dim); border-color: rgba(45, 212, 191, 0.2); }
.badge--suspended { color: var(--danger); background: var(--danger-dim); border-color: rgba(248, 113, 113, 0.2); }
.badge--cancelled { color: var(--text-muted); background: rgba(255,255,255,0.04); border-color: var(--border); }

/* ── Forms ── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field span {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
}
.field--full { grid-column: 1 / -1; }

.field--check {
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.field--check input[type="checkbox"] {
    margin-top: 2px;
    accent-color: var(--teal);
    flex-shrink: 0;
}

.field--check > span {
    text-transform: none;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--text);
    line-height: 1.45;
}

.field--check-inline {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin: 0;
}

.scope-checks {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.scope-checks--inline {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
}

.scope-checks .field--check span {
    text-transform: none;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0;
}

.scope-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    user-select: none;
}

.scope-chip:has(input:checked) {
    border-color: rgba(45, 212, 191, 0.45);
    background: var(--teal-dim);
}

.scope-chip input[type="checkbox"] {
    margin: 0;
    accent-color: var(--teal);
    flex-shrink: 0;
}

.scope-chip span {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    line-height: 1;
}

.scope-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.scope-pill {
    display: inline-flex;
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 999px;
    border: 1px solid rgba(45, 212, 191, 0.22);
    background: var(--teal-dim);
    color: var(--teal);
    white-space: nowrap;
}

.input {
    background: var(--bg);
    border: 1px solid var(--border-strong);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-family: var(--font-sans);
    font-size: 13px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input:focus {
    outline: none;
    border-color: rgba(45, 212, 191, 0.45);
    box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.1);
}

.input--area { min-height: 80px; resize: vertical; font-family: inherit; }
.input--sm { padding: 6px 8px; font-size: 12px; min-width: 110px; }

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* ── Alerts ── */
.alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
    border: 1px solid transparent;
}

.alert__body {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
}

.alert__icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert--success {
    background: var(--teal-dim);
    border-color: rgba(45, 212, 191, 0.2);
    color: #99f6e4;
}

.alert--error {
    background: var(--danger-dim);
    border-color: rgba(248, 113, 113, 0.2);
    color: #fecaca;
}

.alert--warn {
    background: var(--orange-dim);
    border-color: rgba(245, 158, 11, 0.25);
    color: #fde68a;
}

/* ── Token display ── */
.token-reveal {
    padding: 16px 18px;
    margin-bottom: 16px;
    border: 1px solid rgba(45, 212, 191, 0.5);
    background: linear-gradient(180deg, rgba(45, 212, 191, 0.12) 0%, rgba(26, 26, 26, 1) 100%);
}

.token-reveal--sticky {
    position: relative;
    z-index: 2;
}

.token-reveal__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 13px;
    flex-wrap: wrap;
}

.token-reveal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.token-reveal__hint {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.token-display {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.token-display--highlight {
    padding: 0;
}

.token-display--unavailable {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border-strong);
    background: rgba(255, 255, 255, 0.02);
}

.token-display__full {
    display: block;
    word-break: break-all;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: #000;
    border: 1px solid rgba(45, 212, 191, 0.35);
    font-family: var(--font-mono);
    font-size: 12px;
    color: #6ee7d6;
    line-height: 1.55;
    white-space: pre-wrap;
}

.token-display__prefix {
    display: block;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    word-break: break-all;
}

.token-display__note {
    font-size: 11px;
    color: var(--orange);
    line-height: 1.4;
}

.token-display__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.token-display--table {
    gap: 6px;
}

.token-display--table.token-display--unavailable {
    padding: 8px 10px;
}

.token-display__full--compact {
    font-size: 10px;
    line-height: 1.45;
    padding: 8px 10px;
    max-height: 4.5em;
    overflow-y: auto;
}

.info-note--compact {
    margin-top: 16px;
    padding: 0;
    border: 0;
    background: transparent;
}

.info-note--compact summary {
    list-style: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    transition: color var(--transition), border-color var(--transition);
}

.info-note--compact summary::-webkit-details-marker { display: none; }

.info-note--compact summary::after {
    content: " ▾";
    font-size: 10px;
    color: var(--text-muted);
}

.info-note--compact[open] summary::after { content: " ▴"; }

.info-note--compact summary:hover {
    color: var(--teal);
    border-color: rgba(45, 212, 191, 0.25);
}

.info-note--compact p {
    margin: 10px 0 0;
    padding: 0 2px;
}

.info-note {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
}

.field--check-revoke > span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.field--check-revoke strong {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.35;
}

.field--check-revoke small {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.35;
}

.token-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.token-form__client {
    margin: 0;
}

.token-form__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px 20px;
    align-items: end;
}

.token-form__scopes {
    margin: 0;
    min-width: 0;
}

.token-form__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.token-form__actions .btn {
    min-width: 132px;
    white-space: nowrap;
}

.scope-chip--revoke span {
    display: flex;
    flex-direction: column;
    gap: 1px;
    line-height: 1.2;
}

.scope-chip--revoke small {
    font-size: 10px;
    font-weight: 400;
    color: var(--text-muted);
}

.scope-chip--revoke:has(input:checked) {
    border-color: rgba(245, 158, 11, 0.45);
    background: var(--orange-dim);
}

.token-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 100%;
}

.panel--token-gen {
    align-self: stretch;
}

.panel--token-list {
    min-width: 0;
    width: 100%;
}

.panel__head--compact {
    margin-bottom: 14px;
    padding-bottom: 12px;
    align-items: center;
}

.info-note--inline {
    margin: 0;
    flex-shrink: 0;
}

.info-note--inline summary {
    white-space: nowrap;
}

@media (max-width: 720px) {
    .token-form__row {
        grid-template-columns: 1fr;
    }

    .token-form__actions {
        justify-content: stretch;
        flex-direction: column;
        align-items: stretch;
    }

    .token-form__actions .btn {
        width: 100%;
    }

    .token-row {
        flex-direction: column;
        align-items: stretch;
    }

    .token-row__btns {
        justify-content: flex-start;
    }
}

.info-note strong {
    display: block;
    font-size: 12px;
    margin-bottom: 6px;
    color: var(--text);
}

.info-note p {
    margin: 0 0 8px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.info-note p:last-child { margin-bottom: 0; }

.info-note code {
    font-size: 11px;
    color: var(--teal);
}

.info-note__warn {
    color: var(--orange) !important;
}

.info-note em {
    color: var(--teal);
    font-style: normal;
    font-weight: 500;
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 36px 20px;
}

.empty-state strong {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
    max-width: 360px;
    margin-inline: auto;
}

/* ── Info cards ── */
.info-card {
    display: flex;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    margin-top: 10px;
}

.info-card:first-child { margin-top: 0; }

.info-card strong {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 4px;
}

.info-card p {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}

code {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--teal);
    background: rgba(45, 212, 191, 0.08);
    border: 1px solid rgba(45, 212, 191, 0.15);
    padding: 1px 6px;
    border-radius: 4px;
}

.muted-inline { color: var(--text-secondary); font-size: 12px; margin: 12px 0 0; }
.text-ok { color: var(--teal); font-family: var(--font-mono); font-size: 12px; }
.text-warn { color: var(--orange); font-family: var(--font-mono); font-size: 12px; }

.section {
    display: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}
.section.is-visible { display: block; animation: fadeUp 0.18s ease; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Login ── */
.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--bg);
}

.login-brand {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px;
    border-right: 1px solid var(--border);
    background: var(--bg-panel);
}

.login-brand__logo {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 12px;
    color: var(--teal);
    background: var(--teal-dim);
    border: 1px solid rgba(45, 212, 191, 0.25);
    margin-bottom: 28px;
}

.login-brand h1 {
    margin: 0 0 12px;
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.login-brand p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    max-width: 340px;
    line-height: 1.65;
}

.login-brand__features {
    margin-top: 32px;
    display: grid;
    gap: 10px;
}

.login-brand__feature {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    padding-left: 14px;
    border-left: 2px solid rgba(45, 212, 191, 0.3);
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    padding: 28px;
}

.login-card h2 {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 600;
}

.login-card > p {
    margin: 0 0 24px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    text-transform: lowercase;
}

.login-card .field { margin-bottom: 14px; }

.badge--cancelled { color: var(--text-muted); background: rgba(255,255,255,0.04); border-color: var(--border); }
.badge--teal { color: var(--teal); background: var(--teal-dim); border-color: rgba(45, 212, 191, 0.2); }

.text-ok { color: var(--teal); }
.text-warn { color: var(--orange); }

.panel__head--split {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.panel__tools {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
}

.dashboard-grid--wide {
    grid-template-columns: minmax(0, 1fr);
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    min-height: 140px;
    padding: 8px 4px 0;
}

.chart-bars__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.chart-bars__item span {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

.chart-bars__fill {
    width: 100%;
    max-width: 36px;
    background: linear-gradient(180deg, var(--teal), rgba(45, 212, 191, 0.35));
    border-radius: 4px 4px 0 0;
    min-height: 4px;
}

.alert-panel { margin-bottom: 16px; }

.alert-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.alert-list__item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 13px;
}

.alert-list__item--motor_off { border-color: rgba(248, 113, 113, 0.35); color: var(--danger); }
.alert-list__item--quota_alta { border-color: rgba(245, 158, 11, 0.35); }

.rank-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.rank-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.rank-list li span {
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

.table--compact th, .table--compact td { padding: 8px 10px; font-size: 12px; }

.empty-state--compact { padding: 20px; }

.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.filters-bar--docs {
    margin-bottom: 16px;
    padding-bottom: 0;
    border-bottom: none;
}

.filters-bar--docs .field {
    margin: 0;
    min-width: 0;
    max-width: 420px;
}

.filters-bar--logs {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 10px 12px;
    align-items: end;
}

.filters-bar--logs .filters-bar__client { grid-column: span 4; }
.filters-bar--logs .filters-bar__http { grid-column: span 2; }
.filters-bar--logs .filters-bar__date { grid-column: span 2; }
.filters-bar--logs .filters-bar__errors { grid-column: span 2; }
.filters-bar--logs .filters-bar__submit {
    grid-column: span 2;
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
}

.filters-bar--logs .field {
    margin: 0;
    min-width: 0;
    width: 100%;
}

.filters-bar--logs .field span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filters-bar--logs .field .input,
.filters-bar--logs .field select {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.filters-bar--logs .field--check {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0 0 8px;
    border: none;
    background: transparent;
    min-height: 34px;
    white-space: nowrap;
}

.filters-bar--logs .field--check span {
    text-transform: none;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--text);
    white-space: nowrap;
}

.filters-bar__submit {
    display: flex;
    justify-content: flex-end;
}

.filters-bar__submit .btn {
    min-width: 100px;
    white-space: nowrap;
}

/* ── Logs ── */
.logs-page {
    width: 100%;
}

.panel--logs {
    min-width: 0;
    width: 100%;
}

.table-wrap--logs {
    overflow-x: hidden;
    border-radius: var(--radius-sm);
}

.table-wrap--logs .table--logs thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.table--logs {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.table--logs th,
.table--logs td {
    padding: 8px 10px;
    vertical-align: middle;
    overflow: hidden;
}

.table--logs th {
    white-space: nowrap;
    font-size: 10px;
    letter-spacing: 0.06em;
}

.table--logs .col-date { width: 9%; white-space: nowrap; }
.table--logs .col-client { width: 10%; }
.table--logs .col-endpoint { width: 6%; }
.table--logs .col-request { width: 18%; }
.table--logs .col-response { width: 22%; }
.table--logs .col-status { width: 8%; white-space: nowrap; }
.table--logs th.col-status { text-align: center; }
.table--logs .col-reqid { width: 10%; }
.table--logs .col-error { width: 8%; white-space: nowrap; }

.table--logs .client-cell--compact .client-cell__name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.log-endpoint--short {
    padding: 2px 7px;
    font-size: 10px;
    text-transform: lowercase;
}

.log-status-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.log-status-ms {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1;
}

.log-endpoint {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--teal);
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid rgba(45, 212, 191, 0.22);
    background: var(--teal-dim);
}

.log-reqid {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-secondary);
}

.log-error {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--orange);
    text-transform: uppercase;
}

.log-error--none {
    color: var(--text-muted);
    font-weight: 400;
    text-transform: none;
}

.log-request {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    line-height: 1.35;
    color: var(--text-primary);
}

.log-request--none {
    color: var(--text-muted);
}

.log-ip {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-secondary);
}

.log-response-cell {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.log-response {
    display: block;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    line-height: 1.35;
    color: var(--text-primary);
}

.log-response--none {
    color: var(--text-muted);
}

.log-response-btn {
    flex-shrink: 0;
}

.filters-bar:not(.filters-bar--logs) .field { margin: 0; min-width: 120px; }
.filters-bar .field--check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
}

.code-block {
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}

.code-block__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}

.code-block pre {
    margin: 0;
    padding: 12px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.5;
}

.docs-kit {
    margin-top: 0;
    padding: 0;
    overflow: hidden;
}

.docs-kit__head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
}

.docs-kit__title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.docs-kit__subtitle {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}

.docs-kit__meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0;
    margin: 0;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
}

.docs-kit__meta-row {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}

.docs-kit__meta-row:last-child { border-bottom: 0; }

.docs-kit__meta-row dt {
    margin: 0;
    color: var(--text-muted);
    font-weight: 500;
}

.docs-kit__meta-row dd {
    margin: 0;
    word-break: break-word;
}

.docs-kit__section {
    padding: 0 20px 16px;
}

.docs-kit__section:first-of-type { padding-top: 16px; }

.code-block--docs {
    margin-top: 0;
}

.docs-kit__pre {
    margin: 0;
    max-height: 280px;
    overflow: auto;
}

.docs-kit__note {
    margin: 0;
    padding: 14px 20px 18px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}

.docs-kit__hidden-copy {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.docs-more {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.docs-more > summary {
    cursor: pointer;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    list-style: none;
}

.docs-more > summary::-webkit-details-marker { display: none; }

.docs-more__body {
    padding: 0 16px 16px;
    border-top: 1px solid var(--border);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal[hidden] { display: none; }

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
}

.modal__card {
    position: relative;
    width: min(480px, 100%);
    padding: 20px;
    z-index: 1;
}

.modal__body { margin-top: 12px; font-size: 13px; white-space: pre-wrap; }

/* Modal JSON dos logs — depois de .modal__card para não ser sobrescrito */
.modal--logs {
    padding: clamp(10px, 2vw, 24px);
    align-items: center;
    justify-content: center;
}

.modal--logs .modal__card.modal__card--log-json {
    width: min(96vw, 1680px);
    max-width: none;
    max-height: calc(100dvh - 20px);
    margin: 0;
    display: flex;
    flex-direction: column;
    padding: clamp(14px, 2vw, 24px);
    box-sizing: border-box;
}

.modal--logs .modal__card--log-json .panel__head {
    flex-shrink: 0;
    gap: 12px;
}

.modal--logs .modal__card--log-json .panel__head--split {
    flex-wrap: wrap;
}

.modal--logs .modal__card--log-json .panel__desc {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: min(100%, 72vw);
}

.modal__card--log-json .log-json-view {
    margin: 12px 0 0;
    flex: 1 1 auto;
    min-height: 180px;
    max-height: min(72dvh, 820px);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.28);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: clamp(10px, 1.1vw, 12px);
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.modal__card--wide {
    width: min(920px, 100%);
}

.modal__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.table-search {
    min-width: 0;
    width: min(220px, 100%);
    flex: 1 1 160px;
}

/* ── Mobile ── */
.sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(45, 212, 191, 0.3);
    background: var(--teal);
    color: #000;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle svg { width: 20px; height: 20px; }

/* ── Responsive ── */
@media (min-width: 1101px) {
    .dashboard-grid {
        grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    }

    .dashboard-grid--wide {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    }

    .layout-two-col {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .col-actions .inline-form {
        flex-direction: row;
        align-items: center;
    }

    .col-actions .btn,
    .col-actions .input--sm {
        width: auto;
    }
}

@media (max-width: 1100px) {
    .col-optional { display: none; }
}

@media (max-width: 1280px) {
    .layout-two-col--clients {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 1200px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
    .filters-bar--logs .filters-bar__client { grid-column: span 12; }
    .filters-bar--logs .filters-bar__http { grid-column: span 3; }
    .filters-bar--logs .filters-bar__date { grid-column: span 3; }
    .filters-bar--logs .filters-bar__errors { grid-column: span 3; }
    .filters-bar--logs .filters-bar__submit {
        grid-column: span 3;
        justify-content: stretch;
    }
    .filters-bar--logs .filters-bar__submit .btn { width: 100%; }
}

@media (max-width: 900px) {
    .dashboard-grid,
    .dashboard-grid--wide,
    .layout-two-col {
        grid-template-columns: minmax(0, 1fr);
    }

    .filters-bar:not(.filters-bar--logs) .field {
        flex: 1 1 140px;
        min-width: 0;
    }
}

@media (max-width: 720px) {
    .filters-bar--logs > * {
        grid-column: span 12 !important;
    }

    .filters-bar--logs .filters-bar__submit .btn {
        width: 100%;
    }

    .modal--logs .modal__card--log-json .panel__desc {
        white-space: normal;
        max-width: 100%;
    }

    .modal--logs .modal__actions {
        width: 100%;
        justify-content: stretch;
    }

    .modal--logs .modal__actions .btn {
        flex: 1 1 auto;
    }
}

@media (max-width: 600px) {
    .kpis { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .app-shell { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 90;
        width: var(--sidebar-w);
        transform: translateX(-100%);
        transition: transform 0.22s ease;
    }

    .sidebar.is-open { transform: translateX(0); }
    .sidebar-toggle { display: flex; }
    .content { padding: 20px 16px 72px; }
    .topbar { flex-direction: column; }
    .topbar__actions { width: 100%; }
    .topbar__actions .btn { flex: 1; }
    .form-grid { grid-template-columns: 1fr; }
    .quick-actions { grid-template-columns: 1fr; }
    .login-page { grid-template-columns: 1fr; }
    .login-brand { display: none; }

    .alert { flex-direction: column; align-items: stretch; }
}
