/* ============================================================
   SUÊFY — Sistema Financeiro da Suê Corretora
   Cores do branding: #00367A · #004FC5 · #00D7AF
   Fonte: Nunito (similar ao Cocogoose/Cocon Pro do manual)
   ============================================================ */

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

:root {
    /* Marca Suêfy */
    --color-deep-blue:      #00367A;   /* Credibilidade */
    --color-blue:           #004FC5;   /* Confiança */
    --color-teal:           #00D7AF;   /* Frescor / Leveza */

    --color-primary:        var(--color-blue);
    --color-primary-hover:  #003FA5;
    --color-accent:         var(--color-teal);
    --color-danger:         #EF4444;
    --color-warning:        #F59E0B;
    --color-bg:             #F3F7FB;
    --color-surface:        #FFFFFF;
    --color-sidebar:        #00367A;
    --color-sidebar-text:   #B8D0EE;
    --color-sidebar-active: #004FC5;
    --color-border:         #DCE6F2;
    --color-text:           #00367A;
    --color-text-muted:     #5A7090;

    --sidebar-width:        260px;
    --sidebar-width-mini:   72px;
    --topbar-height:        62px;

    --radius:               10px;
    --radius-sm:            6px;
    --shadow-sm:            0 1px 3px rgba(0, 54, 122, 0.08);
    --shadow-md:            0 6px 18px rgba(0, 54, 122, 0.12);

    --gradient-brand:       linear-gradient(135deg, #00D7AF 0%, #004FC5 60%, #00367A 100%);

    --font-base: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--font-base);
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
code {
    background: #EEF3FA;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--color-blue);
}

/* ============================================================
   LOGOTIPO REUTILIZÁVEL
   ============================================================ */
.suefy-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    font-weight: 800;
}
.suefy-logo .bird {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
}
.suefy-logo .name {
    font-size: 22px;
    letter-spacing: -0.5px;
    line-height: 1;
}
.suefy-logo .name .accent { color: var(--color-teal); }

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrapper {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: var(--gradient-brand);
    background-attachment: fixed;
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.login-wrapper::before,
.login-wrapper::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.35;
}
.login-wrapper::before {
    width: 380px; height: 380px;
    background: #00D7AF;
    top: -100px; left: -100px;
}
.login-wrapper::after {
    width: 480px; height: 480px;
    background: #004FC5;
    bottom: -150px; right: -150px;
}

.login-card {
    background: var(--color-surface);
    padding: 44px 40px 32px;
    border-radius: 18px;
    box-shadow: 0 25px 70px rgba(0, 54, 122, 0.35);
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}
.login-logo .bird-big {
    width: 78px;
    height: 78px;
    margin: 0 auto 12px;
}
.login-logo h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--color-deep-blue);
    letter-spacing: -0.5px;
}
.login-logo h1 .accent { color: var(--color-teal); }
.login-logo p {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-top: 4px;
    font-weight: 600;
}

.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--color-deep-blue);
}

.form-control {
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
    background: #fff;
    color: var(--color-text);
}
.form-control:focus {
    outline: none;
    border-color: var(--color-blue);
    box-shadow: 0 0 0 3px rgba(0, 79, 197, 0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    font-size: 14px;
    font-weight: 700;
    transition: all .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--color-blue);
    color: #fff;
}
.btn-primary:hover {
    background: var(--color-primary-hover);
    box-shadow: 0 4px 12px rgba(0, 79, 197, .35);
}
.btn-gradient {
    background: var(--gradient-brand);
    color: #fff;
    border: none;
}
.btn-gradient:hover { filter: brightness(1.05); }
.btn-block { width: 100%; padding: 12px; }
.btn-secondary {
    background: #fff;
    color: var(--color-deep-blue);
    border-color: var(--color-border);
}
.btn-secondary:hover { background: #EEF3FA; }
.btn-danger {
    background: var(--color-danger);
    color: #fff;
}
.btn-danger:hover { background: #DC2626; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

.login-footer {
    text-align: center;
    margin-top: 22px;
    font-size: 12px;
    color: var(--color-text-muted);
    font-weight: 600;
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--topbar-height) 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar main";
    height: 100vh;
    overflow: hidden;
    transition: grid-template-columns .25s ease;
}
.app.sidebar-collapsed {
    grid-template-columns: var(--sidebar-width-mini) 1fr;
}

/* SIDEBAR */
.sidebar {
    grid-area: sidebar;
    background: var(--color-sidebar);
    background-image:
        radial-gradient(1200px 200px at -100px 100%, rgba(0, 215, 175, .18), transparent 60%),
        radial-gradient(800px 200px at 100% -50px, rgba(0, 79, 197, .35), transparent 60%);
    color: var(--color-sidebar-text);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,.10);
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
}
.sidebar-header .bird {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}
.sidebar-header .brand {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    white-space: nowrap;
}
.sidebar-header .brand .accent { color: var(--color-teal); }
.app.sidebar-collapsed .sidebar-header .brand { display: none; }

