/* ================================================================
   REGISTOBRA — identidade visual "Índigo Digital"
   ================================================================ */

:root {
  --ink: #14141F;
  --paper: #F6F7FB;
  --card: #FFFFFF;
  --safety: #FF6152;
  --safety-dk: #E1493A;
  --steel: #4338CA;
  --steel-lt: #EEECFB;
  --good: #16A34A;
  --good-lt: #E3F7E9;
  --bad: #C0152F;
  --bad-lt: #FBE4E6;
  --amber: #B07A0A;
  --amber-lt: #F6ECD4;
  --line: #E5E7F0;
  --line-soft: #EDEEF6;
  --shadow-sm: 0 1px 2px rgba(20,20,31,0.05), 0 1px 1px rgba(20,20,31,0.04);
  --shadow-md: 0 6px 18px rgba(67,56,202,0.10), 0 1px 3px rgba(20,20,31,0.05);
  --shadow-lift: 0 16px 36px rgba(20,20,31,0.16), 0 2px 8px rgba(20,20,31,0.06);
  --font-display: "Sora", -apple-system, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body {
  background-image:
    linear-gradient(rgba(67,56,202,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(67,56,202,0.035) 1px, transparent 1px);
  background-size: 24px 24px;
  background-attachment: fixed;
}
button, input, select, textarea { font-family: inherit; }
#app { min-height: 100vh; padding-bottom: 88px; }

@media (prefers-reduced-motion: no-preference) {
  .fade-in { animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--safety); border-radius: 50%; animation: spin 0.8s linear infinite; }

header.topbar { position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: 1.5px solid var(--line); padding: 18px 16px 14px; }
.eyebrow { font-family: var(--font-display); font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--steel); display: flex; justify-content: space-between; align-items: center; }
.eyebrow .logout-link { color: var(--ink); opacity: 0.4; font-weight: 700; text-decoration: none; font-size: 11px; font-family: var(--font-body); letter-spacing: normal; text-transform: none; }
h1.title { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; margin: 4px 0 0; }

.auth-buttons { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: normal; font-family: var(--font-body); }
.auth-btn { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; text-decoration: none; padding: 6px 13px; border-radius: 999px; transition: opacity 0.15s, transform 0.1s; }
.auth-btn:active { transform: scale(0.96); }
.auth-btn-ghost { color: var(--ink); opacity: 0.65; border: 1.5px solid var(--line); }
.auth-btn-solid { background: var(--safety); color: white; box-shadow: var(--shadow-sm); }
.due-date { font-size: 11px; font-weight: 700; text-transform: none; color: var(--bad); }
.due-date strong { font-weight: 900; }
.guest-banner { margin-top: 12px; font-size: 12.5px; background: var(--amber-lt); color: var(--amber); border: 1px solid #E9D9A8; border-radius: var(--radius-sm); padding: 9px 11px; text-transform: none; letter-spacing: normal; font-family: var(--font-body); }
.guest-banner a { color: var(--steel); font-weight: 700; text-decoration: underline; }

.px { padding-left: 16px; padding-right: 16px; }
.py { padding-top: 16px; padding-bottom: 16px; }

.card { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius-md); padding: 17px; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
.card-title { font-family: var(--font-display); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; opacity: 0.55; margin-bottom: 10px; }
.row { display: flex; justify-content: space-between; align-items: baseline; padding: 5px 0; font-size: 14px; }
.row .lbl { opacity: 0.68; }
.row .val { font-family: var(--font-mono); }
.row .val.bold { font-weight: 700; }
.bar-bg { height: 8px; border-radius: 999px; background: var(--line-soft); overflow: hidden; margin-top: 9px; }
.bar-fill { height: 100%; border-radius: 999px; transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: var(--radius-md); font-weight: 700; font-size: 14.5px; padding: 13px 16px; cursor: pointer; border: none; transition: transform 0.1s, box-shadow 0.15s, opacity 0.15s; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--safety); color: white; box-shadow: var(--shadow-sm); }
.btn-primary:active { box-shadow: none; }
.btn-outline { background: var(--card); border: 2px solid var(--ink); color: var(--ink); }
.btn-steel-outline { background: var(--card); border: 2px solid var(--steel); color: var(--steel); }
.btn-pill { border-radius: 999px; padding: 7px 13px; font-size: 12px; background: var(--card); border: 1px solid var(--line); font-weight: 700; box-shadow: var(--shadow-sm); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 9px; margin-bottom: 16px; }
.btn-grid-3 .btn { flex-direction: column; padding: 15px 4px; font-size: 12px; }
.btn-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.btn-grid-2 .btn { flex-direction: column; padding: 17px; }

label.field-label { display: block; font-family: var(--font-display); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.6; margin-bottom: 5px; }
input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card); font-size: 15px; margin-bottom: 12px; color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type=text]:focus, input[type=number]:focus, input[type=date]:focus, input[type=password]:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--steel); box-shadow: 0 0 0 3px var(--steel-lt);
}
input[type=file] { margin-bottom: 12px; }
.field-note { font-size: 11.5px; opacity: 0.55; margin-top: -8px; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.badge { font-size: 11px; font-weight: 700; padding: 3px 11px; border-radius: 999px; display: inline-block; letter-spacing: 0.01em; }
.badge-pago { background: var(--good-lt); color: var(--good); }
.badge-pendente { background: var(--bad-lt); color: var(--bad); }
.badge-parcial { background: var(--amber-lt); color: var(--amber); }

.chip { padding: 8px 15px; border-radius: 999px; font-size: 14px; font-weight: 700; background: var(--card); border: 1.5px solid var(--line); cursor: pointer; transition: all 0.15s; }
.chip.sel { background: var(--steel); color: white; border-color: var(--steel); box-shadow: var(--shadow-sm); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.section { border: 1px solid var(--line-soft); background: var(--card); border-radius: var(--radius-md); overflow: hidden; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
.section > .section-head { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 13px 16px; background: none; border: none; font-family: var(--font-display); font-weight: 600; font-size: 13.5px; text-transform: uppercase; letter-spacing: 0.04em; cursor: pointer; color: var(--ink); }
.section > .section-body { padding: 2px 16px 16px; }

.alert { display: flex; gap: 9px; align-items: flex-start; padding: 11px 13px; border-radius: var(--radius-sm); background: var(--bad-lt); color: var(--safety-dk); font-size: 14px; margin-bottom: 12px; }
.alert a.retry { display: block; margin-top: 6px; font-weight: 700; font-size: 13px; text-decoration: underline; cursor: pointer; }
.saving-hint { font-size: 12px; opacity: 0.5; margin-bottom: 10px; }

.expense-item { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius-md); padding: 13px; margin-bottom: 9px; box-shadow: var(--shadow-sm); transition: box-shadow 0.15s; }
.expense-item .top { display: flex; justify-content: space-between; gap: 8px; }
.expense-item .fornecedor { font-weight: 700; font-size: 14.5px; }
.expense-item .meta { font-size: 12px; opacity: 0.62; margin-top: 2px; }
.expense-item .meta2 { font-size: 11px; opacity: 0.5; margin-top: 2px; }
.expense-item .valor { font-family: var(--font-mono); font-weight: 700; text-align: right; }
.expense-item .actions { display: flex; gap: 15px; margin-top: 11px; padding-top: 11px; border-top: 1px dashed var(--line); font-size: 12px; font-weight: 700; }
.expense-item .actions a, .expense-item .actions button { color: var(--steel); background: none; border: none; cursor: pointer; display: flex; align-items: center; gap: 4px; padding: 0; font-size: 12px; font-weight: 700; }
.expense-item .actions .danger { color: var(--bad); margin-left: auto; }
.expense-item .actions .good { color: var(--good); }
.doc-link { color: var(--steel); font-size: 12px; font-weight: 700; text-decoration: underline; }

.phase-card { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius-md); margin-bottom: 9px; overflow: hidden; box-shadow: var(--shadow-sm); }
.phase-head { padding: 13px 16px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.phase-head .name { font-weight: 700; font-size: 14.5px; }
.phase-head .sub { font-size: 11px; opacity: 0.5; }
.phase-bars { padding: 0 16px 13px; display: flex; flex-wrap: wrap; gap: 12px; }
.phase-bar { flex: 1; min-width: 110px; }
.phase-bar .lbl { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; text-transform: uppercase; opacity: 0.6; margin-bottom: 4px; }
.phase-body { padding: 0 16px 16px; }

nav.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line-soft); box-shadow: 0 -2px 12px rgba(33,31,28,0.06); display: flex; z-index: 20; padding-bottom: env(safe-area-inset-bottom); overflow-x: auto; }
nav.bottom-nav button { flex: 1; min-width: 58px; background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 2px 8px; color: var(--ink); opacity: 0.5; cursor: pointer; position: relative; transition: opacity 0.15s; }
nav.bottom-nav button.active { color: var(--safety); opacity: 1; }
nav.bottom-nav button.active::before { content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 22px; height: 2.5px; background: var(--safety); border-radius: 0 0 3px 3px; }
nav.bottom-nav .label { font-family: var(--font-display); font-size: 9.5px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.02em; }

