:root {
  --navy: #061f35;
  --navy-2: #0b3155;
  --blue: #0969f5;
  --blue-soft: #e9f2ff;
  --green: #07955b;
  --green-soft: #e6f7ee;
  --orange: #ed8b00;
  --orange-soft: #fff3df;
  --gold: #d99b00;
  --purple: #644be8;
  --red: #c81e3a;
  --ink: #09203a;
  --muted: #607086;
  --line: #d9e2ed;
  --surface: #ffffff;
  --canvas: #f4f7fb;
  --radius: 7px;
  --shadow: 0 5px 18px rgba(15, 42, 70, .07);
  --blue-950: var(--navy);
  --blue-900: var(--navy-2);
  --blue-800: #073873;
  --blue-100: var(--blue-soft);
  --gray-950: var(--ink);
  --gray-800: #18365b;
  --gray-700: #4e6075;
  --gray-500: var(--muted);
  --gray-300: #cbd8e8;
  --gray-200: var(--line);
  --gray-100: #f2f5f9;
  --white: var(--surface);
  --amber: var(--orange);
  --soft-border: 1px solid var(--line);
}

html,
body {
  max-width: 100%;
  letter-spacing: 0;
}

body {
  color: var(--ink);
  background: var(--canvas);
  font-family: "Poppins", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font-family: inherit;
  letter-spacing: 0;
}

h1,
h2,
h3,
h4,
strong {
  font-weight: 600;
}

.login-page {
  grid-template-columns: minmax(360px, 450px) minmax(0, 1fr);
  background: var(--surface);
}

.login-panel {
  padding: clamp(32px, 4vw, 54px) 42px;
  border-right: 1px solid var(--line);
}

.login-panel img {
  width: 285px;
  height: 85px;
  margin-bottom: 30px;
  object-fit: contain;
  object-position: left center;
}

.login-panel h1 {
  font-size: 29px;
  font-weight: 600;
}

.login-panel .muted {
  margin: 9px 0 18px;
}

.login-visual {
  position: relative;
  align-items: flex-end;
  padding: clamp(44px, 6vw, 84px);
  background-color: var(--navy);
  background-image:
    linear-gradient(rgba(6, 31, 53, .78), rgba(6, 31, 53, .88)),
    linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: auto, 120px 120px, 120px 120px;
}

.login-visual h2 {
  max-width: 760px;
  font-size: 40px;
  font-weight: 600;
}

.login-visual p {
  font-size: 16px;
  font-weight: 400;
}

