:root {
  --bg: #F6F7FB; --surface: #FFFFFF; --surface-2: #F9FAFC; --text: #0F172A; --text-2: #475569; --muted: #94A3B8;
  --line: #E6E8F0; --line-2: #EEF0F6;
  --brand: #4F46E5; --brand-2: #4338CA; --brand-soft: #EEF0FF; --sky: #0EA5E9;
  --ok: #059669; --ok-soft: #E7F7F0; --warn: #B45309; --warn-soft: #FEF3E2; --danger: #DC2626; --danger-soft: #FDECEC;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05); --shadow: 0 1px 2px rgba(15,23,42,.04), 0 6px 24px rgba(15,23,42,.06);
  --shadow-lg: 0 24px 60px rgba(15,23,42,.18);
  --r: 12px; --r-sm: 8px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1020; --surface: #121933; --surface-2: #0F1630; --text: #E7EAF3; --text-2: #A9B1C7; --muted: #6B7591;
    --line: #222B4A; --line-2: #1B2340; --brand: #818CF8; --brand-2: #A5B4FC; --brand-soft: #1E2550;
    --ok: #34D399; --ok-soft: #10302A; --warn: #FBBF24; --warn-soft: #33280F; --danger: #F87171; --danger-soft: #3A1717;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.brand img { width: 34px; height: 34px; }
.brand b { font-weight: 800; letter-spacing: .04em; font-size: 15px; }
.brand b span { color: var(--brand); }
.brand small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 500; letter-spacing: 0; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 10px 6px; font-weight: 600; }
.nav a, .nav span { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav span { opacity: .55; cursor: default; }
.nav svg { width: 18px; height: 18px; flex: none; }
.soon { margin-left: auto; font-size: 10.5px; padding: 1px 7px; border-radius: 99px; background: var(--line-2); color: var(--muted); font-weight: 600; }
.side-foot { margin-top: auto; }
.status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); padding: 8px 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.mock { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.user { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r); margin-top: 8px; }
.user .who { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.user .who small { display: block; color: var(--muted); font-weight: 500; font-size: 11.5px; }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 14px 32px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid transparent; }
.topbar.scrolled { border-bottom-color: var(--line); }
.menu-btn { display: none; }
.page { padding: 8px 32px 48px; max-width: 1240px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin: 12px 0 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.page-head .spacer { flex: 1; }

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; }
.btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--line) 50%, var(--muted)); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(79,70,229,.3), inset 0 1px 0 rgba(255,255,255,.15); }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--line-2); color: var(--text); }
.btn.icon { width: 36px; padding: 0; }
.btn:disabled { opacity: .55; cursor: default; }
.kbd { font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--surface); }

.search { position: relative; flex: 1; max-width: 460px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search input { padding-left: 38px; padding-right: 40px; }
.search .kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }

.input, .search input, textarea.input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.input:hover { border-color: color-mix(in srgb, var(--line) 50%, var(--muted)); }
.input:focus, .search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.input[readonly] { background: var(--surface-2); color: var(--text-2); }
.input.right { text-align: right; font-variant-numeric: tabular-nums; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--danger); font-weight: 500; }
.field.invalid .input { border-color: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 12%, transparent); }
.affix { position: relative; }
.affix .input { padding-right: 30px; }
.affix i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-size: 13px; }

.seg { display: inline-flex; padding: 3px; background: var(--line-2); border-radius: 10px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--text-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 36px; height: 20px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .track { background: var(--danger); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 25%, transparent); }

