:root {
    --blue: #0f63ce;
    --blue-dark: #0b3f88;
    --green: #16b873;
    --green-dark: #0b8f60;
    --ink: #152033;
    --muted: #6b7688;
    --line: #dfe6f0;
    --soft: #f4f8fb;
    --panel: #ffffff;
    --danger: #c93636;
    --warning: #b97809;
    --shadow: 0 16px 35px rgba(15, 50, 91, .10);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--soft);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    letter-spacing: 0;
}

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

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

img {
    max-width: 100%;
}

.app-shell {
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 22px;
    color: #fff;
    background: linear-gradient(145deg, var(--blue-dark), var(--blue) 46%, var(--green-dark));
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    margin-bottom: 28px;
}

.brand img {
    width: 46px;
    height: 46px;
    object-fit: contain;
    border-radius: 8px;
    background: rgba(255, 255, 255, .16);
    padding: 4px;
}

.brand small,
.company-block small {
    display: block;
    color: rgba(255, 255, 255, .72);
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    border-radius: 8px;
    color: #fff;
    background: linear-gradient(135deg, var(--green), #57d392);
    font-weight: 800;
}

.brand-mark.large {
    width: 62px;
    height: 62px;
    flex-basis: 62px;
    font-size: 20px;
}

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

.nav-link {
    padding: 11px 12px;
    border-radius: 8px;
    color: rgba(255, 255, 255, .82);
    transition: background .18s ease, color .18s ease;
}

.nav-link:hover,
.nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, .16);
}

.sidebar-footer {
    display: grid;
    gap: 14px;
    margin-top: auto;
    padding-top: 18px;
}

.company-block {
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 8px;
    background: rgba(255, 255, 255, .08);
    overflow-wrap: anywhere;
}

.main {
    min-width: 0;
    padding: 26px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.topbar h1,
.auth-card h1,
.panel h2,
.summary-panel h2,
.asaas-summary h2 {
    margin: 0;
    line-height: 1.15;
}

.topbar h1 {
    font-size: 28px;
}

.eyebrow {
    display: block;
    margin-bottom: 5px;
    color: var(--green-dark);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    max-width: 260px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.menu-toggle {
    display: none;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

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

.metric-card {
    min-height: 112px;
    padding: 18px;
    border-top: 4px solid var(--green);
}

.metric-card span {
    display: block;
    min-height: 40px;
    color: var(--muted);
}

.metric-card strong {
    display: block;
    margin-top: 8px;
    font-size: 25px;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.metric-card.danger {
    border-top-color: var(--danger);
}

.metric-card.warning {
    border-top-color: #f2b43d;
}

.metric-card.money {
    border-top-color: var(--blue);
}

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

.panel {
    padding: 18px;
}

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

.panel h2 {
    font-size: 18px;
}

.toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.filters {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.filters.wide label {
    min-width: 150px;
}

label {
    display: grid;
    gap: 6px;
    min-width: 0;
}

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

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 11px;
    color: var(--ink);
    background: #fff;
    outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(15, 99, 206, .14);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
}

.btn-small {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
}

.btn-full {
    width: 100%;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--blue), var(--green-dark));
}

.btn-secondary {
    color: #fff;
    background: var(--blue-dark);
}

.btn-light {
    color: var(--blue-dark);
    border-color: var(--line);
    background: #fff;
}

.btn-ghost {
    color: #fff;
    border-color: rgba(255, 255, 255, .22);
    background: rgba(255, 255, 255, .08);
}

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

.btn-whatsapp {
    color: #fff;
    background: #13a65a;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

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

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

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

td strong {
    display: block;
}

td small {
    display: block;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.actions-col {
    width: 240px;
}

.row-actions,
.quick-actions,
.form-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-actions {
    margin-bottom: 16px;
}

.form-panel {
    max-width: 980px;
}

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

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

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

.form-actions {
    justify-content: flex-end;
    margin-top: 18px;
}

.settings-actions {
    grid-column: 1 / -1;
}

.switch-line {
    display: inline-flex;
    grid-column: span 2;
    align-items: center;
    gap: 9px;
}

.switch-line input {
    width: 18px;
    min-height: 18px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 9px;
    border-radius: 8px;
    color: #435066;
    background: #eef2f7;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.badge-green {
    color: #07633c;
    background: #dcf8eb;
}

.badge-blue {
    color: #0b4d97;
    background: #e0efff;
}

.badge-yellow {
    color: #805207;
    background: #fff3d8;
}

.badge-red {
    color: #9b1f1f;
    background: #ffe2e2;
}

.badge-teal {
    color: #08756e;
    background: #def7f3;
}

.badge-gray {
    color: #4f5967;
    background: #edf0f4;
}

.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: 700;
}

.alert-success {
    color: #075b3b;
    background: #dff8eb;
}

.alert-error {
    color: #8f1d1d;
    background: #ffe2e2;
}

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

.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.segmented a {
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--muted);
    font-weight: 800;
}

.segmented a.active {
    color: #fff;
    background: linear-gradient(135deg, var(--blue), var(--green-dark));
}

.summary-panel,
.asaas-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: 18px;
    max-width: 980px;
    margin-bottom: 16px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.summary-grid span {
    display: grid;
    gap: 4px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
}

.summary-grid strong {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.auth-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 22px;
    background:
        linear-gradient(135deg, rgba(15, 99, 206, .92), rgba(22, 184, 115, .88)),
        #0f63ce;
}

.auth-wrap {
    width: min(430px, 100%);
}

.auth-card {
    padding: 26px;
}

.auth-brand {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 22px;
}

.auth-brand p,
.auth-card p {
    margin: 8px 0 0;
    color: var(--muted);
}

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

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

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

    .sidebar {
        position: fixed;
        z-index: 20;
        inset: 0 auto 0 0;
        width: min(300px, 86vw);
        transform: translateX(-105%);
        transition: transform .2s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main {
        padding: 18px;
    }

    .topbar {
        align-items: flex-start;
    }

    .topbar h1 {
        font-size: 23px;
    }

    .menu-toggle {
        display: inline-flex;
        align-items: center;
        min-height: 40px;
        padding: 8px 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
        color: var(--blue-dark);
        font-weight: 800;
    }

    .user-chip {
        display: none;
    }

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

    .filters,
    .filters.wide {
        display: grid;
        grid-template-columns: 1fr;
    }

    .filters.wide label {
        min-width: 0;
    }

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

    .summary-panel,
    .asaas-summary,
    .summary-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .metric-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .span-2,
    .switch-line {
        grid-column: span 1;
    }

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

    .row-actions,
    .quick-actions,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .row-actions .btn,
    .row-actions form,
    .row-actions button,
    .quick-actions .btn,
    .form-actions .btn,
    .form-actions button {
        width: 100%;
    }
}