.nav {
    padding: 14px 0;
    flex: 1;
}
.nav-group {
    margin-bottom: 8px;
}
.nav-group-title {
    padding: 14px 20px 6px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #6FAFE8;
}
.app.sidebar-collapsed .nav-group-title { padding: 14px 0 6px; text-align: center; }
.app.sidebar-collapsed .nav-group-title span { display: none; }
.app.sidebar-collapsed .nav-group-title::after { content: "•••"; color: #4A78A8; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: var(--color-sidebar-text);
    cursor: pointer;
    transition: all .12s;
    border-left: 3px solid transparent;
    white-space: nowrap;
    font-weight: 600;
}
.nav-item:hover {
    background: rgba(255,255,255,.05);
    color: #fff;
}
.nav-item.active {
    background: linear-gradient(90deg, rgba(0, 215, 175, .15), transparent 80%);
    color: #fff;
    border-left-color: var(--color-teal);
}
.nav-item .icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    font-size: 17px;
}
.app.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
}
.app.sidebar-collapsed .nav-item .label { display: none; }

/* TOPBAR */
.topbar {
    grid-area: topbar;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    box-shadow: var(--shadow-sm);
}
.topbar-toggle {
    background: none;
    border: none;
    font-size: 22px;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    display: grid;
    place-items: center;
}
.topbar-toggle:hover { background: var(--color-bg); color: var(--color-deep-blue); }

.topbar-title {
    font-size: 16px;
    font-weight: 800;
    flex: 1;
    color: var(--color-deep-blue);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    font-weight: 700;
}
.topbar-user .avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--gradient-brand);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
}

/* MAIN */
.main {
    grid-area: main;
    overflow-y: auto;
    padding: 24px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}
.page-header h2 {
    font-size: 24px;
    font-weight: 800;
    color: var(--color-deep-blue);
    letter-spacing: -0.3px;
}
.page-header .subtitle {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-top: 4px;
    font-weight: 600;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-header h3 {
    font-size: 15px;
    font-weight: 800;
    color: var(--color-deep-blue);
}
.card-body { padding: 20px; }

/* Filter bar */
.filter-bar {
    margin-bottom: 14px;
    padding: 14px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px 12px;
    align-items: end;
}
.filter-grid .form-group { margin: 0; }
.filter-grid label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}
.filter-grid .form-control {
    padding: 7px 10px;
    font-size: 13px;
}
.filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

/* Tabela genérica + edição inline */
.table-wrapper {
    overflow: auto;
    max-height: calc(100vh - 340px);
    border-radius: var(--radius-sm);
}
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: fixed;             /* respeita widths fixos */
}
table.data-table th,
table.data-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
table.data-table th {
    background: #EEF3FA;
    font-weight: 800;
    color: var(--color-deep-blue);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .05em;
    position: sticky;
    top: 0;
    z-index: 1;
    user-select: none;
}
.col-resizer {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    background: transparent;
    z-index: 2;
}
table.data-table th { position: relative; }
.col-resizer:hover, .col-resizer.active {
    background: var(--color-blue);
}
table.data-table tbody tr:hover {
    background: #F7FAFD;
}
table.data-table td.editable {
    cursor: text;
    position: relative;
}
table.data-table td.editable:hover {
    background: #E6F0FB;
    outline: 1px dashed var(--color-blue);
    outline-offset: -2px;
}
table.data-table td.editing {
    padding: 0;
    background: #fff;
    outline: 2px solid var(--color-blue);
    outline-offset: -2px;
}
table.data-table td .cell-input {
    width: 100%;
    height: 100%;
    padding: 10px 14px;
    border: none;
    outline: none;
    font: inherit;
    color: inherit;
    background: transparent;
}
table.data-table td .cell-input:focus { background: #FFFCE6; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-text-muted);
    font-weight: 600;
}
.empty-state .icon { font-size: 38px; margin-bottom: 10px; }

