@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ============================================================
   SISTEMA DE CONCILIAÇÃO — Design System
   Identidade: índigo profundo + slate, destaque âmbar discreto.
   App de dados denso para contadores power-users.
   ============================================================ */

:root {
    /* Marca — índigo/slate profundo */
    --brand-900: #0B1220;   /* sidebar base */
    --brand-850: #0F172A;   /* sidebar gradiente topo */
    --brand-800: #111c33;
    --brand-700: #1e293b;
    --brand-600: #334155;

    /* Acento — índigo vibrante (ações, foco, ativo) */
    --accent: #6366F1;
    --accent-strong: #4F46E5;
    --accent-soft: #EEF0FE;
    --accent-ring: rgba(99, 102, 241, .35);

    /* Destaque secundário — âmbar (pendências, atenção) */
    --amber: #D97706;
    --amber-soft: #FEF3C7;
    --amber-border: #FCD34D;

    /* Semânticos */
    --green: #15803D;
    --green-soft: #DCFCE7;
    --red: #B91C1C;
    --red-soft: #FEE2E2;

    /* Neutros */
    --bg: #F6F8FB;
    --surface: #FFFFFF;
    --border: #E5EAF1;
    --border-strong: #D5DCE6;
    --text: #1E293B;
    --text-soft: #64748B;
    --text-faint: #94A3B8;

    /* Tokens estruturais */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
    --shadow: 0 4px 12px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);
    --sidebar-w: 248px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', system-ui, -apple-system, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.mono { font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace; font-variant-numeric: tabular-nums; }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, .28); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, .45); }
::-webkit-scrollbar-track { background: transparent; }
.sidebar ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); }

