/* =====================================================
   MontaPack — Estilo global
   Tema dark na home/auth, tema claro no app interno
   ===================================================== */

:root {
    --bg-dark: #0D1117;
    --bg-dark-2: #161B22;
    --border-dark: #21262D;
    --text-dark: #F0F0F0;
    --text-dark-muted: #8B949E;

    --bg: #F6F8FA;
    --bg-card: #FFFFFF;
    --border: #E5E7EB;
    --text: #111827;
    --text-muted: #6B7280;

    --accent: #1D9E75;
    --accent-hover: #168A64;
    --accent-soft: rgba(29, 158, 117, 0.12);

    --danger: #DC2626;
    --warn: #D97706;
    --success: #16A34A;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);

    --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; height: auto; display: block; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.main { min-height: 60vh; }

/* ===== Botões ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: background .15s, transform .05s, border-color .15s, color .15s;
    text-decoration: none;
}
.btn:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-secondary {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); color: var(--text); border-color: #d1d5db; }
.btn-ghost {
    background: transparent;
    color: inherit;
    border-color: transparent;
}
.btn-ghost:hover { background: rgba(0,0,0,0.05); color: inherit; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 8px 14px; font-size: 14px; }
.btn-lg { padding: 14px 26px; font-size: 16px; }
.btn-block { width: 100%; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--text);
}
.input, input[type="text"], input[type="password"], input[type="number"], input[type="email"], select, textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.input:focus, input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.help { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.error { color: var(--danger); font-size: 14px; margin-top: 6px; }
.success { color: var(--success); font-size: 14px; margin-top: 6px; }

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid;
}
.alert-error  { background: #FEF2F2; color: #991B1B; border-color: #FECACA; }
.alert-success{ background: #ECFDF5; color: #065F46; border-color: #A7F3D0; }
.alert-info   { background: #EFF6FF; color: #1E40AF; border-color: #BFDBFE; }
.alert-warn   { background: #FFFBEB; color: #92400E; border-color: #FDE68A; }

/* ===== Card ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}
.card-tight { padding: 16px; }

/* ============================================================
   HOME / AUTH — TEMA ESCURO
   ============================================================ */
body.dark {
    background: var(--bg-dark);
    color: var(--text-dark);
}
body.dark a:not(.btn) { color: var(--accent); }
/* Garante que botões mantenham texto branco mesmo no tema dark */
body.dark a.btn,
body.dark a.btn:hover { color: #fff; }
body.dark a.btn-secondary,
body.dark a.btn-secondary:hover { color: var(--text-dark); }

.site-header-dark {
    padding: 20px 0;
    border-bottom: 1px solid var(--border-dark);
}
.site-header-dark .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
    color: inherit;
    text-decoration: none;
}
.brand:hover { text-decoration: none; }

.nav-dark a {
    color: var(--text-dark-muted);
    margin-left: 20px;
    font-size: 15px;
    text-decoration: none;
}
.nav-dark a:hover { color: var(--text-dark); }

/* Hero */
.hero {
    padding: 80px 0 100px;
    text-align: center;
}
.hero h1 {
    font-size: clamp(34px, 6vw, 56px);
    line-height: 1.1;
    margin: 0 0 18px;
    letter-spacing: -0.02em;
    font-weight: 800;
}
.hero h1 .accent { color: var(--accent); }
.hero p.lead {
    font-size: clamp(16px, 2.2vw, 20px);
    color: var(--text-dark-muted);
    max-width: 640px;
    margin: 0 auto 36px;
}
.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}
.hero-actions .btn-secondary {
    background: transparent;
    color: var(--text-dark);
    border-color: var(--border-dark);
}
.hero-actions .btn-secondary:hover { background: var(--bg-dark-2); color: var(--text-dark); }

.hero-art {
    margin: 50px auto 0;
    max-width: 420px;
    opacity: 0.95;
}

/* Sections */
.section {
    padding: 70px 0;
    border-top: 1px solid var(--border-dark);
}
.section h2 {
    font-size: clamp(26px, 4vw, 36px);
    margin: 0 0 12px;
    text-align: center;
    letter-spacing: -0.01em;
}
.section .sub {
    text-align: center;
    color: var(--text-dark-muted);
    margin-bottom: 48px;
    max-width: 620px;
    margin-left: auto;
    margin-right: auto;
}

.steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}
@media (max-width: 800px) { .steps { grid-template-columns: 1fr; } }
.step-card {
    background: var(--bg-dark-2);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    padding: 28px;
    text-align: center;
}
.step-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
}
.step-card h3 {
    font-size: 18px;
    margin: 0 0 8px;
    color: var(--text-dark);
}
.step-card p { margin: 0; color: var(--text-dark-muted); font-size: 15px; }

