:root {
    color-scheme: dark;
    --bg: #0d0d0e;
    --panel: #1b1b1d;
    --panel-2: #252527;
    --line: #363638;
    --text: #f3f3f4;
    --muted: #a6a6aa;
    --green: #29ac4a;
    --green-2: #35d267;
    --blue: #10a8ff;
    --red: #ff5f5f;
    --shadow: 0 24px 60px rgba(0, 0, 0, .36);
}

* {
    box-sizing: border-box;
}

html {
    width: 100%;
    min-height: 100%;
    background: var(--bg);
    overflow-x: hidden;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100svh;
    width: 100%;
    overflow-x: hidden;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 80% 0%, rgba(16, 168, 255, .09), transparent 28%), var(--bg);
    -webkit-text-size-adjust: 100%;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: var(--bg);
}

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

button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 7px;
    padding: 13px 18px;
    color: white;
    background: var(--green);
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
    text-align: center;
    cursor: pointer;
}

button:hover,
.button-link:hover {
    background: var(--green-2);
}

input,
select {
    width: 100%;
    min-height: 54px;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 0 16px;
    color: var(--text);
    background: var(--panel-2);
    font: inherit;
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(16, 168, 255, .13);
}

.auth-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    min-height: 100svh;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.auth-card {
    width: min(760px, 100%);
    padding: clamp(28px, 5vw, 58px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #1a1a1c;
    box-shadow: var(--shadow);
}

.logo-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 230px;
    padding: clamp(22px, 5vw, 44px);
    margin-bottom: 42px;
    border-radius: 8px;
    background: #19191b;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.02), 0 16px 36px rgba(0,0,0,.22);
    overflow: hidden;
}

.logo-mark {
    width: clamp(76px, 13vw, 118px);
    height: clamp(76px, 13vw, 118px);
    display: grid;
    place-items: center;
    border: 1px solid rgba(16, 168, 255, .55);
    border-radius: 8px;
    color: #f8fbff;
    font-size: clamp(28px, 5vw, 48px);
    font-weight: 950;
    line-height: 1;
    background: linear-gradient(135deg, #1aa7ef, #0b2b66 58%, #29ac4a);
    box-shadow: 0 14px 36px rgba(16, 168, 255, .22);
}

.logo-text {
    max-width: 100%;
    font-size: clamp(38px, 8vw, 82px);
    font-weight: 900;
    line-height: .96;
    text-align: center;
    letter-spacing: 0;
    overflow-wrap: anywhere;
    background: linear-gradient(#ffffff, #d9d9d9 44%, #5a5a5d 48%, #f1f1f1 58%, #8a8a8e);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 12px 22px rgba(0,0,0,.32);
}

.auth-form {
    display: grid;
    gap: 26px;
}

.auth-form input {
    min-height: 76px;
    font-size: clamp(18px, 2.5vw, 26px);
    font-weight: 700;
}

.auth-form button {
    min-height: 76px;
    margin-top: 22px;
    font-size: clamp(18px, 2.4vw, 26px);
}

.auth-link {
    display: block;
    width: fit-content;
    margin: 34px auto 0;
    font-size: 20px;
}

.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
    min-height: 100svh;
    background: var(--bg);
}

.mobile-topbar,
.menu-backdrop,
.menu-close {
    display: none;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 26px 18px;
    border-right: 1px solid var(--line);
    background: #121214;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    color: var(--text);
    font-size: 20px;
    font-weight: 900;
    line-height: 1.05;
    letter-spacing: 0;
}

.brand-mark {
    display: grid;
    place-items: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border-radius: 7px;
    background: linear-gradient(135deg, #158dcc, #061f4e 62%, #29ac4a);
    color: white;
    font-size: 15px;
    font-weight: 950;
}

.nav {
    display: grid;
    gap: 8px;
    margin-top: 28px;
}

.nav a,
.logout {
    display: block;
    padding: 14px 15px;
    border-radius: 7px;
    color: var(--muted);
    font-weight: 700;
}

.nav a:hover,
.nav a.is-active {
    color: var(--text);
    background: var(--panel-2);
}

.logout {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 20px;
}

.content {
    width: min(1220px, 100%);
    min-width: 0;
    padding: 34px;
}

.page-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 26px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--blue);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: clamp(32px, 5vw, 52px);
    line-height: 1;
}

