/* Pedacito · Sistema de Gestão — identidade: verde-sálvia, coral e creme */
@font-face { font-family: 'Lilita One'; src: url('/fonts/lilita/lilita-one-latin-400-normal.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Nunito'; font-weight: 400; src: url('/fonts/nunito/nunito-latin-400-normal.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Nunito'; font-weight: 600; src: url('/fonts/nunito/nunito-latin-600-normal.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Nunito'; font-weight: 700; src: url('/fonts/nunito/nunito-latin-700-normal.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Nunito'; font-weight: 800; src: url('/fonts/nunito/nunito-latin-800-normal.woff2') format('woff2'); font-display: swap; }

:root {
  --sage: #5b6b5e;
  --sage-700: #46554a;
  --sage-900: #2f3a32;
  --sage-100: #e6ebe4;
  --sage-50: #f1f4ef;
  --coral: #ff6b73;
  --coral-700: #e2525b;
  --coral-100: #ffe3e4;
  --cream: #f8f4ea;
  --paper: #fffdf8;
  --ink: #26302a;
  --muted: #6d776f;
  --line: #e4dfd2;
  --revenue: #3f8a5c;
  --revenue-100: #e3f1e7;
  --expense: #d9534f;
  --expense-100: #fbe6e4;
  --warning: #c98a1b;
  --warning-100: #fbf0d9;
  --info: #3d7a99;
  --info-100: #e1eef4;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(38, 48, 42, .05), 0 6px 18px rgba(38, 48, 42, .06);
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --brand-font: 'Lilita One', 'Nunito', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--cream); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Marca ---------- */
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--coral); display: grid; place-items: center; flex-shrink: 0; }
.brand-mark svg { width: 26px; height: 26px; }
.brand-name { font-family: var(--brand-font); font-size: 24px; letter-spacing: .3px; line-height: 1; }
.brand-sub { font-size: 9.5px; font-weight: 800; letter-spacing: 1.6px; text-transform: uppercase; opacity: .8; font-style: italic; }

/* ---------- Layout da gestão ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar { background: var(--sage); color: #fff; padding: 22px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.sidebar .brand { padding: 0 8px 8px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.4px; font-weight: 800; opacity: .6; padding: 8px 10px 4px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; text-decoration: none; font-weight: 600; font-size: 14px; color: rgba(255,255,255,.88); }
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: var(--paper); color: var(--sage-900); }
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-sub { margin-left: 28px; display: flex; flex-direction: column; gap: 1px; }
.nav-sub .nav-link { padding: 6px 10px; font-size: 13px; font-weight: 600; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.15); padding-top: 14px; font-size: 13px; }
.sidebar-foot .who { font-weight: 700; }
.sidebar-foot button { background: none; border: 0; color: rgba(255,255,255,.8); padding: 6px 0; cursor: pointer; font-weight: 600; }
.sidebar-foot button:hover { color: #fff; text-decoration: underline; }

.main { padding: 28px 32px 60px; min-width: 0; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-size: 26px; font-weight: 800; letter-spacing: -.3px; }
.page-sub { color: var(--muted); margin-top: 4px; font-size: 14px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mobile-bar { display: none; }

/* ---------- Componentes ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.card-title { font-weight: 800; font-size: 15.5px; }
.card-desc { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.section-title { font-size: 12px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); margin: 26px 0 12px; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }

.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; min-width: 0; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--tone, var(--sage)); }
.kpi-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .9px; font-weight: 800; color: var(--muted); }
.kpi-value { font-size: 24px; font-weight: 800; margin-top: 6px; letter-spacing: -.4px; color: var(--tone-text, var(--ink)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.kpi.big .kpi-value { font-size: 30px; }
.t-revenue { --tone: var(--revenue); --tone-text: var(--revenue); }
.t-expense { --tone: var(--expense); --tone-text: var(--expense); }
.t-warning { --tone: var(--warning); --tone-text: var(--warning); }
.t-info { --tone: var(--info); }
.t-coral { --tone: var(--coral); }
.t-sage { --tone: var(--sage); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 800; white-space: nowrap; background: var(--sage-100); color: var(--sage-900); }
.badge.ok, .badge.success { background: var(--revenue-100); color: var(--revenue); }
.badge.danger { background: var(--expense-100); color: var(--expense); }
.badge.warn { background: var(--warning-100); color: var(--warning); }
.badge.info { background: var(--info-100); color: var(--info); }
.badge.coral { background: var(--coral-100); color: var(--coral-700); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 12px; padding: 10px 16px; font-weight: 700; font-size: 14px; cursor: pointer; background: var(--sage); color: #fff; text-decoration: none; transition: background .15s, box-shadow .15s; }
.btn:hover { background: var(--sage-700); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.coral { background: var(--coral); }
.btn.coral:hover { background: var(--coral-700); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--sage-50); }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; padding: 14px; font-size: 15.5px; }
.btn.danger-text { background: none; color: var(--expense); padding: 4px 8px; }
.btn svg { width: 16px; height: 16px; }
.link-btn { background: none; border: 0; color: var(--sage-700); font-weight: 700; cursor: pointer; padding: 0; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 700; }
.input, .select, .textarea { width: 100%; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 11px 13px; font-size: 15px; outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--sage); box-shadow: 0 0 0 3px rgba(91,107,94,.15); }
.input[readonly] { background: var(--sage-50); color: var(--muted); }
.textarea { resize: vertical; min-height: 80px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236d776f' stroke-width='2'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-stack { display: flex; flex-direction: column; gap: 14px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; padding: 5px; background: var(--sage-50); border-radius: 14px; border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 11px 10px; border-radius: 10px; font-weight: 800; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--sage); color: #fff; box-shadow: var(--shadow); }
.seg.compact button { padding: 7px 10px; font-size: 13px; }

.radio-row { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-pill { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 16px; cursor: pointer; font-weight: 700; background: #fff; }
.radio-pill:has(input:checked) { border-color: var(--sage); background: var(--sage-50); }
.radio-pill input { accent-color: var(--sage); width: 18px; height: 18px; margin: 0; }

.item-card { border: 1.5px dashed var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 12px; background: #fff; }
.item-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 14px; }

/* Combobox com busca */
.combo { position: relative; }
.combo-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px rgba(38,48,42,.14); max-height: 280px; overflow-y: auto; padding: 4px; }
.combo-opt { padding: 9px 11px; border-radius: 9px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.combo-opt:hover, .combo-opt.hl { background: var(--sage-50); }
.combo-opt small { color: var(--muted); white-space: nowrap; }
.combo-empty { padding: 12px; color: var(--muted); font-size: 14px; text-align: center; }

/* Tabelas */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 800; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--paper); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid #efeadf; vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #fbf8f1; }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.scroll-y { max-height: 420px; overflow-y: auto; }

.bar-list { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: 13.5px; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .val { font-weight: 800; font-variant-numeric: tabular-nums; }
.bar-track { grid-column: 1 / -1; height: 7px; background: var(--sage-50); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--bar, var(--sage)); border-radius: 99px; }

.progress { height: 7px; background: var(--sage-50); border-radius: 99px; overflow: hidden; min-width: 80px; }
.progress > div { height: 100%; background: var(--sage); }

.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }
.chart-box.short { height: 220px; }