.benefits, .audience {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}
@media (max-width: 700px) { .benefits, .audience { grid-template-columns: 1fr; } }
.benefit, .audience-item {
    background: var(--bg-dark-2);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    padding: 22px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}
.benefit-icon, .audience-icon {
    color: var(--accent);
    flex-shrink: 0;
    margin-top: 2px;
}
.benefit strong, .audience-item strong { display: block; margin-bottom: 4px; color: var(--text-dark); }
.benefit span, .audience-item span { color: var(--text-dark-muted); font-size: 14px; }

/* Footer dark */
body.dark .site-footer {
    border-top: 1px solid var(--border-dark);
    background: transparent;
    color: var(--text-dark-muted);
}
body.dark .site-footer a { color: var(--text-dark-muted); }
body.dark .site-footer a:hover { color: var(--text-dark); }

.site-footer { padding: 28px 0; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 14px; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.footer-links a { margin-right: 16px; }

/* ============================================================
   AUTH FORMS (login / register) — fundo escuro
   ============================================================ */
.auth-wrap {
    min-height: calc(100vh - 80px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}
.auth-card {
    background: var(--bg-dark-2);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    padding: 36px;
    width: 100%;
    max-width: 420px;
}
.auth-card h1 {
    margin: 0 0 6px;
    font-size: 24px;
    color: var(--text-dark);
}
.auth-card .auth-sub {
    color: var(--text-dark-muted);
    margin-bottom: 24px;
    font-size: 15px;
}
.auth-card label { color: var(--text-dark); }
.auth-card input {
    background: #0B0E12;
    border-color: var(--border-dark);
    color: var(--text-dark);
}
.auth-card input:focus { border-color: var(--accent); }
.auth-card .alt-link {
    text-align: center;
    margin-top: 18px;
    color: var(--text-dark-muted);
    font-size: 14px;
}

/* ============================================================
   APP INTERNO (dashboard / project) — TEMA CLARO
   ============================================================ */
.app-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.app-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
}
.app-nav {
    display: flex;
    align-items: center;
    gap: 18px;
}
.app-nav .nav-link {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}
.app-nav .nav-link:hover { color: var(--text); }
.app-nav .user-name { font-size: 14px; color: var(--text-muted); }
@media (max-width: 700px) {
    .app-nav .nav-link, .app-nav .user-name { display: none; }
}

.page-head {
    padding: 28px 0 8px;
}
.page-head h1 {
    margin: 0 0 6px;
    font-size: 26px;
    letter-spacing: -0.01em;
}
.page-head p { color: var(--text-muted); margin: 0; }
.page-head-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* Dashboard: grid de projetos */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
    margin-top: 24px;
}
.project-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: box-shadow .15s, transform .05s;
    display: flex;
    flex-direction: column;
}
.project-card:hover { box-shadow: var(--shadow); }
.project-card h3 {
    margin: 0 0 4px;
    font-size: 17px;
}
.project-card .config-badge {
    display: inline-block;
    background: var(--accent-soft);
    color: var(--accent);
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 10px;
}
.project-card .meta { color: var(--text-muted); font-size: 13px; margin-bottom: 14px; }
.project-card .progress { margin-bottom: 14px; }
.project-card .actions { display: flex; gap: 8px; margin-top: auto; }

