/* ============================================================
   Onnel — Ionic-like UI System
   Primary: #2F76F2
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ══════════════════════════════════════════════════
   TEMA CLARO (padrão)
══════════════════════════════════════════════════ */
:root {
  /* Cor primária */
  --ion-color-primary:        #2F76F2;
  --ion-color-primary-shade:  #2968d6;
  --ion-color-primary-tint:   #4484f3;
  --ion-color-primary-rgb:    47, 118, 242;
  --ion-color-secondary:      #3dc2ff;
  --ion-color-success:        #2dd36f;
  --ion-color-warning:        #ffc409;
  --ion-color-danger:         #eb445a;
  --ion-color-medium:         #92949c;
  --ion-color-light:          #f4f5f8;

  /* Superfícies */
  --ion-background-color:     #f4f5f8;
  --ion-text-color:           #1a1a1a;
  --ion-text-color-secondary: #6b6b6b;
  --ion-border-color:         #e0e2e8;
  --ion-card-background:      #ffffff;
  --ion-toolbar-background:   #ffffff;
  --ion-tab-bar-background:   #ffffff;
  --ion-item-background:      #ffffff;
  --ion-overlay-background:   rgba(0,0,0,.4);
  --ion-input-background:     #f4f5f8;
  --ion-placeholder-color:    #b0b3bb;

  /* Fundo com gradiente */
  --app-gradient:        linear-gradient(150deg, #1a54c8 0%, #2F76F2 55%, #4ea0ff 100%);
  --app-panel-bg:        #f4f5f8;
  --app-sidebar-bg:      rgba(255,255,255,.13);
  --app-sidebar-border:  rgba(255,255,255,.15);
  --app-stat-pill-bg:    rgba(255,255,255,.18);
  --app-stat-pill-border:rgba(255,255,255,.25);
  --app-tab-bar-bg:      #ffffff;
  --app-tab-bar-shadow:  0 -2px 20px rgba(0,0,0,.12), 0 4px 16px rgba(0,0,0,.08);
  --app-form-card-bg:    #ffffff;
  --app-header-badge-bg: rgba(255,255,255,.2);

  /* Sombras */
  --ion-shadow-sm:   0 1px 4px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.04);
  --ion-shadow-md:   0 4px 16px rgba(0,0,0,.10), 0 1px 4px rgba(0,0,0,.06);
  --ion-shadow-lg:   0 8px 32px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.08);

  /* Tipografia e forma */
  --ion-font-family:     -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --ion-border-radius:   12px;
  --ion-border-radius-sm:8px;
  --ion-border-radius-lg:16px;
  --ion-header-height:   56px;
  --ion-footer-height:   56px;
  --ion-safe-top:        env(safe-area-inset-top, 0px);
  --ion-safe-bottom:     env(safe-area-inset-bottom, 0px);
}

/* ══════════════════════════════════════════════════
   TEMA ESCURO
══════════════════════════════════════════════════ */
[data-theme="dark"] {
  --ion-color-medium:         #6e7490;
  --ion-color-light:          #1e2438;

  --ion-background-color:     #141828;
  --ion-text-color:           #e4e6f4;
  --ion-text-color-secondary: #7a80a0;
  --ion-border-color:         #2a3050;
  --ion-card-background:      #1e2438;
  --ion-toolbar-background:   #1e2438;
  --ion-tab-bar-background:   #1a1f30;
  --ion-item-background:      #1e2438;
  --ion-input-background:     #141828;
  --ion-placeholder-color:    #3d4460;

  --app-gradient:        linear-gradient(150deg, #060d1a 0%, #0d1e3d 55%, #112650 100%);
  --app-panel-bg:        #141828;
  --app-sidebar-bg:      rgba(0,0,0,.35);
  --app-sidebar-border:  rgba(255,255,255,.07);
  --app-stat-pill-bg:    rgba(255,255,255,.06);
  --app-stat-pill-border:rgba(255,255,255,.10);
  --app-tab-bar-bg:      #1a1f30;
  --app-tab-bar-shadow:  0 -2px 20px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  --app-form-card-bg:    #1e2438;
  --app-header-badge-bg: rgba(255,255,255,.1);

  --ion-shadow-sm:   0 1px 4px rgba(0,0,0,.3), 0 2px 8px rgba(0,0,0,.2);
  --ion-shadow-md:   0 4px 16px rgba(0,0,0,.35), 0 1px 4px rgba(0,0,0,.2);
  --ion-shadow-lg:   0 8px 32px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.3);
}