/* ============================================================
   SHELL — Sidebar
   ============================================================ */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    height: 100vh;
    overflow-y: auto;
    background: linear-gradient(180deg, var(--brand-850) 0%, var(--brand-900) 100%);
    border-right: 1px solid rgba(255, 255, 255, .06);
    z-index: 40;
    transition: transform .24s cubic-bezier(.4, 0, .2, 1);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.brand-mark {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    display: flex; align-items: center; justify-content: center;
    color: #fff; flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(79, 70, 229, .4);
}
.brand-mark svg { width: 19px; height: 19px; }
.brand-name { color: #fff; font-weight: 700; font-size: 14px; line-height: 1.15; letter-spacing: -.01em; }
.brand-sub { color: rgba(255, 255, 255, .42); font-size: 10.5px; margin-top: 1px; letter-spacing: .01em; }

.nav { flex: 1; padding: 10px 12px 14px; }
.nav-group {
    font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
    color: rgba(255, 255, 255, .34); font-weight: 700;
    padding: 16px 10px 6px;
}

.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 8px 10px; margin: 1px 0;
    color: rgba(255, 255, 255, .68);
    font-size: 13.5px; font-weight: 500;
    border-radius: var(--radius-sm);
    transition: background .14s, color .14s;
    cursor: pointer; position: relative;
    text-decoration: none;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active {
    background: rgba(99, 102, 241, .16);
    color: #fff; font-weight: 600;
}
.nav-item.active::before {
    content: ''; position: absolute; left: -4px; top: 50%; transform: translateY(-50%);
    width: 3px; height: 18px; border-radius: 3px; background: var(--accent);
}
.nav-item.active .nav-ico { color: #a5b4fc; }
.nav-item.disabled { color: rgba(255, 255, 255, .30); cursor: default; }
.nav-item.disabled:hover { background: transparent; color: rgba(255, 255, 255, .30); }
.nav-ico { width: 18px; height: 18px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; opacity: .92; }
.nav-ico svg { width: 17px; height: 17px; stroke-width: 2; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.soon {
    font-size: 8.5px; letter-spacing: .04em;
    background: rgba(255, 255, 255, .09); color: rgba(255, 255, 255, .5);
    padding: 2px 6px; border-radius: 6px; text-transform: uppercase; font-weight: 600;
}

.sidebar-foot {
    padding: 12px 14px;
    border-top: 1px solid rgba(255, 255, 255, .07);
    display: flex; align-items: center; gap: 10px;
}
.avatar {
    width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
    background: rgba(255, 255, 255, .1); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; text-transform: uppercase;
}
.sidebar-user { color: rgba(255, 255, 255, .82); font-size: 12.5px; font-weight: 600; line-height: 1.1; }
.sidebar-logout { color: rgba(255, 255, 255, .42); font-size: 11px; text-decoration: none; transition: color .14s; }
.sidebar-logout:hover { color: #fff; }

/* ============================================================
   SHELL — Conteúdo / Topbar
   ============================================================ */
.shell { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
    background: rgba(255, 255, 255, .85);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 0 28px; height: 60px;
    display: flex; align-items: center; gap: 16px;
    position: sticky; top: 0; z-index: 30;
}

.menu-btn {
    display: none; width: 38px; height: 38px; border-radius: var(--radius-sm);
    align-items: center; justify-content: center; color: var(--text-soft);
    border: 1px solid var(--border); background: #fff; cursor: pointer;
}
.menu-btn:hover { background: var(--bg); }

.group-picker { display: flex; align-items: center; gap: 9px; }
.group-picker-label {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em;
    color: var(--text-faint); font-weight: 700;
}
.select {
    appearance: none; -webkit-appearance: none;
    border: 1px solid var(--border-strong); background: #fff;
    border-radius: var(--radius-sm); padding: 7px 34px 7px 12px;
    font-size: 13.5px; font-weight: 600; color: var(--text);
    cursor: pointer; transition: border-color .14s, box-shadow .14s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 11px center;
}
.select:hover { border-color: var(--accent); }
.select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

/* Select em formulário — mesma altura/peso/foco dos .input */
.select-field {
    appearance: none; -webkit-appearance: none;
    width: 100%;
    border: 1px solid var(--border-strong); background: #fff;
    border-radius: var(--radius-sm); padding: 9px 36px 9px 12px;
    font-size: 13.5px; font-weight: 500; color: var(--text); font-family: inherit;
    cursor: pointer; transition: border-color .14s, box-shadow .14s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
}
.select-field:hover { border-color: var(--text-faint); }
.select-field:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--text-soft); }

.content { padding: 28px; flex: 1; max-width: 1400px; width: 100%; }

/* ============================================================
   Tipografia de página
   ============================================================ */
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.page-sub { color: var(--text-soft); font-size: 13.5px; margin-top: 3px; }
.page-head { margin-bottom: 22px; }

.backlink {
    display: inline-flex; align-items: center; gap: 5px;
    color: var(--accent-strong); font-size: 13px; font-weight: 600;
    text-decoration: none; margin-bottom: 14px; transition: gap .14s;
}
.backlink:hover { gap: 8px; }
.backlink svg { width: 15px; height: 15px; }

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card-title { font-weight: 700; font-size: 14.5px; color: var(--text); letter-spacing: -.01em; }

/* Métricas (dashboard) */
.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px 22px;
    box-shadow: var(--shadow-sm); transition: box-shadow .18s, transform .18s, border-color .18s;
    position: relative; overflow: hidden;
}
.stat:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--border-strong); }
.stat-ico {
    width: 38px; height: 38px; border-radius: 10px; margin-bottom: 14px;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent-strong);
}
.stat-ico svg { width: 19px; height: 19px; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); font-weight: 700; }
.stat-value { font-size: 32px; font-weight: 800; letter-spacing: -.03em; color: var(--text); margin-top: 4px; line-height: 1; }
.stat-foot { font-size: 12px; color: var(--text-soft); margin-top: 7px; }

/* ============================================================
   Botões
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    font-size: 13.5px; font-weight: 600; border-radius: var(--radius-sm);
    padding: 9px 16px; cursor: pointer; transition: background .14s, box-shadow .14s, border-color .14s, color .14s;
    border: 1px solid transparent; text-decoration: none; white-space: nowrap; line-height: 1.2;
}
.btn svg { width: 16px; height: 16px; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }

.btn-primary { background: var(--accent-strong); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent); }
.btn-primary:active { background: var(--accent-strong); }

.btn-secondary { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg); border-color: var(--text-faint); }

.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.link { color: var(--accent-strong); font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ============================================================
   Formulários
   ============================================================ */