/* Filtros */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 18px; box-shadow: var(--shadow); }
.filters .field { min-width: 150px; }
.filters .field > span { font-size: 11.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); }
.filters .input, .filters .select { padding: 8px 11px; font-size: 14px; border-radius: 10px; }
.filters .select { padding-right: 30px; }

.alert { border-radius: 12px; padding: 12px 14px; font-size: 14px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.alert.error { background: var(--expense-100); color: #8f2c29; border-color: #f3c4c0; }
.alert.warn { background: var(--warning-100); color: #7a5410; border-color: #efd9a6; }
.alert.info { background: var(--info-100); color: #24536a; border-color: #bcd8e6; }
.alert.ok { background: var(--revenue-100); color: #23573a; border-color: #bfdfc9; }

.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 14px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); padding: 50px 10px; }
.spinner { width: 20px; height: 20px; border: 3px solid var(--sage-100); border-top-color: var(--sage); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toasts { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.2); font-weight: 600; font-size: 14px; animation: pop .2s ease-out; }
.toast.ok { background: var(--revenue); }
.toast.error { background: var(--expense); }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } }

.health { display: flex; align-items: center; gap: 14px; }
.health-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }

/* ---------- Páginas públicas (formulários) ---------- */
.public { min-height: 100vh; }
.public-hero { background: var(--sage); color: #fff; padding: 22px 20px 64px; }
.public-hero .inner { max-width: 680px; margin: 0 auto; }
.public-hero h1 { font-size: 26px; font-weight: 800; margin-top: 22px; letter-spacing: -.3px; }
.public-hero p { opacity: .88; margin: 6px 0 0; }
.public-hero .back { color: rgba(255,255,255,.85); font-weight: 700; text-decoration: none; font-size: 14px; }
.public-body { max-width: 680px; margin: -44px auto 0; padding: 0 16px 50px; display: flex; flex-direction: column; gap: 16px; }
.public-body .card { padding: 22px; }
.form-section-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.3px; color: var(--muted); margin-bottom: 14px; }