html, body {
  width: 100%; height: 100%;
  font-family: var(--ion-font-family);
  color: var(--ion-text-color);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  background: var(--app-gradient);
  background-attachment: fixed;
  transition: background .4s ease, color .25s ease;
}

/* ---------- App Shell ---------- */
#app {
  position: fixed;
  inset: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Page ---------- */
.ion-page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--ion-background-color);
  opacity: 1;
  transform: translateX(0);
  transition: opacity .25s ease, transform .25s ease;
}

.ion-page.page-hidden {
  display: none;
}

.ion-page.page-enter {
  opacity: 0;
  transform: translateX(60px);
}

/* ---------- Header ---------- */
.ion-header {
  position: relative;
  z-index: 10;
  background: var(--ion-toolbar-background);
  box-shadow: var(--ion-shadow-sm);
}

.ion-toolbar {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: var(--ion-header-height);
  background: var(--ion-toolbar-background);
  gap: 12px;
}

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

.ion-title {
  flex: 1;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ion-title.center {
  text-align: center;
}

.ion-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ion-button-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  color: inherit;
  font-size: 20px;
  transition: background .15s;
}

.ion-button-icon:hover {
  background: rgba(0,0,0,.06);
}

/* ---------- Content ---------- */
.ion-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.ion-content-inner {
  padding: 16px;
  min-height: 100%;
}

.ion-padding { padding: 16px; }
.ion-padding-sm { padding: 8px; }
.ion-padding-lg { padding: 24px; }

/* ---------- Cards ---------- */
.ion-card {
  background: var(--ion-card-background);
  border-radius: var(--ion-border-radius);
  box-shadow: var(--ion-shadow-sm);
  margin-bottom: 16px;
  overflow: hidden;
}

.ion-card-header {
  padding: 16px 16px 8px;
}

.ion-card-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--ion-text-color);
  margin-bottom: 2px;
}

.ion-card-subtitle {
  font-size: 13px;
  color: var(--ion-text-color-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.ion-card-content {
  padding: 8px 16px 16px;
}

.ion-card-content p {
  color: var(--ion-text-color-secondary);
  font-size: 14px;
}

/* ---------- Items / List ---------- */
.ion-list {
  background: var(--ion-card-background);
  border-radius: var(--ion-border-radius);
  box-shadow: var(--ion-shadow-sm);
  overflow: hidden;
  margin-bottom: 16px;
}

.ion-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--ion-item-background);
  border-bottom: 1px solid var(--ion-border-color);
  gap: 12px;
  min-height: 52px;
  position: relative;
  transition: background .15s;
}

.ion-item:last-child { border-bottom: none; }

.ion-item:active, .ion-item.active-item {
  background: var(--ion-color-light);
}

.ion-item-start {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.ion-item-end {
  flex-shrink: 0;
  margin-left: auto;
  color: var(--ion-text-color-secondary);
  font-size: 13px;
}

/* ---------- Label & Input ---------- */
.ion-label {
  display: block;
  font-size: 13px;
  color: var(--ion-text-color-secondary);
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: .2px;
}

.ion-input-group {
  margin-bottom: 16px;
  position: relative;
}

.ion-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--ion-input-background);
  border: 1.5px solid transparent;
  border-radius: var(--ion-border-radius-sm);
  transition: border-color .2s, box-shadow .2s, background .25s;
  overflow: hidden;
}

.ion-input-wrapper:focus-within {
  border-color: var(--ion-color-primary);
  box-shadow: 0 0 0 3px rgba(var(--ion-color-primary-rgb), .12);
  background: var(--ion-card-background);
}

.ion-input-icon {
  padding: 0 12px;
  font-size: 18px;
  color: var(--ion-color-medium);
  flex-shrink: 0;
}

