/* ============================================================
   MimiBakeIt — style.css
   Layout responsivo: sidebar fixa + main scroll
   Suporte: Full HD portátil → tablet → smartphone
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=Nunito:wght@300;400;500;600;700;800&display=swap');

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* Paleta */
  --primary:        #c8556a;
  --primary-light:  #e8899a;
  --primary-dark:   #a03a4e;
  --secondary:      #f9a8ba;
  --accent:         #f4d4da;

  /* Fundo */
  --bg:             #fdf6f8;
  --bg-card:        #ffffff;

  /* Sidebar */
  --sidebar-bg:     #2d1f24;
  --sidebar-width:  240px;

  /* Texto */
  --text-dark:      #2d1f24;
  --text-medium:    #6b4f57;
  --text-light:     #a08090;

  /* Bordas */
  --border:         #f0dde2;
  --border-dark:    #e0c5cc;

  /* Semânticas */
  --success:        #4caf7d;
  --success-light:  #e8f5ee;
  --warning:        #f9a825;
  --warning-light:  #fff8e1;
  --danger:         #e53935;
  --danger-light:   #ffebee;
  --info:           #1976d2;
  --info-light:     #e3f2fd;

  /* Sombras */
  --shadow:         0 1px 4px rgba(0,0,0,.05), 0 4px 16px rgba(200,85,106,.06);
  --shadow-hover:   0 4px 12px rgba(0,0,0,.08), 0 8px 28px rgba(200,85,106,.14);
  --shadow-modal:   0 20px 60px rgba(0,0,0,.18), 0 4px 20px rgba(200,85,106,.1);

  /* Radii */
  --radius:         12px;
  --radius-sm:      8px;
  --radius-lg:      20px;

  /* Layout */
  --header-height:  62px;
  --transition:     all 0.22s cubic-bezier(0.4,0,0.2,1);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  height: 100%;
  font-size: 16px;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  height: 100%;
  display: flex;
  overflow: hidden; /* sidebar layout: only .page-content scrolls */
}

/* ============================================================
   LAYOUT ROOT
   ============================================================ */
/* Sidebar: fixed left panel */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform var(--transition), width var(--transition);
  overflow: hidden;
  flex-shrink: 0;
}

/* Accent line on top of sidebar */
.sidebar::before {
  content: '';
  display: block;
  height: 3px;
  flex-shrink: 0;
  background: linear-gradient(to right, var(--primary), var(--secondary));
}

/* Main wrapper: fills remaining space, scrolls independently */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
  overflow: hidden;
}

/* Page content: the only scrolling zone */
.page-content {
  flex: 1;
  padding: 24px 28px 32px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  height: 0; /* forces flex child to respect parent height and scroll */
}

/* Scrollbar */
.page-content::-webkit-scrollbar { width: 6px; }
.page-content::-webkit-scrollbar-track { background: transparent; }
.page-content::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 6px; }
.page-content::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }

/* ============================================================
   SIDEBAR INTERNALS
   ============================================================ */
.sidebar-logo {
  padding: 18px 16px 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

.sidebar-logo .logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), #e8899a);
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.sidebar-logo .logo-text h2 {
  font-family: 'Playfair Display', serif;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logo .logo-text span {
  color: rgba(249,168,186,.8);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }

.nav-section-label {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  color: rgba(255,255,255,.28);
  padding: 14px 12px 5px;
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: rgba(255,255,255,.68);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  transition: var(--transition);
  border-radius: 9px;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  margin-bottom: 1px;
  user-select: none;
}

.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.nav-item.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 3px 10px rgba(200,85,106,.4);
}

.nav-item .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,.07);
  background: rgba(0,0,0,.15);
  flex-shrink: 0;
}

.sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  padding: 7px 8px;
  border-radius: 9px;
  transition: background .2s;
}

.sidebar-footer .user-info:hover { background: rgba(255,255,255,.06); }

.user-avatar {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--primary), #e8899a);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
}

