:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #1b1f27;
  --text-2: #5b626f;
  --text-3: #8b919c;
  --primary: #2f5fa3;
  --primary-dark: #234a82;
  --primary-bg: #eaf1fb;
  --success: #2f7a4f;
  --success-bg: #e7f4ec;
  --warning: #a36a1e;
  --warning-bg: #fbf0de;
  --danger: #b3413a;
  --danger-bg: #fbeceb;
  --sidebar-bg: #1b2433;
  --sidebar-text: #aeb6c4;
  --sidebar-hover: #263145;
  --sidebar-active: #2f5fa3;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(20, 24, 32, 0.06), 0 1px 2px rgba(20, 24, 32, 0.04);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

.guest-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: var(--bg);
}

.login-shell {
  width: 100%;
  max-width: 390px;
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.brand-mark,
.login-mark {
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.login-mark {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  font-size: 22px;
  margin: 0 auto 14px;
}

.login-brand h1 {
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 4px;
}

.login-brand p,
.guest-note {
  color: var(--text-3);
  font-size: 13px;
  margin: 0;
}

.guest-note {
  text-align: center;
  margin-top: 18px;
}

.app {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 18px 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 18px;
  margin-bottom: 6px;
  border-bottom: 1px solid #2a3344;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 15px;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-text strong {
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
}

.brand-text span {
  color: #7d8595;
  font-size: 11px;
}

.sidebar-section-label {
  color: #5d6678;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 14px 20px 6px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 1px 8px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  transition: background 0.12s, color 0.12s;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 500;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
}

.nav-badge {
  margin-left: auto;
  background: #3a4150;
  color: #cfd4dc;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 20px 0;
  border-top: 1px solid #2a3344;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.user-avatar,
.mini-avatar,
.profile-avatar {
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: #3a4f73;
  color: #fff;
  font-size: 12.5px;
}

.user-meta strong {
  display: block;
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
}

.user-meta span {
  color: #7d8595;
  font-size: 11px;
}

.logout-form {
  margin: 8px 0 0;
}

.logout-link {
  width: 100%;
  border: 0;
  background: transparent;
  color: #8a93a3;
  padding: 6px 0;
  text-align: left;
  font-size: 12px;
}

.logout-link:hover {
  color: #fff;
}

.main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-title h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.topbar-title span {
  color: var(--text-3);
  font-size: 12.5px;
}

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

.content {
  flex: 1;
  padding: 24px 28px 60px;
}

.breadcrumb {
  color: var(--text-3);
  font-size: 12px;
  margin-bottom: 14px;
}

.breadcrumb b {
  color: var(--text-2);
  font-weight: 500;
}

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

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

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

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

.span-2 {
  grid-column: span 2;
}

.span-3 {
  grid-column: span 3;
}

.card,
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card {
  padding: 18px 20px;
}

.stat-card {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-top,
.panel-title,
.row-item,
.boleto-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stat-label {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
}

.stat-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.stat-value {
  font-size: 25px;
  font-weight: 600;
}

.stat-sub {
  color: var(--text-3);
  font-size: 11.5px;
}

.stat-sub.up {
  color: var(--success);
}

.ic-blue {
  background: var(--primary-bg);
  color: var(--primary);
}

.ic-green {
  background: var(--success-bg);
  color: var(--success);
}

.ic-amber {
  background: var(--warning-bg);
  color: var(--warning);
}

.ic-red {
  background: var(--danger-bg);
  color: var(--danger);
}

.panel-title {
  margin-bottom: 14px;
}

.panel-title h3 {
  font-size: 14.5px;
  font-weight: 600;
  margin: 0;
}

.panel-title .link {
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 500;
}

.row-list {
  display: flex;
  flex-direction: column;
}

.row-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.row-item:last-child {
  border-bottom: 0;
}

.row-left {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.row-name {
  font-weight: 500;
}

.row-sub {
  color: var(--text-3);
  font-size: 11.5px;
}

.mini-avatar {
  width: 30px;
  height: 30px;
  font-size: 11px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.tag-success {
  background: var(--success-bg);
  color: var(--success);
}

.tag-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.tag-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.tag-neutral {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.bars {
  height: 140px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding-top: 10px;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.bar {
  width: 100%;
  min-height: 4px;
  border-radius: 5px 5px 0 0;
  background: var(--primary);
}

.bar-label {
  color: var(--text-3);
  font-size: 10.5px;
}

.map-placeholder {
  height: 200px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background:
    linear-gradient(var(--surface-2) 1px, transparent 1px) 0 0 / 20px 20px,
    linear-gradient(90deg, var(--surface-2) 1px, transparent 1px) 0 0 / 20px 20px,
    var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  color: var(--text-3);
  font-size: 12.5px;
  position: relative;
  overflow: hidden;
}

.map-pin {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary-bg);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  color: var(--text-3);
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
  padding: 0 14px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover {
  background: var(--surface-2);
}

tr:last-child td {
  border-bottom: 0;
}

.cell-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  min-width: 180px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-box,
.filter-chip {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 260px;
  padding: 8px 12px;
}

.search-box input {
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  outline: 0;
}

.filter-chip {
  padding: 8px 12px;
}

.actions-cell {
  display: flex;
  gap: 6px;
}

.ghost-btn,
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  font-size: 13px;
}

.ghost-btn:hover,
.icon-btn:hover {
  background: var(--surface-2);
}

.btn {
  min-height: 36px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:hover {
  background: var(--surface-2);
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

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

.btn-sm {
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.span-2 {
  grid-column: span 2;
}

.field label {
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--primary-bg);
  border-color: var(--primary);
}

.field-hint {
  color: var(--text-3);
  font-size: 11px;
}

.form-section-title {
  border-top: 1px solid var(--border);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  margin: 18px 0 2px;
  padding-top: 14px;
}

.form-section-title:first-child {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.form-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.alert {
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #c4e3d0;
}

.alert-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #f1c9c5;
}

.alert ul {
  margin: 0;
  padding-left: 18px;
}

.empty-state {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-2);
}

.empty-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.empty-state h3 {
  color: var(--text);
  font-size: 15px;
  margin: 0;
}

.empty-state p {
  max-width: 420px;
  color: var(--text-3);
  font-size: 13px;
  margin: 0;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  font-size: 24px;
}

.profile-name {
  font-size: 19px;
  font-weight: 600;
  margin: 0;
}

.profile-role {
  color: var(--text-2);
  font-size: 13px;
  margin-top: 2px;
}

.tab-row {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab-item {
  padding: 10px 16px;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab-item.active {
  color: var(--primary);
  border-color: var(--primary);
}

.boleto-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
}

.boleto-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.boleto-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
}

.boleto-title {
  font-size: 13.5px;
  font-weight: 500;
}

.boleto-sub {
  color: var(--text-3);
  font-size: 11.5px;
}

.switch-input {
  width: 34px;
  height: 19px;
  appearance: none;
  border: 0;
  border-radius: 20px;
  background: var(--border-strong);
  position: relative;
  cursor: pointer;
}

.switch-input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.15s;
}

.switch-input:checked {
  background: var(--primary);
}

.switch-input:checked::after {
  left: 17px;
}

.error-box {
  max-width: 720px;
  margin: 0 auto;
}

.debug-trace {
  max-height: 320px;
  overflow: auto;
  padding: 14px;
  background: #11151d;
  color: #d8dee9;
  border-radius: 8px;
  font-size: 12px;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

@media (max-width: 1100px) {
  .grid-4,
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .span-3 {
    grid-column: span 2;
  }
}

@media (max-width: 780px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    padding: 12px 0;
  }

  .sidebar-brand,
  .sidebar-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .sidebar-section-label {
    padding-left: 16px;
    padding-right: 16px;
  }

  .nav-item {
    margin-left: 8px;
    margin-right: 8px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 18px;
  }

  .content {
    padding: 18px 18px 42px;
  }

  .grid-4,
  .grid-3,
  .grid-2,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2,
  .span-3,
  .field.span-2 {
    grid-column: span 1;
  }

  .toolbar {
    align-items: stretch;
  }

  .search-box,
  .filter-chip,
  .toolbar .inline-actions {
    width: 100%;
  }

  .boleto-card {
    align-items: flex-start;
    flex-direction: column;
  }
}