.ion-input-wrapper:focus-within .ion-input-icon {
  color: var(--ion-color-primary);
}

.ion-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 14px 16px 14px 0;
  font-size: 15px;
  color: var(--ion-text-color);
  font-family: var(--ion-font-family);
  width: 100%;
}

.ion-input::placeholder {
  color: var(--ion-placeholder-color);
}

.ion-toggle-pass {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0 14px;
  color: var(--ion-color-medium);
  font-size: 16px;
  display: flex;
  align-items: center;
}

/* ---------- Buttons ---------- */
.ion-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font-family: var(--ion-font-family);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .2px;
  text-decoration: none;
  border-radius: var(--ion-border-radius-sm);
  padding: 13px 24px;
  transition: opacity .15s, transform .1s, box-shadow .15s;
  position: relative;
  overflow: hidden;
  outline: none;
}

.ion-button:active { transform: scale(.97); }

.ion-button.btn-primary {
  background: var(--ion-color-primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(var(--ion-color-primary-rgb), .35);
}

.ion-button.btn-primary:hover {
  background: var(--ion-color-primary-shade);
  box-shadow: 0 6px 20px rgba(var(--ion-color-primary-rgb), .45);
}

.ion-button.btn-outline {
  background: transparent;
  color: var(--ion-color-primary);
  border: 1.5px solid var(--ion-color-primary);
}

.ion-button.btn-light {
  background: var(--ion-color-light);
  color: var(--ion-text-color);
}

.ion-button.btn-danger {
  background: var(--ion-color-danger);
  color: #fff;
}

.ion-button.btn-full {
  width: 100%;
  display: flex;
}

.ion-button.btn-round {
  border-radius: 100px;
}

.ion-button.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.ion-button.btn-lg {
  padding: 16px 32px;
  font-size: 17px;
}

.ion-button:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

/* Ripple */
.ion-button::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.15);
  opacity: 0;
  transition: opacity .15s;
}

.ion-button:active::after { opacity: 1; }

/* ---------- Badges ---------- */
.ion-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.6;
}

.ion-badge.badge-primary { background: var(--ion-color-primary); color: #fff; }
.ion-badge.badge-success { background: var(--ion-color-success); color: #fff; }
.ion-badge.badge-warning { background: var(--ion-color-warning); color: #1a1a1a; }
.ion-badge.badge-danger  { background: var(--ion-color-danger); color: #fff; }
.ion-badge.badge-medium  { background: var(--ion-color-medium); color: #fff; }
.ion-badge.badge-light   { background: var(--ion-color-light); color: var(--ion-text-color); }

/* ---------- Avatar ---------- */
.ion-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--ion-color-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.ion-avatar img { width: 100%; height: 100%; object-fit: cover; }

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

.ion-avatar.avatar-lg {
  width: 64px; height: 64px;
  font-size: 24px;
}

/* ---------- Chip ---------- */
.ion-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  background: var(--ion-color-light);
  color: var(--ion-text-color);
  border: 1.5px solid var(--ion-border-color);
}

.ion-chip.chip-primary {
  background: rgba(var(--ion-color-primary-rgb), .1);
  color: var(--ion-color-primary);
  border-color: transparent;
}

/* ---------- Footer / Tab Bar ---------- */
.ion-footer {
  background: var(--ion-tab-bar-background);
  box-shadow: 0 -1px 0 var(--ion-border-color), 0 -4px 12px rgba(0,0,0,.05);
  z-index: 10;
  padding-bottom: var(--ion-safe-bottom);
}

.ion-tab-bar {
  display: flex;
  align-items: stretch;
  height: var(--ion-footer-height);
}

.ion-tab-button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--ion-color-medium);
  font-size: 10px;
  font-weight: 600;
  font-family: var(--ion-font-family);
  letter-spacing: .3px;
  padding: 8px 4px;
  transition: color .2s;
  position: relative;
}

.ion-tab-button .tab-icon {
  font-size: 22px;
  display: block;
  line-height: 1;
  transition: transform .2s;
}

.ion-tab-button.tab-active {
  color: var(--ion-color-primary);
}

.ion-tab-button.tab-active .tab-icon {
  transform: translateY(-1px);
}

.ion-tab-button.tab-active::before {
  content: '';
  position: absolute;
  top: 0; left: 25%; right: 25%;
  height: 2px;
  background: var(--ion-color-primary);
  border-radius: 0 0 2px 2px;
}

/* ---------- Segments ---------- */
.ion-segment {
  display: flex;
  background: var(--ion-color-light);
  border-radius: var(--ion-border-radius-sm);
  padding: 3px;
  gap: 2px;
  margin-bottom: 16px;
}

.ion-segment-button {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--ion-text-color-secondary);
  cursor: pointer;
  transition: background .2s, color .2s, box-shadow .2s;
  font-family: var(--ion-font-family);
}

.ion-segment-button.seg-active {
  background: #fff;
  color: var(--ion-color-primary);
  box-shadow: var(--ion-shadow-sm);
}

/* ---------- Stats Cards ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--ion-card-background);
  border-radius: var(--ion-border-radius);
  box-shadow: var(--ion-shadow-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--ion-border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-icon.icon-blue   { background: rgba(47,118,242,.12); }
.stat-icon.icon-green  { background: rgba(45,211,111,.12); }
.stat-icon.icon-orange { background: rgba(255,196,9,.15); }
.stat-icon.icon-red    { background: rgba(235,68,90,.12); }

.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--ion-text-color-secondary);
  font-weight: 600;
}

/* ---------- Section Titles ---------- */
.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--ion-text-color-secondary);
  margin: 20px 0 10px;
}