.user-details h4 {
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.user-details span {
  color: rgba(255,255,255,.38);
  font-size: 10.5px;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

/* ============================================================
   TOP HEADER
   ============================================================ */
.top-header {
  height: var(--header-height);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
  gap: 16px;
}

.header-left {
  min-width: 0;
  flex: 1;
}

.header-left h1 {
  font-family: 'Playfair Display', serif;
  font-size: 19px;
  font-weight: 700;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-left p {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header-btn {
  width: 38px;
  height: 38px;
  border: none;
  background: var(--bg);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--text-medium);
  transition: var(--transition);
  position: relative;
  flex-shrink: 0;
}

.header-btn:hover { background: var(--accent); color: var(--primary); }

.header-btn .notif-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

/* ============================================================
   PAGE SECTIONS
   ============================================================ */
.page-section {
  display: none;
  animation: fadeUp .25s ease;
}

.page-section.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
  overflow: hidden;
}

.card:hover { box-shadow: var(--shadow-hover); }

.card-header {
  padding: 18px 22px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
  background: linear-gradient(to right, var(--bg), var(--bg-card));
}

.card-title {
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dark);
}

.card-subtitle {
  font-size: 12.5px;
  color: var(--text-light);
  margin-top: 2px;
}

.card-body { padding: 20px 22px; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: -20px;
  right: -14px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .45;
  pointer-events: none;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.pink   { background: rgba(200,85,106,.1);  color: var(--primary); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.blue   { background: var(--info-light);    color: var(--info); }
.stat-icon.purple { background: rgba(103,58,183,.1);  color: #673ab7; }

.stat-info { min-width: 0; flex: 1; }

.stat-info .stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-dark);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-info .stat-label {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
  font-weight: 600;
}

.stat-info .stat-change {
  font-size: 11px;
  margin-top: 3px;
  font-weight: 700;
}

.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

thead th {
  background: var(--bg);
  color: var(--text-medium);
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  padding: 11px 15px;
  text-align: left;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}

tbody tr:hover { background: rgba(200,85,106,.03); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 12px 15px;
  vertical-align: middle;
  color: var(--text-dark);
}

.td-name  { font-weight: 700; color: var(--text-dark); }
.td-sub   { font-size: 11.5px; color: var(--text-light); margin-top: 2px; }

/* ============================================================
   BADGES / PILLS
   ============================================================ */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-pill.pendente   { background: var(--warning-light);          color: #c57b00; }
.badge-pill.producao   { background: var(--info-light);             color: #0d47a1; }
.badge-pill.pronta     { background: rgba(103,58,183,.1);           color: #4527a0; }
.badge-pill.entregue   { background: var(--success-light);          color: #1b5e20; }
.badge-pill.cancelada  { background: var(--danger-light);           color: #b71c1c; }
.badge-pill.pago       { background: var(--success-light);          color: var(--success); }
.badge-pill.nao-pago   { background: var(--danger-light);           color: var(--danger); }
.badge-pill.vip        { background: linear-gradient(135deg,#ffd700,#ff8c00); color: #fff; }
.badge-pill.stock-ok   { background: var(--success-light);          color: var(--success); }
.badge-pill.stock-baixo{ background: var(--warning-light);          color: var(--warning); }
.badge-pill.stock-critico { background: var(--danger-light);        color: var(--danger); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 10px;
  font-family: 'Nunito', sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 2px 8px rgba(200,85,106,.28);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark), #8a2f40);
  box-shadow: 0 4px 16px rgba(200,85,106,.42);
  transform: translateY(-1px);
}

.btn-secondary { background: var(--accent); color: var(--primary); }
.btn-secondary:hover { background: var(--secondary); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border-dark);
  color: var(--text-medium);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--accent); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #388e5e; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c62828; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #f57f17; }

.btn-sm    { padding: 6px 12px; font-size: 12px; border-radius: 7px; }
.btn-lg    { padding: 12px 28px; font-size: 15px; }

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
}

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

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text-medium);
  margin-bottom: 6px;
  letter-spacing: 0.25px;
  text-transform: uppercase;
}

.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-family: 'Nunito', sans-serif;
  font-size: 13.5px;
  color: var(--text-dark);
  background: var(--bg);
  transition: border-color .18s, box-shadow .18s, background .18s;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(200,85,106,.1);
}

.form-control::placeholder { color: var(--text-light); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; line-height: 1.5; }

.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.form-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.form-check label { font-size: 13.5px; color: var(--text-medium); cursor: pointer; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45,31,36,.52);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s, visibility .22s;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overflow-x: hidden;
  transform: translateY(18px) scale(.98);
  transition: transform .22s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: var(--shadow-modal);
  border: 1px solid var(--border);
}

.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
  padding: 20px 24px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1.5px solid var(--border);
  position: sticky;
  top: 0;
  background: linear-gradient(to right, var(--accent), var(--bg-card));
  z-index: 10;
  gap: 12px;
}

.modal-title {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.modal-close:hover { background: var(--danger-light); color: var(--danger); }

.modal-body  { padding: 22px 24px; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
}

/* ============================================================
   TOOLBAR (search + filters row)
   ============================================================ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 180px;
}

.search-box input {
  width: 100%;
  padding: 9px 13px 9px 38px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: 'Nunito', sans-serif;
  font-size: 13.5px;
  color: var(--text-dark);
  background: var(--bg);
  transition: border-color .18s, box-shadow .18s, background .18s;
  outline: none;
}

.search-box input:focus {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(200,85,106,.1);
}

.search-box .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 14px;
  pointer-events: none;
}

.toolbar .form-control {
  width: auto;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--bg);
}

/* ============================================================
   GRID LAYOUTS
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ============================================================
   ALERT / INFO BOXES
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
  line-height: 1.5;
}

.alert-success { background: var(--success-light); color: #1b5e20; border-left: 4px solid var(--success); }
.alert-danger  { background: var(--danger-light);  color: #b71c1c; border-left: 4px solid var(--danger); }
.alert-warning { background: var(--warning-light); color: #c57b00; border-left: 4px solid var(--warning); }
.alert-info    { background: var(--info-light);    color: #0d47a1; border-left: 4px solid var(--info); }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 18px;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 9px;
  box-shadow: 0 6px 20px rgba(0,0,0,.16);
  animation: toastIn .28s ease;
  min-width: 260px;
  max-width: 360px;
  pointer-events: auto;
  border-left: 4px solid rgba(255,255,255,.35);
}

.toast.success { background: var(--success); color: #fff; }
.toast.error   { background: var(--danger);  color: #fff; }
.toast.warning { background: var(--warning); color: #fff; }
.toast.info    { background: var(--info);    color: #fff; }

@keyframes toastIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(110%); }
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 52px 20px;
  color: var(--text-light);
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 2px dashed var(--border-dark);
}

.empty-state .empty-icon {
  font-size: 52px;
  margin-bottom: 14px;
  opacity: .25;
}

.empty-state h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-medium);
  margin-bottom: 6px;
}

.empty-state p { font-size: 13.5px; margin-bottom: 18px; }

/* ============================================================
   LOADING
   ============================================================ */
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--accent);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .65s linear infinite;
}

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

/* ============================================================
   TABS
   ============================================================ */
.tab-nav {
  display: flex;
  gap: 3px;
  background: var(--bg);
  padding: 4px;
  border-radius: 11px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
}

.tab-btn {
  padding: 7px 14px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-light);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(200,85,106,.12);
}