h2 {
    margin-bottom: 0;
    font-size: 20px;
}

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

.month-filter {
    position: relative;
    display: flex;
    gap: 10px;
    align-items: center;
}

.month-filter input {
    min-width: 180px;
}

.month-picker {
    align-items: stretch;
}

.month-arrow,
.month-current,
.date-display {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 54px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text);
    background: var(--panel-2);
    font-weight: 900;
    text-transform: none;
}

.month-arrow {
    width: 54px;
    padding: 0;
    font-size: 28px;
}

.month-current {
    min-width: 210px;
    padding: 0 18px;
}

.month-current:hover,
.month-arrow:hover,
.date-display:hover {
    background: #303034;
}

.month-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 20;
    display: none;
    grid-template-columns: repeat(3, minmax(110px, 1fr));
    gap: 8px;
    width: min(390px, calc(100vw - 32px));
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #18181a;
    box-shadow: var(--shadow);
}

.month-picker.is-open .month-menu {
    display: grid;
}

.month-menu button {
    min-height: 42px;
    padding: 10px 12px;
    background: var(--panel-2);
    text-transform: none;
}

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

.metric-card,
.panel,
.planning-hero {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 16px 38px rgba(0,0,0,.16);
}

.metric-card {
    display: grid;
    gap: 12px;
    min-height: 138px;
    padding: 22px;
}

.metric-card span,
.focus-panel span,
.planning-hero span {
    color: var(--muted);
    font-weight: 800;
}

.metric-card strong {
    font-size: clamp(25px, 3vw, 34px);
    overflow-wrap: anywhere;
}

.accent-green strong {
    color: var(--green-2);
}

.accent-blue strong {
    color: var(--blue);
}

.danger strong,
.negative strong {
    color: var(--red);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr);
    gap: 16px;
    margin-bottom: 16px;
}

.small-side {
    grid-template-columns: minmax(0, 1fr) 310px;
}

.panel {
    padding: 22px;
}

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

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

th,
td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

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

.table-sort {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    color: var(--muted);
    font-weight: 900;
}

.table-sort:hover,
.table-sort.is-active {
    color: var(--blue);
}

.pill {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.pill.entrada,
.timeline-item.entrada b {
    color: var(--green-2);
    background: rgba(53, 210, 103, .11);
}

.pill.saida,
.timeline-item.saida b {
    color: #ff9b9b;
    background: rgba(255, 95, 95, .12);
}

.due-list,
.bars,
.timeline {
    display: grid;
    gap: 12px;
}

.due-item,
.timeline-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #202023;
}

.due-item span,
.timeline-item span {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
}

.bar-label {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.bar-track {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #2b2b2e;
}

.bar-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--green), var(--blue));
}

.focus-panel {
    display: grid;
    align-content: center;
    gap: 14px;
}

.focus-panel strong {
    font-size: 40px;
    color: var(--blue);
    overflow-wrap: anywhere;
}

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

.finance-form {
    display: grid;
    gap: 22px;
}

.date-picker {
    position: relative;
}

.date-display {
    width: 100%;
    padding: 0 16px;
    text-align: left;
}

.calendar-popover {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 30;
    display: none;
    width: min(360px, calc(100vw - 40px));
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #18181a;
    box-shadow: var(--shadow);
}