/* ---------- Alert / Toast ---------- */
.ion-toast {
  position: fixed;
  bottom: calc(var(--ion-footer-height) + 16px + var(--ion-safe-bottom));
  left: 16px;
  right: 16px;
  background: #1a1a1a;
  color: #fff;
  padding: 14px 18px;
  border-radius: var(--ion-border-radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--ion-shadow-lg);
  z-index: 9999;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .3s, transform .3s;
  pointer-events: none;
}

.ion-toast.toast-show {
  opacity: 1;
  transform: translateY(0);
}

.ion-toast.toast-success { background: var(--ion-color-success); }
.ion-toast.toast-danger  { background: var(--ion-color-danger); }
.ion-toast.toast-warning { background: var(--ion-color-warning); color: #1a1a1a; }

/* ---------- Skeleton / Loading ---------- */
.skeleton {
  background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%);
  background-size: 200% 100%;
  animation: skeleton-load 1.4s infinite;
  border-radius: 6px;
}

@keyframes skeleton-load {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Divider ---------- */
.ion-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--ion-text-color-secondary);
  font-size: 13px;
}

.ion-divider::before, .ion-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--ion-border-color);
}

/* ---------- Progress Bar ---------- */
.ion-progress {
  height: 6px;
  background: var(--ion-border-color);
  border-radius: 100px;
  overflow: hidden;
}

.ion-progress-bar {
  height: 100%;
  background: var(--ion-color-primary);
  border-radius: 100px;
  transition: width .4s ease;
}

