:root {
    --g-blue:    #1a73e8;
    --g-blue-d:  #1765cc;
    --g-bg:      #f8f9fa;
    --g-surface: #ffffff;
    --g-text:    #202124;
    --g-text2:   #5f6368;
    --g-border:  #dadce0;
    --g-hover:   #f1f3f4;
    --g-green:   #188038;
    --g-red:     #d93025;
    --g-yellow:  #f9ab00;
}

* { box-sizing: border-box; }
body {
    font-family: 'Roboto', system-ui, -apple-system, sans-serif;
    background: var(--g-bg);
    color: var(--g-text);
    margin: 0;
}
a { color: var(--g-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.material-symbols-outlined { font-size: 20px; vertical-align: middle; line-height: 1; }

/* ── Top bar ─────────────────────────────────────────── */
.g-topbar {
    background: var(--g-surface);
    border-bottom: 1px solid var(--g-border);
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.g-brand {
    font-size: 1.32rem;
    font-weight: 500;
    color: var(--g-text);
    display: flex;
    align-items: center;
    gap: 10px;
}
.g-brand .logo {
    width: 34px; height: 34px; border-radius: 50%;
    background: #000;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700;
}
.g-spacer { flex: 1; }
.g-user {
    display: flex; align-items: center; gap: 12px;
    color: var(--g-text2); font-size: .88rem;
}
.g-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--g-blue); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 500; font-size: 1rem;
}

/* ── Tabs ────────────────────────────────────────────── */
.g-tabs {
    background: var(--g-surface);
    border-bottom: 1px solid var(--g-border);
    padding: 0 16px;
    display: flex;
    gap: 2px;
    position: sticky;
    top: 64px;
    z-index: 99;
}
.g-tab {
    padding: 16px 22px;
    color: var(--g-text2);
    font-size: .9rem;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    display: flex; align-items: center; gap: 8px;
}
.g-tab:hover { background: var(--g-hover); color: var(--g-text); text-decoration: none; }
.g-tab.active { color: var(--g-blue); border-bottom-color: var(--g-blue); }

/* ── Layout ──────────────────────────────────────────── */
.g-main { max-width: 1200px; margin: 0 auto; padding: 28px 24px; }
.g-page-title { font-size: 1.5rem; font-weight: 400; margin: 0 0 20px; }

/* ── Card ────────────────────────────────────────────── */
.g-card {
    background: var(--g-surface);
    border: 1px solid var(--g-border);
    border-radius: 10px;
    padding: 22px 24px;
}
.g-card + .g-card { margin-top: 18px; }

/* ── Botões ──────────────────────────────────────────── */
.btn-g, .btn-g-outline {
    border-radius: 4px; padding: 9px 22px; font-weight: 500; font-size: .88rem;
    cursor: pointer; border: 1px solid transparent; display: inline-flex; align-items: center; gap: 6px;
    transition: background .15s, box-shadow .15s;
}
.btn-g { background: var(--g-blue); color: #fff; }
.btn-g:hover { background: var(--g-blue-d); box-shadow: 0 1px 3px rgba(60,64,67,.3); color: #fff; text-decoration: none; }
.btn-g-outline { background: #fff; color: var(--g-blue); border-color: var(--g-border); }
.btn-g-outline:hover { background: #f6faff; text-decoration: none; }
.btn-danger-g { background: #fff; color: var(--g-red); border: 1px solid var(--g-border); border-radius: 4px; padding: 6px 14px; cursor: pointer; font-size: .85rem; }
.btn-danger-g:hover { background: #fce8e6; }

/* ── Form fields ─────────────────────────────────────── */
.g-field { margin-bottom: 18px; }
.g-field label { display: block; font-size: .8rem; color: var(--g-text2); margin-bottom: 6px; }
.g-input, .g-select {
    width: 100%; padding: 11px 14px; font-size: .95rem;
    border: 1px solid var(--g-border); border-radius: 6px; background: #fff; color: var(--g-text);
}
.g-input:focus, .g-select:focus { outline: none; border-color: var(--g-blue); box-shadow: 0 0 0 1px var(--g-blue); }

/* ── Toolbar (busca/filtros) ─────────────────────────── */
.g-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.g-search { flex: 1; min-width: 220px; position: relative; }
.g-search .material-symbols-outlined { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--g-text2); }
.g-search input { width: 100%; padding: 10px 14px 10px 42px; border: 1px solid var(--g-border); border-radius: 24px; font-size: .92rem; }
.g-search input:focus { outline: none; border-color: var(--g-blue); box-shadow: 0 1px 4px rgba(60,64,67,.2); }

/* ── Tabela ──────────────────────────────────────────── */
.g-table { width: 100%; border-collapse: collapse; background: #fff; }
.g-table th {
    text-align: left; font-size: .75rem; font-weight: 500; letter-spacing: .04em;
    text-transform: uppercase; color: var(--g-text2);
    padding: 14px 16px; border-bottom: 1px solid var(--g-border);
}
.g-table td { padding: 14px 16px; border-bottom: 1px solid var(--g-border); font-size: .9rem; }
.g-table tr:hover td { background: var(--g-hover); }
.g-table tr:last-child td { border-bottom: none; }
.g-table-wrap { background: #fff; border: 1px solid var(--g-border); border-radius: 10px; overflow: hidden; }

/* ── Chips / badges ──────────────────────────────────── */
.chip {
    display: inline-block; padding: 3px 10px; border-radius: 12px;
    font-size: .76rem; font-weight: 500; background: var(--g-hover); color: var(--g-text2);
}
.chip-blue  { background: #e8f0fe; color: var(--g-blue); }
.chip-green { background: #e6f4ea; color: var(--g-green); }
.chip-red   { background: #fce8e6; color: var(--g-red); }

/* ── KPIs (analytics) ────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--g-border); border-radius: 10px; padding: 20px 22px; }
.kpi .label { font-size: .82rem; color: var(--g-text2); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 2.1rem; font-weight: 400; margin-top: 6px; }
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; grid-auto-rows: 1fr; align-items: stretch; }
.chart-card { display: flex; flex-direction: column; }
.chart-card h3 { font-size: .95rem; font-weight: 500; margin: 0 0 14px; color: var(--g-text); }
.chart-box { position: relative; height: 280px; }

/* ── Detalhe do registro ─────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 28px; }
.detail-item .k { font-size: .76rem; color: var(--g-text2); text-transform: uppercase; letter-spacing: .03em; }
.detail-item .v { font-size: .98rem; margin-top: 2px; }
.section-title { font-size: 1rem; font-weight: 500; color: var(--g-blue); margin: 4px 0 16px; padding-bottom: 8px; border-bottom: 1px solid var(--g-border); }

/* ── Empty / alert ───────────────────────────────────── */
.g-empty { text-align: center; padding: 60px 20px; color: var(--g-text2); }
.g-empty .material-symbols-outlined { font-size: 56px; color: #bdc1c6; }
.g-alert { padding: 12px 16px; border-radius: 6px; font-size: .9rem; margin-bottom: 16px; }
.g-alert-error { background: #fce8e6; color: var(--g-red); }
.g-alert-ok { background: #e6f4ea; color: var(--g-green); }

/* ── Login ───────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
    background: #fff; border: 1px solid var(--g-border); border-radius: 12px;
    padding: 44px 40px; width: 100%; max-width: 400px; text-align: center;
}
.login-card .logo-big {
    width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 18px;
    background: #000;
    display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.6rem; font-weight: 700;
}
.login-card h1 { font-size: 1.5rem; font-weight: 400; margin: 0 0 6px; }
.login-card p.sub { color: var(--g-text2); font-size: .92rem; margin: 0 0 28px; }
.login-card .g-field { text-align: left; }
.pagination { display: flex; gap: 6px; justify-content: flex-end; margin-top: 16px; align-items: center; }
.pagination a, .pagination span { padding: 6px 12px; border-radius: 4px; font-size: .85rem; color: var(--g-text2); }
.pagination a:hover { background: var(--g-hover); text-decoration: none; }
.pagination .cur { background: var(--g-blue); color: #fff; }

/* Botão exportar empurrado para a direita (desktop) */
.export-btn { margin-left: auto; }

/* ── Filtros avançados ───────────────────────────────── */
.filters-panel { background: #fff; border: 1px solid var(--g-border); border-radius: 10px; margin-bottom: 18px; }
.filters-panel > summary {
    padding: 14px 18px; cursor: pointer; font-weight: 500; color: var(--g-text);
    display: flex; align-items: center; gap: 8px; list-style: none;
}
.filters-panel > summary::-webkit-details-marker { display: none; }
.filters-panel[open] > summary { border-bottom: 1px solid var(--g-border); }
.filter-count { background: var(--g-blue); color: #fff; border-radius: 12px; padding: 1px 9px; font-size: .75rem; }
.filters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; padding: 18px; align-items: start; }
.filter-dd { position: relative; }
.filter-dd > summary {
    padding: 10px 14px; border: 1px solid var(--g-border); border-radius: 6px; cursor: pointer;
    font-size: .88rem; display: flex; justify-content: space-between; align-items: center; gap: 8px;
    list-style: none; background: #fff; color: var(--g-text);
}
.filter-dd > summary::-webkit-details-marker { display: none; }
.filter-dd > summary::after { content: "▾"; color: var(--g-text2); font-size: .8rem; }
.filter-dd[open] > summary { border-color: var(--g-blue); box-shadow: 0 0 0 1px var(--g-blue); }
.filter-dd .badge-n { color: var(--g-blue); font-weight: 500; }
.filter-options {
    position: absolute; z-index: 30; top: calc(100% + 4px); left: 0;
    min-width: 100%; width: max-content; max-width: 320px;
    background: #fff; border: 1px solid var(--g-border); border-radius: 8px;
    box-shadow: 0 4px 18px rgba(0,0,0,.16); padding: 6px; max-height: 280px; overflow: auto;
}
.filter-options label { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; font-size: .88rem; cursor: pointer; white-space: nowrap; }
.filter-options label:hover { background: var(--g-hover); }
.filter-options input[type=checkbox] { accent-color: var(--g-blue); width: 16px; height: 16px; flex-shrink: 0; }
.filter-period { display: flex; gap: 12px; align-items: center; grid-column: span 2; }
.filter-period label { flex: 1; font-size: .8rem; color: var(--g-text2); display: flex; align-items: center; gap: 8px; }
.filter-period input { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--g-border); border-radius: 6px; }
.filter-actions { display: flex; gap: 10px; padding: 0 18px 18px; align-items: center; }

/* ══════════════ MOBILE (≤ 768px) ══════════════ */
@media (max-width: 768px) {
    .g-topbar { height: 56px; padding: 0 14px; }
    .g-brand { font-size: 1.1rem; gap: 8px; }
    .g-brand .logo { width: 30px; height: 30px; }
    .g-user-name { display: none; }

    .g-tabs { top: 56px; padding: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .g-tabs::-webkit-scrollbar { display: none; }
    .g-tab { padding: 13px 16px; font-size: .84rem; white-space: nowrap; }

    .g-main { padding: 18px 14px; }
    .g-page-title { font-size: 1.3rem; }

    /* Toolbar empilhada */
    .g-toolbar { flex-direction: column; align-items: stretch; }
    .g-search { min-width: 0; }
    .g-toolbar .g-select,
    .g-toolbar .btn-g,
    .g-toolbar .btn-g-outline { width: 100%; max-width: none; justify-content: center; }
    .export-btn { margin-left: 0; }

    /* Tabelas viram cards */
    .g-table-wrap { border: none; background: transparent; overflow: visible; }
    .g-table thead { display: none; }
    .g-table, .g-table tbody, .g-table tr, .g-table td { display: block; width: 100%; }
    .g-table tr {
        background: #fff; border: 1px solid var(--g-border);
        border-radius: 10px; margin-bottom: 12px; padding: 4px 14px;
    }
    .g-table tr:hover td { background: transparent; }
    .g-table td {
        border: none; border-bottom: 1px solid #f1f3f4;
        padding: 10px 0; display: flex; align-items: center;
        justify-content: space-between; gap: 16px;
    }
    .g-table td:last-child { border-bottom: none; }
    .g-table td::before {
        content: attr(data-label);
        font-size: .72rem; font-weight: 500; text-transform: uppercase;
        letter-spacing: .03em; color: var(--g-text2); flex-shrink: 0;
    }
    .g-table td[data-label=""] { padding-top: 12px; }
    .g-table td[data-label=""]::before { display: none; }
    .g-table td[data-label=""] .btn-g-outline,
    .g-table td[data-label=""] form { width: 100%; }
    .g-table td[data-label=""] .btn-g-outline { justify-content: center; }
    /* Nome em destaque (bloco, à esquerda) */
    .g-table td[data-label="Nome"] { display: block; }
    .g-table td[data-label="Nome"]::before { display: block; margin-bottom: 2px; }

    .detail-grid { grid-template-columns: 1fr; }
    .kpi .value { font-size: 1.8rem; }

    .filters-grid { grid-template-columns: 1fr; padding: 14px; }
    .filter-options { max-width: none; right: 0; }
    .filter-period { grid-column: auto; flex-direction: column; align-items: stretch; gap: 6px; }
    .filter-actions .btn-g,
    .filter-actions .btn-g-outline { width: 100%; justify-content: center; }
}
