/* ==========================================================
   Construtora — estilo base (mobile-first, app-like)
   Cores centralizadas em variaveis para troca facil depois.
   ========================================================== */

:root {
    /* Paleta Vergari — carmim + preto */
    --brand:        #a5123c;   /* carmim da marca */
    --brand-dark:   #820e2f;
    --brand-light:  #f8e5eb;
    --accent:       #a5123c;
    --ink:          #17141a;   /* superficies escuras (sidebar/topbar) */
    --ink-soft:     #221d26;

    --bg:           #f4f6f8;
    --surface:      #ffffff;
    --text:         #1c2529;
    --muted:        #6b7885;
    --border:       #e2e8ec;

    --danger:       #d64545;
    --danger-bg:    #fdeaea;
    --success:      #1e8e5a;
    --success-bg:   #e7f6ee;

    --radius:       14px;
    --radius-sm:    10px;
    --shadow:       0 2px 10px rgba(20, 40, 50, .06);
    --tabbar-h:     64px;
    --topbar-h:     54px;

    --safe-bottom:  env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 15px;
    overscroll-behavior-y: none;
}

a { color: var(--brand); text-decoration: none; }
h1 { font-size: 1.4rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; }
.muted { color: var(--muted); font-size: .85rem; }
.inline { display: inline; }
.print-only { display: none; }

/* ---------- App shell ---------- */
.app { min-height: 100vh; }
.app__main { min-height: 100vh; }

/* ---------- Sidebar (desktop) — oculta no mobile ---------- */
.sidebar { display: none; }
.sidebar__brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 18px; font-weight: 700; font-size: 1.05rem;
    color: #fff;
}
.sidebar__logo { height: 30px; width: auto; }
.wordmark { font-weight: 800; letter-spacing: 2px; text-transform: uppercase; }
.sidebar__nav { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; flex: 1; }
.sidebar__item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: 10px;
    color: rgba(255,255,255,.82); font-weight: 600; font-size: .92rem;
    transition: background .15s, color .15s;
}
.sidebar__item .nav-ico { font-size: 1.15rem; width: 22px; text-align: center; }
.sidebar__item:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar__item.is-active { background: var(--brand); color: #fff; }
.sidebar__foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.14); }
.sidebar__user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar__uname { color: #fff; font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 50%;
    background: rgba(255,255,255,.22); color: #fff; font-weight: 700; flex: none;
}
.sidebar__logout {
    width: 100%; padding: 9px; border: 1px solid rgba(255,255,255,.3);
    background: transparent; color: #fff; border-radius: 9px;
    font-weight: 600; cursor: pointer; font-size: .85rem;
}
.sidebar__logout:hover { background: rgba(255,255,255,.12); }

.topbar {
    position: sticky; top: 0; z-index: 20;
    height: var(--topbar-h);
    background: var(--ink);
    color: #fff;
    display: flex; align-items: center;
    padding: 0 16px;
    box-shadow: var(--shadow);
}
.topbar__inner { width: 100%; max-width: 900px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.topbar__brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .95rem; }
.topbar__logo { height: 24px; width: auto; }
.topbar__user { display: flex; align-items: center; gap: 10px; }
.topbar__name { font-size: .85rem; opacity: .9; }
.btn-icon { background: transparent; border: 0; color: #fff; font-size: 1.2rem; cursor: pointer; padding: 6px; display: inline-flex; align-items: center; justify-content: center; line-height: 0; }

.content {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 20px);
}

/* ---------- Bottom tab bar ---------- */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tabbar-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex; justify-content: space-around; align-items: stretch;
    box-shadow: 0 -2px 12px rgba(20, 40, 50, .05);
}
.tabbar__item {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    color: var(--muted);
    font-size: .68rem; font-weight: 600;
    text-decoration: none;
    transition: color .15s;
}
.tabbar__ico { font-size: 1.35rem; line-height: 1; }
.tabbar__item.is-active { color: var(--brand); }