/* ---------- Spinner ---------- */
.ion-spinner {
  display: inline-block;
  width: 22px; height: 22px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

/* ---------- Welcome banner ---------- */
.welcome-banner {
  background: linear-gradient(135deg, var(--ion-color-primary) 0%, #1a54c8 100%);
  border-radius: var(--ion-border-radius);
  padding: 20px;
  color: #fff;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.welcome-banner::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 120px; height: 120px;
  background: rgba(255,255,255,.08);
  border-radius: 50%;
}

.welcome-banner::after {
  content: '';
  position: absolute;
  bottom: -50px; right: 20px;
  width: 160px; height: 160px;
  background: rgba(255,255,255,.05);
  border-radius: 50%;
}

.welcome-banner h2 {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 4px;
  position: relative;
}

.welcome-banner p {
  font-size: 13px;
  opacity: .85;
  position: relative;
}

/* ---------- Login Page Specific ---------- */
.login-page {
  background: #fff;
  display: flex;
  flex-direction: column;
}

.login-hero {
  background: linear-gradient(160deg, var(--ion-color-primary) 0%, #1a54c8 100%);
  padding: 60px 32px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.login-logo {
  max-width: 180px;
  max-height: 72px;
  object-fit: contain;
  margin-bottom: 16px;
  filter: brightness(0) invert(1);
}

.login-tagline {
  color: rgba(255,255,255,.8);
  font-size: 14px;
  text-align: center;
}

.login-form-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px 40px;
}

.login-form-wrap h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.5px;
  margin-bottom: 4px;
}

.login-form-wrap p {
  font-size: 14px;
  color: var(--ion-text-color-secondary);
  margin-bottom: 28px;
}

.error-msg {
  background: rgba(235,68,90,.08);
  border: 1px solid rgba(235,68,90,.25);
  color: var(--ion-color-danger);
  padding: 12px 14px;
  border-radius: var(--ion-border-radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
  display: none;
}

.error-msg.show { display: block; }

/* ---------- Responsive ---------- */

/* Tablet: 768px+ */
@media (min-width: 768px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Desktop: 1024px+ — sidebar layout */
@media (min-width: 1024px) {
  html, body { overflow: auto; }

  /* Sidebar */
  .app-sidebar {
    display: flex !important;
    flex-direction: column;
    width: 240px;
    flex-shrink: 0;
    background: rgba(255,255,255,.12);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid rgba(255,255,255,.15);
    height: 100vh;
    position: sticky;
    top: 0;
    padding: 28px 0 20px;
    overflow-y: auto;
  }

  .app-sidebar-logo {
    padding: 0 24px 32px;
  }

  .app-sidebar-logo img {
    height: 28px;
    object-fit: contain;
    filter: brightness(0) invert(1);
  }

  .app-sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 12px;
  }

  .app-sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    color: rgba(255,255,255,.75);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: transparent;
    font-family: var(--ion-font-family);
    width: 100%;
    text-align: left;
    transition: background .15s, color .15s;
    text-decoration: none;
  }

  .app-sidebar-item:hover {
    background: rgba(255,255,255,.12);
    color: #fff;
  }

  .app-sidebar-item.active {
    background: rgba(255,255,255,.2);
    color: #fff;
  }

  .app-sidebar-item .s-icon { font-size: 18px; width: 22px; text-align: center; }

  .app-sidebar-footer {
    padding: 16px 12px 0;
    border-top: 1px solid rgba(255,255,255,.15);
    margin: 0 12px;
  }

  .app-sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    color: rgba(255,255,255,.85);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
  }

  .app-sidebar-user:hover { background: rgba(255,255,255,.12); color: #fff; }

  .app-sidebar-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    border: 2px solid rgba(255,255,255,.35);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: #fff;
    flex-shrink: 0;
  }

  /* Oculta header mobile e footer tabs no desktop */
  .app-header  { display: none !important; }
  .app-footer  { display: none !important; }

  /* Layout principal vira linha */
  #app {
    flex-direction: row;
    height: 100vh;
    overflow: hidden;
  }

  /* Área principal à direita */
  .app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
  }

  /* Top bar do desktop */
  .app-topbar {
    display: flex !important;
    align-items: center;
    padding: 20px 32px 0;
    gap: 16px;
    flex-shrink: 0;
  }

  .app-topbar-title {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -.4px;
    flex: 1;
  }

  .app-topbar-badge {
    background: rgba(255,255,255,.2);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 100px;
    letter-spacing: .5px;
  }

  /* Conteúdo desktop */
  .app-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 32px 32px;
  }

  /* Stats em linha no desktop */
  .stats-scroll {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    overflow-x: visible;
    margin: 0 0 24px !important;
    padding: 0 !important;
  }

  .stat-pill { min-width: auto; }

  /* Painel branco vira area normal no desktop */
  .white-panel {
    background: #f4f5f8;
    border-radius: 20px;
    margin: 0 !important;
    padding: 24px 24px 40px !important;
    min-height: auto;
  }

  /* Quick grid 4 colunas no desktop */
  .quick-grid { grid-template-columns: repeat(4, 1fr); }

  /* Welcome section no desktop */
  .welcome-section { padding-top: 16px; }
}

