/* HN Obras – baseline styles */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; color: #222; background: #f5f6f8; }
a { color: #1f5fb5; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; padding: 0.75rem 1.25rem;
    background: #1f2a37; color: #fff; flex-wrap: wrap;
}
.topbar a { color: #fff; }
.topbar .brand a { font-weight: 700; font-size: 1.1rem; }
.topbar .brand .tagline { display: block; font-size: 0.75rem; opacity: 0.75; }
.topbar .menu { display: flex; gap: 1rem; flex-wrap: wrap; }
.topbar .menu a { opacity: 0.9; }
.topbar .menu a:hover { opacity: 1; }
.topbar .user { font-size: 0.85rem; opacity: 0.9; display: flex; gap: 0.75rem; align-items: center; }

/* Container */
.container { max-width: 1280px; margin: 1.5rem auto; padding: 0 1rem; }

/* Cards */
.card {
    background: #fff; border: 1px solid #e3e5ea; border-radius: 8px;
    padding: 1.25rem; margin-bottom: 1.25rem;
}
.card-narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.card h1, .card h2 { margin-top: 0; }

/* Forms */
form label { display: block; margin-bottom: 0.85rem; font-size: 0.9rem; }
form input[type="text"], form input[type="email"], form input[type="password"],
form input[type="date"], form input[type="month"], form input[type="number"],
form select, form textarea {
    width: 100%; padding: 0.5rem 0.6rem; border: 1px solid #cfd3db; border-radius: 6px;
    font-size: 0.95rem; margin-top: 0.25rem;
}
form textarea { min-height: 80px; }
.btn, button {
    display: inline-block; padding: 0.5rem 1rem; border-radius: 6px;
    border: 1px solid #cfd3db; background: #fff; cursor: pointer; font-size: 0.95rem;
}
.btn-primary { background: #1f5fb5; color: #fff; border-color: #1f5fb5; }
.btn-primary:hover { background: #184c93; }
.btn-link {
    background: transparent; border: 0; padding: 0; color: #fff; cursor: pointer;
    text-decoration: underline;
    font: inherit; /* herda a fonte do contexto — evita divergência entre <a> e <button> */
}

/* Tables */
table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; table-layout: auto; }
table.data th, table.data td { text-align: left; padding: 0.45rem 0.55rem; border-bottom: 1px solid #eceef2; vertical-align: top; }
table.data thead th { background: #f0f2f5; font-weight: 600; white-space: nowrap; }
table.data tr:hover td { background: #fafbfd; }
table.data small { color: #6b7280; }

/* Flash */
.flash { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.flash-ok    { background: #e6f4ea; color: #1e6b36; border: 1px solid #bfe3ca; }
.flash-erro  { background: #fdecea; color: #8a1c1c; border: 1px solid #f5c2bd; }
.flash-aviso { background: #fff4d6; color: #7a5500; border: 1px solid #f2d98c; }

/* Footer */
.bottombar { text-align: center; color: #888; margin: 2rem 0 1rem; font-size: 0.8rem; }

.muted { color: #888; }

/* Preview modal para anexos */
.preview-modal {
    position: fixed !important;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
    z-index: 9999;
    display: none !important;
}
.preview-modal.open { display: flex !important; align-items: center; justify-content: center; }
.preview-backdrop { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.65); }
body.modal-open { overflow: hidden; }
.preview-panel {
    position: relative; z-index: 1;
    background: #fff; border-radius: 8px;
    width: min(960px, 92vw); max-height: 92vh;
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.preview-header {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.6rem 0.85rem; border-bottom: 1px solid #eceef2;
    background: #f7f8fa;
}
.preview-filename { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-body { flex: 1; overflow: auto; background: #111; }
.preview-iframe { width: 100%; height: 80vh; border: 0; background: #fff; }
.preview-image { max-width: 100%; max-height: 80vh; display: block; margin: 0 auto; }
.preview-office { color: #fff; padding: 2rem; text-align: center; }
.icone-anexo { text-decoration: none; color: #1f5fb5; cursor: pointer; }
.icone-anexo:hover { text-decoration: underline; }
@media print { .preview-modal { display: none !important; } .icone-anexo { display: none !important; } }

/* Dashboard: cards de métrica */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.metric-card {
    background: #fff;
    border: 1px solid #e3e5ea;
    border-radius: 8px;
    padding: 1.1rem 1.25rem;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: box-shadow 0.15s, transform 0.15s;
}
.metric-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.06); transform: translateY(-1px); text-decoration: none; }
.metric-card .label { font-size: 0.82rem; color: #6b7280; text-transform: uppercase; letter-spacing: 0.03em; }
.metric-card .value { font-size: 1.8rem; font-weight: 700; margin: 0.2rem 0 0.25rem; color: #1f2a37; }
.metric-card .value.muted { color: #9ca3af; }
.metric-card .value.ok    { color: #1e6b36; }
.metric-card .value.alert { color: #c1121f; }
.metric-card small { display: block; color: #6b7280; }

/* Estorno: valor negativo em vermelho */
.valor-estorno { color: #c1121f; font-weight: 600; }
@media print {
    .valor-estorno { color: #c1121f !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* List page header row */
.row-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.75rem; }
.row-head h1 { margin: 0; }

/* Make btn-link usable outside the topbar (default color) */
.card .btn-link, main .btn-link { color: #1f5fb5; text-decoration: underline; cursor: pointer; }

/* Form grids */
.grid-2, .grid-3, .grid-4 { display: grid; gap: 0 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Report paper */
.report-paper { padding: 2rem; }
.report-head { border-bottom: 2px solid #1f2a37; padding-bottom: 0.75rem; margin-bottom: 0.5rem; }
.report-table th { background: #f0f2f5; }
.report-total { margin-top: 1.25rem; padding: 0.75rem 1rem; background: #f0f2f5; border-radius: 6px; text-align: right; font-size: 1.05rem; }
.report-foot { margin-top: 1.25rem; padding-top: 0.75rem; border-top: 1px solid #e3e5ea; font-size: 0.8rem; }

@media print {
    .topbar, .bottombar, .no-print-actions, .flash { display: none !important; }
    body, html { background: #fff; }
    .container { max-width: none; margin: 0; padding: 0; }
    .card { border: none; box-shadow: none; padding: 0; margin: 0; }
    .report-paper { padding: 0; }
    .report-head { border-bottom-color: #000; }
    table.data, table.data * { color: #000; }
    table.data th, table.data td { border-bottom: 1px solid #888; }
    table.data thead th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .report-total { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    a { color: #000; text-decoration: none; }
}
