:root {
  color-scheme: light;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  background: #f5f7fb;
  color: #27344b;
  --background: #f5f7fb;
  --surface: #ffffff;
  --ink: #202f47;
  --muted: #64748b;
  --line: #e5ebf3;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --sidebar-width: 260px;
  --radius: 16px;
  --shadow: 0 8px 28px rgba(22, 40, 75, .045);
}

*, *::before, *::after { box-sizing: border-box; }
html { min-width: 280px; scroll-behavior: smooth; }
body { min-width: 280px; margin: 0; min-height: 100vh; background: var(--background); }
body, button, input, select, textarea { font-family: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: .55; }
img, svg { max-width: 100%; }
:focus-visible { outline: 3px solid #91b9ff; outline-offset: 3px; }
::selection { background: #cddfff; color: #142742; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 1000; top: 10px; left: 10px; padding: 12px 16px; color: #fff; background: var(--primary); border-radius: 10px; transform: translateY(-180%); }
.skip-link:focus { transform: translateY(0); }

/* Estrutura e navegação */
.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; height: 100dvh; min-width: 0; padding: 25px 15px 20px; color: #c4d1e6; background: #101d36; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #405273 transparent; }
.brand { display: inline-flex; align-items: center; gap: 12px; padding: 3px 9px; min-width: 0; color: #fff; font-weight: 850; font-size: 13px; line-height: 1.25; letter-spacing: .07em; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-name { min-width: 0; overflow-wrap: anywhere; }
.brand small { display: block; margin-top: 4px; color: #9cbdf8; font-size: 10px; letter-spacing: .24em; }
.brand-mark { display: inline-grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; border-radius: 13px; background: linear-gradient(135deg, #3a83ff, #215dd2); box-shadow: 0 5px 14px rgba(40, 107, 238, .24); color: #fff; font-weight: 850; font-size: 13px; letter-spacing: 0; }
.tenant { margin: 25px 7px 17px; padding: 15px 13px; border: 1px solid #33415e; border-radius: 12px; background: #192943; overflow-wrap: anywhere; }
.tenant strong { display: block; font-size: 13px; line-height: 1.45; color: #f8fafc; }
.tenant small { display: block; margin-top: 6px; font-size: 11px; line-height: 1.55; color: #b3c4de; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { display: flex; align-items: center; min-width: 0; min-height: 44px; gap: 12px; padding: 11px 12px; border-radius: 10px; color: #c8d5e8; font-size: 13px; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
.sidebar nav a:hover, .sidebar nav a.active { background: #25426e; color: #fff; text-decoration: none; }
.sidebar nav a.active { box-shadow: inset 3px 0 0 #73a9ff; }
.nav-icon { display: inline-grid; place-items: center; flex: 0 0 18px; width: 18px; height: 18px; color: currentColor; }
.nav-icon svg, .ui-icon { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.nav-label { margin: 18px 0 5px; padding: 0 12px; font-size: 10px; font-weight: 800; letter-spacing: .13em; color: #89a4cf; }
.logout-form { margin-top: auto; padding-top: 28px; }
.logout { width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 12px; min-height: 44px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: #c8d5e8; font-size: 13px; font-weight: 650; text-align: left; }
.logout:hover { background: #25426e; color: #fff; }
.sidebar-backdrop, .menu-toggle { display: none; }
.main { min-width: 0; }
.topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; min-width: 0; min-height: 72px; gap: 16px; padding: 12px clamp(22px, 3.3vw, 48px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.97); backdrop-filter: blur(8px); }
.topbar-left, .topbar-user { display: flex; min-width: 0; align-items: center; gap: 11px; }
.topbar-title { min-width: 0; font-size: 11px; font-weight: 850; color: #738298; letter-spacing: .12em; text-transform: uppercase; }
.topbar-user-name { min-width: 0; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #43516a; font-size: 12px; font-weight: 700; }
.avatar { display: inline-grid; place-items: center; flex: 0 0 37px; width: 37px; height: 37px; border: 1px solid #dce8fa; border-radius: 50%; background: #eaf2ff; color: #225ad2; font-weight: 850; font-size: 13px; }
.content { width: 100%; max-width: 1540px; margin: 0 auto; padding: clamp(24px, 3.3vw, 45px); min-width: 0; }

/* Títulos e ações */
.page-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; min-width: 0; margin-bottom: 27px; }
.page-heading > div:first-child { flex: 1 1 280px; min-width: 0; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-width: 0; }
.eyebrow { margin: 0 0 8px; color: #3475d9; font-size: 10px; font-weight: 850; letter-spacing: .13em; line-height: 1.5; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { margin: 0; color: var(--ink); letter-spacing: -.025em; }
h1 { font-size: clamp(24px, 2.5vw, 32px); line-height: 1.22; font-weight: 780; }
h2 { font-size: 16px; line-height: 1.42; font-weight: 760; }
h3 { font-size: 14px; font-weight: 750; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.65; margin: 8px 0 0; }
.date-pill, .role-pill { display: inline-flex; align-items: center; gap: 7px; padding: 9px 13px; border: 1px solid #dfe8f5; border-radius: 999px; background: #edf3fb; color: #48678c; font-size: 12px; font-weight: 750; white-space: nowrap; }
.link-back { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; gap: 6px; font-size: 13px; font-weight: 700; }
.section-description { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

/* Cards e indicadores */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 222px), 1fr)); gap: 16px; margin-bottom: 23px; }
.stat, .card { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat { position: relative; display: flex; flex-direction: column; align-items: flex-start; min-height: 148px; padding: 22px 23px; overflow: hidden; }
.stat::before { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: #7baafa; }
.stat.warn::before { background: #edaa54; }
.stat.success::before { background: #49b991; }
.stat small { max-width: 100%; color: #68788c; font-size: 12px; font-weight: 700; line-height: 1.5; overflow-wrap: anywhere; }
.stat strong { display: block; max-width: 100%; margin: 10px 0 6px; color: #1f3047; font-size: clamp(29px, 2.8vw, 36px); font-weight: 800; line-height: 1.15; letter-spacing: -.04em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat strong.currency { font-size: clamp(20px, 1.65vw, 24px); line-height: 1.28; letter-spacing: -.05em; }
.stat strong.currency-long { font-size: clamp(17px, 1.3vw, 19px); }
.stat > span { margin-top: auto; max-width: 100%; color: #8895a7; font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.stat.warn strong, .overdue { color: #b85d22 !important; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 19px; }
.card { padding: clamp(18px, 2vw, 25px); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; min-width: 0; gap: 8px 14px; margin-bottom: 14px; }
.card-head h2 { flex: 1 1 210px; }
.card-head a { font-size: 12px; line-height: 1.5; font-weight: 750; }
.activity { display: grid; grid-template-columns: 10px minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 16px 0; border-top: 1px solid #edf1f7; }
.activity > div { min-width: 0; }
.activity strong, .activity small { display: block; max-width: 100%; overflow-wrap: anywhere; }
.activity strong { color: #27384f; font-size: 13px; line-height: 1.5; }
.activity small { color: #758399; font-size: 12px; line-height: 1.6; margin-top: 3px; }
.activity > a { font-size: 12px; font-weight: 750; }
.dot { display: inline-block; flex-shrink: 0; width: 9px; height: 9px; border-radius: 50%; }
.dot.amber { background: #eba839; }.dot.blue { background: #367dec; }
.empty { padding: 35px 15px; text-align: center; color: #758399; font-size: 13px; line-height: 1.7; }

/* Botões e mensagens */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: auto; max-width: 100%; min-height: 42px; padding: 10px 16px; border: 1px solid transparent; border-radius: 10px; font-size: 13px; font-weight: 750; line-height: 1.35; text-align: center; overflow-wrap: anywhere; white-space: normal; transition: background .15s ease, border-color .15s ease, box-shadow .15s ease; }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 5px 13px rgba(37,99,235,.13); }
.btn.primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn.secondary { background: #edf3fd; color: #245dae; border-color: #dce8fa; }
.btn.secondary:hover { background: #e2edfc; text-decoration: none; }
.btn.full { width: 100%; }
.linkbutton { display: inline-flex; align-items: center; max-width: 100%; min-height: 35px; padding: 6px 0; color: var(--primary); background: transparent; border: 0; text-align: left; font-size: 12px; font-weight: 750; line-height: 1.4; }
.linkbutton:hover { text-decoration: underline; }
.alert { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; margin-bottom: 19px; border: 1px solid transparent; border-radius: 12px; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.alert::before { display: inline-grid; place-items: center; flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%; font-size: 13px; font-weight: 800; }
.alert.ok { background: #e9f8f0; color: #11613e; border-color: #c9ecd8; }.alert.ok::before { content: '✓'; background: #c9ecd8; }
.alert.bad { background: #fff0f1; color: #992d41; border-color: #f5d2d7; }.alert.bad::before { content: '!'; background: #f5d2d7; }
.alert ul { padding-left: 20px; margin: 6px 0 0; }

/* Tabelas */
.list-card { padding: 0; overflow: hidden; }
.list-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 18px 21px; border-bottom: 1px solid var(--line); }
.searchbar { display: flex; flex-wrap: wrap; align-items: stretch; min-width: 0; width: 100%; gap: 9px; }
.searchbar input { flex: 1 1 200px; width: 100%; max-width: 390px; margin: 0; }
.table-scroll { min-width: 0; width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: #b8c6d9 #eff3f8; }
.table-scroll:focus-visible { outline-offset: -4px; }
table { width: 100%; min-width: 720px; border-collapse: collapse; table-layout: auto; }
.table-scroll.wide table { min-width: 940px; }
th { padding: 14px 17px; background: #f9fbfe; border-bottom: 1px solid var(--line); color: #63758d; text-align: left; font-size: 11px; font-weight: 800; line-height: 1.4; letter-spacing: .055em; text-transform: uppercase; white-space: nowrap; }
td { max-width: 275px; padding: 15px 17px; border-bottom: 1px solid #eef2f7; vertical-align: middle; color: #54637a; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fbfcff; }
td strong { display: block; color: #293a52; font-size: 13px; font-weight: 750; line-height: 1.5; }
td small { display: block; margin-top: 4px; color: #79889d; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
td .empty { padding: 28px 12px; }
.cell-nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell-action { white-space: nowrap; text-align: right; }
.cell-action a { display: inline-block; padding: 8px 0; font-weight: 750; font-size: 12px; }
.table-scroll a:not(.btn) { overflow-wrap: anywhere; }
.badge { display: inline-flex; align-items: center; justify-content: center; max-width: 100%; padding: 5px 10px; border: 1px solid #dfe8fb; border-radius: 999px; background: #edf3ff; color: #3962a8; font-size: 11px; font-weight: 750; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }
.badge.paid, .badge.success { background: #e7f7ee; border-color: #ccead9; color: #176c49; }
.badge.overdue, .badge.high { background: #fff0e6; border-color: #ffdfc5; color: #a74c1e; }
.badge.waiting { background: #fff7df; border-color: #f4e6ac; color: #906619; }
.badge.neutral { background: #f0f3f7; border-color: #e0e6ed; color: #5e6c7e; }
.scroll-hint { display: none; padding: 9px 19px 0; color: #7b889d; font-size: 11px; line-height: 1.5; }
.pagination { padding: 13px 20px 17px; border-top: 1px solid var(--line); }
.pagination:empty { display: none; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 18px; font-size: 12px; }
.pager a, .pager span { display: inline-flex; align-items: center; min-height: 35px; }
.pager a { color: #255fcb; font-weight: 750; }
.pager .muted { margin: 0; font-size: 12px; }

/* Formulários */
.form-card { width: 100%; max-width: 1020px; padding: clamp(20px, 3vw, 34px); }
.form-section { padding: 0 0 20px; margin: 0 0 23px; border-bottom: 1px solid var(--line); }
.form-section:last-of-type { margin-bottom: 0; }
.form-section-title { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; min-width: 0; }
.field { display: flex; flex-direction: column; min-width: 0; margin-bottom: 18px; color: #43546c; font-size: 12px; font-weight: 750; line-height: 1.45; }
.field-label { display: block; margin-bottom: 8px; }
.required { color: #b45335; }
.field-hint { display: block; margin-top: 7px; color: #758399; font-size: 11px; font-weight: 500; line-height: 1.5; }
input, select, textarea { display: block; width: 100%; max-width: 100%; min-width: 0; min-height: 44px; margin: 0; padding: 11px 12px; border: 1px solid #d5deeb; border-radius: 10px; outline: none; background: #fff; color: #25354d; font-size: 13px; font-weight: 500; line-height: 1.5; transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: #92a0b4; }
input:hover, select:hover, textarea:hover { border-color: #aebed5; }
input:focus, select:focus, textarea:focus { border-color: #4285ed; box-shadow: 0 0 0 3px rgba(66,133,237,.16); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: #cf5361; }
textarea { min-height: 105px; resize: vertical; }
select { text-overflow: ellipsis; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 11px; padding-top: 4px; }
.form-actions .btn { min-width: 150px; }

/* Autenticação */
.login-wrap { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 24px 16px; background: radial-gradient(circle at 15% 15%, #244d8e 0%, transparent 33%), linear-gradient(140deg, #0b1a33 0%, #132b51 65%, #1b4787 100%); }
.login-content { width: 100%; max-width: 440px; }
.login-card { width: 100%; padding: clamp(25px, 5vw, 40px); border: 1px solid #dfe7f2; border-radius: 20px; background: #fff; box-shadow: 0 25px 80px rgba(5,18,42,.27); }
.login-card .brand { padding: 0; margin-bottom: 38px; color: #1a3356; }
.login-card .brand small { color: #3973d8; }
.login-card h1 { font-size: clamp(25px, 5vw, 30px); }
.login-card .muted { margin: 10px 0 26px; }
.login-card .field { margin-bottom: 18px; }
.login-card .small { margin: 19px 0 0; color: #78879b; font-size: 11px; line-height: 1.6; text-align: center; }
.login-content .alert { margin-top: 16px; }

/* Responsividade */
@media (max-width: 1180px) {
  :root { --sidebar-width: 238px; }
  .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 28px; }
}
@media (max-width: 940px) {
  .app-shell { grid-template-columns: minmax(0,1fr); }
  .sidebar { position: fixed; z-index: 60; top: 0; left: 0; width: min(86vw, 300px); height: 100vh; height: 100dvh; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 15px 0 40px rgba(7,19,38,.15); }
  .menu-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; z-index: 50; inset: 0; width: 100%; height: 100vh; padding: 0; border: 0; background: rgba(10,23,44,.47); }
  .menu-open .sidebar-backdrop { display: block; }
  .menu-open { overflow: hidden; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 40px; width: 40px; height: 40px; border: 1px solid #dfe7f0; border-radius: 10px; background: #fff; color: #344c6a; }
  .menu-toggle:hover { background: #f1f5fc; }
  .topbar { min-height: 66px; padding: 11px 23px; }
  .content { padding: 27px 23px; }
  .scroll-hint { display: block; }
}
@media (max-width: 660px) {
  .topbar { min-height: 60px; padding: 9px 15px; }
  .topbar-title { font-size: 10px; letter-spacing: .06em; }
  .topbar-user-name { display: none; }
  .avatar { width: 35px; height: 35px; flex-basis: 35px; }
  .content { padding: 23px 16px 36px; }
  .page-heading { gap: 14px; margin-bottom: 20px; }
  .page-heading > div:first-child { flex-basis: 100%; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .page-actions .date-pill { display: none; }
  .stats { grid-template-columns: 1fr; gap: 12px; }
  .stat { min-height: 116px; padding: 17px 20px; }
  .stat strong { font-size: 30px; margin: 5px 0; }
  .stat strong.currency { font-size: 25px; }
  .stat strong.currency-long { font-size: 20px; }
  .grid-2 { gap: 13px; }
  .card { padding: 18px 16px; }
  .list-card { padding: 0; }
  .list-toolbar { padding: 14px; }
  .list-toolbar .btn { flex: 0 0 auto; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
  .form-card { padding: 21px 17px; }
  .form-section { margin-bottom: 19px; padding-bottom: 14px; }
  .form-actions .btn { flex: 1 1 auto; }
  .activity { grid-template-columns: 10px minmax(0,1fr); gap: 10px; }
  .activity > a { grid-column: 2; justify-self: start; margin-top: -1px; }
  .card-head { gap: 8px; }
  .card-head h2 { flex-basis: 100%; }
  .pagination { padding: 11px 12px; }
  .pager { gap: 4px 10px; }
}
@media (max-width: 370px) {
  .content { padding-left: 12px; padding-right: 12px; }
  .topbar { padding-left: 12px; padding-right: 12px; }
  .topbar-title { font-size: 9px; }
  .btn { width: 100%; }
  .page-actions .link-back { width: 100%; }
  .searchbar input { flex-basis: 100%; }
  .searchbar .btn { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