/* Tablet médio: sidebar compacta (ícones) */
@media (min-width: 768px) and (max-width: 1023px) {
  .app-sidebar { display: none; }
  .app-header, .app-footer { display: flex; }
}

/* ══════════════════════════════════════════════════
   CROPPER — Modal de corte de imagem 1:1
══════════════════════════════════════════════════ */
.cropper-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fade-in .2s ease;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.cropper-modal {
  background: #1a1a1a;
  border-radius: 20px;
  width: 100%; max-width: 480px;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
  max-height: 90vh;
}

.cropper-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
}

.cropper-title { color: #fff; font-size: 16px; font-weight: 700; }

.cropper-close {
  background: rgba(255,255,255,.12); border: none; border-radius: 50%;
  width: 32px; height: 32px; color: #fff; font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.cropper-close:hover { background: rgba(255,255,255,.2); }

.cropper-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background-color: #444;
  background-image:
    linear-gradient(45deg, #666 25%, transparent 25%),
    linear-gradient(-45deg, #666 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #666 75%),
    linear-gradient(-45deg, transparent 75%, #666 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}
.cropper-stage:active { cursor: grabbing; }

.cropper-canvas { display: block; width: 100%; height: 100%; }

.cropper-frame {
  position: absolute;
  pointer-events: none;
}

.cf-corner {
  position: absolute;
  width: 20px; height: 20px;
  border-color: #fff;
  border-style: solid;
}
.cf-tl { top: -2px; left: -2px; border-width: 3px 0 0 3px; border-radius: 3px 0 0 0; }
.cf-tr { top: -2px; right: -2px; border-width: 3px 3px 0 0; border-radius: 0 3px 0 0; }
.cf-bl { bottom: -2px; left: -2px; border-width: 0 0 3px 3px; border-radius: 0 0 0 3px; }
.cf-br { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; border-radius: 0 0 3px 0; }

.cropper-footer {
  display: flex; gap: 10px; padding: 12px 16px 16px;
}
.cropper-footer .ion-button { flex: 1; justify-content: center; }
.cropper-cancel  { background: rgba(255,255,255,.1) !important; color: #fff !important; }
.cropper-confirm { }

/* ── Avatar com foto de perfil ── */
.avatar-photo {
  width: 100%; height: 100%;
  object-fit: cover; border-radius: 50%;
}

.avatar-upload-wrap { position: relative; display: inline-block; cursor: pointer; }

.avatar-upload-overlay {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s;
  color: #fff; font-size: 16px;
}
.avatar-upload-wrap:hover .avatar-upload-overlay { opacity: 1; }

/* ══════════════════════════════════════════════════
   BADGE de role na sidebar
══════════════════════════════════════════════════ */
.role-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
  padding: 2px 8px; border-radius: 100px; text-transform: uppercase;
}
.role-admin   { background: rgba(47,118,242,.2);  color: #6fa3ff; }
.role-gerente { background: rgba(255,196,9,.2);   color: #ffc409; }
.role-user    { background: rgba(255,255,255,.1); color: rgba(255,255,255,.6); }

/* ---------- Scrollbar ---------- */
.ion-content::-webkit-scrollbar { width: 3px; }
.ion-content::-webkit-scrollbar-track { background: transparent; }
.ion-content::-webkit-scrollbar-thumb { background: var(--ion-border-color); border-radius: 10px; }

/* ---------- Utility ---------- */
.text-primary { color: var(--ion-color-primary); }
.text-success  { color: var(--ion-color-success); }
.text-danger   { color: var(--ion-color-danger); }
.text-medium   { color: var(--ion-color-medium); }
.text-sm       { font-size: 13px; }
.text-xs       { font-size: 11px; }
.fw-700        { font-weight: 700; }
.fw-800        { font-weight: 800; }
.mt-8          { margin-top: 8px; }
.mt-16         { margin-top: 16px; }
.mb-0          { margin-bottom: 0; }
.d-flex        { display: flex; }
.align-center  { align-items: center; }
.gap-8         { gap: 8px; }
.gap-12        { gap: 12px; }
.flex-1        { flex: 1; }
.w-full        { width: 100%; }

/* ══════════════════════════════════════════════════
   TEMA ESCURO — overrides de componentes
══════════════════════════════════════════════════ */
[data-theme="dark"] .ion-card,
[data-theme="dark"] .ion-list,
[data-theme="dark"] .ion-item { background: var(--ion-card-background); }

[data-theme="dark"] .ion-item { border-bottom-color: var(--ion-border-color); }

[data-theme="dark"] .ion-segment { background: rgba(255,255,255,.05); }

[data-theme="dark"] .ion-segment-button.seg-active,
[data-theme="dark"] .seg-btn.active { background: var(--ion-card-background); }

[data-theme="dark"] .ion-button.btn-light {
  background: rgba(255,255,255,.08);
  color: var(--ion-text-color);
}

[data-theme="dark"] .ion-chip {
  background: rgba(255,255,255,.06);
  border-color: var(--ion-border-color);
  color: var(--ion-text-color);
}

[data-theme="dark"] .ion-chip.chip-primary {
  background: rgba(47,118,242,.18);
}

/* Transições suaves em trocas de tema */
*, *::before, *::after {
  transition-property: background-color, border-color, color, box-shadow;
  transition-duration: .25s;
  transition-timing-function: ease;
}
/* Exceto animações que não devem ter essa transição */
.ion-spinner, .skeleton, .cropper-overlay, .cropper-stage,
.app-tab-btn .t-icon, [class*="page-enter"] {
  transition: none !important;
}

/* ══════════════════════════════════════════════════
   BOTÃO DE TEMA — Lâmpada (Light Switch)
══════════════════════════════════════════════════ */
.theme-switch-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 0 8px;
}

.theme-switch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.theme-switch-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ion-text-color-secondary);
  letter-spacing: .3px;
}

/* Lâmpada */
.lamp-btn {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: none;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Halo de luz */
.lamp-btn::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,220,50,.35) 0%, transparent 70%);
  opacity: 0;
  transition: opacity .4s ease, transform .4s ease;
  transform: scale(.6);
}

/* Tema claro: lâmpada acesa */
:root:not([data-theme="dark"]) .lamp-btn::before {
  opacity: 1;
  transform: scale(1);
}

.lamp-body {
  width: 60px; height: 60px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  position: relative;
  z-index: 1;
  transition: background .4s, box-shadow .4s;
}

/* Claro: fundo amarelo brilhante */
:root:not([data-theme="dark"]) .lamp-body {
  background: linear-gradient(135deg, #ffe566 0%, #ffc820 100%);
  box-shadow: 0 0 0 4px rgba(255,220,50,.25),
              0 4px 16px rgba(255,180,0,.4);
}

/* Escuro: fundo acinzentado apagado */
[data-theme="dark"] .lamp-body {
  background: linear-gradient(135deg, #2a2f42 0%, #1e2336 100%);
  box-shadow: 0 0 0 4px rgba(255,255,255,.04),
              0 4px 12px rgba(0,0,0,.4);
  filter: grayscale(.5);
}

/* Cordão */
.lamp-cord {
  position: absolute;
  top: -20px; left: 50%;
  transform: translateX(-50%);
  width: 2px; height: 20px;
  background: var(--ion-border-color);
  border-radius: 1px;
}

/* Toggle track abaixo da lâmpada */
.lamp-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ion-text-color-secondary);
  font-weight: 600;
}

.lamp-track {
  width: 44px; height: 24px;
  border-radius: 100px;
  position: relative;
  transition: background .3s;
  cursor: pointer;
}

:root:not([data-theme="dark"]) .lamp-track { background: #ffc820; }
[data-theme="dark"] .lamp-track            { background: var(--ion-border-color); }

.lamp-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}

:root:not([data-theme="dark"]) .lamp-thumb { transform: translateX(20px); }
[data-theme="dark"] .lamp-thumb            { transform: translateX(0); }
