/* Componentes: botões, cartões, tabelas, avisos, toasts, selos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; padding: .55rem 1.1rem; border-radius: var(--radius-sm); border: 2px solid var(--black); background: var(--black); color: var(--white); font-weight: 700; cursor: pointer; text-decoration: none; transition: background .15s; }
.btn:hover { background: #2a2a2a; }
.btn.secondary { background: var(--white); color: var(--black); }
.btn.secondary:hover { background: var(--gray-100); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.block { width: 100%; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .6; cursor: progress; }
.btn .spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); overflow: hidden; margin-bottom: 1.25rem; }
.card-head { background: var(--gray-300); padding: .8rem 1.25rem; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; }
.card-body { padding: 1.25rem; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 1rem 1.25rem; }
.stat .value { font-family: var(--font-display); font-size: 2rem; font-weight: 700; line-height: 1.1; }
.stat .label { color: var(--gray-700); font-size: .9rem; }
.stat .hint { color: var(--gray-500); font-size: .8rem; margin-top: .25rem; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { background: var(--black); color: var(--white); text-align: left; padding: .7rem .9rem; font-family: var(--font-display); font-weight: 700; white-space: nowrap; }
table.data td { padding: .7rem .9rem; border-bottom: 1px solid var(--gray-200); vertical-align: middle; }

.badge { display: inline-block; padding: .1rem .6rem; border-radius: 99px; font-size: .8rem; font-weight: 700; background: var(--gray-200); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }

.notice { border-radius: var(--radius-sm); padding: .8rem 1rem; margin-bottom: 1rem; border: 1px solid var(--gray-300); background: var(--gray-100); }
.notice.warn { background: var(--warn-bg); border-color: #e8cf94; }
.notice.error { background: var(--danger-bg); border-color: #efb3ae; color: #6d1510; }
.notice.ok { background: var(--ok-bg); border-color: #a9d6b8; }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--gray-700); }
.empty strong { display: block; font-family: var(--font-display); font-size: 1.2rem; color: var(--ink); margin-bottom: .25rem; }

.toasts { position: fixed; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); display: grid; gap: .5rem; z-index: 100; max-width: min(420px, calc(100vw - 2rem)); }
.toast { background: var(--black); color: var(--white); padding: .8rem 1rem; border-radius: var(--radius-sm); border-left: 6px solid var(--gray-300); box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.success { border-left-color: #3ecf6d; }
.toast.error { border-left-color: #ff6b61; }

dialog.modal { border: 0; border-radius: var(--radius); padding: 0; max-width: min(460px, calc(100vw - 2rem)); width: 100%; }
dialog.modal::backdrop { background: rgba(0,0,0,.55); }
dialog.modal .card-body p { margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; flex-wrap: wrap; }

.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.panel { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 440px; }
.panel .brand-logo { width: 96px; height: 96px; display: block; margin: 0 auto 1rem; }
.panel h1 { text-align: center; font-size: 1.6rem; }

/* Logo redonda também fora do layout principal (tela de login) */
.brand-logo { border-radius: 50%; object-fit: cover; }
.btn svg { width: 18px; height: 18px; flex: none; }
.badge.info { background: #e3ecfb; color: #1a4a9c; }
.badge.muted { background: var(--gray-100); color: var(--gray-700); text-decoration: line-through; }

/* ───── Fase 3: orçamentos ───── */
.quote-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.quote-aside { position: sticky; top: 1rem; }
.summary .sum { margin: 0 0 1rem; }
.sum > div { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px dashed var(--gray-200); }
.sum dt { color: var(--gray-700); } .sum dd { margin: 0; font-variant-numeric: tabular-nums; }
.sum .strong dt, .sum .strong dd { color: var(--ink); font-weight: 700; }
.grand { display: flex; justify-content: space-between; align-items: center; background: var(--black); color: var(--white); border-radius: var(--radius-sm); padding: .8rem 1rem; margin: 1rem 0 .5rem; }
.grand strong { font-family: var(--font-display); font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.stack-actions { display: grid; gap: .5rem; margin-top: .75rem; }
.form-grid.compact { gap: .6rem; }
.item-row { border: 1px solid var(--gray-300); border-radius: var(--radius-sm); padding: .75rem; margin-bottom: .75rem; background: var(--white); }
.item-top { display: flex; gap: .6rem; align-items: flex-start; }
.item-num { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--gray-200); display: grid; place-items: center; font-weight: 700; font-size: .85rem; margin-top: .55rem; }
.item-desc { flex: 1; min-width: 0; }
.item-move { display: flex; gap: .25rem; flex: none; }
.item-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .6rem; margin: .6rem 0; }
.item-grid .lbl, .lbl { display: block; font-weight: 700; font-size: .9rem; color: var(--gray-700); }
.item-sub { display: flex; align-items: center; min-height: 44px; font-weight: 700; font-variant-numeric: tabular-nums; }
.icon-btn { width: 40px; height: 40px; border: 1px solid var(--gray-300); background: var(--white); border-radius: var(--radius-sm); cursor: pointer; font-size: 1rem; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.linklike { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }
.danger-text { color: var(--danger) !important; }
.total-bar { display: none; }
.action-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.pre { white-space: pre-wrap; margin: .25rem 0 .75rem; }
.timeline { margin: 0; padding-left: 1.2rem; display: grid; gap: .6rem; }
.pager { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.pager > span:last-child { display: flex; gap: .5rem; }
table.clickable tbody tr { cursor: pointer; }
table.clickable tbody tr:hover { background: var(--gray-50); }
@media (max-width: 900px) {
  .quote-layout { display: block; }
  .quote-aside { position: static; }
  .total-bar { display: flex; position: sticky; bottom: 0; z-index: 25; align-items: center; gap: .75rem; background: var(--black); color: var(--white); padding: .6rem 1rem; padding-bottom: calc(.6rem + env(safe-area-inset-bottom, 0px)); margin: 0 -1rem; }
  .total-bar strong { margin-left: auto; font-family: var(--font-display); font-size: 1.3rem; }
  .total-bar .btn { background: var(--white); color: var(--black); border-color: var(--white); }
  .action-bar .btn { flex: 1 1 calc(50% - .5rem); }
  .item-grid { grid-template-columns: 1fr 1fr; }
}
.item-grid .field { grid-column: auto; min-width: 0; }
.item-row .field .input { min-width: 0; }
@media (max-width: 900px) {
  .item-top { flex-wrap: wrap; }
  .item-desc { flex: 1 1 calc(100% - 40px); }
  .item-move { width: 100%; justify-content: flex-end; }
}

/* ───── Fase 5: financeiro ───── */
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 2px solid var(--gray-200); margin-bottom: 1.25rem; }
.tabs a { padding: .65rem 1rem; text-decoration: none; font-weight: 700; color: var(--gray-700); border-radius: var(--radius-sm) var(--radius-sm) 0 0; min-height: 44px; display: flex; align-items: center; }
.tabs a[aria-current="page"] { background: var(--black); color: var(--white); }
.page-head.sub { margin-bottom: 1rem; } .page-head.sub h2 { margin: 0; }
.section-title { font-size: 1.05rem; margin: 1.25rem 0 .6rem; color: var(--gray-700); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
a.stat.link { text-decoration: none; color: inherit; display: block; transition: border-color .15s; }
a.stat.link:hover { border-color: var(--black); }
.stat.neg .value, td.neg { color: var(--danger); } td.pos { color: var(--ok); }
tr.overdue td:first-child { color: var(--danger); font-weight: 700; }
ul.plain { list-style: none; padding: 0; margin: .5rem 0 1rem; display: grid; gap: .35rem; }
dialog.modal.wide { max-width: min(720px, calc(100vw - 2rem)); }
.field.s2 { grid-column: span 2; }
@media (max-width: 900px) { .field.s2 { grid-column: span 12; } .tabs { overflow-x: auto; flex-wrap: nowrap; } .tabs a { white-space: nowrap; } }

/* ───── Fase 6 ───── */
.period { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.period .input { width: auto; }
.stat.attn { border-color: #e8cf94; background: #fffaf0; }
.logo-row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
pre.diff { white-space: pre-wrap; font-family: var(--font-body); font-size: .8rem; color: var(--gray-700); margin: .3rem 0 0; }
table.perm tr.grp td { background: var(--gray-100); }
table.perm input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--black); }
@media (max-width: 900px) { .period { width: 100%; } .period .input { flex: 1; } }
