@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0d1117;
    --bg2: #161b22;
    --bg3: #21262d;
    --border: rgba(255,255,255,0.08);
    --border2: rgba(255,255,255,0.14);
    --text: #e6edf3;
    --text2: #8b949e;
    --text3: #6e7681;
    --green: #2ea043;
    --green-glow: rgba(46,160,67,0.25);
    --green-light: #3fb950;
    --red: #da3633;
    --red-glow: rgba(218,54,51,0.25);
    --red-light: #f85149;
    --blue: #1f6feb;
    --blue-glow: rgba(31,111,235,0.25);
    --blue-light: #58a6ff;
    --purple: #8957e5;
    --purple-glow: rgba(137,87,229,0.25);
    --orange: #d97706;
    --orange-glow: rgba(217,119,6,0.2);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px rgba(0,0,0,0.4);
    --transition: all 0.2s ease;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    padding-bottom: 40px;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 3px; }

/* ===== TOPBAR ===== */
.topbar {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.topbar-brand .icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}

.topbar-user {
    display: flex; align-items: center; gap: 12px;
    color: var(--text2); font-size: 0.85rem;
}

.topbar-user a {
    color: var(--text2);
    text-decoration: none;
    display: flex; align-items: center; gap: 5px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.topbar-user a:hover {
    background: var(--bg3);
    color: var(--text);
    border-color: var(--border2);
}

/* ===== CONTAINER ===== */
.container {
    max-width: 1100px;
    margin: 32px auto;
    padding: 0 20px;
}

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 28px;
}

.page-title h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
}

.page-title p {
    color: var(--text2);
    font-size: 0.85rem;
    margin-top: 2px;
}

/* ===== DATE FILTER ===== */
.date-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 6px 6px 14px;
}

.date-filter label {
    font-size: 0.8rem;
    color: var(--text2);
    font-weight: 500;
    white-space: nowrap;
}

.date-filter input[type="date"] {
    background: transparent;
    border: none;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    color-scheme: dark;
}

.date-filter button {
    background: var(--blue);
    color: white;
    border: none;
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Inter', sans-serif;
}

.date-filter button:hover { background: #388bfd; }

/* ===== QUICK ACTIONS ===== */
.actions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 28px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-green {
    background: rgba(46,160,67,0.15);
    color: var(--green-light);
    border: 1px solid rgba(46,160,67,0.3);
}
.btn-green:hover { background: rgba(46,160,67,0.25); border-color: var(--green-light); box-shadow: 0 0 12px var(--green-glow); }

.btn-blue {
    background: rgba(31,111,235,0.15);
    color: var(--blue-light);
    border: 1px solid rgba(31,111,235,0.3);
}
.btn-blue:hover { background: rgba(31,111,235,0.25); border-color: var(--blue-light); box-shadow: 0 0 12px var(--blue-glow); }

.btn-red {
    background: rgba(218,54,51,0.15);
    color: var(--red-light);
    border: 1px solid rgba(218,54,51,0.3);
}
.btn-red:hover { background: rgba(218,54,51,0.25); border-color: var(--red-light); box-shadow: 0 0 12px var(--red-glow); }

.btn-ghost {
    background: transparent;
    color: var(--text2);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); border-color: var(--border2); }

.btn-primary {
    background: var(--blue);
    color: white;
    border: 1px solid transparent;
}
.btn-primary:hover { background: #388bfd; box-shadow: 0 0 16px var(--blue-glow); }

.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-danger { background: rgba(218,54,51,0.12); color: var(--red-light); border: 1px solid rgba(218,54,51,0.25); }
.btn-danger:hover { background: rgba(218,54,51,0.22); }

/* ===== SUMMARY CARDS ===== */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 32px;
}