.app-shell {
  display: block;
  min-width: 0;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 258px;
  height: 100vh;
  padding: 24px 15px 18px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  background: linear-gradient(180deg, var(--navy) 0%, #073873 100%);
  border-right: 0;
  box-shadow: 8px 0 24px rgba(6, 31, 53, .08);
}

.brand {
  min-height: 72px;
  justify-content: center;
  padding: 0 8px 18px;
  margin-bottom: 16px;
  border-bottom-color: rgba(255, 255, 255, .15);
}

.brand img {
  width: 190px;
  height: 62px;
  object-fit: contain;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.nav-link,
.nav button {
  position: relative;
  min-height: 45px;
  padding: 10px 12px;
  gap: 14px;
  border-radius: 6px;
  color: rgba(255, 255, 255, .86);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.nav-link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: transparent;
}

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

.nav-link.active::before {
  background: #ffd500;
}

.sidebar-account {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: auto;
  padding: 16px 10px 10px;
  border-top: 1px solid rgba(255, 255, 255, .15);
}

.sidebar-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-weight: 600;
}

.sidebar-account-copy {
  min-width: 0;
  display: grid;
  line-height: 1.25;
}

.sidebar-account-copy strong,
.sidebar-account-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-account-copy strong {
  color: #fff;
  font-size: 13px;
}

.sidebar-account-copy small {
  color: rgba(255, 255, 255, .68);
  font-size: 11.5px;
  font-weight: 400;
}

.logout-form {
  margin-top: 2px;
}

.logout-form .nav-link {
  width: 100%;
  justify-content: flex-start;
  border: 0;
  background: transparent;
}

.main {
  width: calc(100% - 258px);
  min-width: 0;
  margin-left: 258px;
}

.topbar {
  min-height: 72px;
  height: 72px;
  padding: 14px 27px;
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar-user-summary {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-user-summary strong {
  color: var(--ink);
}

.content {
  width: 100%;
  max-width: 1700px;
  min-width: 0;
  padding: 24px 27px 50px;
}

.page-title {
  gap: 18px;
  margin-bottom: 22px;
}

.page-title h1 {
  color: var(--ink);
  font-size: 27px;
  line-height: 1.2;
  font-weight: 600;
}

.page-title p {
  margin: 8px 0 0;
}

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

.panel,
.stat,
.modal-panel,
.metric-card,
.dashboard-hero {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

.panel-header h2,
.chart-panel h2,
.settings-section > h2,
.backup-tool h3 {
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
}

.dashboard-hero {
  padding: 20px 22px;
  border-left: 4px solid #073873;
  background: linear-gradient(135deg, #fff 0%, #f3f8fd 100%);
}

.dashboard-hero h2 {
  color: var(--ink);
  font-size: 23px;
}

.section-kicker,
.metric-label {
  color: #18365b;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
}

.executive-metrics {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.metric-card {
  min-height: 112px;
  padding: 14px;
}

.metric-card strong {
  color: var(--ink);
  font-size: 28px;
  font-weight: 600;
}

.metric-card small {
  color: var(--muted);
  font-size: 11.5px;
}

.metric-icon,
.stat-icon {
  border-radius: 6px;
  background: var(--blue-soft);
  color: #073873;
}

.metric-card.alert .metric-icon {
  color: var(--red);
  background: #fff0f3;
}

.metric-card.ok .metric-icon {
  color: var(--green);
  background: var(--green-soft);
}

.analytics-grid {
  gap: 16px;
}

.chart-panel {
  min-height: 250px;
  overflow: hidden;
}

.trend-chart-wrap {
  border-color: var(--line);
  border-radius: 6px;
  background: #fbfdff;
}

.chart-grid-line {
  stroke: #d9e2ed;
  stroke-width: .65;
}

.btn {
  min-height: 38px;
  padding: 8px 14px;
  gap: 8px;
  border: 1px solid #cbd8e8;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: none;
}

.btn:hover {
  border-color: var(--blue);
  transform: none;
  background: #fbfdff;
}

.btn.primary {
  border-color: var(--navy-2);
  background: var(--navy-2);
}

.btn.success {
  border-color: var(--green);
  background: var(--green);
}

.btn.danger {
  border-color: var(--red);
  background: var(--red);
}

.btn.icon-only,
.table-actions .btn {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  gap: 0;
  font-size: 0;
  line-height: 0;
  display: inline-grid;
  place-items: center;
}

.btn.icon-only .icon,
.table-actions .btn .icon {
  display: block;
  width: 17px;
  height: 17px;
  margin: 0;
}

.table-actions,
.user-actions,
.compact-actions {
  min-width: 0;
  width: max-content;
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 6px;
}

.users-table th:last-child,
.users-table td:last-child {
  width: auto;
  min-width: 116px;
}

.field {
  gap: 6px;
  margin-bottom: 14px;
}

.field label,
.inline-label,
.settings-add-row label,
.settings-edit-row label,
.settings-selector-row label,
.settings-single-field label,
.profile-selector label,
.backup-form label,
.form-grid label,
.modal-form > label {
  color: #18365b;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea,
.table-input,
.toolbar input,
.toolbar select,
.settings-add-row input,
.settings-edit-row input,
.settings-selector-row select,
.settings-single-field select,
.profile-selector select,
.backup-form input,
.backup-form select,
.settings-item-row input,
.form-grid input,
.form-grid select,
.form-grid textarea {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #cbd8e8;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-size: 14.5px;
  font-weight: 400;
}

.field textarea,
.form-grid textarea {
  min-height: 105px;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.table-input:focus,
.toolbar input:focus,
.toolbar select:focus,
.settings-add-row input:focus,
.settings-edit-row input:focus,
.settings-selector-row select:focus,
.settings-single-field select:focus,
.profile-selector select:focus,
.backup-form input:focus,
.backup-form select:focus,
.settings-item-row input:focus,
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(9, 105, 245, .09);
}

.readonly-field,
input[readonly],
textarea[readonly] {
  color: #4e6075;
  background: #f2f5f9;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  contain: layout paint inline-size;
}

table {
  min-width: 760px;
}

th {
  padding: 10px 11px;
  color: #18365b;
  background: #edf3f9;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
}

td {
  padding: 10px 11px;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  color: var(--ink);
  font-size: 13px;
  overflow-wrap: break-word;
}

tbody tr:hover {
  background: #fbfdff;
}

.status,
.badge {
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 500;
}

.status.rascunho {
  color: #4e6075;
  background: #f2f5f9;
}

.status.em_revisao {
  color: #9a5a00;
  background: var(--orange-soft);
}

.status.confirmada {
  color: #0758c9;
  background: var(--blue-soft);
}

.status.finalizada {
  color: var(--green);
  background: var(--green-soft);
}

.status.cancelada {
  color: var(--red);
  background: #ffedf1;
}

.form-section-title {
  padding: 9px 12px;
  border-color: var(--line);
  border-radius: 6px;
  color: #18365b;
  background: #edf3f9;
  font-size: 12px;
  font-weight: 600;
}

.empty,
.empty-settings {
  padding: 22px;
  border: 1px dashed #cbd8e8;
  border-radius: 6px;
  color: var(--muted);
  background: #fbfdff;
  text-align: center;
}

.toast {
  right: 18px;
  bottom: 18px;
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--green);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 28px rgba(15, 42, 70, .18);
}

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

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

.modal-panel,
.signature-modal-panel {
  border-radius: 7px;
}

.settings-tabs {
  border-color: var(--line);
  border-radius: 7px;
  background: #f7faff;
}

.settings-tab {
  color: #4e6075;
  font-size: 13px;
  font-weight: 600;
}

.settings-tab.is-active {
  color: #fff;
  background: var(--navy-2);
  box-shadow: none;
}

.settings-card,
.settings-editor-box,
.role-editor,
.settings-item-row,
.selection-summary {
  border-color: var(--line);
  border-radius: 7px;
  background: #fbfdff;
}

@media (max-width: 1450px) {
  .content {
    padding-inline: 24px;
  }
}

@media (max-width: 1350px) {
  .executive-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .analytics-grid,
  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .wide-chart {
    grid-column: auto;
  }

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

@media (max-width: 1050px) {
  .executive-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(160px, .45fr);
  }
}

@media (max-width: 760px) {
  .login-page {
    display: block;
    min-height: 100vh;
  }

  .login-panel {
    width: 100%;
    min-height: 100vh;
    padding: 32px 22px;
    border-right: 0;
  }

  .login-panel img {
    width: 245px;
    height: 74px;
  }

  .login-visual {
    display: none;
  }

  .mobile-menu-toggle {
    position: fixed;
    top: 12px;
    right: 14px;
    z-index: 60;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    background: #fff;
    box-shadow: var(--shadow);
  }

  .mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 39;
    display: block;
    visibility: hidden;
    opacity: 0;
    background: rgba(6, 31, 53, .5);
    transition: opacity .2s ease, visibility .2s ease;
  }

  .app-shell.menu-open .mobile-menu-backdrop {
    visibility: visible;
    opacity: 1;
  }

  .sidebar {
    z-index: 50;
    width: min(300px, 86vw);
    max-width: 300px;
    transform: translateX(-105%);
    transition: transform .22s ease;
  }

  .app-shell.menu-open .sidebar {
    transform: translateX(0);
  }

  .main {
    width: 100%;
    margin-left: 0;
  }

  .topbar {
    height: 64px;
    min-height: 64px;
    padding: 9px 66px 9px 18px;
  }

  .mobile-topbar-brand {
    display: block;
  }

  .mobile-topbar-brand img {
    width: 145px;
    height: 46px;
    max-height: 46px;
  }

  .topbar-user-summary {
    display: none;
  }

  .content {
    padding: 22px 16px 40px;
  }

  .page-title {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .page-title h1 {
    font-size: 23px;
  }

  .dashboard-hero,
  .donut-layout,
  .toolbar,
  .grid.cols-4,
  .grid.cols-3,
  .form-grid,
  .modal-form,
  .settings-selector-grid,
  .settings-selector-row,
  .settings-add-row,
  .settings-edit-row,
  .settings-single-field {
    grid-template-columns: minmax(0, 1fr);
  }

  .dashboard-actions {
    justify-content: flex-start;
  }

  .settings-row-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .content {
    padding-inline: 12px;
  }

  .login-panel {
    padding-inline: 20px;
  }

  .executive-metrics,
  .stat-grid,
  .analytics-grid,
  .backup-grid,
  .settings-grid,
  .permission-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-title .actions,
  .dashboard-actions,
  .modal-actions,
  .attachment-actions,
  .settings-row-actions {
    width: 100%;
  }

  .page-title .actions .btn:not(.icon-only),
  .dashboard-actions .btn,
  .modal-actions .btn,
  .attachment-actions > .btn,
  .settings-row-actions .btn {
    width: 100%;
  }

  .panel,
  .settings-section {
    padding: 15px;
  }

  .toast {
    right: 12px;
    left: 12px;
    max-width: none;
  }
}

@media (max-width: 460px) {
  .login-panel h1 {
    font-size: 25px;
  }

  .settings-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-tab {
    width: 100%;
  }
}