.progress {
    background: #EEF2F7;
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
}
.progress > span {
    display: block;
    height: 100%;
    background: var(--accent);
    transition: width .3s;
}
.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state h3 { color: var(--text); margin-bottom: 8px; }
.empty-state svg { color: var(--accent); margin-bottom: 12px; }

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin: 18px 0 22px;
    overflow-x: auto;
}
.tabs button {
    background: transparent;
    border: none;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.tabs button:disabled { opacity: 0.5; cursor: not-allowed; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin: 20px 0;
}
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}
.stat .label { color: var(--text-muted); font-size: 13px; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat.ok .value { color: var(--success); }
.stat.bad .value { color: var(--danger); }
.stat.warn .value { color: var(--warn); }
.stat-help {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
    line-height: 1.35;
}

/* ============================================================
   Card explicativo (aba Resultado) — details/summary
   ============================================================ */
.explainer-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin: 18px 0 22px;
    overflow: hidden;
}
.explainer-card summary {
    cursor: pointer;
    padding: 14px 20px;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
    list-style: none;
}
.explainer-card summary::-webkit-details-marker { display: none; }
.explainer-card summary::marker { display: none; content: ''; }
.explainer-card summary:hover { background: #FAFBFC; }
.explainer-icon { font-size: 17px; }
.explainer-arrow {
    margin-left: auto;
    transition: transform .2s;
    color: var(--text-muted);
    flex-shrink: 0;
}
.explainer-card[open] .explainer-arrow { transform: rotate(180deg); }
.explainer-body {
    padding: 4px 22px 22px;
    border-top: 1px solid var(--border);
    background: #FAFBFC;
}
.explainer-section {
    padding: 18px 0;
    border-bottom: 1px dashed var(--border);
}
.explainer-section:last-child { border-bottom: none; }
.explainer-section h4 {
    margin: 0 0 8px;
    font-size: 15px;
    color: var(--text);
}
.explainer-section p {
    color: var(--text-muted);
    line-height: 1.55;
    margin: 8px 0;
    font-size: 14px;
}
.explainer-section strong { color: var(--text); font-weight: 600; }
.explainer-section ul {
    padding-left: 20px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
    margin: 8px 0;
}
.explainer-section ul li { margin-bottom: 3px; }

/* Linha de métricas dentro do explainer (grupo mais forte/mais fraco/prático) */
.metric-row {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 12px;
    overflow: hidden;
}
.metric-row > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.metric-row > div:last-child { border-bottom: none; }
.metric-row .metric-label { color: var(--text-muted); }
.metric-row .metric-value { font-weight: 700; color: var(--text); }
.metric-row .metric-highlight {
    background: var(--accent-soft);
}
.metric-row .metric-highlight .metric-value { color: var(--accent); }

/* Thresholds (faixas de qualidade) */
.explainer-thresholds {
    margin-top: 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
}
.explainer-thresholds > div {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    padding: 6px 0;
    color: var(--text-muted);
    border-bottom: 1px dashed var(--border);
}
.explainer-thresholds > div:last-child { border-bottom: none; }
.explainer-thresholds .badge {
    min-width: 110px;
    text-align: center;
    flex-shrink: 0;
}

/* Exemplo visual do algoritmo serpentina */
.explainer-example {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    margin-top: 10px;
    font-size: 13px;
}
.example-row {
    display: grid;
    grid-template-columns: 110px repeat(4, 1fr);
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}
@media (max-width: 560px) {
    .example-row { grid-template-columns: 90px repeat(4, 1fr); gap: 4px; font-size: 12px; }
}
.example-label {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
}
.example-row .cap {
    background: var(--accent-soft);
    color: var(--accent);
    padding: 6px 8px;
    border-radius: 6px;
    text-align: center;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.example-arrow-note {
    text-align: center;
    margin: 10px 0 4px;
    font-size: 12px;
    color: var(--text-muted);
}
.example-result {
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 16px;
}
@media (max-width: 600px) { .example-result { grid-template-columns: 1fr; } }
.example-group { font-size: 13px; color: var(--text-muted); }
.example-group strong { color: var(--text); }
.example-conclusion { margin-top: 12px; }
.example-conclusion p { margin: 4px 0; font-size: 13px; }

/* Tag no card de grupo (mais forte / mais fraco) */
.group-tag {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    vertical-align: middle;
    margin-left: 4px;
}
.group-tag.tag-weak   { background: #FEE2E2; color: #991B1B; }
.group-tag.tag-strong { background: #DCFCE7; color: #166534; }

.group-sum {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
    text-align: right;
}
.group-sum strong { color: var(--text); font-weight: 700; }

/* Tabela de células */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    margin-top: 18px;
}
table.cells-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table.cells-table th, table.cells-table td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.cells-table th {
    background: #F9FAFB;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: var(--text-muted);
}
table.cells-table th:hover { background: #F3F4F6; }
table.cells-table tbody tr:hover { background: #FAFBFC; }
table.cells-table tbody tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge.ok   { background: #DCFCE7; color: #166534; }
.badge.warn { background: #FEF3C7; color: #92400E; }
.badge.bad  { background: #FEE2E2; color: #991B1B; }

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.icon-btn:hover { background: #F3F4F6; color: var(--text); }
.icon-btn.cell-edit:hover { color: var(--accent); }
.icon-btn.cell-dup:hover  { color: #2563EB; }
.icon-btn.cell-del-btn:hover { color: var(--danger); background: #FEE2E2; }

.cell-actions {
    display: flex;
    gap: 2px;
    justify-content: flex-end;
    white-space: nowrap;
}

/* Quick form (add cell) */
.quick-form {
    display: grid;
    grid-template-columns: 1fr 1.3fr 1.3fr 1.1fr 1.6fr auto;
    gap: 10px;
    align-items: start;
}
@media (max-width: 1100px) { .quick-form { grid-template-columns: 1fr 1fr; } }
@media (max-width: 500px) { .quick-form { grid-template-columns: 1fr; } }
.quick-form > div { display: flex; flex-direction: column; }

/* Hint inline (mAh detector etc.) abaixo de um campo */
.hint-inline {
    margin-top: 6px;
    padding: 8px 10px;
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    color: #92400E;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.35;
    display: none;
}
.hint-inline.show { display: block; }
.hint-inline a {
    color: #92400E;
    text-decoration: underline;
    font-weight: 600;
}

/* ============================================================
   Layout duas colunas (formulário + cards de referência)
   ============================================================ */
.entry-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}
@media (min-width: 1100px) {
    .entry-layout { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
}

/* Botão toggle (visível só no mobile) */
.ref-toggle {
    display: none;
    width: 100%;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    transition: background .15s;
}
.ref-toggle:hover { background: var(--bg); }
.ref-toggle svg { transition: transform .2s; }
.ref-toggle.open svg { transform: rotate(180deg); }
@media (max-width: 1099px) {
    .ref-toggle { display: flex; }
    .ref-cards { display: none; }
    .ref-cards.open { display: flex; }
}

.ref-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 80px;
}
@media (max-width: 1099px) {
    .ref-cards { position: static; }
}

.ref-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    font-size: 14px;
}
.ref-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}
.ref-card-head strong { font-size: 15px; color: var(--text); }
.ref-unit {
    background: var(--accent-soft);
    color: var(--accent);
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.ref-desc {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.4;
    margin: 4px 0 10px;
}
.ref-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 13px;
}
.ref-row:last-of-type { border-bottom: none; }
.ref-row span { color: var(--text-muted); }
.ref-row strong { color: var(--text); font-weight: 600; text-align: right; }
.ref-row-accent strong { color: var(--accent); }
.ref-row-bad strong { color: var(--danger); }

.ref-note {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    color: #78350F;
    font-size: 12.5px;
    line-height: 1.45;
}
.ref-note-soft {
    background: #F6F8FA;
    border-color: var(--border);
    color: var(--text-muted);
}
.ref-note strong { color: inherit; }

/* Seletor de formato de célula (18650 / 21700) */
.format-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 500px) { .format-picker { grid-template-columns: 1fr; } }
.format-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: #fff;
    transition: border-color .15s, background .15s;
    margin: 0;
}
.format-option:hover { border-color: var(--accent); }
.format-option.active {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.format-option input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    margin: 0;
    flex-shrink: 0;
}
.format-option div { display: flex; flex-direction: column; }
.format-option strong { font-size: 16px; color: var(--text); }
.format-option span { font-size: 12px; color: var(--text-muted); }

/* Badge de formato (dashboard / project header) */
.format-badge {
    display: inline-block;
    background: #EEF2F7;
    color: var(--text-muted);
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    margin-left: 6px;
    vertical-align: middle;
}

/* Resultado / grupos */
.groups {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    margin-top: 18px;
}
.group-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.group-card h4 {
    margin: 0 0 10px;
    display: flex;
    justify-content: space-between;
    font-size: 15px;
}
.group-card h4 .avg {
    color: var(--accent);
    font-weight: 700;
    font-size: 14px;
}
.group-card ul { list-style: none; padding: 0; margin: 0; }
.group-card li {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 14px;
}
.group-card li:last-child { border-bottom: none; }
.group-card li .cid { color: var(--text-muted); font-family: monospace; }

.quality-banner {
    padding: 14px 18px;
    border-radius: var(--radius);
    font-weight: 500;
    margin: 16px 0;
}
.quality-banner.q-excellent { background: #DCFCE7; color: #166534; }
.quality-banner.q-good      { background: #FEF3C7; color: #92400E; }
.quality-banner.q-bad       { background: #FEE2E2; color: #991B1B; }

/* Misc */
.row-flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.hide { display: none !important; }

/* Animação fade-in */
@media (prefers-reduced-motion: no-preference) {
    .fade-in { opacity: 0; transform: translateY(12px); transition: opacity .6s, transform .6s; }
    .fade-in.visible { opacity: 1; transform: none; }
}

/* ============================================================
   Modal (editar célula)
   ============================================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal.show { display: flex; }
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    animation: fade-in .15s ease;
}
.modal-content {
    position: relative;
    background: #fff;
    border-radius: var(--radius);
    padding: 24px 26px;
    width: 100%;
    max-width: 540px;
    z-index: 1;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    animation: pop-in .18s cubic-bezier(.2,.9,.3,1.1);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}
.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 18px; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(60px);
    background: #111827;
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    opacity: 0;
    transition: opacity .25s, transform .25s;
    z-index: 100;
    pointer-events: none;
    box-shadow: var(--shadow-lg);
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.toast.toast-success { background: var(--accent); }
.toast.toast-error { background: var(--danger); }