.date-picker.is-open .calendar-popover {
    display: block;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.calendar-header button {
    width: 42px;
    height: 42px;
    padding: 0;
    font-size: 24px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.calendar-weekday {
    display: grid;
    place-items: center;
    min-height: 28px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.calendar-blank {
    min-height: 38px;
}

.calendar-grid button {
    min-height: 38px;
    padding: 0;
    border: 1px solid transparent;
    background: var(--panel-2);
    text-transform: none;
}

.calendar-grid button:hover,
.calendar-grid button.is-selected {
    border-color: var(--green);
    background: var(--green);
}

.segmented {
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    max-width: 360px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #141416;
}

.segmented input {
    position: absolute;
    opacity: 0;
}

.segmented span {
    display: block;
    padding: 12px 26px;
    border-radius: 7px;
    color: var(--muted);
    font-weight: 900;
    text-align: center;
    cursor: pointer;
}

.segmented input:checked + span {
    color: white;
    background: var(--green);
}

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

label span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-weight: 800;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.check-row input {
    width: 18px;
    min-height: 18px;
}

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

.actions button {
    padding: 9px 12px;
    font-size: 12px;
}

.ghost-danger {
    background: transparent;
    color: var(--red);
    border: 1px solid rgba(255, 95, 95, .35);
}

.ghost-danger:hover {
    background: rgba(255, 95, 95, .12);
}

.planning-hero {
    padding: clamp(24px, 5vw, 44px);
    margin-bottom: 18px;
}

.planning-hero strong {
    display: block;
    margin: 8px 0 12px;
    font-size: clamp(42px, 8vw, 78px);
    line-height: 1;
    overflow-wrap: anywhere;
}

.planning-hero.positive strong {
    color: var(--green-2);
}

.timeline-item time {
    display: grid;
    place-items: center;
    min-width: 64px;
    height: 48px;
    border-radius: 7px;
    background: #151517;
    color: var(--blue);
    font-weight: 900;
}

.flash {
    margin-bottom: 18px;
    padding: 14px 16px;
    border: 1px solid rgba(53, 210, 103, .35);
    border-radius: 7px;
    color: #d9ffe4;
    background: rgba(53, 210, 103, .12);
}

.flash-error {
    border-color: rgba(255, 95, 95, .38);
    color: #ffd6d6;
    background: rgba(255, 95, 95, .12);
}

@media (max-width: 960px) {
    .app-shell {
        display: block;
        padding-top: 74px;
    }

    body.menu-is-open {
        overflow: hidden;
    }

    .mobile-topbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 60;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        min-height: 74px;
        padding: max(12px, env(safe-area-inset-top)) 16px 12px;
        border-bottom: 1px solid var(--line);
        background: rgba(18, 18, 20, .96);
        backdrop-filter: blur(14px);
    }

    .mobile-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
        color: var(--text);
        font-size: 18px;
        font-weight: 950;
        line-height: 1;
    }

    .mobile-brand span:last-child {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .menu-toggle {
        flex: 0 0 48px;
        width: 48px;
        height: 48px;
        display: grid;
        place-items: center;
        gap: 5px;
        padding: 12px;
        border: 1px solid var(--line);
        background: var(--panel-2);
    }

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 999px;
    background: var(--text);
    transition: transform .18s ease, opacity .18s ease;
}

.menu-is-open .menu-toggle span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.menu-is-open .menu-toggle span:nth-child(2) {
    opacity: 0;
}

.menu-is-open .menu-toggle span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

    .menu-backdrop {
        position: fixed;
        inset: 0;
        z-index: 70;
        background: rgba(0, 0, 0, .58);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 80;
        width: min(315px, calc(100vw - 42px));
        height: auto;
        padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
        border-right: 1px solid var(--line);
        border-bottom: 0;
        box-shadow: var(--shadow);
        transform: translateX(-105%);
        transition: transform .22s ease;
        overflow-y: auto;
    }

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

    .menu-is-open .menu-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .menu-close {
        position: absolute;
        top: max(14px, env(safe-area-inset-top));
        right: 14px;
        width: 42px;
        height: 42px;
        display: grid;
        place-items: center;
        padding: 0;
        border: 1px solid var(--line);
        background: var(--panel-2);
        font-size: 28px;
        line-height: 1;
    }

    .sidebar .brand {
        padding-right: 52px;
    }

    .nav {
        display: grid;
        gap: 10px;
        margin-top: 28px;
        overflow-x: visible;
    }

    .logout {
        position: static;
        margin-top: 8px;
    }

    .content {
        width: 100%;
        padding: 18px;
    }

    .page-header,
    .month-filter {
        align-items: stretch;
        flex-direction: column;
    }

    .month-picker {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .month-current {
        flex: 1 1 180px;
        min-width: 0;
    }

    .month-menu {
        left: 0;
        right: auto;
    }

    .metric-grid,
    .dashboard-grid,
    .small-side,
    .form-grid {
        grid-template-columns: 1fr;
    }

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

    .calendar-popover {
        left: 50%;
        transform: translateX(-50%);
    }
}

@media (max-width: 640px) {
    .auth-page {
        padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    }

    .auth-card {
        padding: 18px;
    }

    .logo-panel {
        min-height: 135px;
        margin-bottom: 26px;
        padding: 16px;
        overflow: hidden;
    }

    .logo-mark {
        width: 64px;
        height: 64px;
        font-size: 24px;
    }

    .logo-text {
        font-size: clamp(34px, 12vw, 50px);
    }

    .auth-form input,
    .auth-form button {
        min-height: 62px;
    }

    .content {
        padding: 14px;
    }

    .page-header {
        gap: 14px;
        margin-bottom: 18px;
    }

    h1 {
        font-size: clamp(29px, 11vw, 40px);
    }

    .metric-card,
    .panel,
    .planning-hero {
        padding: 16px;
    }

    .metric-card {
        min-height: 112px;
    }

    .month-filter {
        width: 100%;
    }

    .month-arrow {
        width: 48px;
        min-height: 48px;
    }

    .month-current {
        min-height: 48px;
        padding: 0 10px;
        font-size: 14px;
    }

    .month-menu {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: calc(100vw - 28px);
        max-width: none;
    }

    .button-link,
    .month-filter > .button-link {
        width: 100%;
    }

    .segmented {
        width: 100%;
        max-width: none;
    }

    .segmented span {
        padding: 12px 10px;
    }

    .check-row {
        align-items: flex-start;
    }

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

    .form-actions button,
    .form-actions a {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

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

    .actions form,
    .actions button {
        width: 100%;
    }

    .calendar-popover {
        width: calc(100vw - 28px);
        padding: 12px;
    }

    .calendar-grid {
        gap: 4px;
    }

    .calendar-grid button {
        min-height: 36px;
    }

    .table-wrap {
        margin-inline: -16px;
        padding-inline: 16px;
    }

    table {
        min-width: 0;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
    }

    thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    tr {
        margin-bottom: 12px;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #202023;
    }

    td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 14px;
        padding: 10px 0;
        border-bottom: 1px solid rgba(255, 255, 255, .07);
        white-space: normal;
        overflow-wrap: anywhere;
        text-align: right;
    }

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

    td::before {
        content: attr(data-label);
        flex: 0 0 42%;
        color: var(--muted);
        font-size: 12px;
        font-weight: 900;
        text-align: left;
        text-transform: uppercase;
    }

    td.empty {
        display: block;
        text-align: left;
    }

    td.empty::before {
        content: "";
        display: none;
    }

    td.actions {
        display: grid;
        gap: 10px;
        text-align: left;
    }

    td.actions::before {
        flex: none;
    }

    .timeline-item,
    .due-item {
        align-items: flex-start;
        flex-direction: column;
        width: 100%;
    }

    .timeline-item b,
    .due-item b {
        max-width: 100%;
        overflow-wrap: anywhere;
    }
}