.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.card-green::before { background: linear-gradient(90deg, var(--green), var(--green-light)); }
.card-blue::before { background: linear-gradient(90deg, var(--blue), var(--blue-light)); }
.card-red::before { background: linear-gradient(90deg, var(--red), var(--red-light)); }
.card-purple::before { background: linear-gradient(90deg, var(--purple), #a78bfa); }
.card-orange::before { background: linear-gradient(90deg, var(--orange), #fbbf24); }

.card:hover { border-color: var(--border2); transform: translateY(-2px); box-shadow: var(--shadow); }

.card-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text2);
    margin-bottom: 8px;
    display: flex; align-items: center; gap: 6px;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.card-green .card-value { color: var(--green-light); }
.card-blue .card-value { color: var(--blue-light); }
.card-red .card-value { color: var(--red-light); }
.card-purple .card-value { color: #a78bfa; }
.card-orange .card-value { color: #fbbf24; }

.card-sub {
    font-size: 0.75rem;
    color: var(--text3);
    margin-top: 4px;
}

/* ===== SECTION ===== */
.section {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.section-header:hover { background: rgba(255,255,255,0.03); }

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.section-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    background: var(--bg3);
    color: var(--text2);
}

.section-total {
    font-size: 0.88rem;
    font-weight: 700;
    display: flex; align-items: center; gap: 8px;
}

.section-toggle { color: var(--text3); font-size: 12px; transition: transform 0.2s; }
.section.collapsed .section-toggle { transform: rotate(-90deg); }
.section.collapsed .section-body { display: none; }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

thead tr {
    background: var(--bg3);
}

th {
    padding: 11px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text2);
    text-align: left;
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    font-size: 0.85rem;
    color: var(--text);
    border-top: 1px solid var(--border);
    vertical-align: middle;
}

tr:hover td { background: rgba(255,255,255,0.02); }

.empty-row td {
    text-align: center;
    color: var(--text3);
    font-size: 0.82rem;
    padding: 24px;
    font-style: italic;
}

.valor-positivo { color: var(--green-light); font-weight: 600; }
.valor-negativo { color: var(--red-light); font-weight: 600; }
.valor-neutro { color: var(--blue-light); font-weight: 600; }

.td-actions { display: flex; gap: 6px; }

/* ===== BADGE ===== */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
}
.badge-banco { background: rgba(31,111,235,0.2); color: var(--blue-light); }
.badge-caixa { background: rgba(137,87,229,0.2); color: #a78bfa; }

/* ===== FORMS ===== */
.form-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    max-width: 520px;
    margin: 32px auto;
}

.form-card h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 6px;
    display: flex; align-items: center; gap: 10px;
}

.form-subtitle {
    font-size: 0.82rem;
    color: var(--text2);
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 7px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
    outline: none;
    color-scheme: dark;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--blue-light);
    box-shadow: 0 0 0 3px rgba(88,166,255,0.1);
}

.form-group select option { background: var(--bg3); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.form-actions {
    display: flex; gap: 10px; margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.form-actions .btn { flex: 1; justify-content: center; padding: 12px; }

/* ===== LOGIN ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 20px;
}

.login-box {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
    text-align: center;
}

.login-logo {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 26px;
    margin: 0 auto 20px;
    box-shadow: 0 0 24px var(--blue-glow);
}

.login-box h1 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 4px;
}

.login-box p {
    color: var(--text2);
    font-size: 0.84rem;
    margin-bottom: 28px;
}

.login-box .form-group { text-align: left; }

.login-box .btn { width: 100%; justify-content: center; padding: 12px; font-size: 0.9rem; margin-top: 8px; }

.alert-error {
    background: rgba(218,54,51,0.15);
    border: 1px solid rgba(218,54,51,0.35);
    color: var(--red-light);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 18px;
    display: flex; align-items: center; gap: 8px;
}

.alert-success {
    background: rgba(46,160,67,0.15);
    border: 1px solid rgba(46,160,67,0.35);
    color: var(--green-light);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 18px;
    display: flex; align-items: center; gap: 8px;
}

/* ===== SALDO DESTAQUE ===== */
.saldo-card {
    background: linear-gradient(135deg, rgba(31,111,235,0.1), rgba(137,87,229,0.1));
    border: 1px solid rgba(88,166,255,0.2);
    border-radius: var(--radius);
    padding: 24px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 28px;
}

.saldo-info { display: flex; flex-direction: column; gap: 4px; }
.saldo-label { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text2); }
.saldo-value { font-size: 2rem; font-weight: 800; letter-spacing: -1px; }
.saldo-positivo { color: var(--green-light); }
.saldo-negativo { color: var(--red-light); }
.saldo-anterior-tag { font-size: 0.78rem; color: var(--text3); }

/* ===== ANIMATIONS ===== */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.summary-grid { animation: fadeUp 0.35s ease both; }
.section       { animation: fadeUp 0.4s ease both; }
.section:nth-child(2) { animation-delay: 0.05s; }
.section:nth-child(3) { animation-delay: 0.10s; }
.section:nth-child(4) { animation-delay: 0.15s; }
.section:nth-child(5) { animation-delay: 0.20s; }
.form-card     { animation: fadeUp 0.35s ease both; }
.login-box     { animation: fadeUp 0.4s ease both; }

.card { animation: fadeUp 0.3s ease both; }
.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.10s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.20s; }

/* Button press effect */
.btn:active { transform: scale(0.97); }

/* Topbar saldo chip */
.topbar-saldo {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 20px;
    background: rgba(46,160,67,0.12);
    border: 1px solid rgba(46,160,67,0.25);
    color: var(--green-light);
}

.topbar-saldo.negativo {
    background: rgba(218,54,51,0.12);
    border-color: rgba(218,54,51,0.25);
    color: var(--red-light);
}

/* Input focus ring animation */
.form-group input:focus,
.form-group select:focus {
    animation: focusRing 0.2s ease;
}

@keyframes focusRing {
    from { box-shadow: 0 0 0 0 rgba(88,166,255,0.3); }
    to   { box-shadow: 0 0 0 3px rgba(88,166,255,0.1); }
}

/* Table row animation */
tbody tr {
    animation: fadeIn 0.2s ease both;
}

/* Divider utility */
.divider {
    height: 1px;
    background: var(--border);
    margin: 24px 0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .topbar { padding: 0 16px; }
    .container { margin: 16px auto; padding: 0 14px; }
    .page-header { flex-direction: column; }
    .date-filter { width: 100%; }
    .summary-grid { grid-template-columns: 1fr 1fr; }
    .card-value { font-size: 1.25rem; }
    th, td { padding: 10px 12px; }
    .saldo-value { font-size: 1.6rem; }
    .form-row { grid-template-columns: 1fr; }
    .form-card { padding: 20px; margin: 16px auto; }
}

@media (max-width: 480px) {
    .summary-grid { grid-template-columns: 1fr; }
    .actions-bar { flex-direction: column; }
    .actions-bar .btn { justify-content: center; }
    .topbar-brand span { display: none; }
}
