/*
 * Gestor de Obras — estilos da interface.
 * Organização: tokens, layout, componentes, formulários e responsividade.
 * Arquivo intencionalmente não minificado para facilitar manutenção.
 */
:root {
    color-scheme: light;
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --text: #18253d;
    --muted: #6c7890;
    --border: #e3e9f1;
    --canvas: #f5f7fb;
    --surface: #ffffff;
    --sidebar: #12213b;
    --radius: 13px;
    --shadow: 0 4px 22px rgba(22, 34, 60, 0.045);
}
*, *::before, *::after { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; }
body { margin: 0; background: var(--canvas); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.6rem, 2vw, 2rem); letter-spacing: -.035em; }
h2 { font-size: 1.15rem; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 230px; min-width: 230px; background: var(--sidebar); color: #e7edf8; padding: 24px 15px; display: flex; flex-direction: column; }
.brand { color: white; display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 1.16rem; letter-spacing: -.03em; padding: 0 10px 35px; }
.brand:hover { text-decoration: none; }
.brand-mark { background: #2f61e8; padding: 9px 11px; border-radius: 10px; font-size: 1.4rem; }
.brand-sub { display: block; font-size: .86rem; font-weight: 500; color: #a6b3ca; letter-spacing: 0; margin-top: 1px; }
.side-label { font-size: .72rem; color: #8699b7; letter-spacing: .13em; font-weight: 800; margin: 0 10px 10px; }
.sidebar nav { display: flex; flex-direction: column; gap: 3px; }
.nav-link { display: block; border-radius: 8px; color: #c3d0e7; padding: 11px 13px; font-weight: 560; }
.nav-link:hover, .nav-link.active { background: #253a60; color: #fff; text-decoration: none; }
.sidebar-foot { margin-top: auto; padding: 24px 10px 0; color: #92a6c4; font-size: .77rem; }
.content-shell { min-width: 0; flex: 1; }
.topbar { display: flex; align-items: center; gap: 12px; justify-content: space-between; height: 70px; padding: 0 34px; border-bottom: 1px solid var(--border); background: white; }
.topbar-title { font-size: .9rem; color: var(--muted); }
.account { display: flex; align-items: center; gap: 14px; }
.account-name { font-weight: 600; }
.account form { margin: 0; }
.menu-toggle { display: none; background: transparent; border: 0; font-size: 1.5rem; }
.page { max-width: 1680px; margin: 0 auto; padding: 32px 35px 70px; }
.page-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.page-title h1 { margin: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.card-head h2 { margin-bottom: 0; }
.card h2 { margin-bottom: 20px; }
.card-head h2 { margin-bottom: 0; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 24px; }
.metrics-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric { background: white; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.metric > span { color: var(--muted); font-size: .91rem; font-weight: 560; }
.metric strong { font-size: clamp(1.3rem, 1.8vw, 1.9rem); line-height: 1.4; letter-spacing: -.035em; overflow-wrap: anywhere; }
.metric strong.small-heading { font-size: 1.2rem; }
.metric small { color: var(--muted); }
.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px; margin: -5px 0 20px; }
.toolbar p { margin: 0; }
.action-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 22px; }
.button { border: 1px solid #d5deec; border-radius: 8px; color: #233654; background: #fff; display: inline-flex; align-items: center; justify-content: center; min-height: 37px; padding: 8px 14px; font-weight: 650; white-space: nowrap; }
.button:hover { text-decoration: none; background: #f1f5fd; }
.button-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-dark); color: #fff; }
.button-ghost { border-color: transparent; color: var(--muted); }
.button-small { padding: 5px 9px; min-height: 31px; font-size: .87rem; }
.table-wrap { overflow-x: auto; width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: .91rem; }
th { text-align: left; color: var(--muted); font-size: .8rem; font-weight: 750; background: #f8faff; white-space: nowrap; }
td, th { padding: 12px 11px; border-bottom: 1px solid #edf0f5; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.subtext { display: block; color: var(--muted); margin-top: 5px; font-size: .82rem; font-weight: 400; }
.badge { display: inline-block; border-radius: 999px; background: #eef3fc; color: #36517d; padding: 4px 9px; font-size: .79rem; font-weight: 650; white-space: nowrap; }
.badge-success { background: #e4f8ee; color: #18744e; }
.empty { padding: 22px 8px; color: var(--muted); }
.form-card { max-width: 920px; }
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .span-two { grid-column: 1 / -1; }
label { color: #3f4d64; display: flex; flex-direction: column; gap: 7px; font-size: .86rem; font-weight: 600; }
.form-label { font-weight: 700; font-size: .9rem; }
input, textarea, select { display: block; width: 100%; min-width: 0; color: var(--text); padding: 10px 11px; border: 1px solid #d8e1ee; background: white; border-radius: 8px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: #72a0f7; box-shadow: 0 0 0 3px #2563eb19; }
textarea { resize: vertical; }
label.check { flex-direction: row; align-items: center; gap: 8px; }
label.check input { width: auto; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
.inline-filter { display: inline-flex; align-items: flex-end; flex-wrap: wrap; gap: 8px; }
.inline-filter label { display: flex; flex-direction: column; }
.inline-filter input { max-width: 110px; }
.inline-filter select { max-width: 240px; }
.hint { color: var(--muted); font-size: .8rem; margin: -5px 0 0; line-height: 1.5; }
.alert { padding: 12px 15px; border: 1px solid; border-radius: 9px; margin: 0 0 20px; }
.alert-success { background: #e9f9f0; border-color: #b9e7d0; color: #166443; }
.alert-error { background: #fef0f0; border-color: #f8c6c6; color: #982e2e; }
.progress { height: 8px; background: #e9eef6; border-radius: 10px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.progress-wrap { min-width: 115px; display: flex; gap: 10px; align-items: center; }
.progress-wrap .progress { width: 95px; }
.stage-row { border-top: 1px solid var(--border); padding: 17px 2px; display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.stage-item { border-bottom: 1px solid var(--border); padding: 18px 0; }
.stage-item:last-child { border-bottom: 0; }
.stage-title { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.stage-item .progress { margin-bottom: 13px; }
.details-form { background: #f8faff; padding: 14px; border: 1px solid var(--border); border-radius: 8px; margin-top: 10px; min-width: 180px; }
.details-form .form-stack { margin-bottom: 10px; }
.details-form p { margin-bottom: 9px; }
.text-link { display: block; margin-top: 10px; font-size: .85rem; }
summary { cursor: pointer; color: var(--primary); font-weight: 650; }
.purchase-row { display: grid; grid-template-columns: minmax(140px, 2fr) 80px minmax(126px, 160px) 32px; gap: 5px; margin-bottom: 7px; }
.purchase-row input, .purchase-row select { padding: 8px; }
.login-shell { min-height: 100vh; display: flex; justify-content: center; align-items: center; flex-direction: column; padding: 20px; }
.login-card { width: min(100%, 405px); padding: 36px; }
.login-card h1 { margin-bottom: 9px; }
.login-card .muted { margin-bottom: 28px; }
.login-card .button { width: 100%; margin-top: 4px; }
.login-icon { font-size: 2.3rem; color: var(--primary); margin-bottom: 14px; }
@media (max-width: 1150px) {
    .grid-side { grid-template-columns: 1fr; }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 850px) {
    .sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s ease; overflow-y: auto; }
    .menu-open .sidebar { transform: translateX(0); box-shadow: 10px 0 70px #11182788; }
    .menu-toggle { display: block; }
    .topbar { padding: 0 18px; }
    .topbar-title { display: none; }
    .page { padding: 24px 17px 50px; }
    .grid-two { grid-template-columns: 1fr; }
}
@media (max-width: 550px) {
    .metrics, .metrics-three { grid-template-columns: 1fr; gap: 10px; }
    .metric { padding: 17px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-two { grid-column: auto; }
    .card { padding: 17px; }
    .account-name { display: none; }
    .purchase-row { grid-template-columns: 1fr 1fr 34px; }
    .purchase-row select { grid-column: 1 / -1; }
}

/* Formulários completos e gerenciamento de anexos da versão 0.3.0. */
.section-heading { font-size: 1.05rem; margin: 8px 0 0; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.attachment-field { padding: 16px; background: #f6f9fe; border: 1px dashed #bdcde2; border-radius: 10px; }
.attachment-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.attachment-row a { min-width: 0; overflow-wrap: anywhere; }
.attachment-row form { flex-shrink: 0; }
.button-danger { color: #b22323; border-color: #f0c5c5; background: #fff7f7; }
.button-danger:hover { color: #8d1515; background: #ffeaea; }
.badge-deleted { color: #7f4242; background: #f9eded; }
.hint { font-size: .81rem; color: var(--muted); font-weight: 400; line-height: 1.5; }
@media (max-width: 700px) { .attachment-row { align-items: flex-start; flex-direction: column; } }

/* Ações alinhadas nos filtros de listagem (evita o botão alto em Financeiro). */
.toolbar .action-row { margin: 0; align-items: flex-end; }
.toolbar .action-row > .button { align-self: flex-end; min-height: 37px; height: 37px; }
/* Componentes compartilhados de anexos e parcelas. */
.invoice-manager { border: 1px solid var(--border); border-radius: 10px; padding: 18px; }
.invoice-manager h3, .payment-plan h3 { margin: 0 0 9px; font-size: 1rem; }
.invoice-explanation { font-size: .84rem; margin-bottom: 16px; }
.invoice-picker { margin-bottom: 13px; }
.invoice-picker input[data-invoice-picker] { margin-top: 6px; }
.invoice-list { margin-top: 16px; }
.invoice-list-item { display:flex; gap:12px; justify-content:space-between; align-items:center; border-top:1px solid var(--border); padding:12px 0; word-break:break-word; }
.invoice-list-item > span { min-width: 0; }
.invoice-list-item .button { flex-shrink: 0; }
.invoice-list-item.invoice-removed > span { text-decoration:line-through; opacity:.5; }
.invoice-list-item.invoice-removed { background: #fff5f5; }
.purchase-total { display:flex; align-items:baseline; flex-wrap:wrap; gap: 8px 14px; margin-top: 12px; }
.purchase-total > span { font-weight: 600; color: var(--muted); }
.purchase-total > strong { font-size: 1.25rem; color: var(--text); }
.payment-plan { border: 1px solid var(--border); border-radius: 10px; padding: 18px; }
.payment-plan > .form-grid { margin-top: 15px; }
.alert-warning { background:#fffbeb; border-color:#f7d17a; color:#805919; margin-top:14px; }
[hidden] { display:none !important; }
