:root {
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { overflow-x: clip; }
body { margin: 0; display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
aside { display: flex; flex-direction: column; background: var(--brand-wine); color: var(--sidebar-ink); padding: 20px 14px; position: sticky; top: 0; align-self: start; height: 100vh; overflow: auto; }
aside > * { flex-shrink: 0; }
nav [hidden] { display: none; }
.office-session { margin-top: auto; padding-top: 20px; }
.office-session button { width: 100%; }
#mobile-navigation { display: none; }
#office-status { color: inherit; margin: 0; font-size: 12px; }
.login-screen, .office-mode:not(.office-ready) { display: block; }
.login-screen aside, .office-mode:not(.office-ready) aside { display: none; }
.login-screen main { min-height: 100vh; display: grid; place-items: center; }
.login-screen .access-card { width: min(100%, 480px); margin: 0; padding: clamp(22px, 5vw, 38px); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .2em; }
:where(.link-nav, .link-back, .link-action, .link-help):not([hidden]) {
  display: inline-flex; align-items: center; gap: .4em; min-height: 44px;
}
.link-nav, .link-back, .link-action { text-decoration: none; font-weight: 600; }
:is(.link-nav, .link-back):is(:hover, :focus-visible), .link-help { text-decoration-line: underline; }
.link-nav::after { content: "→" / ""; }
.link-back::before { content: "←" / ""; }
a[href][target="_blank"]::after { content: "↗" / ""; }
.link-action { padding: 0 14px; border: 1px solid currentColor; border-radius: 8px; }
.link-action:hover { background: var(--accent-soft); }
.link-notice { margin: 8px 0 0; font-size: .875rem; }
aside a { color: inherit; text-decoration: none; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px 16px; margin-bottom: 14px; border-bottom: 1px solid var(--sidebar-border); font: 24px/1.15 var(--font-display); }
.brand span { display: grid; place-items: center; }
.brand small { display: block; margin-top: 4px; font: 400 12px/1.4 var(--font-text); color: var(--sidebar-muted); }
nav, .portals { display: grid; gap: 4px; }
nav { gap: 14px; }
.nav-group { display: grid; gap: 2px; }
.nav-group h2, .portals h2 { margin: 0 10px 4px; color: var(--sidebar-muted); font: 600 11px/1.4 var(--font-text); letter-spacing: .08em; text-transform: uppercase; }
nav a, .portals a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px; font-size: 14px; transition: background-color .15s; }
nav a span { color: var(--sidebar-muted); width: 15px; text-align: center; }
nav a:hover, .portals a:hover, nav a[aria-current] { background: var(--accent-hover); }
nav a[aria-current] { box-shadow: inset 3px 0 var(--brand-gold); font-weight: 700; }
.portals { margin-top: 18px; border-top: 1px solid var(--sidebar-border); padding-top: 14px; }
main { width: 100%; max-width: 1260px; margin: 0 auto; padding: clamp(20px, 5vw, 64px); }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { min-width: 0; overflow-wrap: break-word; text-wrap: balance; }
h1 { font: 400 clamp(32px, 4.5vw, 50px)/1.12 var(--font-display); margin-bottom: 13px; }
h2 { font: 400 26px/1.2 var(--font-display); margin-bottom: 14px; }
h3 { font-size: 17px; margin-bottom: 4px; }
p { color: var(--muted); }
.banner, .card { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--card-radius); padding: var(--card-padding); }
.banner { margin-bottom: 22px; }
.banner p:last-child, .card p:last-child { margin-bottom: 0; }
.dashboard-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.dashboard-header .actions { justify-content: flex-start; }
.client-heading h1 { margin-bottom: 0; }
.client-list { padding: 0; }
.client-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 155px), 1fr)); gap: 12px; padding: 18px; }
.client-filters label { font-size: 13px; }
.client-filters input { max-width: none; }
.client-table-scroll { overflow-x: auto; border-radius: 0 0 var(--card-radius) var(--card-radius); }
.client-table-scroll:focus-visible { outline-offset: -3px; }
.client-table { width: 100%; border-collapse: collapse; font-size: 14px; text-align: left; }
.client-table th, .client-table td { padding: 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.client-table thead th { background: var(--brand-background); color: var(--ink); font-size: 13px; font-weight: 600; }
.client-table tbody tr:nth-child(even) { background: var(--brand-background); }
.client-table tbody th, .client-table td:nth-child(2) { min-width: 125px; overflow-wrap: anywhere; }
.client-table tbody small { display: block; color: var(--muted); font-weight: 400; }
.client-table .tag { display: inline-block; }
.client-table td:nth-child(5), .client-table td:nth-child(6) { white-space: nowrap; }
.client-note { display: -webkit-box; min-width: 130px; overflow: hidden; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; color: var(--muted); }
.client-empty { padding: 0 18px 18px; }
.archive-help { padding: 18px 18px 0; margin-bottom: 0; font-size: 14px; }
.access-card { max-width: 520px; margin: clamp(0px, 5vw, 50px) auto 0; }
.access-card h1 { font-size: clamp(30px, 5vw, 42px); }
#login-form { display: grid; gap: 14px; margin: 20px 0; }
#login-form button { justify-self: start; }
#auth-qr { display: block; max-width: 100%; height: auto; }
#auth-manual-key { overflow-wrap: anywhere; }
#auth-recovery-codes { font-family: monospace; }
#petition-form { display: grid; gap: 16px; }
#petition-form label[hidden] { display: none; }
.sheet-canvas { height: max(420px, calc(100vh - 250px)); overflow-y: scroll; scrollbar-color: var(--control-border) transparent; padding: clamp(10px, 2vw, 24px); background: var(--accent-soft); border: 1px solid var(--border); border-radius: 0 0 8px 8px; }
#petition-preview { box-sizing: border-box; width: 100%; max-width: 794px; min-height: 1123px; margin: 0 auto; padding: clamp(24px, 8.7%, 69px); white-space: pre-wrap; overflow-wrap: anywhere; font: 14.67px/1.55 Helvetica, Arial, sans-serif; background: white; box-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 18%, transparent), 0 12px 28px -18px color-mix(in srgb, var(--ink) 45%, transparent); }
#petition-preview p, #petition-preview div { margin: 0; min-height: 1.5em; }
#petition-preview [data-align=center] { text-align: center; }
#petition-preview [data-align=right] { text-align: right; }
#petition-preview [data-align=justify] { text-align: justify; }
#petition-preview [data-indent="1"] { margin-left: 48px; }
#petition-preview [data-indent="2"] { margin-left: 96px; }
#petition-preview [data-indent="3"] { margin-left: 144px; }
#petition-preview [data-indent="4"] { margin-left: 192px; }
#petition-preview [data-size="10"] { font-size: 13.33px; }
#petition-preview [data-size="12"] { font-size: 16.00px; }
#petition-preview [data-size="14"] { font-size: 18.67px; }
#petition-preview [data-size="16"] { font-size: 21.33px; }
#petition-preview [data-list] { position: relative; padding-left: 24px; }
#petition-preview [data-list]::before { position: absolute; left: 4px; content: "•"; }
#petition-preview [data-list=number] { counter-increment: sheet-item; }
#petition-preview [data-list=number]::before { content: counter(sheet-item) "."; }
#petition-preview > :not([data-list=number]) { counter-reset: sheet-item; }
.sheet-toolbar select { width: auto; height: 34px; min-height: 0; padding: 0 6px; font-size: .8125rem; }
#petition-preview mark { background: var(--accent-soft); color: var(--accent); }
.document-models, .sheet-toolbar, .document-edited { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.document-models { margin-bottom: var(--card-gap); }
.document-models [aria-pressed=true] { background: var(--accent); border-color: transparent; color: white; }
.sheet-toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px; border: 1px solid var(--border); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--surface); }
.sheet-toolbar span { display: flex; gap: 2px; }
.sheet-toolbar span + span { padding-left: 6px; border-left: 1px solid var(--border); }
.sheet-toolbar button { display: grid; place-items: center; width: 34px; height: 34px; min-height: 0; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 1rem; }
.sheet-toolbar button:hover { background: var(--accent-soft); color: var(--accent); }
.sheet-toolbar svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#petition-preview, #petition-preview p { color: var(--ink); }
.sheet-bold { font-weight: 700; }
.sheet-italic { font-style: italic; }
.sheet-underline { text-decoration: underline; }
.document-edited { justify-content: space-between; flex-wrap: nowrap; padding: 4px 8px 4px 12px; border: 1px solid var(--border); border-bottom: 0; background: var(--accent-soft); font-size: .875rem; }
.document-edited[hidden] { display: none; }
.document-edited p { margin: 0; }
.document-edited button { flex: none; min-height: 30px; padding: 2px 10px; font-size: .8125rem; }
.sheet-toolbar button[aria-pressed=true] { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.document-downloads { flex-wrap: wrap; justify-content: flex-end; }
.document-editor-preview .card-heading { flex-wrap: wrap; gap: 8px; }
#petition-destination { width: min(460px, calc(100% - 32px)); padding: 24px; border: 1px solid var(--border); background: var(--surface); color: inherit; }
.document-editor-heading, .area-title { display: flex; justify-content: space-between; align-items: end; flex-wrap: wrap; gap: 12px; margin-bottom: 22px; }
.document-editor-heading p, .area-title p { margin-bottom: 0; }
.document-editor-layout { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); align-items: start; gap: var(--card-gap); margin-bottom: var(--card-gap); }
.document-editor-fields, .document-template-form, .area-form, .routine-form { display: grid; gap: 12px; }
.document-editor-fields { grid-template-columns: minmax(0, 1fr); align-items: start; }
.document-editor-fields label:has(textarea), .document-editor-fields label:has(input[type=date]) { grid-column: 1 / -1; }
.document-message summary { color: var(--accent); cursor: pointer; margin-bottom: 8px; }
.document-message label { margin-bottom: 8px; }
#document-missing, #deadline-result:not([hidden]) { background: var(--accent-soft); color: var(--accent); padding: 10px 12px; border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; margin: 0; }
.routine-form[hidden] { display: none; }
.area-actions, .routine-actions, .area-filters, .routine-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; }
.area-actions button, .routine-actions button { white-space: normal; }
.area-check, .routine-check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.area-check input, .routine-check input { width: auto; accent-color: var(--accent); }
.area-content > .card + .card, .routine-card, .area-content > .metric-group + .card { margin-top: var(--card-gap); }
.area-status:empty, .routine-form [role=alert]:empty, #guide-notice:empty, #petition-status:empty { display: none; }
.area-status:not(:empty), #guide-notice:not(:empty), #deadline-appointment:not([hidden]), #deadline-result:not([hidden]) { margin-top: 12px; }
.area-chart { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; list-style: none; padding: 0; margin: 0; }
.area-chart li { text-align: center; color: var(--muted); font-size: 11px; }
.area-chart-column { height: 136px; display: flex; align-items: end; justify-content: center; border-bottom: 1px solid var(--border); }
.area-chart-column span { display: block; width: min(30px, 85%); height: var(--height); background: var(--accent); border-radius: 5px 5px 0 0; }
.area-categories { list-style: none; margin: 0; padding: 0; }
.area-categories li { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--border); }
.area-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.office-followup { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.office-followup li { padding: 8px 0; border-top: 1px solid var(--border); }
.office-followup li:first-child { padding-top: 0; border-top: 0; }
#access-status:not(:empty) { margin-top: 14px; }
.process-table td:nth-child(5), .process-table td:nth-child(6) { white-space: normal; }
.process-table td { overflow-wrap: anywhere; }
.process-table td:nth-child(7) { white-space: nowrap; }
.dashboard-columns { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--card-gap); align-items: start; }
#proximos-dias, #guias-pendentes { grid-column: 1 / -1; }
.dashboard-office #guias-pendentes { grid-column: auto; }
.dashboard-columns + .backup-card { margin-top: var(--card-gap); }
.dashboard-single-column { grid-template-columns: minmax(0, 1fr); }
.backup-card { margin-bottom: var(--card-gap); }
.backup-details { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.backup-details p { margin: 0; }
.backup-card strong { display: block; color: var(--accent); }
.backup-summary, .backup-run-status, .backup-history { flex-basis: 100%; }
.backup-run-status:empty { display: none; }
.backup-history summary { cursor: pointer; color: var(--accent); }
.backup-history li { overflow-wrap: anywhere; }
.movement-card { margin-bottom: 14px; }
#meu-inss { margin-bottom: var(--card-gap); }
#meu-inss .heading { justify-content: flex-start; margin-bottom: 0; }
.movement-source { margin-top: 14px; }
#backup-folder-form { flex-basis: 100%; display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
#backup-folder-form label { flex: 1 1 220px; }
#backup-folder-form p { flex-basis: 100%; }
#backup-folder-form p:empty { display: none; }
#office-lists-form { display: grid; gap: 12px; max-width: 700px; }
#office-lists-form button { justify-self: start; }
#office-lists-form p:empty { display: none; }
.office-export { margin-top: 14px; }
.audit-results small { overflow-wrap: anywhere; }
.week-calendar { display: grid; grid-template-columns: repeat(7, minmax(100px, 1fr)); list-style: none; overflow-x: auto; gap: 6px; padding: 2px; margin: 0; }
.week-day time { display: block; color: var(--accent); font: 24px/1.2 var(--font-display); margin-bottom: 8px; }
.week-day small { display: block; color: var(--muted); font: 11px/1.4 system-ui; }
.week-event { width: 100%; padding: 6px; margin-bottom: 5px; text-align: left; overflow-wrap: anywhere; }
.week-event strong { display: block; font-size: 12px; }
.eyebrow { font-size: 13px; font-weight: 500; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: var(--card-gap); margin-bottom: 22px; }
.metric-group { container: metrics / inline-size; margin-block-end: 22px; }
.metric-grid { display: grid; grid-template-columns: minmax(0, 1fr); grid-auto-rows: 1fr; gap: var(--card-gap); }
.metric { display: flex; flex-direction: column; justify-content: space-between; gap: 10px; min-block-size: 108px; padding: 16px; color: inherit; text-decoration: none; }
a.metric:hover { border-color: var(--accent); }
.metric-label { color: var(--muted); font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.metric-value { color: var(--accent); font: 400 clamp(24px, 3vw, 31px)/1.15 var(--font-display); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@container metrics (min-width: 20rem) {
  .metric-grid:is([data-count="4"], [data-count="6"]) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container metrics (min-width: 34rem) {
  .metric-grid, .metric-grid[data-count="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@container metrics (min-width: 65rem) {
  .metric-grid[data-count="6"] { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@container metrics (min-width: 53rem) {
  .metric-grid[data-count="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.heading, .card-heading, .row, .actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.heading, .card-heading { margin-bottom: var(--card-gap); }
.heading h2, .card-heading h2, .row p { margin-bottom: 0; }
.row { border-top: 1px solid var(--border); padding: 13px 0; }
.row:last-child { padding-bottom: 0; }
.row a { font-weight: 650; }
.row small { display: block; color: var(--muted); }
.tag { padding: 4px 10px; background: var(--accent-soft); color: var(--accent); border-radius: 4px; font-size: 13px; overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; }
button { border: 1px solid transparent; background: var(--accent); color: white; border-radius: 8px; padding: 8px 14px; cursor: pointer; }
button:hover { filter: brightness(1.12); }
.secondary { background: var(--surface); color: var(--accent); border-color: var(--border); }
input, select, textarea { width: 100%; border: 1px solid var(--control-border); border-radius: 7px; padding: 8px 10px; background: var(--surface); color: inherit; }
input[type=search] { max-width: 360px; }
[data-document-create] { display: grid; gap: 12px; }
[data-document-create] fieldset { min-width: 0; border: 1px solid var(--border); }
[data-document-create] input[type=checkbox] { width: auto; accent-color: var(--accent); }
[data-document-share] { margin-top: 12px; }
[data-document-share] .actions { justify-content: flex-start; margin-top: 10px; }
label { display: grid; gap: 4px; font-weight: 600; }
.identifier-field { display: grid; align-content: start; gap: 4px; }
.identifier-field small { color: var(--muted); }
.identifier-field .identifier-error { color: var(--danger); }
.identifier-error:empty { display: none; }
.identifier-field [aria-invalid="true"] { border-color: var(--danger); }
dialog { width: min(520px, calc(100% - 28px)); max-height: 90vh; border: 1px solid var(--border); border-radius: 16px; padding: 24px; }
.editor-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.editor-header h2 { margin: 0; }
.client-editor { inset: 0 0 0 auto; margin: 0; width: min(660px, 100%); height: 100dvh; max-width: none; max-height: none; border-radius: 20px 0 0 20px; padding: 0; overflow: hidden; }
.client-editor form { display: flex; flex-direction: column; height: 100%; }
.client-editor .editor-header { padding: 20px clamp(16px, 4vw, 32px); margin: 0; border-bottom: 1px solid var(--border); }
.client-editor #fields { padding: 21px clamp(16px, 4vw, 32px); overflow-y: auto; flex: 1; min-height: 0; gap: 21px; }
.client-editor fieldset { min-width: 0; margin: 0; padding: 12px 0 0; border: 0; border-top: 1px solid var(--border); }
.client-editor legend { padding-right: 10px; color: var(--accent); font: 21px/1.25 var(--font-display); }
.client-fields, .process-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.process-facts { display: flex; flex-wrap: wrap; gap: 12px 22px; }
.process-facts dt { font-size: 12px; color: var(--muted); }
.process-facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.client-editor label { font-size: 13px; }
.client-editor label > :is(input, select, textarea) { font-size: 15px; }
.client-editor .check-option { display: flex; align-items: center; gap: 7px; font-weight: 500; }
.client-editor input[type=checkbox] { width: auto; accent-color: var(--accent); }
.client-editor .client-checks { display: flex; flex-wrap: wrap; gap: 8px 15px; margin-top: 17px; }
.client-editor .client-checks legend { font: 600 13px system-ui; }
.client-editor .actions { border-top: 1px solid var(--border); background: var(--brand-background); padding: 13px clamp(16px, 4vw, 32px); }
.client-editor #form-error { margin: 0 16px; }
.client-editor #form-error:empty { display: none; }
main:has(> .full-client-page) > :not(.full-client-page) { display: none; }
.full-client-page { width: 100%; height: auto; overflow: visible; }
.full-client-page .editor-header { padding: 0 0 16px; }
.full-client-page #fields { padding: 24px 0; overflow: visible; }
.full-client-page label:has([name="nome"], [name="endereco"]) { grid-column: 1 / -1; }
.full-client-page .actions { position: sticky; bottom: 0; }
.client-editor:has([value="abrir-ficha"]:not([hidden])) #fields { align-content: start; }
@media (max-width: 720px) {
  dialog.client-editor { width: 100%; max-height: 100dvh; }
  .client-editor .actions { gap: 8px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  dialog.client-editor .actions #cancel { display: none; }
  dialog.client-editor .actions button[type="submit"] { flex: 1; min-height: 44px; }
  .client-editor label > :is(input, select, textarea) { font-size: 16px; }
}
@media (max-width: 480px) { .client-fields, .process-fields { grid-template-columns: minmax(0, 1fr); } }
#fields { display: grid; gap: 12px; }
.actions { justify-content: flex-end; }
#form-error { color: var(--danger); }
.toast { position: fixed; bottom: 18px; right: 18px; margin: 0; padding: 10px 16px; background: var(--brand-wine); color: var(--surface); border-radius: 8px; }
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 3px; }
@media (max-width: 950px) {
  .dashboard-columns { grid-template-columns: minmax(0, 1fr); }
  .document-editor-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  body { display: block; }
  aside { position: static; height: auto; padding: 15px; }
  .brand { margin-bottom: 12px; padding-bottom: 12px; }
  nav, .portals, .nav-group { display: flex; flex-wrap: wrap; }
  nav { gap: 9px 15px; }
  .nav-group h2 { width: 100%; }
  .portals { margin-top: 10px; padding-top: 6px; }
  .portals h2 { width: 100%; }
  #mobile-navigation { display: inline-flex; align-self: flex-start; margin-bottom: 10px; }
  aside:not(.navigation-open) > :is(nav, .portals, .office-session) { display: none; }
}
@media (max-width: 440px) {
  .document-editor-fields { grid-template-columns: minmax(0, 1fr); }
}