.stat-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.mini-stat { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 11px 8px; text-align: center; box-shadow: var(--shadow-sm); }
.mini-stat .v { font-size: 15.5px; font-weight: 700; font-family: var(--font-mono); }
.mini-stat .l { font-size: 9.5px; text-transform: uppercase; opacity: 0.55; margin-top: 3px; letter-spacing: 0.03em; }

.partilha-bar { display: flex; align-items: center; gap: 8px; background: var(--steel); color: white; border-radius: var(--radius-md); padding: 11px 13px; font-size: 12px; margin-bottom: 16px; opacity: 0.55; transition: opacity 0.2s; }
.partilha-bar.ativo { opacity: 1; box-shadow: var(--shadow-md); }
.partilha-bar .btn-pill { color: var(--steel); font-size: 11px; white-space: nowrap; }

.obras-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.obra-card { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); padding: 15px; display: flex; flex-direction: column; box-shadow: var(--shadow-md); }
.obra-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.obra-avatar { width: 36px; height: 36px; border-radius: 10px; color: white; font-weight: 700; font-family: var(--font-display); font-size: 15px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: var(--shadow-sm); }
.obra-card-nome { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.obra-card-sub { font-size: 11px; opacity: 0.55; }
.obra-card-total { font-size: 21px; font-weight: 700; font-family: var(--font-mono); }
.obra-partilha-check { display: flex; align-items: center; justify-content: center; width: 38px; border: 2px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; background: var(--card); color: var(--ink); flex-shrink: 0; transition: all 0.15s; }
.obra-card-add { align-items: center; justify-content: center; gap: 6px; border: 2px dashed var(--line); background: none; color: var(--ink); opacity: 0.5; cursor: pointer; min-height: 140px; font-size: 13px; font-weight: 700; border-radius: var(--radius-lg); }
.obra-card-add:active { opacity: 0.8; }

.modal-overlay { position: fixed; inset: 0; background: rgba(33,31,28,0.6); z-index: 30; display: flex; align-items: flex-end; justify-content: center; backdrop-filter: blur(1px); }
.modal-sheet { width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; background: var(--paper); border-radius: 22px 22px 0 0; padding: 22px; box-shadow: var(--shadow-lift); }
@media (min-width: 640px) { .modal-overlay { align-items: center; } .modal-sheet { border-radius: 18px; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h2 { font-family: var(--font-display); font-size: 19px; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--ink); font-size: 20px; line-height: 1; padding: 4px; opacity: 0.6; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
.preview-img { width: 100%; max-height: 160px; object-fit: contain; border-radius: var(--radius-sm); border: 1px solid var(--line); margin-bottom: 12px; background: var(--card); }
.icon-btn { background: none; border: none; cursor: pointer; padding: 4px; display: inline-flex; align-items: center; }

svg.icon { width: 1em; height: 1em; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.15em; }
.icon.spin { animation: spin 0.9s linear infinite; }
.font-mono { font-family: var(--font-mono); }

.guest-lock-card { text-align: center; padding: 44px 20px; }
.guest-lock-card svg.icon { width: 42px; height: 42px; color: var(--steel); margin-bottom: 14px; }
.guest-lock-card h2 { font-family: var(--font-display); font-size: 18px; font-weight: 600; text-transform: uppercase; margin: 0 0 9px; }
.guest-lock-card p { font-size: 13.5px; opacity: 0.65; margin: 0 0 22px; max-width: 320px; margin-left: auto; margin-right: auto; }

.compare-card { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); padding: 15px; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
.compare-head { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 600; font-size: 14.5px; text-transform: uppercase; letter-spacing: 0.01em; margin-bottom: 11px; color: var(--steel); }
.compare-head svg { flex-shrink: 0; }
.compare-count { margin-left: auto; font-size: 10px; font-weight: 700; text-transform: none; opacity: 0.5; background: var(--paper); border-radius: 999px; padding: 3px 9px; font-family: var(--font-body); }
.compare-row { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px; margin-bottom: 6px; }
.compare-row.melhor { border-color: var(--good); background: var(--good-lt); }
.compare-row:last-child { margin-bottom: 0; }
.compare-row-main { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.compare-fornecedor { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 4px; }
.compare-fornecedor svg { width: 12px; height: 12px; color: var(--amber); }
.compare-desc { font-size: 11px; opacity: 0.6; margin-top: 2px; }
.compare-preco { font-family: var(--font-mono); font-weight: 700; font-size: 15px; text-align: right; white-space: nowrap; }
.compare-preco-un { font-size: 10px; font-weight: 400; opacity: 0.5; }
.compare-diff { font-size: 10px; color: var(--bad); font-weight: 700; margin-top: 4px; }

.orc-item-row { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px; margin-bottom: 8px; }
.orc-item-row-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.orc-item-row-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 6px; }
.orc-item-row-grid input { margin-bottom: 0; font-size: 13px; padding: 8px 10px; }
.orc-item-row-grid4 { display: grid; grid-template-columns: 0.7fr 0.9fr 1fr 1fr; gap: 6px; align-items: center; }
.orc-item-row-grid4 input, .orc-item-row-grid4 select { margin-bottom: 0; font-size: 13px; padding: 8px 6px; }
.orc-item-total { font-family: var(--font-mono); font-weight: 700; font-size: 13px; text-align: right; }

.alerta-linha { display: flex; gap: 10px; align-items: flex-start; padding: 11px 0; font-size: 13px; border-top: 1px solid var(--line-soft); }
.alerta-linha:first-child { border-top: none; padding-top: 0; }
.alerta-linha svg { flex-shrink: 0; margin-top: 1px; }
.alerta-linha a { font-weight: 700; text-decoration: underline; cursor: pointer; }
.alerta-bad svg { color: var(--bad); }
.alerta-amber svg { color: var(--amber); }
.alerta-good svg { color: var(--good); }

.clima-dias-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.clima-dia { flex: 1; min-width: 58px; text-align: center; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 4px; }
.clima-dia-nome { font-size: 10px; font-weight: 700; text-transform: uppercase; opacity: 0.6; }
.clima-dia-icon { color: var(--steel); margin: 5px 0; }
.clima-dia-icon svg { width: 20px; height: 20px; }
.clima-dia-precip { font-size: 11px; font-weight: 700; }
.clima-dia-temp { font-size: 12px; font-family: var(--font-mono); margin-top: 2px; }

.pdf-pages-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.pdf-page-wrap { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px; }
.pdf-page-canvas-wrap { position: relative; background: var(--card); border-radius: 6px; overflow: hidden; min-height: 90px; display: flex; align-items: center; justify-content: center; }
.pdf-page-canvas-wrap canvas { width: 100%; height: auto; display: block; }
.pdf-page-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--steel); }
.pdf-page-select { position: absolute; top: 4px; right: 4px; background: var(--card); border-radius: 6px; padding: 2px; box-shadow: var(--shadow-sm); }
.pdf-page-checkbox { width: 18px; height: 18px; cursor: pointer; accent-color: var(--safety); }
.pdf-page-num { font-size: 10px; font-weight: 700; text-align: center; opacity: 0.5; margin: 6px 0 4px; }

.offline-banner { margin-top: 10px; font-size: 12px; border-radius: var(--radius-sm); padding: 9px 11px; display: flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: normal; font-family: var(--font-body); }
.offline-banner-off { background: var(--bad-lt); color: var(--safety-dk); }
.offline-banner-sync { background: var(--good-lt); color: var(--good); }
.offline-banner a { font-weight: 700; text-decoration: underline; cursor: pointer; margin-left: auto; }
.offline-banner svg.icon { flex-shrink: 0; }

.badge-estado-disponivel { background: var(--good-lt); color: var(--good); }
.badge-estado-em-uso { background: var(--amber-lt); color: var(--amber); }
.badge-estado-manutencao { background: var(--bad-lt); color: var(--bad); }

.mais-menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mais-menu-item { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 6px; background: var(--card); border: 1.5px solid var(--line-soft); border-radius: var(--radius-md); cursor: pointer; color: var(--ink); font-size: 12px; font-weight: 700; transition: all 0.15s; }
.mais-menu-item svg.icon { width: 22px; height: 22px; color: var(--steel); }
.mais-menu-item.ativo { border-color: var(--steel); background: var(--steel-lt); }
.mais-menu-item:active { transform: scale(0.96); }