.tab-btn:hover:not(.active) { color: var(--text-medium); background: rgba(200,85,106,.06); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #ccc;
  border-radius: 26px;
  transition: .25s;
}

.toggle-slider:before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background: #fff;
  border-radius: 50%;
  transition: .25s;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(22px); }

/* ============================================================
   ALERTA CARDS
   ============================================================ */
.alerta-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 14px 16px 14px 12px;
  margin-bottom: 9px;
  position: relative;
  transition: box-shadow .18s, transform .15s;
  overflow: hidden;
}

.alerta-card:hover {
  box-shadow: 0 4px 18px rgba(0,0,0,.07);
  transform: translateY(-1px);
}

.alerta-card.alerta-read { opacity: .58; background: var(--bg); }

.alerta-stripe {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  flex-shrink: 0;
}

.alerta-icon  { font-size: 24px; line-height: 1; margin-top: 1px; flex-shrink: 0; }

.alerta-content { flex: 1; min-width: 0; }

.alerta-header-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 5px;
}

.alerta-title  { font-weight: 700; font-size: 14px; color: var(--text-dark); line-height: 1.3; }
.alerta-badges { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.alerta-msg    { font-size: 12.5px; color: var(--text-medium); line-height: 1.55; margin-bottom: 5px; white-space: pre-line; }

.alerta-date {
  font-size: 11.5px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 4px;
}

.alerta-actions {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
  align-items: flex-start;
}

.alerta-urgency {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.alerta-urgency.overdue { background: var(--danger-light);  color: var(--danger); }
.alerta-urgency.today   { background: var(--warning-light); color: #c57b00; }
.alerta-urgency.soon    { background: var(--info-light);    color: var(--info); }

/* ============================================================
   RATING STARS
   ============================================================ */
.stars      { display: inline-flex; gap: 2px; }
.star       { color: var(--warning); font-size: 14px; }
.star.empty { color: var(--border); }

/* ============================================================
   CALENDAR
   ============================================================ */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-day-header {
  text-align: center;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 7px 0;
}

.cal-day {
  min-height: 72px;
  padding: 5px;
  border-radius: 7px;
  border: 1px solid transparent;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}

.cal-day:hover { background: var(--bg); border-color: var(--border); }
.cal-day.today { background: var(--accent); border-color: var(--primary-light); }
.cal-day.other-month { opacity: .33; }

.cal-day-num { font-size: 12.5px; font-weight: 700; color: var(--text-medium); margin-bottom: 3px; }

.cal-day.today .cal-day-num {
  background: var(--primary);
  color: #fff;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
}

.cal-event {
  font-size: 10px;
  padding: 2px 4px;
  border-radius: 4px;
  margin-bottom: 2px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   PROGRESS BARS
   ============================================================ */
.progress-bar  { height: 7px; background: var(--border); border-radius: 10px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 10px; transition: width .5s ease; }

/* ============================================================
   SECTION LABELS
   ============================================================ */
.section-label {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-light);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.section-title-bar {
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
  padding: 8px 0 6px;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 16px;
}

/* ============================================================
   MISC COMPONENTS
   ============================================================ */
.section-divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

.info-box {
  background: var(--info-light);
  border: 1px solid #90caf9;
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  font-size: 13px;
  color: #1565c0;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  line-height: 1.5;
}

.avatar-sm {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  background: var(--accent);
  color: var(--primary-dark);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

.chip-remove { cursor: pointer; font-size: 13px; line-height: 1; opacity: .7; }
.chip-remove:hover { opacity: 1; color: var(--danger); }

/* ============================================================
   ESTATÍSTICAS PAGE
   ============================================================ */
.est-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}

/* ============================================================
   CONFIGURAÇÕES PAGE
   ============================================================ */
#configSection {
  max-width: 900px;
}

#configSection .card { margin-bottom: 0; }

#configSection .tab-nav {
  border-radius: 11px;
  padding: 4px;
}

#configSection .tab-btn {
  font-size: 12.5px;
  padding: 7px 12px;
}

/* Config cards: constrained width on wide screens, full width on small */
.cfg-card {
  max-width: 680px;
  width: 100%;
  padding: 22px 24px;
}

/* Config card headings */
.cfg-card h3 {
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1.5px solid var(--border);
}

.cfg-card h4 {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-medium);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.cfg-section-box {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 11px;
  padding: 16px 18px;
  margin-bottom: 18px;
}

@media (max-width: 768px) {
  .cfg-card { max-width: 100%; }
  #configSection { max-width: 100%; }
}

/* Palette buttons */
.palette-btn:hover {
  border-color: var(--primary) !important;
  box-shadow: 0 2px 8px rgba(200,85,106,.2);
  transform: translateY(-1px);
}

/* ============================================================
   SCROLLBARS (global)
   ============================================================ */
::-webkit-scrollbar              { width: 5px; height: 5px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        { background: var(--border-dark); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover  { background: var(--primary-light); }

/* ============================================================
   UTILS
   ============================================================ */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mt-24  { margin-top: 24px; }
.mb-8   { margin-bottom: 8px; }
.mb-16  { margin-bottom: 16px; }
.mb-24  { margin-bottom: 24px; }
.w-100  { width: 100%; }
.hidden { display: none !important; }
.font-bold    { font-weight: 700; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted   { color: var(--text-light); }
.cursor-pointer { cursor: pointer; }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
#loginScreen { position: fixed !important; }

/* ============================================================
   DARK THEME
   ============================================================ */
body.dark-theme {
  --bg:           #13111a;
  --bg-card:      #1e1b2e;
  --border:       #2d2a3e;
  --border-dark:  #3d3a52;
  --text-dark:    #ede9f6;
  --text-medium:  #a89bc2;
  --text-light:   #6e6580;
  --sidebar-bg:   #0e0c18;
  --info-light:   #0d1f3e;
  --success-light:#0a1f12;
  --warning-light:#2d1b00;
  --danger-light: #2d0a0a;
  --shadow:       0 2px 12px rgba(0,0,0,.4);
  --shadow-hover: 0 6px 24px rgba(0,0,0,.55);
}

body.dark-theme .form-control   { background: #16132a; color: var(--text-dark); }
body.dark-theme .form-control:focus { background: #1e1b2e; }
body.dark-theme .search-box input { background: #16132a; }
body.dark-theme .toolbar .form-control { background: #16132a; }
body.dark-theme .tab-nav        { background: #16132a; }
body.dark-theme .tab-btn.active { background: var(--bg-card); }
body.dark-theme .top-header     { background: rgba(30,27,46,.94); }
body.dark-theme .alerta-card    { background: var(--bg-card); }
body.dark-theme .alerta-card.alerta-read { background: var(--bg); }
body.dark-theme tbody tr:hover  { background: rgba(255,255,255,.03); }
body.dark-theme .badge-pill     { filter: brightness(.88); }
body.dark-theme .empty-state    { background: var(--bg-card); }

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .sidebar, .top-header, .toolbar, .btn, .modal-overlay { display: none !important; }
  .main-wrapper { margin: 0; }
  .page-content { padding: 0; overflow: visible; }
}

/* ============================================================
   RESPONSIVE — Mobile-first breakpoints
   ============================================================ */

/* ── Tablet landscape / small laptop (≤ 1024px) ── */
@media (max-width: 1024px) {
  :root { --sidebar-width: 220px; }
  .grid-3            { grid-template-columns: 1fr 1fr; }
  .est-kpi-grid      { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .stats-grid        { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

/* ── Tablet portrait (≤ 768px) ── */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 0px;
    --header-height: 56px;
  }

  /* On mobile, body can scroll normally (no fixed sidebar) */
  body { overflow-x: hidden; overflow-y: auto; height: auto; min-height: 100vh; }

  /* Sidebar becomes a drawer */
  .sidebar {
    width: 256px;
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,.3);
  }

  /* Overlay when sidebar is open */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 999;
    display: none;
  }
  .sidebar-overlay.visible { display: block; }

  .main-wrapper {
    margin-left: 0;
    min-height: 100vh;
    height: auto;
    overflow: visible;
  }

  .page-content {
    overflow-y: visible;
    overflow-x: hidden;
    height: auto;
  }

  .top-header { padding: 0 14px; }

  .page-content { padding: 16px; }

  .grid-2, .grid-3  { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid       { grid-template-columns: 1fr 1fr; }
  .est-kpi-grid     { grid-template-columns: 1fr 1fr; }

  /* Menu toggle visible */
  #menuToggle { display: flex !important; }

  .toolbar { gap: 8px; }
  .toolbar .btn { font-size: 12.5px; padding: 8px 13px; }

  .modal { border-radius: var(--radius); }
  .modal-body { padding: 18px 18px; }
  .modal-header { padding: 16px 18px 13px; }
  .modal-footer { padding: 12px 18px; }

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

  #configSection { max-width: 100%; }
  #configSection .tab-btn { font-size: 12px; padding: 6px 10px; }
}

/* ── Smartphone (≤ 480px) ── */
@media (max-width: 480px) {
  :root { --header-height: 52px; }

  .stats-grid  { grid-template-columns: 1fr 1fr; }
  .est-kpi-grid { grid-template-columns: 1fr 1fr; }

  .header-left h1 { font-size: 16px; }
  .header-left p  { display: none; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .search-box { min-width: unset; }
  .toolbar .form-control { width: 100%; }
  .toolbar .btn { width: 100%; justify-content: center; }

  .alerta-card  { flex-wrap: wrap; padding: 12px; }
  .alerta-actions { width: 100%; justify-content: flex-end; margin-top: 6px; }

  .modal-title { font-size: 16px; }

  .tab-btn { font-size: 11.5px; padding: 6px 9px; }

  .btn-icon { width: 32px; height: 32px; }

  .stat-value { font-size: 20px !important; }
}

/* ── Extra small (≤ 360px) ── */
@media (max-width: 360px) {
  .stats-grid   { grid-template-columns: 1fr; }
  .est-kpi-grid { grid-template-columns: 1fr; }
  .page-content { padding: 12px; }
}