/* ---------- Cards / KPIs ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi { padding: 18px 20px; position: relative; overflow: hidden; }
.kpi .label { color: var(--text-2); font-weight: 500; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.kpi .label i { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.kpi .label i svg { width: 15px; height: 15px; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 10px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 15px; color: var(--text-2); font-weight: 600; margin-left: 2px; }
.kpi .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kpi.hero { background: linear-gradient(135deg, #4F46E5, #0EA5E9); color: #fff; border: 0; }
.kpi.hero .label, .kpi.hero .sub, .kpi.hero .value small { color: rgba(255,255,255,.82); }
.kpi.hero .label i { background: rgba(255,255,255,.18); color: #fff; }
.kpi.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: rgba(255,255,255,.08); }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.card-head h3 { margin: 0; font-size: 15px; font-weight: 650; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px 20px; }

.bar { height: 10px; border-radius: 99px; background: var(--line-2); overflow: hidden; display: flex; }
.bar span { display: block; height: 100%; }
.legend { display: grid; gap: 10px; margin-top: 16px; }
.legend div { display: flex; align-items: center; gap: 10px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.legend b { margin-left: auto; font-variant-numeric: tabular-nums; }
.legend small { color: var(--muted); width: 46px; text-align: right; }

.todo { list-style: none; margin: 0; padding: 0; }
.todo li { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-top: 1px solid var(--line-2); cursor: pointer; }
.todo li:first-child { border-top: 0; }
.todo li:hover { background: var(--surface-2); }
.todo .spacer { flex: 1; }

/* ---------- Table ---------- */
.table-wrap { overflow: hidden; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); position: sticky; top: 0; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
th.r, td.r { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 0; }
tr.off td:not(:first-child) { color: var(--muted); }
.office { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; color: var(--brand); background: var(--brand-soft); }
.office .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.office .s { color: var(--muted); font-size: 12.5px; }
.owner { max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--ok-soft); color: var(--ok); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.off { background: var(--line-2); color: var(--muted); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.muted { color: var(--muted); }

.empty { padding: 56px 24px; text-align: center; color: var(--text-2); }
.empty .ic { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.empty h3 { margin: 0 0 4px; color: var(--text); font-size: 16px; }
.skeleton { background: linear-gradient(90deg, var(--line-2) 25%, var(--surface-2) 50%, var(--line-2) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 6px; height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

.mobile-list { display: none; }

/* ---------- Drawer (ficha) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(15,23,42,.38); backdrop-filter: blur(2px); z-index: 40; opacity: 0; transition: opacity .2s; }
.scrim.in { opacity: 1; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100vw); z-index: 41; background: var(--bg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; transform: translateX(24px); opacity: 0; transition: transform .25s cubic-bezier(.2,.8,.2,1), opacity .2s; }
.drawer.in { transform: none; opacity: 1; }
.drawer-head { display: flex; align-items: center; gap: 14px; padding: 18px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.drawer-head .avatar { width: 44px; height: 44px; font-size: 14px; border-radius: 12px; }
.drawer-head h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.drawer-head p { margin: 0; color: var(--muted); font-size: 12.5px; }
.drawer-head .spacer { flex: 1; }
.drawer-body { flex: 1; overflow: auto; padding: 20px 24px 32px; display: grid; gap: 16px; align-content: start; }
.drawer-foot { display: flex; align-items: center; gap: 10px; padding: 14px 24px; background: var(--surface); border-top: 1px solid var(--line); }
.drawer-foot .spacer { flex: 1; }
.drawer-foot .note { color: var(--muted); font-size: 12px; }
.section { padding: 18px 20px; }
.section h4 { margin: 0 0 14px; font-size: 13px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.section h4 svg { width: 16px; height: 16px; color: var(--brand); }
.row { display: grid; gap: 14px; }
.row + .row { margin-top: 14px; }
.c2 { grid-template-columns: 1fr 1fr; } .c3 { grid-template-columns: 140px 1fr; } .c4 { grid-template-columns: 1.2fr 1fr; }
.money { display: grid; grid-template-columns: 1fr 140px 150px; gap: 10px 12px; align-items: center; }
.money .h { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.money .name { font-weight: 600; display: flex; align-items: center; gap: 10px; }
.money .name i { width: 10px; height: 10px; border-radius: 3px; }
.money .total { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; padding-top: 12px; margin-top: 4px; border-top: 1px dashed var(--line); }
.money .total b { font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

.lookup { position: relative; }
.lookup-menu { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 280px; overflow: auto; padding: 6px; }
.lookup-menu button { display: flex; width: 100%; gap: 10px; align-items: center; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.lookup-menu button:hover, .lookup-menu button.hl { background: var(--brand-soft); }
.lookup-menu .no { font-weight: 700; color: var(--brand); min-width: 44px; font-variant-numeric: tabular-nums; }
.lookup-menu small { display: block; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 4px; font-size: 16px; line-height: 1; opacity: .7; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.login-art { position: relative; overflow: hidden; background: radial-gradient(1200px 600px at 10% 10%, #6366F1 0%, transparent 60%), radial-gradient(900px 600px at 90% 90%, #0EA5E9 0%, transparent 55%), #1E1B4B; color: #fff; padding: 48px; display: flex; flex-direction: column; }
.login-art .brand b span { color: #A5B4FC; }
.login-art .brand small { color: rgba(255,255,255,.65); }
.login-art h2 { font-size: 40px; line-height: 1.1; letter-spacing: -.03em; margin: auto 0 14px; max-width: 460px; font-weight: 750; }
.login-art p { color: rgba(255,255,255,.75); max-width: 420px; font-size: 15px; margin: 0; }
.login-art .grid-bg { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(ellipse at 70% 30%, #000 0%, transparent 70%); }
.login-art > * { position: relative; }
.login-form { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.login-form form { width: 100%; max-width: 360px; display: grid; gap: 16px; }
.login-form h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.login-form .lead { margin: -8px 0 8px; color: var(--text-2); }
.login-form .btn { height: 44px; }
.alert { padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-weight: 500; font-size: 13px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 60; bottom: 20px; right: 20px; display: grid; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: #0F172A; color: #fff; box-shadow: var(--shadow-lg); font-weight: 500; animation: tin .25s cubic-bezier(.2,.8,.2,1); max-width: 380px; }
.toast svg { width: 18px; height: 18px; flex: none; color: #34D399; }
.toast.error svg { color: #F87171; }
@keyframes tin { from { transform: translateY(10px); opacity: 0; } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 50; left: 0; width: 260px; transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow-lg); }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .topbar, .page { padding-left: 16px; padding-right: 16px; }
  .topbar .kbd, .hide-sm { display: none; }
  .desktop-table { display: none; }
  .mobile-list { display: block; }
  .login { grid-template-columns: 1fr; } .login-art { display: none; }
  .c2, .c3, .c4 { grid-template-columns: 1fr; }
  .money { grid-template-columns: 1fr 1fr; } .money .name { grid-column: 1 / -1; } .money .h { display: none; }
}
@media (max-width: 520px) { .kpis { grid-template-columns: 1fr; } }
.m-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.m-item:last-child { border-bottom: 0; }
.m-item .grow { flex: 1; min-width: 0; }
.m-item .grow div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ajustes */
.btn.menu-btn { display: none; }
@media (max-width: 860px) { .btn.menu-btn { display: inline-flex; } }
.search input.sq { padding-left: 38px; padding-right: 40px; }
.soon { font-style: normal; }
.nav span, .nav a { white-space: nowrap; }
.avatar svg { width: 18px; height: 18px; }
.tb-space { flex: 1; }
.toasts { top: 20px; bottom: auto; }
@media (max-width: 860px) { .tb-space { display: none; } .search { max-width: none; } }

/* Parâmetros */
.perm-table th.c, .perm-table td.c { text-align: center; width: 104px; }
.perm-table tbody tr { cursor: default; }
.soon-s { font-size: 10px; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--muted); }
.check { display: inline-grid; place-items: center; cursor: pointer; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check span { width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--line); background: var(--surface); display: grid; place-items: center; transition: background .15s, border-color .15s; }
.check span::after { content: ""; width: 10px; height: 6px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
.check input:checked + span { background: var(--brand); border-color: var(--brand); }
.check input:checked + span::after { opacity: 1; }
.check input:disabled + span { opacity: .45; cursor: default; }
.check input:focus-visible + span { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 25%, transparent); }
.pill svg { width: 13px; height: 13px; }
.drawer-foot .pill::before { display: none; }
@media (max-width: 860px) { #perms { overflow-x: auto; } .perm-table { min-width: 720px; } }
[hidden] { display: none !important; }

/* Faturas */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.input.sel { width: auto; min-width: 150px; max-width: 320px; height: 38px; padding-right: 32px; cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-link { display: block; transition: transform .15s, box-shadow .15s; }
.kpi-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi .label i.warn { background: var(--warn-soft); color: var(--warn); }
.kpi .label i.danger { background: var(--danger-soft); color: var(--danger); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--brand-soft); color: var(--brand); }
.txt-danger { color: var(--danger); } .txt-warn { color: var(--warn); }
.nowrap { white-space: nowrap; }
.t-ellipsis { max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; gap: 4px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.tabs button { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 12px 12px; font-weight: 600; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button svg { width: 16px; height: 16px; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .count { background: var(--warn-soft); color: var(--warn); border-radius: 99px; padding: 0 7px; font-size: 11.5px; }
#dfat .kpi .value { font-size: 22px; }
#dfat .kpis { gap: 10px; margin-bottom: 14px; }
#dfat .kpi { padding: 14px 16px; }
#dfat td, #dfat th { padding: 10px 12px; }

.modal-wrap { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px; background: rgba(15,23,42,.45); backdrop-filter: blur(3px); opacity: 0; transition: opacity .18s; }
.modal-wrap.in { opacity: 1; }
.modal { width: min(920px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-lg); transform: translateY(8px) scale(.99); transition: transform .2s cubic-bezier(.2,.8,.2,1); }
.modal-wrap.in .modal { transform: none; }
.modal-head { display: flex; align-items: center; gap: 14px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.modal-head p { margin: 0; color: var(--muted); font-size: 12.5px; }
.modal-head .spacer { flex: 1; }
.modal-body { overflow: auto; padding: 20px 22px 24px; }
.facts { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.facts > div { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 14px; min-width: 0; }
.facts span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.facts b { display: block; font-size: 15px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.facts small { color: var(--text-2); }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.lines tbody tr { cursor: default; }
table.lines tr.comment td { color: var(--text-2); font-style: italic; }
.totals { margin-left: auto; margin-top: 14px; width: min(320px, 100%); display: grid; gap: 6px; }
.totals div { display: flex; justify-content: space-between; color: var(--text-2); font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; color: var(--text); font-size: 18px; }
@media (max-width: 860px) {
  .kpis-3 { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr 1fr; } .facts > div:first-child { grid-column: 1 / -1; }
  .modal-wrap { padding: 0; } .modal { max-height: 100vh; height: 100%; border-radius: 0; }
  .input.sel { flex: 1; max-width: none; }
}
.table-wrap { overflow-x: auto; }
.t-ellipsis { max-width: 210px; }
#fatpanel th, #fatpanel td { padding-left: 12px; padding-right: 12px; }
th.r, td.r { white-space: nowrap; }

/* Fornecedores */
.nav-parent { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-top: 2px; color: var(--text-2); font-weight: 600; }
.nav-parent svg { width: 18px; height: 18px; }
.nav a.sub { padding-left: 22px; margin-left: 18px; border-left: 1px solid var(--line); border-radius: 0 8px 8px 0; font-size: 13.5px; }
.nav a.sub svg { width: 16px; height: 16px; }
.txt-ok { color: var(--ok); }
.years { display: grid; gap: 10px; }
.yr { display: grid; grid-template-columns: 56px 1fr 130px 230px; align-items: center; gap: 14px; padding: 6px 8px; margin: 0 -8px; border-radius: 8px; }
.yr:hover { background: var(--surface-2); }
.yr .y { font-weight: 700; color: var(--text-2); }
.yr .track { height: 12px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.yr .track span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #6366F1, #0EA5E9); }
.yr b { text-align: right; }
.yr small { color: var(--muted); }
@media (max-width: 860px) { .yr { grid-template-columns: 48px 1fr 110px; } .yr small { grid-column: 2 / -1; margin-top: -8px; } }

/* Formulários de compras / pagamentos */
.modal.wide { width: min(1080px, 100%); }
.modal.wide .modal-body { padding-bottom: 8px; }
.modal .drawer-foot { position: static; }
.c4x { grid-template-columns: 1.3fr 1fr 1fr 1.6fr; }
select.input { cursor: pointer; }
table.lines.edit td { padding: 6px 6px; vertical-align: middle; }
table.lines.edit .input { height: 36px; padding: 0 8px; }
table.lines.edit tr.invalid td { background: var(--danger-soft); }
@media (max-width: 860px) { .c4x { grid-template-columns: 1fr 1fr; } table.lines.edit { min-width: 760px; } }
table.lines.edit .affix .input { padding-right: 26px; }

/* ---------- Fichas de fornecedores ---------- */
.tchips { display: flex; flex-wrap: wrap; gap: 8px; }
.tchip { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; font-size: 13px; color: var(--text-2); }
.tchip span { font-size: 11.5px; font-weight: 600; background: var(--line-2); color: var(--text-2); border-radius: 99px; padding: 1px 7px; }
.tchip:hover { border-color: var(--brand); color: var(--text); }
.tchip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tchip.on span { background: rgba(255,255,255,.22); color: #fff; }
.notice { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.notice > svg { width: 18px; height: 18px; flex: none; }
.notice > span, .notice > div { flex: 1; }
.bulk { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); }
.bulk[hidden] { display: none !important; }
.bulk .input.sel { min-width: 200px; background: var(--surface); }
select.tsel { height: 34px; padding-top: 0; padding-bottom: 0; font-size: 13px; }
select.tsel.empty { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.fgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.fgrid .field.wide { grid-column: span 2; }
.fgrid .field:has(textarea) { grid-column: 1 / -1; }
@media (max-width: 860px) { .fgrid { grid-template-columns: 1fr; } .fgrid .field.wide { grid-column: auto; } .bulk { flex-wrap: wrap; } }

/* ---------- Relatório de contas (ecrã) ---------- */
.rf-h { margin: 26px 0 10px; font-size: 14px; }
.c3e { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) { .c3e { grid-template-columns: 1fr; } }
.card-head h3 svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
.rel-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.miss { color: var(--warn); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.sheet { background: #fff; color: #0F172A; max-width: 900px; margin: 0 auto; padding: 44px 52px; border-radius: var(--r); box-shadow: var(--shadow); font-size: 13px; }
.sh-head { display: flex; align-items: center; gap: 16px; padding-bottom: 18px; border-bottom: 2px solid #0F172A; }
.sh-head img { width: 46px; height: 46px; }
.sh-head h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.sh-head p { margin: 2px 0 0; color: #475569; }
.sh-head .spacer { flex: 1; }
.sh-head small { color: #64748B; white-space: nowrap; }
.sh-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 20px 0 6px; }
.sh-kpis > div { border: 1px solid #E2E8F0; border-radius: 10px; padding: 10px 12px; }
.sh-kpis span { display: block; font-size: 11.5px; color: #64748B; }
.sh-kpis b { font-size: 17px; font-variant-numeric: tabular-nums; }
.sh-kpis .pos b { color: #047857; } .sh-kpis .neg b { color: #B91C1C; }
.sheet h2 { font-size: 14.5px; margin: 26px 0 8px; padding-bottom: 4px; border-bottom: 1px solid #E2E8F0; color: #312E81; }
.sh-t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sh-t th { position: static; text-align: left; font-size: 11.5px; color: #64748B; font-weight: 600; padding: 5px 6px; border-bottom: 1px solid #CBD5E1; background: none; }
.sh-t td { padding: 4px 6px; border-bottom: 1px solid #F1F5F9; color: #0F172A; }
.sh-t tbody tr:hover { background: none; }
.sh-t .r { text-align: right; white-space: nowrap; width: 120px; }
.sh-t .pct { width: 60px; color: #64748B; }
.sh-t tr.grp td { font-weight: 600; padding-top: 8px; }
.sh-t tr.det td { color: #475569; font-size: 12px; padding: 2px 6px 2px 20px; border-bottom: 0; }
.sh-t tr.det td.r { padding-right: 6px; }
.sh-t tr.sub td { font-weight: 600; }
.sh-t tfoot td { font-weight: 700; border-top: 1.5px solid #0F172A; border-bottom: 0; padding-top: 6px; background: none; color: #0F172A; }
.sh-t tfoot tr + tr td { border-top: 0; font-weight: 600; padding-top: 2px; }
.sh-t tfoot tr.paid td { font-weight: 500; color: #475569; }
.sh-t tr.pos td { color: #047857; } .sh-t tr.neg td { color: #B91C1C; }
.sh-t .ref { color: #94A3B8; font-size: 11px; margin-left: 4px; }
.sh-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.sh-note { margin: 6px 0 0; color: #64748B; font-size: 11.5px; }
.sh-obs { white-space: normal; line-height: 1.6; }
.sh-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; margin-top: 60px; }
.sh-sign div { text-align: center; color: #475569; font-size: 12px; }
.sh-sign span { display: block; border-bottom: 1px solid #0F172A; height: 34px; margin-bottom: 6px; }
@media (max-width: 860px) { .sheet { padding: 22px 16px; } .sh-kpis, .sh-2 { grid-template-columns: 1fr 1fr; } .sh-2 { grid-template-columns: 1fr; } .sh-head { flex-wrap: wrap; } }

/* ---------- Impressão (relatório em A4) ---------- */
@page { size: A4; margin: 14mm 12mm; }
@media print {
  body { background: #fff; }
  .side, .topbar, .no-print, .toasts { display: none !important; }
  .shell { display: block; }
  .page { padding: 0 !important; max-width: none; }
  .sheet { box-shadow: none; padding: 0; max-width: none; border-radius: 0; }
  .sheet h2 { break-after: avoid; }
  .sh-t, .sh-2 > * { break-inside: avoid; }
  .sh-kpis { grid-template-columns: repeat(4, 1fr) !important; }
  .sh-2 { grid-template-columns: 1fr 1fr !important; }
}