.field { display: block; margin-bottom: 18px; }
.field-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-soft); font-weight: 700; margin-bottom: 6px; }
.field-hint { display: block; font-size: 12px; color: var(--text-faint); margin-top: 6px; }

.input {
    width: 100%; border: 1px solid var(--border-strong); background: #fff;
    border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13.5px; color: var(--text);
    transition: border-color .14s, box-shadow .14s; font-family: inherit;
}
.input::placeholder { color: var(--text-faint); }
.input:hover { border-color: var(--text-faint); }
.input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* Inputs nativos de data — igualar caixa/altura ao .input de texto (senão o ícone de
   calendário nativo estoura o baseline de .form-row items-end). min-height (não height)
   p/ conviver com os .input !py-1 dos popovers. NÃO usar appearance:none aqui: ela colapsa
   o widget nativo de date/month e TRUNCA o texto (dd/mm/aaaa). */
.input[type="date"], .input[type="month"] {
    min-height: 38px; line-height: 1.2; min-width: 9rem;
}
.input[type="date"]::-webkit-calendar-picker-indicator,
.input[type="month"]::-webkit-calendar-picker-indicator {
    opacity: .55; cursor: pointer; margin-left: 2px;
}
.input[type="date"]:hover::-webkit-calendar-picker-indicator,
.input[type="month"]:hover::-webkit-calendar-picker-indicator { opacity: .85; }

/* Busca com ícone */
.search { position: relative; display: inline-block; }
@media (max-width: 640px) { .search.w-full { display: block; } }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-faint); pointer-events: none; }
.search .input { padding-left: 36px; }

/* Checkbox */
.checkbox { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text); cursor: pointer; user-select: none; }
.checkbox input[type="checkbox"] {
    appearance: none; -webkit-appearance: none; width: 18px; height: 18px; flex-shrink: 0;
    border: 1.5px solid var(--border-strong); border-radius: 5px; background: #fff;
    cursor: pointer; position: relative; transition: background .14s, border-color .14s;
}
.checkbox input[type="checkbox"]:hover { border-color: var(--accent); }
.checkbox input[type="checkbox"]:checked { background: var(--accent-strong); border-color: var(--accent-strong); }
.checkbox input[type="checkbox"]:checked::after {
    content: ''; position: absolute; left: 5px; top: 1.5px; width: 5px; height: 9px;
    border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.checkbox input[type="checkbox"]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }

/* Upload estilizado */
.file-drop {
    display: flex; align-items: center; gap: 11px;
    border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
    padding: 12px 14px; background: var(--bg); transition: border-color .14s, background .14s;
    cursor: pointer; position: relative;
}
.file-drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.file-drop:focus-within { border-color: var(--accent); border-style: solid; background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-ring); }
.file-drop input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-drop-ico { width: 34px; height: 34px; border-radius: 9px; background: #fff; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--accent-strong); flex-shrink: 0; }
.file-drop-ico svg { width: 17px; height: 17px; }
.file-drop-text { font-size: 12.5px; line-height: 1.3; min-width: 0; }
.file-drop-name { font-weight: 600; color: var(--text); }
.file-drop-hint { color: var(--text-faint); font-size: 11.5px; }

/* ============================================================
   Tabelas
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table thead th {
    background: #FAFBFD; color: var(--text-faint);
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700;
    text-align: left; padding: 11px 16px; white-space: nowrap;
    position: sticky; top: 0; z-index: 2;
    border-bottom: 1px solid var(--border);
}
.table tbody td { padding: 11px 16px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #FAFBFE; }
.table .num { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.table .t-soft { color: var(--text-soft); }
.table .t-faint { color: var(--text-faint); }
.td-center { text-align: center; }
.td-right { text-align: right; }

/* sticky header inside scroll wrapper */
.table-scroll { max-height: calc(100vh - 280px); overflow: auto; }
.table-scroll thead th { position: sticky; top: 0; }

/* ============================================================
   Badges / Chips
   ============================================================ */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
    line-height: 1.4; white-space: nowrap;
}
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-gray { background: #F1F5F9; color: var(--text-soft); }
.badge-indigo { background: var(--accent-soft); color: var(--accent-strong); }
.badge-red { background: var(--red-soft); color: var(--red); }

.status-on { color: var(--green); }
.status-off { color: var(--text-faint); }

/* Segmented control (abas de eixo: Movimento | Saldo) */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; }
.seg-item { font-size: 12.5px; font-weight: 600; color: var(--text-soft); padding: 5px 14px; border-radius: 7px; text-decoration: none; transition: background .12s, color .12s; white-space: nowrap; }
.seg-item:hover { color: var(--text); }
.seg-on { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow-sm); }