.portal { max-width: 980px; margin: 0 auto; padding: 0 20px 60px; }
.portal-hero { background: var(--sage); color: #fff; }
.portal-hero .inner { max-width: 980px; margin: 0 auto; padding: 36px 20px 90px; display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.portal-hero h1 { font-size: 30px; font-weight: 800; margin-top: 28px; }
.portal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: -60px; }
.portal-card { background: var(--paper); border: 1px solid var(--line); border-radius: 20px; padding: 22px; text-decoration: none; color: inherit; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; transition: transform .15s, box-shadow .15s; }
.portal-card:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(38,48,42,.12); }
.portal-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--coral-100); color: var(--coral-700); }
.portal-icon svg { width: 24px; height: 24px; }
.portal-card h3 { font-size: 17px; font-weight: 800; }
.portal-card p { margin: 0; color: var(--muted); font-size: 13.5px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 15% 10%, rgba(255,107,115,.18), transparent 40%), radial-gradient(circle at 85% 90%, rgba(91,107,94,.22), transparent 45%), var(--cream); }
.login-card { width: 100%; max-width: 400px; background: var(--paper); border: 1px solid var(--line); border-radius: 24px; padding: 34px; box-shadow: 0 20px 50px rgba(38,48,42,.12); }

.success-box { text-align: center; padding: 30px 10px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.success-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--revenue-100); color: var(--revenue); display: grid; place-items: center; }
.success-icon svg { width: 34px; height: 34px; }
.protocol { font-family: ui-monospace, Consolas, monospace; font-size: 20px; font-weight: 800; color: var(--sage-700); letter-spacing: 1px; }

.check-item { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; }
.check-item.done { opacity: .55; }
.check-item.done .ci-name { text-decoration: line-through; }
.check-item input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--sage); margin-top: 2px; flex-shrink: 0; }
.ci-name { font-weight: 800; }

/* ---------- Responsivo ---------- */
@media (max-width: 1200px) {
  .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; background: var(--sage); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 40; }
  .mobile-bar button { background: none; border: 0; color: #fff; cursor: pointer; padding: 6px; }
  .main { padding: 18px 14px 50px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .portal-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .g4, .g6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-row { grid-template-columns: 1fr; }
  .portal-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 20px; }
  .page-title { font-size: 22px; }
}