/* ---------- Flash ---------- */
.flash {
    max-width: 900px; margin: 12px auto; padding: 12px 16px;
    border-radius: var(--radius-sm); font-size: .9rem;
}
.flash--ok  { background: var(--success-bg); color: var(--success); }
.flash--err { background: var(--danger-bg); color: var(--danger); }
.flash--warn { background: #fdf0dd; color: #9a6412; border: 1px solid #f0d9ac; }

/* ---------- Page head ---------- */
.page-head { margin-bottom: 16px; }

/* ---------- Cards / stats ---------- */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat__num { font-size: 1.8rem; font-weight: 700; color: var(--brand); }
.stat__label { font-size: .8rem; color: var(--muted); }
.stat--alert .stat__num { color: var(--danger); }

/* ---------- Sections / lists ---------- */
.section { margin-top: 24px; }
.section__title { font-size: 1rem; margin: 0 0 10px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list__item {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 14px 16px;
    display: flex; align-items: center; justify-content: space-between;
    color: var(--text);
}
.list__item small { display: block; }
.list__item { gap: 10px; }
.list__item .obra-item__main { flex: 1 1 auto; min-width: 0; }
.list__item .badge, .list__item .row-actions, .list__item .obra-item__meta, .list__item > form { flex: none; }

.badge { font-size: .7rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--ok { background: var(--success-bg); color: var(--success); }

.empty-hint { margin-top: 24px; text-align: center; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .85rem; font-weight: 600; }
.field input, .field select, .field textarea {
    width: 100%; padding: 12px 14px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 1rem; background: #fff; color: var(--text);
    -webkit-appearance: none; appearance: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-light);
}
.field__err { color: var(--danger); font-size: .8rem; }
.field__hint { color: var(--muted); font-size: .78rem; }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 20px; border: 0; border-radius: var(--radius-sm);
    font-size: 1rem; font-weight: 600; cursor: pointer;
    background: var(--border); color: var(--text);
    transition: background .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:active { background: var(--brand-dark); }
.btn--block { width: 100%; }
.btn--danger { background: var(--danger); color: #fff; }

/* ---------- Auth screens ---------- */
.auth {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(150deg, var(--brand) 0%, var(--brand-dark) 45%, var(--ink) 100%);
    padding: 20px;
}
.auth__wrap { width: 100%; max-width: 400px; }
.auth__card {
    background: var(--surface); border-radius: var(--radius);
    padding: 28px 24px; box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.auth__brand { text-align: center; margin-bottom: 20px; }
.auth__logo-full { width: 210px; max-width: 72%; height: auto; display: block; margin: 0 auto; }
.auth__logo { height: 64px; width: auto; margin-bottom: 8px; }
.auth__brand h1 { font-size: 1.5rem; color: var(--ink); margin: 4px 0 0; }
.auth__tag { color: var(--muted); font-size: .72rem; letter-spacing: 2px; text-transform: uppercase; margin: 2px 0 0; }
.auth__title { font-size: 1.15rem; margin: 0 0 4px; }
.auth__hint { color: var(--muted); font-size: .88rem; margin: 0 0 16px; }
.auth__links { text-align: center; margin-top: 4px; font-size: .88rem; }
.auth__foot { text-align: center; color: rgba(255,255,255,.75); font-size: .78rem; margin-top: 16px; }
.cf-turnstile { display: flex; justify-content: center; }

/* ---------- Page head em linha ---------- */
.page-head--row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

/* ---------- Toolbar (busca/filtro) ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.toolbar input[type="search"] {
    flex: 1 1 200px; min-width: 0; padding: 10px 14px;
    border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .95rem; background: #fff;
}
.toolbar select {
    padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; font-size: .95rem;
}

/* ---------- Badges extra ---------- */
.badge--muted { background: #eef1f4; color: #6b7885; }
.badge--warn  { background: #fdf0dd; color: #b5731a; }
.badge--info  { background: #e5eefb; color: #2b6cb0; }

/* ---------- Estados vazios ---------- */
.empty-state { text-align: center; padding: 40px 16px; display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* ---------- Item de obra na lista ---------- */
.obra-item { gap: 12px; }
.obra-item__main { min-width: 0; }
.obra-item__main strong { display: block; }
.obra-item__meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.obra-item__valor { font-weight: 700; color: var(--brand); font-size: .9rem; white-space: nowrap; }

/* ---------- Formulario em card / grade ---------- */
.form-card { gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field--uf { max-width: 90px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
@media (max-width: 620px) { .form-actions .btn { flex: 1; text-align: center; } }
.field textarea { resize: vertical; font-family: inherit; }

/* ---------- Cabecalho da obra + abas ---------- */
.obra-header { margin-bottom: 20px; }
.obra-header__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.obra-header__top h1 { margin: 8px 0 2px; }
.obra-header__actions { display: flex; gap: 8px; flex: none; }
.tabs {
    display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border);
    -ms-overflow-style: none; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs__item {
    padding: 10px 14px; white-space: nowrap; color: var(--muted); font-weight: 600; font-size: .9rem;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs__item.is-active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs-select {
    display: none; width: 100%; padding: 12px 14px; font-size: 1rem; font-weight: 700;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
    color: var(--brand); -webkit-appearance: none; appearance: none;
    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='%23a5123c' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
}
@media (max-width: 700px) {
    .tabs { display: none; }
    .tabs-select { display: block; }
}

/* ---------- Lista de definicao (ficha) ---------- */
.definition dl { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; margin: 0; }
.definition dt { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.definition dd { margin: 2px 0 0; font-weight: 600; }
.definition__obs { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.definition__obs dt { font-size: .75rem; color: var(--muted); text-transform: uppercase; }
.definition__obs dd { margin: 4px 0 0; font-weight: 400; }

/* ---------- Acoes em linha (listas) ---------- */
.row-actions { display: flex; align-items: center; gap: 12px; }
.link-sm { font-size: .8rem; font-weight: 600; color: var(--brand); background: none; border: 0; cursor: pointer; padding: 0; }
.link-sm--danger { color: var(--danger); }

.btn--sm { padding: 8px 14px; font-size: .85rem; }
.danger-zone { margin-top: 28px; padding-top: 18px; border-top: 1px dashed var(--border); }

/* ---------- Banner de ajuda ---------- */
.help-banner {
    background: var(--brand-light); border: 1px solid #e7cdd6; border-radius: var(--radius-sm);
    padding: 12px 14px; margin-bottom: 14px; font-size: .86rem; line-height: 1.5; color: #6a2438;
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.help-banner em { font-style: normal; font-weight: 700; }
.help-banner .btn { margin-left: auto; }

/* ---------- Botoes em grade de largura igual ---------- */
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-grid .btn { width: 100%; text-align: center; }
@media (max-width: 380px) { .btn-grid { grid-template-columns: 1fr; } }

/* ---------- Presenca: alternador de modo ---------- */
.modo-toggle { display: flex; width: 100%; background: #eceef1; border-radius: 999px; padding: 4px; margin-bottom: 14px; gap: 4px; }
.modo-btn { flex: 1; border: 0; background: transparent; padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: .9rem; color: var(--muted); cursor: pointer; text-align: center; }
.modo-btn.is-active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
@media (min-width: 620px) { .modo-toggle { width: auto; display: inline-flex; } .modo-btn { flex: 0 0 auto; } }

/* ---------- Presenca por dia ---------- */
.dia-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 8px; }
.dia-nav__data { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; font-size: 1rem; font-weight: 700; text-align: center; background: #fff; }
.dia-hint { font-size: .82rem; margin: 0 0 12px; }
.dia-func { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow); transition: border-color .2s, opacity .2s; }
.dia-func__nome { margin-bottom: 9px; }
.dia-func__nome strong { display: block; }
.dia-func__btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
@media (max-width: 480px) { .dia-func__btns { grid-template-columns: 1fr 1fr; } }
.dstatus {
    padding: 12px 6px; border: 1.5px solid var(--border); border-radius: 10px;
    background: #fff; font-size: .85rem; font-weight: 700; color: var(--muted); cursor: pointer;
    text-align: center; white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.dstatus--presente.is-on { background: var(--success); border-color: var(--success); color: #fff; }
.dstatus--meia.is-on { background: #e08a1e; border-color: #e08a1e; color: #fff; }
.dstatus--falta.is-on { background: var(--danger); border-color: var(--danger); color: #fff; }
.dstatus--folga.is-on { background: #6b7885; border-color: #6b7885; color: #fff; }
.dia-func.is-saving { opacity: .55; }
.dia-func.is-saved { border-color: var(--success); }
.dia-func.is-error { border-color: var(--danger); }

/* ---------- Navegacao de semana ---------- */
.week-nav {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 12px; margin-bottom: 16px;
}
.week-nav__label { font-size: .9rem; text-align: center; }

/* ---------- Alocacao ---------- */
.alloc__form { display: flex; gap: 8px; flex-wrap: wrap; }
.alloc__form select { flex: 1 1 220px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; font-size: .95rem; }

/* ---------- Grade de presenca ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.grade { border-collapse: collapse; width: 100%; min-width: 640px; font-size: .85rem; }
.grade th, .grade td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: center; }
.grade thead th { background: #faf7f8; font-size: .72rem; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); position: sticky; top: 0; }
.grade thead th small { font-weight: 400; text-transform: none; letter-spacing: 0; }
.grade__col-nome, .grade__nome { text-align: left; min-width: 170px; }
.grade__nome strong { display: block; }
.grade__nome small { display: block; }
.grade__remove { display: inline; }
.grade .is-fds { background: #fbfafa; }
.cell-status { width: 100%; min-width: 62px; padding: 6px 4px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: .82rem; }
.col-diarias, .col-total { font-weight: 700; white-space: nowrap; }
.col-total { color: var(--brand); }
.grade tfoot td { border-bottom: 0; padding-top: 12px; }
.total-geral { color: var(--brand); font-size: 1rem; white-space: nowrap; }
.grade__actions { display: flex; align-items: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }
.grade__hint { font-size: .78rem; }

/* Tabelas viram cards no mobile (.grade--cards) */
@media (max-width: 700px) {
    .table-wrap:has(.grade--cards) { overflow: visible; border: 0; background: transparent; border-radius: 0; }
    .grade--cards { min-width: 0; width: 100%; font-size: .92rem; }
    .grade--cards thead { display: none; }
    .grade--cards, .grade--cards tbody, .grade--cards tfoot { display: block; width: 100%; }
    .grade--cards tr {
        display: block; background: var(--surface); border: 1px solid var(--border);
        border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow);
    }
    .grade--cards td {
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
        padding: 7px 0; border: 0 !important; text-align: right;
    }
    .grade--cards td::before {
        content: attr(data-label); font-size: .76rem; color: var(--muted);
        font-weight: 700; text-align: left; text-transform: uppercase; letter-spacing: .3px;
    }
    .grade--cards td.grade__nome, .grade--cards td.td-acao { display: block; text-align: left; }
    .grade--cards td.grade__nome { border-bottom: 1px solid var(--border) !important; padding-bottom: 9px; margin-bottom: 4px; }
    .grade--cards td.grade__nome::before, .grade--cards td.td-acao::before { content: none; }
    .grade--cards td.td-acao { text-align: right; }
    .grade--cards .is-fds { background: transparent; }
    .grade--cards .cell-status { width: auto; min-width: 120px; max-width: 62%; flex: 0 0 auto; padding: 8px; font-size: .9rem; }
    .grade--cards td.is-empty { display: none !important; }
    .grade--cards tfoot tr { background: var(--brand-light); }
    .grade--cards tfoot td { justify-content: space-between; }
}

/* ---------- Formularios inline (orcamento/gastos) ---------- */
.inline-form { padding: 14px 16px; margin-top: 12px; }
.inline-form__row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.inline-form__row + .inline-form__row { margin-top: 12px; }
.inline-form .field { flex: 1 1 160px; gap: 4px; }
.inline-form .field--num { flex: 0 1 120px; }
.inline-form label { font-size: .78rem; }
.inline-form input, .inline-form select {
    padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .9rem; background: #fff; width: 100%;
}
.inline-form .btn { flex: 0 0 auto; }
.text-danger { color: var(--danger); font-weight: 700; }

/* ---------- Aditivos ---------- */
.aditivo { display: flex; flex-direction: column; gap: 8px; }
.aditivo__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.aditivo__head strong { display: block; margin-top: 4px; }
.aditivo__meta { font-size: .8rem; }
.aditivo__motivo { margin: 0; font-size: .88rem; background: #faf7f8; padding: 8px 10px; border-radius: 8px; }
.aditivo__decisao { font-size: .8rem; padding-top: 6px; border-top: 1px solid var(--border); }
.aditivo__acoes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 8px; border-top: 1px solid var(--border); }
.aditivo__obs { flex: 1 1 180px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .85rem; }

/* ---------- Relatorios fotograficos ---------- */
.relatorio { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.relatorio__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.relatorio__head strong { display: block; }
.relatorio__desc { margin: 0; font-size: .9rem; }
.fotos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.foto { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #eee; }
.foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto__del { position: absolute; top: 4px; right: 4px; }
.foto__del button {
    width: 24px; height: 24px; border: 0; border-radius: 50%;
    background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: 15px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
}
.relatorio__add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 10px; border-top: 1px solid var(--border); }
.relatorio__add input[type="file"] { font-size: .82rem; flex: 1 1 200px; }

/* ---------- Hub "Mais" ---------- */
.menu-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.menu-card {
    display: flex; flex-direction: column; gap: 4px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 16px; color: var(--text); box-shadow: var(--shadow); position: relative;
}
.menu-card__ico { font-size: 1.6rem; }
.menu-card__t { font-weight: 700; }
.menu-card__d { font-size: .78rem; }
.menu-card--soon { opacity: .6; }
.menu-card--soon .badge { position: absolute; top: 12px; right: 12px; }
@media (min-width: 720px) { .menu-grid { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Dashboard: graficos ---------- */
.cards--3 { grid-template-columns: 1fr; }
@media (min-width: 620px) { .cards--3 { grid-template-columns: repeat(3, 1fr); } }
.stat__num--sm { font-size: 1.15rem; word-break: break-word; }
a.stat { color: var(--text); text-decoration: none; }

.dash-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
.chart-card { margin-top: 12px; }
.chart-card__title { font-size: 1rem; margin: 0 0 14px; }

.bars { display: flex; flex-direction: column; gap: 14px; }
/* Mobile: nome completo em cima, barra + valor embaixo */
.bar-row { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "label label" "track val"; align-items: center; gap: 5px 10px; }
.bar-row__label { grid-area: label; font-size: .85rem; font-weight: 700; line-height: 1.25; }
.bar-row__track { grid-area: track; display: flex; flex-direction: column; gap: 3px; }
.bar-row__val { grid-area: val; font-size: .82rem; font-weight: 700; white-space: nowrap; text-align: right; }
@media (min-width: 620px) {
    .bar-row { grid-template-columns: minmax(130px, 26%) 1fr auto; grid-template-areas: "label track val"; gap: 10px; }
    .bar-row__label { font-size: .82rem; font-weight: 600; }
}
.bar-row__val small { font-weight: 400; }
.bar { height: 9px; border-radius: 5px; min-width: 2px; transition: width .4s ease; }
.bar--orc { background: #d7c2c9; }
.bar--gasto { background: var(--brand); }
.bar--over { background: var(--danger); }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; font-size: .78rem; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; margin-right: 2px; }
.dot--orc { background: #d7c2c9; } .dot--gasto { background: var(--brand); } .dot--over { background: var(--danger); }

.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; flex: none; }
.donut__num { font-size: 26px; font-weight: 800; fill: var(--text); }
.donut__lbl { font-size: 11px; fill: var(--muted); }
.donut-legend { display: flex; flex-direction: column; gap: 6px; font-size: .84rem; }

@media (min-width: 860px) { .dash-grid { grid-template-columns: 1.4fr 1fr; } }

/* ---------- Atalhos rapidos (resumo da obra) ---------- */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 16px; }
.quick-actions .btn, .quick-actions form { width: 100%; }
.quick-actions .btn { width: 100%; text-align: center; }

/* ---------- Paginador ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; font-size: .85rem; }

/* ---------- Preview de upload ---------- */
.up-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.up-thumb { width: 68px; height: 68px; border-radius: 8px; overflow: hidden; background: #eee; border: 1px solid var(--border); flex: none; }
.up-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.up-thumb--file { display: flex; align-items: center; justify-content: center; font-size: .62rem; padding: 4px; text-align: center; color: var(--muted); overflow: hidden; }
.up-info { width: 100%; font-size: .78rem; }

/* ---------- Card "continuar na obra" ---------- */
.continuar-card {
    display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
    background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--brand);
    border-radius: var(--radius); padding: 12px 16px; color: var(--text); box-shadow: var(--shadow);
}
.continuar-card__ico { font-size: 1.5rem; }
.continuar-card__arrow { margin-left: auto; font-size: 1.6rem; color: var(--muted); }

/* ---------- FAB (acao rapida, mobile) ---------- */
.fab {
    position: fixed; right: 16px; z-index: 45;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
    display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
}
.fab__main {
    width: 56px; height: 56px; border-radius: 50%; border: 0;
    background: var(--brand); color: #fff; font-size: 30px; line-height: 1;
    box-shadow: 0 4px 16px rgba(20,10,15,.35); cursor: pointer; transition: transform .2s;
}
.fab.is-open .fab__main { transform: rotate(45deg); }
.fab__actions {
    display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
    opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .15s, transform .15s;
}
.fab.is-open .fab__actions { opacity: 1; pointer-events: auto; transform: none; }
.fab__action {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--surface); color: var(--text); border: 1px solid var(--border);
    border-radius: 999px; padding: 9px 15px; font-size: .85rem; font-weight: 700;
    box-shadow: var(--shadow); text-decoration: none;
}
.fab__ico { font-size: 1.05rem; }
@media (min-width: 960px) { .fab { display: none; } }

/* ---------- Banner de alertas ---------- */
.alert-banner {
    display: flex; align-items: center; gap: 10px;
    background: var(--danger-bg); border: 1px solid #f3c4c4; color: var(--danger);
    border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; font-size: .9rem;
}
.alert-banner__ico { font-size: 1.2rem; }
.alert-banner__arrow { margin-left: auto; font-size: 1.4rem; }

/* ---------- Progresso / Cronograma ---------- */
.prog { background: #eceef1; border-radius: 999px; height: 12px; overflow: hidden; }
.prog--sm { height: 8px; }
.prog__bar { background: var(--brand); height: 100%; border-radius: 999px; transition: width .4s ease; }

.avanco-card { margin-bottom: 16px; }
.avanco-card__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.avanco-card__pct { font-size: 2rem; font-weight: 800; color: var(--brand); margin-right: 8px; }
.avanco-card__vals { font-size: .85rem; }

.etapas { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.etapa-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; }
.etapa-row__form { display: flex; align-items: center; gap: 8px; flex: 1 1 320px; }
.etapa-row__nome { flex: 1 1 160px; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .9rem; }
.etapa-row__valor { width: 120px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .9rem; text-align: right; }
.etapa-row__prog { display: flex; align-items: center; gap: 10px; flex: 1 1 220px; }
.etapa-row__prog .prog { flex: 1; }
.etapa-row__pct { font-size: .82rem; font-weight: 700; white-space: nowrap; color: var(--brand); }

/* ---------- Chips de periodo ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font-size: .82rem; font-weight: 600;
}
.chip.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }
.date-label { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); }
.date-label input { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .9rem; }

/* ---------- Relatorio imprimivel ---------- */
.report { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.report__header { margin-bottom: 14px; }
.report__header h2 { margin: 0 0 2px; }
.report__foot { margin-top: 14px; font-size: .78rem; }

@media print {
    .sidebar, .topbar, .tabbar, .no-print { display: none !important; }
    .app__main { margin-left: 0 !important; }
    body, .app { background: #fff !important; }
    .content { padding: 0 !important; max-width: none !important; }
    .report { border: 0; box-shadow: none; padding: 0; }
    .table-wrap { overflow: visible !important; border: 0; }
    .grade { min-width: 0 !important; font-size: 11px; }
    .col-total, .total-geral { color: #000 !important; }
    a[href]::after { content: ""; }
    /* Ao imprimir, mantem formato de tabela (nunca cards) */
    .grade--cards { display: table !important; }
    .grade--cards thead { display: table-header-group !important; }
    .grade--cards tbody { display: table-row-group !important; }
    .grade--cards tfoot { display: table-footer-group !important; }
    .grade--cards tr { display: table-row !important; border: 0 !important; box-shadow: none !important; padding: 0 !important; margin: 0 !important; }
    .grade--cards td { display: table-cell !important; text-align: center; border-bottom: 1px solid #ccc !important; padding: 6px 8px !important; }
    .grade--cards td.grade__nome { text-align: left; }
    .grade--cards td::before { content: none !important; }

    /* ---- Cabecalho/rodape/marca d'agua de impressao ---- */
    @page { margin: 1.4cm; }
    .print-only { display: block !important; }

    /* Esconde elementos interativos em qualquer relatorio impresso */
    .grade__remove, .th-acao, .td-acao, .help-banner, .week-nav, .grade__actions,
    .toolbar, .chips, .pager, .quick-actions, .aditivo__acoes, .row-actions,
    .inline-form, .alloc, .form-card, .flash { display: none !important; }

    .print-head {
        display: flex !important; align-items: center; gap: 16px;
        border-bottom: 2.5px solid #a5123c; padding-bottom: 10px; margin-bottom: 4px;
        position: relative; z-index: 1;
    }
    .print-head__logo { height: 58px; width: auto; }
    .print-head__info { display: flex; flex-direction: column; line-height: 1.35; }
    .print-head__info strong { font-size: 13px; color: #111; }
    .print-head__info span { font-size: 10px; color: #444; }

    .print-title { margin: 12px 0 14px; position: relative; z-index: 1; }
    .print-title h2 { margin: 0; font-size: 17px; color: #111; }
    .print-title__sub { margin: 3px 0 0; font-size: 12px; color: #333; }
    .print-title__per { margin: 2px 0 0; font-size: 12px; font-weight: 700; color: #a5123c; }

    .print-watermark {
        position: fixed; inset: 0; display: flex !important; align-items: center; justify-content: center;
        z-index: 0; pointer-events: none;
    }
    .print-watermark img { width: 55%; max-width: 420px; opacity: .06; }

    .print-foot {
        display: flex !important; justify-content: space-between; align-items: center;
        margin-top: 22px; padding-top: 8px; border-top: 1px solid #bbb;
        font-size: 10px; color: #555; position: relative; z-index: 1;
    }

    /* Conteudo do relatorio acima da marca d'agua */
    .report, .table-wrap, .report__table, .report__foot { position: relative; z-index: 1; }
    .report__table { background: transparent; }
    .report__table thead th { background: #f3e7eb !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .total-geral, .col-total { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Simetria no mobile (regra do projeto) ---------- */
@media (max-width: 620px) {
    /* Formularios inline: campos e botao ocupam a largura toda, empilhados */
    .inline-form__row { gap: 10px; }
    .inline-form .field, .inline-form .field--num { flex: 1 1 100%; }
    .inline-form .btn { width: 100%; }

    /* Toolbar de busca/filtro: busca em cima, selects/botoes dividem a linha igualmente */
    .toolbar { gap: 8px; }
    .toolbar input[type="search"] { flex: 1 1 100%; min-width: 0; }
    .toolbar select, .toolbar > .btn, .toolbar > button, .toolbar > a.btn { flex: 1 1 0; }
    .toolbar .date-label { flex: 1 1 46%; }
    .toolbar .chips { flex: 1 1 100%; }

    /* Alocacao de funcionario */
    .alloc__form { flex-direction: column; align-items: stretch; }
    .alloc__form select, .alloc__form .btn { width: 100%; }

    /* Decisao de aditivo: observacao em cima, botoes iguais embaixo */
    .aditivo__acoes { flex-wrap: wrap; }
    .aditivo__obs { flex: 1 1 100%; }
    .aditivo__acoes .btn { flex: 1; text-align: center; }

    /* Cronograma: linha da etapa empilha */
    .etapa-row__form { flex: 1 1 100%; flex-wrap: wrap; }
    .etapa-row__nome { flex: 1 1 100%; }
    .etapa-row__valor { flex: 1 1 auto; }
    .etapa-row__prog { flex: 1 1 100%; }

    /* Cabecalho de secao/obra: empilha e acoes ocupam a largura */
    .obra-header__top { flex-direction: column; align-items: stretch; gap: 10px; }
    .obra-header__top h1 { font-size: 1.32rem; line-height: 1.2; margin: 6px 0 2px; }
    .obra-header__actions { width: 100%; }
    .obra-header__actions .btn { flex: 1; text-align: center; }
    /* Botao "Imprimir ficha / PDF" em largura cheia no mobile */
    .obra-toolbar { margin-bottom: 12px; }
    .obra-toolbar .btn { width: 100%; text-align: center; }
    .page-head--row { flex-wrap: wrap; }
    .relatorio__add .btn { width: 100%; }
}

/* ---------- Desktop: menu lateral ---------- */
@media (min-width: 720px) {
    .cards { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 960px) {
    :root { --sidebar-w: 244px; }

    .topbar, .tabbar { display: none; }

    .sidebar {
        display: flex; flex-direction: column;
        position: fixed; top: 0; left: 0; bottom: 0; z-index: 40;
        width: var(--sidebar-w);
        background: var(--ink);
        box-shadow: 2px 0 14px rgba(20, 40, 50, .10);
    }

    .app__main { margin-left: var(--sidebar-w); }

    .content {
        max-width: 1280px;
        padding: 28px 36px 44px;
    }
    /* Formularios ficam legiveis mesmo com o conteudo largo */
    .form-card, .inline-form { max-width: 780px; }
}

/* Feedback tatil: remove highlight azul no toque */
* { -webkit-tap-highlight-color: transparent; }

/* ---------- Modal de confirmacao (data-confirm) ---------- */
.cf-modal {
    position: fixed; inset: 0; z-index: 1000; display: none;
    align-items: center; justify-content: center; padding: 20px;
    background: rgba(15, 12, 18, .55); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.cf-modal.is-open { display: flex; animation: cf-fade .15s ease; }
.cf-modal__card {
    background: var(--surface); color: var(--text); width: 100%; max-width: 400px;
    border-radius: var(--radius); padding: 22px 22px 18px; box-shadow: 0 24px 64px rgba(0, 0, 0, .38);
    border-top: 4px solid var(--brand); animation: cf-pop .17s ease;
}
.cf-modal__title { font-size: 1.15rem; margin: 0 0 8px; color: var(--text); }
.cf-modal__msg { margin: 0 0 20px; color: var(--muted); line-height: 1.5; font-size: .95rem; }
.cf-modal__acts { display: flex; gap: 10px; }
.cf-modal__acts .cf-btn {
    flex: 1; padding: 12px 14px; border-radius: var(--radius-sm); font-weight: 700; font-size: .95rem;
    cursor: pointer; border: 1px solid transparent; font-family: inherit; text-align: center;
}
.cf-btn--ghost { background: transparent; border-color: var(--border); color: var(--text); }
.cf-btn--ghost:hover { background: rgba(0, 0, 0, .04); }
.cf-btn--ok { background: var(--brand); color: #fff; }
.cf-btn--ok:hover { background: var(--brand-dark); }
.cf-btn--danger { background: var(--danger); color: #fff; }
.cf-btn--danger:hover { filter: brightness(.95); }
body.cf-open { overflow: hidden; }
@keyframes cf-fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes cf-pop { from { opacity: 0; transform: translateY(10px) scale(.98) } to { opacity: 1; transform: none } }
@media (prefers-reduced-motion: reduce) { .cf-modal.is-open, .cf-modal__card { animation: none } }

/* ---------- Legenda/descricao por foto (relatorio) ---------- */
.foto__cap { display: flex; gap: 4px; margin-top: 5px; }
.foto__cap input { flex: 1; min-width: 0; font-size: .78rem; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); }
.foto__cap button { border: 0; background: var(--brand); color: #fff; border-radius: 8px; padding: 0 10px; cursor: pointer; font-weight: 700; }
.foto__cap button:hover { background: var(--brand-dark); }

/* ---------- Importador de BM ---------- */
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; margin: 4px 0; cursor: pointer; }
.check input { width: auto; }
.bm-preview { margin: 14px 0; padding: 14px; border: 1px dashed var(--border); border-radius: var(--radius-sm); background: #fafbfc; }
.bm-sum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.bm-sum div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.bm-sum span { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.bm-sum b { font-size: 1rem; color: var(--brand); }
.bm-etapas { list-style: none; margin: 0; padding: 0; columns: 2; }
.bm-etapas li { font-size: .85rem; padding: 3px 0; break-inside: avoid; }
.bm-etapas li span { color: var(--muted); }
@media (max-width: 600px) { .bm-sum { grid-template-columns: 1fr 1fr; } .bm-etapas { columns: 1; } }

/* ---------- Destaque de item com quantidade estourada ---------- */
.row-alert { background: var(--danger-bg); }
.row-alert .grade__nome strong { color: var(--danger); }
/* Chips de sugestao (aditivo por quantidade) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { border: 1px solid var(--danger); background: #fff; color: var(--danger); border-radius: 999px; padding: 7px 13px; font-size: .82rem; font-weight: 600; cursor: pointer; text-align: left; }
.chip-btn span { color: var(--muted); font-weight: 500; }
.chip-btn:hover { background: var(--danger-bg); }

/* ---------- Numeracao automatica das fotos do relatorio ---------- */
.foto { position: relative; }
.foto__num { position: absolute; top: 6px; left: 6px; background: rgba(23,20,26,.75); color: #fff; font-size: .68rem; font-weight: 700; letter-spacing: .02em; padding: 2px 8px; border-radius: 6px; z-index: 1; }
.foto__cap-num { font-size: .75rem; font-weight: 700; color: var(--brand); white-space: nowrap; align-self: center; }

/* ---------- Prévia de upload com descrição por foto ---------- */
.up-preview { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.up-photo { width: 150px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.up-photo > img { width: 100%; height: 104px; object-fit: cover; display: block; }
.up-photo__cap { display: flex; flex-direction: column; gap: 3px; padding: 7px 8px; }
.up-photo__cap span { font-size: .68rem; font-weight: 700; color: var(--brand); letter-spacing: .02em; }
.up-photo__cap input { width: 100%; font-size: .8rem; padding: 6px 8px; border: 1px solid var(--border); border-radius: 7px; background: #fff; color: var(--text); }

/* ---------- Legenda da foto: texto visível + editar (details) ---------- */
.foto__capbox { margin-top: 5px; font-size: .8rem; }
.foto__capsum { list-style: none; cursor: pointer; color: var(--text); display: flex; align-items: baseline; gap: 4px; line-height: 1.35; }
.foto__capsum::-webkit-details-marker { display: none; }
.foto__capsum b { color: var(--brand); }
.foto__capedit { margin-left: auto; color: var(--muted); font-size: .78rem; flex: none; }
.foto__capbox[open] .foto__capsum { margin-bottom: 6px; }
.foto__capbox[open] .foto__capedit { display: none; }

/* ---------- Filtro de materiais (aba Materiais da obra) ---------- */
.mat-filtro { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.mat-filtro__q { flex: 1; min-width: 190px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .9rem; background: #fff; color: var(--text); }
.mat-filtro__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-f { border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 7px 12px; font-size: .8rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip-f:hover { border-color: var(--brand); color: var(--brand); }
.chip-f.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.mat-filtro__count { font-size: .78rem; white-space: nowrap; margin-left: auto; }
@media (max-width: 600px) { .mat-filtro__q { min-width: 100%; } .mat-filtro__count { margin-left: 0; } }

/* ---------- Sidebar desktop: menu "Mais" expandido ---------- */
.sidebar__nav { overflow-y: auto; min-height: 0; }
.sidebar__sep { font-size: .66rem; text-transform: uppercase; letter-spacing: .13em; color: rgba(255,255,255,.42); font-weight: 700; padding: 14px 14px 6px; }
.sidebar__nav::-webkit-scrollbar { width: 8px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 8px; }