/* Cabeçalho de balde na matriz por conta */
.bucket-head { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--text-faint); }
.row-zebra:hover { background: #FAFBFE; }
.cell-cod { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11.5px; color: var(--text-soft); }

/* ============================================================
   Alertas / Banners
   ============================================================ */
.alert { display: flex; gap: 11px; align-items: flex-start; border-radius: var(--radius); padding: 13px 16px; font-size: 13px; line-height: 1.45; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-amber { background: var(--amber-soft); border: 1px solid var(--amber-border); color: #92400E; }
.alert-indigo { background: var(--accent-soft); border: 1px solid #C7D2FE; color: var(--accent-strong); }
.alert-red { background: var(--red-soft); border: 1px solid #FECACA; color: var(--red); }

/* ============================================================
   Empty states
   ============================================================ */
.empty { text-align: center; padding: 44px 24px; color: var(--text-faint); }
.empty-ico { width: 46px; height: 46px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; color: var(--text-faint); margin-bottom: 12px; }
.empty-ico svg { width: 22px; height: 22px; }
.empty-title { font-weight: 600; color: var(--text-soft); font-size: 14px; }
.empty-sub { font-size: 12.5px; margin-top: 3px; }

/* ============================================================
   Login
   ============================================================ */
.login-bg {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 24px;
    background:
        radial-gradient(900px 500px at 15% -10%, rgba(99, 102, 241, .25), transparent 60%),
        radial-gradient(800px 600px at 110% 110%, rgba(79, 70, 229, .22), transparent 55%),
        linear-gradient(180deg, var(--brand-850) 0%, var(--brand-900) 100%);
}
.login-card {
    background: var(--surface); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); padding: 32px; width: 100%; max-width: 372px;
    border: 1px solid rgba(255, 255, 255, .6);
}

/* ============================================================
   Drawer / Mobile
   ============================================================ */
.scrim { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 35; backdrop-filter: blur(1px); }

@media (max-width: 900px) {
    .shell { margin-left: 0; }
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .scrim { display: block; }
    .menu-btn { display: inline-flex; }
    .content { padding: 18px; }
    .topbar { padding: 0 16px; }
    .group-picker-label { display: none; }
    .topbar .select { max-width: 46vw; text-overflow: ellipsis; }
    .topbar-right .hidden { display: none; }
}

/* Focus visível geral para teclado */
a:focus-visible, button:focus-visible { outline: none; }
.nav-item:focus-visible { box-shadow: 0 0 0 2px var(--accent-ring); }
.backlink:focus-visible, .link:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; border-radius: 4px; }

/* utilitário de grid responsivo para stats */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 720px) { .stat-grid { grid-template-columns: 1fr; } }
.form-row { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.form-row .field-label { margin-bottom: 6px; }
.form-row .btn { flex-shrink: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

/* Larguras de página padronizadas */
.measure-list { max-width: 1100px; }   /* listas/tabelas largas */
.measure-form { max-width: 720px; }    /* formulários de edição */
.measure-narrow { max-width: 560px; }  /* formulários curtos */

/* Card de adicionar inline (Grupos/Categorias) — cabeçalho coeso */
.add-card { margin-bottom: 22px; }
.add-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.add-card-head .card-title { font-size: 13.5px; }

/* Separador interno de card (seções dentro do mesmo card) */
.card-divider { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }

/* Required marker */
.req { color: var(--red); font-weight: 700; }