.loading {
    text-align: center;
    padding: 40px;
    color: var(--color-text-muted);
    font-weight: 600;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.kpi-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 4px;
    background: var(--gradient-brand);
}
.kpi-card .label {
    font-size: 12px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 8px;
    font-weight: 700;
}
.kpi-card .value {
    font-size: 24px;
    font-weight: 800;
    color: var(--color-deep-blue);
}
.kpi-card.positive .value { color: #008F70; }
.kpi-card.negative .value { color: var(--color-danger); }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.badge-success { background: #CFFAE9; color: #006D54; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-danger  { background: #FEE2E2; color: #991B1B; }
.badge-muted   { background: #E2E8F0; color: #475569; }

/* Responsivo */
@media (max-width: 768px) {
    .app {
        grid-template-columns: 0 1fr;
    }
    .app.sidebar-open {
        grid-template-columns: var(--sidebar-width) 1fr;
    }
    .sidebar { position: fixed; height: 100vh; z-index: 100; }
}

/* ============================================================
   MODAL — redimensionável e com scroll
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 54, 122, 0.55);
    backdrop-filter: blur(2px);
    display: grid;
    place-items: center;
    z-index: 999;
    padding: 20px;
    animation: fadeIn .15s ease;
}
.modal {
    background: var(--color-surface);
    border-radius: 14px;
    width: 720px;
    max-width: 100%;
    height: 80vh;
    max-height: 90vh;
    min-width: 360px;
    min-height: 360px;
    box-shadow: 0 25px 60px rgba(0, 54, 122, 0.40);
    display: grid;
    grid-template-rows: auto 1fr auto;
    resize: both;                /* permite arrastar canto inferior direito */
    overflow: hidden;            /* clip do resize */
    animation: slideIn .2s ease;
}
.modal-header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(180deg, #F7FAFD 0%, #fff 100%);
}
.modal-header h3 {
    font-size: 17px;
    font-weight: 800;
    color: var(--color-deep-blue);
}
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--color-text-muted);
    cursor: pointer;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: grid;
    place-items: center;
}
.modal-close:hover { background: #EEF3FA; color: var(--color-deep-blue); }

.modal-body {
    padding: 22px 24px;
    overflow-y: auto;            /* scroll vertical sempre disponível */
    overflow-x: hidden;
}
.modal-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #F7FAFD;
}

textarea.form-control {
    font-family: inherit;
    resize: vertical;
    min-height: 70px;
}
select.form-control { background: #fff; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
@media (max-width: 580px) {
    .form-row { grid-template-columns: 1fr; }
}

.form-group .hint {
    font-size: 11.5px;
    color: var(--color-text-muted);
    margin-top: 4px;
    font-weight: 600;
}
.form-group .required-mark {
    color: var(--color-danger);
    margin-left: 2px;
}
.form-group.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.form-group.checkbox-group label {
    margin: 0;
    cursor: pointer;
    font-weight: 600;
}
.form-group.checkbox-group input[type=checkbox] {
    width: 17px;
    height: 17px;
    cursor: pointer;
    accent-color: var(--color-blue);
}

/* Ações da tabela */
.row-actions {
    display: flex;
    gap: 6px;
}
.action-btn {
    background: #fff;
    border: 1px solid var(--color-border);
    padding: 4px 9px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--color-text-muted);
    transition: all .12s;
}
.action-btn:hover { background: #EEF3FA; color: var(--color-deep-blue); }
.action-btn.danger:hover {
    background: #FEE2E2;
    border-color: var(--color-danger);
    color: var(--color-danger);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 22px;
    right: 22px;
    background: var(--color-deep-blue);
    color: #fff;
    padding: 13px 22px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 1001;
    animation: slideIn .25s ease;
    max-width: 380px;
    font-weight: 700;
}
.toast.success { background: linear-gradient(135deg, #00D7AF, #00A38A); color: #00367A; }
.toast.error   { background: linear-gradient(135deg, #EF4444, #B91C1C); }

@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
