:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #eef3f8;
    --text: #152033;
    --muted: #65738a;
    --line: #dce3ed;
    --primary: #2563eb;
    --primary-strong: #1d4ed8;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #0f766e;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.10);
    --shadow-soft: 0 10px 26px rgba(15, 23, 42, 0.08);
    --radius: 8px;
    --sidebar: 282px;
  }

  * {
    box-sizing: border-box;
  }

  html {
    min-height: 100%;
  }

  body {
    margin: 0;
    min-height: 100%;
    background:
      linear-gradient(180deg, rgba(37, 99, 235, 0.05), transparent 260px),
      var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
  }

  button,
  input,
  select,
  textarea {
    font: inherit;
  }

  button {
    cursor: pointer;
  }

  .material-symbols-rounded {
    direction: ltr;
    display: inline-block;
    font-family: "Material Symbols Rounded";
    font-feature-settings: "liga";
    font-size: 21px;
    font-style: normal;
    font-weight: normal;
    letter-spacing: normal;
    line-height: 1;
    text-transform: none;
    white-space: nowrap;
    word-wrap: normal;
    -webkit-font-feature-settings: "liga";
    -webkit-font-smoothing: antialiased;
  }

  .login-screen {
    align-items: center;
    display: grid;
    min-height: 100dvh;
    padding: 24px;
  }

  .login-card {
    background: var(--surface);
    border: 1px solid rgba(220, 227, 237, 0.9);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: grid;
    gap: 28px;
    grid-template-columns: minmax(0, 0.92fr) minmax(340px, 420px);
    margin: 0 auto;
    max-width: 980px;
    overflow: hidden;
    width: 100%;
  }

  .login-brand {
    background: #10243f;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 520px;
    padding: 38px;
  }

  .brand-lockup {
    align-items: center;
    display: flex;
    gap: 12px;
  }

  .brand-mark {
    align-items: center;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius);
    display: grid;
    height: 48px;
    place-items: center;
    width: 48px;
  }

  .brand-lockup h1,
  .login-copy h2,
  .panel-title h2,
  .section-title h3 {
    letter-spacing: 0;
    margin: 0;
  }

  .brand-lockup strong {
    display: block;
    font-size: 18px;
  }

  .brand-lockup span,
  .login-copy p,
  .panel-title p,
  .section-title p,
  .empty-state p {
    color: var(--muted);
    margin: 0;
  }

  .login-brand .brand-lockup span,
  .login-brand .login-copy p,
  .login-brand .brand-foot {
    color: rgba(255, 255, 255, 0.72);
  }

  .login-copy {
    display: grid;
    gap: 14px;
    max-width: 450px;
  }

  .login-copy h2 {
    font-size: clamp(28px, 4vw, 44px);
    line-height: 1.05;
  }

  .login-copy p {
    font-size: 16px;
    line-height: 1.6;
  }

  .brand-foot {
    font-size: 13px;
  }

  .login-form-wrap {
    align-self: center;
    display: grid;
    gap: 22px;
    padding: 42px 42px 42px 12px;
  }

  .login-form-wrap h2 {
    font-size: 26px;
    margin: 0;
  }

  .form-grid {
    display: grid;
    gap: 16px;
  }

  .form-row {
    display: grid;
    gap: 8px;
  }

  .form-row label {
    color: #334155;
    font-size: 13px;
    font-weight: 700;
  }

  .field-control {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: flex;
    gap: 10px;
    min-height: 46px;
    padding: 0 12px;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
  }

  .field-control:focus-within {
    border-color: rgba(37, 99, 235, 0.62);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
  }

  .field-control input,
  .field-control select,
  .field-control textarea {
    background: transparent;
    border: 0;
    color: var(--text);
    min-width: 0;
    outline: 0;
    width: 100%;
  }

  .field-control textarea {
    min-height: 104px;
    padding: 12px 0;
    resize: vertical;
  }

  .field-control select {
    appearance: none;
  }

  .autocomplete-control {
    overflow: visible;
    position: relative;
  }

  .autocomplete-menu {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    display: none;
    left: -1px;
    max-height: 230px;
    overflow: auto;
    padding: 6px;
    position: absolute;
    right: -1px;
    top: calc(100% + 6px);
    z-index: 45;
  }

  .autocomplete-menu.open {
    display: grid;
    gap: 4px;
  }

  .autocomplete-option {
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: #24324a;
    font-weight: 800;
    min-height: 38px;
    padding: 0 10px;
    text-align: left;
    transition: background 160ms ease, color 160ms ease;
    width: 100%;
  }

  .autocomplete-option:hover,
  .autocomplete-option:focus {
    background: rgba(37, 99, 235, 0.10);
    color: var(--primary-strong);
    outline: 0;
  }

  .autocomplete-empty {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    padding: 10px;
  }

  .multi-select-panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: grid;
    gap: 8px;
    max-height: 260px;
    overflow: auto;
    padding: 10px;
  }

  .check-option {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    gap: 10px;
    min-height: 48px;
    padding: 9px 10px;
    transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
  }

  .check-option:hover {
    background: #f8fafc;
  }

  .check-option input {
    height: 1px;
    opacity: 0;
    position: absolute;
    width: 1px;
  }

  .check-box {
    align-items: center;
    border: 2px solid #c7d2e3;
    border-radius: 6px;
    color: #fff;
    display: grid;
    flex: 0 0 auto;
    height: 24px;
    place-items: center;
    transition: background 160ms ease, border-color 160ms ease;
    width: 24px;
  }

  .check-box .material-symbols-rounded {
    font-size: 18px;
  }

  .check-option input:checked + .check-box {
    background: var(--primary);
    border-color: var(--primary);
  }

  .check-option:has(input:checked) {
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.40);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
  }

  .check-option strong,
  .check-option small {
    display: block;
  }

  .check-option small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    margin-top: 1px;
  }

  .empty-inline {
    align-items: center;
    color: var(--muted);
    display: flex;
    gap: 8px;
    min-height: 46px;
    padding: 4px;
  }

  .app-shell {
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
    min-height: 100dvh;
  }

  .sidebar {
    background: #10243f;
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 22px;
    min-height: 100dvh;
    padding: 22px 18px;
    position: sticky;
    top: 0;
  }

  .sidebar .brand-lockup {
    padding: 8px 4px 14px;
  }

  .sidebar .brand-mark {
    height: 42px;
    width: 42px;
  }

  .sidebar .brand-lockup span {
    color: rgba(255, 255, 255, 0.68);
    font-size: 13px;
  }

  .nav-list {
    display: grid;
    gap: 8px;
  }

  .nav-button,
  .mobile-nav-button {
    align-items: center;
    border: 0;
    display: flex;
    gap: 10px;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
  }

  .nav-button {
    background: transparent;
    border-radius: var(--radius);
    color: rgba(255, 255, 255, 0.72);
    min-height: 44px;
    padding: 0 12px;
    text-align: left;
    width: 100%;
  }

  .nav-button:hover,
  .nav-button.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
  }

  .sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.68);
    display: grid;
    font-size: 13px;
    gap: 4px;
    margin-top: auto;
    padding: 16px 4px 0;
  }

  .main-panel {
    min-width: 0;
    padding: 22px;
  }

  .topbar {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin: 0 auto 18px;
    max-width: 1240px;
  }

  .panel-title {
    display: grid;
    gap: 4px;
  }

  .panel-title h2 {
    font-size: clamp(22px, 2.6vw, 30px);
  }

  .topbar-actions {
    align-items: center;
    display: flex;
    gap: 10px;
  }

  .user-pill {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: var(--shadow-soft);
    display: flex;
    gap: 9px;
    min-height: 42px;
    padding: 0 14px 0 12px;
  }

  .user-pill span:last-child {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
  }

  .view {
    animation: fadeIn 220ms ease both;
    margin: 0 auto;
    max-width: 1240px;
  }

  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: translateY(8px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .toolbar {
    align-items: end;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    margin-bottom: 16px;
    padding: 16px;
  }

  .toolbar .form-row {
    grid-column: span 3;
  }

  .toolbar .wide {
    grid-column: span 4;
  }

  .toolbar .actions {
    display: flex;
    gap: 8px;
    grid-column: span 2;
  }

  .grid-2 {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 0.9fr) minmax(320px, 0.55fr);
  }

  .dashboard-stack {
    display: grid;
    gap: 16px;
  }

  .panel,
  .metric-card,
  .doc-card,
  .empty-state {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
  }

  .panel {
    overflow: hidden;
  }

  .dashboard-panel {
    margin-top: 16px;
  }

  .panel-header {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 16px;
  }

  .panel-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
  }

  .section-title {
    display: grid;
    gap: 3px;
  }

  .section-title h3 {
    font-size: 17px;
  }

  .panel-body {
    padding: 16px;
  }

  .metric-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 16px;
  }

  .metric-grid-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .metric-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .compact-metrics {
    gap: 10px;
  }

  .metric-card {
    align-items: center;
    display: flex;
    gap: 12px;
    min-height: 86px;
    padding: 13px;
  }

  .metric-icon {
    align-items: center;
    border-radius: var(--radius);
    display: grid;
    flex: 0 0 auto;
    height: 46px;
    place-items: center;
    width: 46px;
  }

  .compact-metrics .metric-icon {
    height: 38px;
    width: 38px;
  }

  .metric-icon.danger {
    background: rgba(220, 38, 38, 0.10);
    color: var(--danger);
  }

  .metric-icon.warning {
    background: rgba(217, 119, 6, 0.13);
    color: var(--warning);
  }

  .metric-icon.info {
    background: rgba(37, 99, 235, 0.10);
    color: var(--primary);
  }

  .metric-icon.success {
    background: rgba(5, 150, 105, 0.12);
    color: var(--success);
  }

  .metric-icon.muted-icon {
    background: rgba(100, 116, 139, 0.14);
    color: #475569;
  }

  .metric-card small {
    color: var(--muted);
    display: block;
    font-weight: 700;
  }

  .metric-card strong {
    display: block;
    font-size: 28px;
    line-height: 1.05;
    margin-top: 4px;
  }

  .split-metric-body {
    display: grid;
    gap: 6px;
    width: 100%;
  }

  .metric-split {
    display: grid;
    gap: 4px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-split span {
    color: var(--muted);
    display: grid;
    font-size: 12px;
    font-weight: 800;
    gap: 1px;
  }

  .metric-split strong {
    color: var(--text);
    font-size: 22px;
    margin: 0;
  }

  .btn {
    align-items: center;
    border: 1px solid transparent;
    border-radius: var(--radius);
    display: inline-flex;
    font-weight: 800;
    gap: 8px;
    justify-content: center;
    min-height: 42px;
    padding: 0 14px;
    text-decoration: none;
    transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, color 160ms ease, transform 160ms ease;
    white-space: nowrap;
  }

  .btn:hover {
    transform: translateY(-1px);
  }

  .btn.primary {
    background: var(--primary);
    color: #fff;
  }

  .btn.primary:hover {
    background: var(--primary-strong);
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.20);
  }

  .btn.secondary {
    background: var(--surface-2);
    color: #24324a;
  }

  .btn.ghost {
    background: #fff;
    border-color: var(--line);
    color: #24324a;
  }

  .btn.danger {
    background: rgba(220, 38, 38, 0.10);
    color: var(--danger);
  }

  .btn.icon-only {
    min-height: 38px;
    padding: 0;
    width: 38px;
  }

  .icon-action.danger {
    background: rgba(220, 38, 38, 0.10);
    color: var(--danger);
  }

  .icon-action.danger:hover {
    background: rgba(220, 38, 38, 0.16);
  }

  .icon-action.success {
    background: rgba(5, 150, 105, 0.12);
    color: var(--success);
  }

  .icon-action.success:hover {
    background: rgba(5, 150, 105, 0.18);
  }

  .icon-action.secondary-action {
    background: rgba(100, 116, 139, 0.12);
    color: #475569;
  }

  .action-stack {
    align-items: center;
    display: flex;
    flex-wrap: nowrap;
    gap: 7px;
    max-width: 100%;
    overflow-x: auto;
  }

  .btn.whatsapp,
  .icon-action.whatsapp {
    background: rgba(5, 150, 105, 0.12);
    color: #047857;
  }

  .btn.whatsapp:hover,
  .icon-action.whatsapp:hover {
    background: rgba(5, 150, 105, 0.18);
  }

  .icon-action {
    align-items: center;
    border: 0;
    border-radius: var(--radius);
    display: inline-flex;
    flex: 0 0 auto;
    font-weight: 800;
    gap: 7px;
    min-height: 36px;
    padding: 0 10px;
    transition: background 160ms ease, transform 160ms ease;
    white-space: nowrap;
  }

  .icon-action:hover {
    transform: translateY(-1px);
  }

  .table-wrap {
    overflow-x: auto;
    width: 100%;
  }

  .data-table {
    border-collapse: collapse;
    min-width: 860px;
    width: 100%;
  }

  .data-table.with-response-column {
    min-width: 980px;
  }

  .data-table th,
  .data-table td {
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
    text-align: left;
    vertical-align: top;
  }

  .data-table th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
  }

  .data-table td {
    color: #24324a;
    font-size: 14px;
  }

  .data-table tbody tr {
    transition: background 160ms ease;
  }

  .data-table tbody tr:hover {
    background: #eaf2ff;
  }

  .clickable-row {
    cursor: pointer;
  }

  .data-table tbody tr.clickable-row:hover {
    background: #dbeafe;
  }

  .compact-table {
    min-width: 720px;
  }

  .cell-strong {
    color: var(--text);
    font-weight: 850;
  }

  .muted {
    color: var(--muted);
  }

  .status-badge {
    align-items: center;
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 900;
    min-height: 28px;
    padding: 0 10px;
    white-space: nowrap;
  }

  .status-pendente {
    background: rgba(37, 99, 235, 0.10);
    color: var(--primary-strong);
  }

  .status-vencido {
    background: rgba(220, 38, 38, 0.10);
    color: var(--danger);
  }

  .status-hoje {
    background: rgba(217, 119, 6, 0.14);
    color: var(--warning);
  }

  .status-respondido {
    background: rgba(5, 150, 105, 0.12);
    color: var(--success);
  }

  .status-concluido {
    background: rgba(5, 150, 105, 0.12);
    color: var(--success);
  }

  .status-cancelado {
    background: rgba(100, 116, 139, 0.14);
    color: #475569;
  }

  .doc-list {
    display: grid;
    gap: 12px;
  }

  .compact-list {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }

  .doc-card {
    display: grid;
    gap: 12px;
    padding: 16px;
  }

  .detail-card {
    box-shadow: none;
  }

  .detail-stack {
    display: grid;
    gap: 14px;
  }

  .doc-card-head {
    align-items: start;
    display: flex;
    gap: 12px;
    justify-content: space-between;
  }

  .doc-card h4 {
    font-size: 17px;
    margin: 0 0 4px;
  }

  .origin-name {
    overflow-wrap: anywhere;
  }

  .doc-meta {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
  }

  .doc-fields {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-section {
    border-top: 1px solid var(--line);
    display: grid;
    gap: 12px;
    padding-top: 12px;
  }

  .detail-section h5 {
    color: var(--text);
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0;
    margin: 0;
    text-transform: uppercase;
  }

  .prazo-edit-form {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
  }

  .inline-edit-row {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .doc-field {
    display: grid;
    gap: 3px;
  }

  .doc-field small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
  }

  .doc-field span {
    color: #24324a;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  .doc-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .empty-state {
    display: grid;
    gap: 10px;
    justify-items: center;
    padding: 36px 22px;
    text-align: center;
  }

  .history-list {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: grid;
    gap: 10px;
    padding: 14px;
  }

  .history-list h4 {
    margin: 0;
  }

  .history-item {
    border-left: 3px solid rgba(37, 99, 235, 0.28);
    display: grid;
    gap: 6px;
    padding: 3px 0 3px 12px;
  }

  .history-item strong,
  .history-item span {
    display: block;
  }

  .history-item span,
  .history-item p {
    color: var(--muted);
    font-size: 13px;
    margin: 0;
  }

  .floating-summary-button {
    align-items: center;
    background: var(--primary);
    border: 0;
    border-radius: var(--radius) 0 0 var(--radius);
    box-shadow: var(--shadow-soft);
    color: #fff;
    display: flex;
    font-weight: 900;
    gap: 8px;
    min-height: 46px;
    padding: 0 12px;
    position: fixed;
    right: 0;
    top: 168px;
    z-index: 42;
    writing-mode: horizontal-tb;
  }

  .floating-summary-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-right: 0;
    border-radius: var(--radius) 0 0 var(--radius);
    box-shadow: var(--shadow);
    display: none;
    max-height: min(78dvh, 720px);
    max-width: min(420px, calc(100vw - 24px));
    overflow: auto;
    position: fixed;
    right: 0;
    top: 220px;
    width: 420px;
    z-index: 43;
  }

  .floating-summary-panel.open {
    display: block;
  }

  .floating-summary-header {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 10px;
    justify-content: space-between;
    padding: 12px;
  }

  .floating-summary-body {
    padding: 12px;
  }

  .summary-list {
    display: grid;
    gap: 8px;
  }

  .summary-row {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: grid;
    gap: 8px;
    padding: 10px;
  }

  .summary-row strong {
    overflow-wrap: anywhere;
  }

  .summary-counts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .summary-zero {
    align-items: center;
    background: #f1f5f9;
    border-radius: 999px;
    color: var(--muted);
    display: inline-flex;
    font-size: 12px;
    font-weight: 900;
    min-height: 28px;
    padding: 0 10px;
  }

  .empty-state .material-symbols-rounded {
    color: var(--success);
    font-size: 42px;
  }

  .pagination-bar {
    align-items: center;
    border-top: 1px solid var(--line);
    color: var(--muted);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-top: 14px;
    padding-top: 14px;
  }

  .pagination-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
  }

  .pagination-actions strong {
    color: #334155;
    font-size: 13px;
  }

  .btn:disabled {
    cursor: not-allowed;
    opacity: 0.52;
    transform: none;
  }

  .modal-root {
    align-items: center;
    background: rgba(15, 23, 42, 0.48);
    display: none;
    inset: 0;
    justify-content: center;
    padding: 22px;
    position: fixed;
    z-index: 50;
  }

  .modal-root.open {
    display: flex;
  }

  .modal-card {
    animation: modalIn 180ms ease both;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-height: min(92dvh, 820px);
    max-width: 620px;
    overflow: auto;
    width: min(100%, 620px);
  }

  @keyframes modalIn {
    from {
      opacity: 0;
      transform: translateY(12px) scale(0.98);
    }

    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }

  .modal-header,
  .modal-footer {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 16px;
  }

  .modal-header {
    border-bottom: 1px solid var(--line);
  }

  .modal-header h3 {
    font-size: 18px;
    margin: 0;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-footer {
    border-top: 1px solid var(--line);
    justify-content: flex-end;
  }

  .loading-overlay {
    align-items: center;
    background: rgba(245, 247, 251, 0.74);
    display: none;
    inset: 0;
    justify-content: center;
    position: fixed;
    z-index: 80;
  }

  .loading-overlay.open {
    display: flex;
  }

  .loader-card {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: grid;
    gap: 8px;
    justify-items: center;
    padding: 22px 26px;
  }

  .loader-card small {
    color: var(--muted);
  }

  .loader {
    animation: spin 780ms linear infinite;
    border: 3px solid #dbe6f4;
    border-radius: 50%;
    border-top-color: var(--primary);
    height: 32px;
    width: 32px;
  }

  @keyframes spin {
    to {
      transform: rotate(360deg);
    }
  }

  .toast-area {
    display: grid;
    gap: 10px;
    pointer-events: none;
    position: fixed;
    right: 18px;
    top: 18px;
    z-index: 90;
  }

  .toast {
    animation: toastIn 180ms ease both;
    background: #10243f;
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    color: #fff;
    font-weight: 800;
    max-width: min(420px, calc(100vw - 36px));
    padding: 12px 14px;
  }

  .toast.error {
    background: var(--danger);
  }

  .toast.success {
    background: var(--success);
  }

  .toast.info {
    background: var(--primary-strong);
  }

  @keyframes toastIn {
    from {
      opacity: 0;
      transform: translateY(-8px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .mobile-nav {
    display: none;
  }

  .mobile-nav-button {
    background: transparent;
    border-radius: var(--radius);
    color: var(--muted);
    flex: 1 1 0;
    flex-direction: column;
    font-size: 11px;
    font-weight: 850;
    gap: 3px;
    justify-content: center;
    min-height: 56px;
    padding: 4px 2px;
  }

  .mobile-nav-button.active {
    background: rgba(37, 99, 235, 0.10);
    color: var(--primary-strong);
  }

  @media (max-width: 1080px) {
    .metric-grid-5 {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .toolbar .form-row,
    .toolbar .wide {
      grid-column: span 6;
    }

    .toolbar .actions {
      grid-column: span 12;
    }

    .grid-2 {
      grid-template-columns: 1fr;
    }
  }

  @media (max-width: 820px) {
    body {
      background: var(--bg);
    }

    .login-card {
      grid-template-columns: 1fr;
    }

    .login-brand {
      min-height: auto;
      padding: 28px;
    }

    .login-copy,
    .brand-foot {
      display: none;
    }

    .login-form-wrap {
      padding: 4px 28px 30px;
    }

    .app-shell {
      display: block;
      min-height: 100dvh;
    }

    .sidebar {
      display: none;
    }

    .main-panel {
      padding: 14px 14px calc(86px + env(safe-area-inset-bottom));
    }

    .topbar {
      align-items: start;
      background: rgba(245, 247, 251, 0.92);
      backdrop-filter: blur(12px);
      margin-bottom: 12px;
      padding: 4px 0 8px;
      position: sticky;
      top: 0;
      z-index: 15;
    }

    .topbar-actions {
      gap: 6px;
    }

    .user-pill {
      max-width: 158px;
      min-height: 38px;
      padding: 0 10px;
    }

    .user-pill span:last-child {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .metric-grid {
      grid-template-columns: 1fr;
    }

    .toolbar {
      grid-template-columns: 1fr;
      padding: 14px;
    }

    .toolbar .form-row,
    .toolbar .wide,
    .toolbar .actions {
      grid-column: auto;
    }

    .toolbar .actions {
      flex-wrap: wrap;
    }

    .pagination-bar {
      align-items: stretch;
      flex-direction: column;
    }

    .pagination-actions {
      justify-content: space-between;
    }

    .doc-fields {
      grid-template-columns: 1fr;
    }

    .inline-edit-row {
      grid-template-columns: 1fr;
    }

    .mobile-nav {
      background: rgba(255, 255, 255, 0.96);
      border-top: 1px solid var(--line);
      bottom: 0;
      box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.08);
      display: flex;
      gap: 5px;
      left: 0;
      padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
      position: fixed;
      right: 0;
      z-index: 30;
    }

    .data-table,
    .data-table thead,
    .data-table tbody,
    .data-table th,
    .data-table td,
    .data-table tr {
      display: block;
      min-width: 0;
      width: 100%;
    }

    .data-table thead {
      display: none;
    }

    .data-table tbody {
      display: grid;
      gap: 10px;
    }

    .data-table tr {
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow-soft);
      overflow: hidden;
    }

    .data-table td {
      align-items: start;
      border-bottom: 1px solid var(--line);
      display: grid;
      gap: 6px;
      grid-template-columns: minmax(120px, 0.42fr) minmax(0, 1fr);
      padding: 11px 12px;
    }

    .data-table td::before {
      color: var(--muted);
      content: attr(data-label);
      font-size: 12px;
      font-weight: 900;
      text-transform: uppercase;
    }

    .data-table td:last-child {
      border-bottom: 0;
    }

    .data-table td[data-label="Ações"] {
      grid-template-columns: 1fr;
    }
  }

  @media (max-width: 520px) {
    .login-screen {
      padding: 12px;
    }

    .login-brand {
      padding: 22px;
    }

    .login-form-wrap {
      padding: 0 22px 24px;
    }

    .topbar {
      gap: 8px;
    }

    .topbar .panel-title p {
      display: none;
    }

    .btn {
      min-height: 40px;
      padding: 0 11px;
    }

    .btn .btn-text-optional {
      display: none;
    }

    .metric-card strong {
      font-size: 30px;
    }

    .modal-root {
      align-items: end;
      padding: 0;
    }

    .modal-card {
      border-radius: var(--radius) var(--radius) 0 0;
      max-height: 92dvh;
      width: 100%;
    }
  }
