@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@500;600;700;800&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

:root {
  --bg: #f5f7f5;
  --surface: #ffffff;
  --surface-2: #eef2ef;
  --surface-3: #e3e9e5;
  --border: #d9e1dc;
  --border-strong: #c2cdc6;
  --text-primary: #16221e;
  --text-secondary: #4c5c55;
  --text-muted: #7c8c84;
  --accent: #244f78;
  --accent-soft: #e6edf4;
  --good: #1f8a5f;
  --good-bg: #e4f3ea;
  --good-text: #146341;
  --warn: #a66a15;
  --warn-bg: #fbf0de;
  --warn-text: #7a4d0a;
  --crit: #c23b3b;
  --crit-bg: #fbe6e6;
  --crit-text: #8f1f1f;
  --shadow: 0 1px 2px rgba(20, 30, 26, 0.06), 0 8px 24px -14px rgba(20, 30, 26, 0.18);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1613;
  --surface: #171f1c;
  --surface-2: #1c2622;
  --surface-3: #253029;
  --border: #2b362f;
  --border-strong: #3a463d;
  --text-primary: #edf3f0;
  --text-secondary: #b4c3bb;
  --text-muted: #7c8d85;
  --accent: #7aa8d9;
  --accent-soft: #1c2b3a;
  --good: #4dc191;
  --good-bg: #163325;
  --good-text: #83e1b4;
  --warn: #dba748;
  --warn-bg: #3a2c11;
  --warn-text: #f0c877;
  --crit: #e37672;
  --crit-bg: #3a1817;
  --crit-text: #f4a5a1;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px -14px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1613;
    --surface: #171f1c;
    --surface-2: #1c2622;
    --surface-3: #253029;
    --border: #2b362f;
    --border-strong: #3a463d;
    --text-primary: #edf3f0;
    --text-secondary: #b4c3bb;
    --text-muted: #7c8d85;
    --accent: #7aa8d9;
    --accent-soft: #1c2b3a;
    --good: #4dc191;
    --good-bg: #163325;
    --good-text: #83e1b4;
    --warn: #dba748;
    --warn-bg: #3a2c11;
    --warn-text: #f0c877;
    --crit: #e37672;
    --crit-bg: #3a1817;
    --crit-text: #f4a5a1;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px -14px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.page,
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 20px 56px;
}

h1, h2, h3 {
  font-family: 'Archivo', system-ui, sans-serif;
  margin: 0;
  text-wrap: balance;
}

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}

.topbar-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 16px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Archivo', sans-serif;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.02em;
  flex: none;
  box-shadow: 0 2px 8px rgba(36, 79, 120, 0.3);
}

.brand-mark.has-logo {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  padding: 0 !important;
  width: auto !important;
  min-width: 44px;
  max-width: 150px;
}

.brand-mark .brand-logo-img {
  max-height: 44px;
  max-width: 150px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

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

.brand-company-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.company-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  cursor: pointer;
  outline: none;
}

.company-select:hover {
  border-color: var(--border-strong);
}

.company-single-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  line-height: 1.2;
}

.topbar h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
}

/* Controls (Date & Actions) */
.topbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.date-nav-group {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px 6px;
  box-shadow: var(--shadow);
}

.btn-nav {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-nav:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.date-input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 6px;
  cursor: pointer;
  outline: none;
}

.action-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow);
  transition: all 0.15s ease;
}

.action-btn:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.spin {
  animation: spin 1s linear infinite;
}

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

.theme-toggle-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: var(--shadow);
}

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

/* Date meta header */
.date-subtitle-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 0 2px;
  gap: 12px;
}

.date-headline {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.period-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
}

.period-subtitle {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.25;
}

.sync-badge-info {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  display: inline-block;
}

/* Seletor de Loja para os Cards de Resumo */
.cards-store-nav-group {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 6px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cards-store-nav-group:hover,
.cards-store-nav-group:focus-within {
  border-color: var(--border-strong);
}

.cards-store-select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}

.cards-store-icon {
  color: var(--accent);
  flex-shrink: 0;
}

.cards-store-select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 6px;
  outline: none;
  cursor: pointer;
  max-width: 240px;
}

.cards-store-select option {
  background: var(--surface);
  color: var(--text-primary);
}

/* ---------- Summary Tiles ---------- */
.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 26px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.15s ease;
}

.tile:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.tile.good:hover {
  border-left-color: var(--good);
}

.tile.warn:hover {
  border-left-color: var(--warn);
}

.tile.crit:hover {
  border-left-color: var(--crit);
}

.tile.accent:hover {
  border-left-color: var(--accent);
}

.tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.tile-label {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tile-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.tile:hover .tile-icon {
  background: var(--surface-3);
  color: var(--text-primary);
}

.tile-icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  display: block;
}

.tile-value {
  font-family: 'Archivo', sans-serif;
  font-size: 23px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
}

.tile-obs {
  font-size: 11.5px;
  font-weight: 600;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.tile-obs.falta {
  background: var(--crit-bg);
  color: var(--crit-text);
  border: 1px solid rgba(227, 118, 114, 0.25);
}

.tile-obs.sobra {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(122, 168, 217, 0.25);
}

.cell-obs {
  font-size: 10.5px;
  font-weight: 600;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  display: inline-block;
  line-height: 1.2;
}

.cell-obs.falta {
  background: var(--crit-bg);
  color: var(--crit-text);
}

.cell-obs.sobra {
  background: var(--accent-soft);
  color: var(--accent);
}

.tile-sub {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.3;
}

.tile-pills-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  margin-top: 8px;
}

.pill.good { background: var(--good-bg); color: var(--good-text); }
.pill.warn { background: var(--warn-bg); color: var(--warn-text); }
.pill.crit { background: var(--crit-bg); color: var(--crit-text); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.pill svg { width: 11px; height: 11px; flex: none; }

/* ---------- Section headings ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 30px 0 12px;
}

.section-head h2 {
  font-size: 16px;
  font-weight: 700;
}

.section-head .hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Rotinas Diárias ---------- */
.routines-section {
  margin-bottom: 26px;
}

.routines-section-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.section-head-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.routines-summary-badges {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.routine-summary-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.routine-summary-badge.ok {
  background: var(--good-bg);
  color: var(--good-text);
  border-color: rgba(34, 197, 94, 0.25);
}

.routine-summary-badge.warn {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-color: rgba(234, 179, 8, 0.25);
}

.routine-summary-badge.crit {
  background: var(--crit-bg);
  color: var(--crit-text);
  border-color: rgba(239, 68, 68, 0.25);
}

.routine-summary-badge svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* Cards Grid */
.routines-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
}

.routine-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-left: 4px solid var(--border);
  transition: transform 0.15s, box-shadow 0.15s;
}

.routine-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.routine-card.ok {
  border-left-color: var(--good);
}

.routine-card.warn {
  border-left-color: var(--warn);
}

.routine-card.crit {
  border-left-color: var(--crit);
}

.routine-card.routine-card-rede {
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.15), var(--shadow);
}

.routine-card.routine-card-rede:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 18px rgba(59, 130, 246, 0.18);
}

.routine-cal-card-rede {
  border: 1px solid rgba(59, 130, 246, 0.35);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.12), var(--shadow);
}

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

.routine-card-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.routine-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.routine-item-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.routine-item-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.routine-item-label.clickable {
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  border-radius: 6px;
  padding: 2px 4px;
  margin: -2px -4px;
}

.routine-item-label.clickable:hover {
  color: var(--text-primary);
  background: var(--surface-2);
}

.routine-item-label.clickable:hover .routine-label-text {
  color: var(--accent);
}

.routine-item-label.clickable.active .routine-label-text {
  color: var(--accent);
}

.routine-label-text {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s ease;
}

.chevron-sec-inline {
  display: inline-block;
  vertical-align: middle;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0.65;
}

.routine-item-label.clickable:hover .chevron-sec-inline {
  opacity: 1;
  color: var(--accent);
}

.routine-icon-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.routine-icon-circle.ok {
  background: var(--good-bg);
  color: var(--good-text);
}

.routine-icon-circle.crit {
  background: var(--crit-bg);
  color: var(--crit-text);
}

.routine-icon-circle.warn {
  background: var(--warn-bg);
  color: #facc15;
  border: 1px solid rgba(250, 204, 21, 0.4);
}

.routine-icon-circle.neutral {
  background: var(--surface-3);
  color: var(--text-muted);
}

.routine-item-value {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-toggle-sectors {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.btn-toggle-sectors:hover {
  background: var(--surface-3);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-toggle-sectors.active {
  background: var(--surface-3);
  color: var(--accent);
  border-color: var(--accent);
}

.chevron-sec {
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.routine-val-text {
  font-size: 13.5px;
  font-weight: 700;
}

.routine-val-text.ok {
  color: var(--good-text);
}

.routine-val-text.crit {
  color: var(--crit-text);
}

.routine-val-text.warn {
  color: var(--warn-text);
}

.routine-val-text.muted {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
}

.btn-point-mini {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 2px 7px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-point-mini:hover {
  background: var(--surface-3);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.routine-item-obs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 30px;
  margin-top: -3px;
  margin-bottom: 3px;
  font-size: 11px;
  color: var(--text-muted);
}

.routine-obs-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.routine-obs-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}

.routine-sectors-wrap {
  margin-top: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.routine-sectors-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.routine-chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.routine-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  transition: all 0.15s;
}

.routine-chip.ok {
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.06);
  color: var(--text-primary);
}

.routine-chip.ok .r-chip-dot {
  background: var(--good);
}

.routine-chip.pending {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.05);
  color: var(--crit-text);
  border-style: dashed;
}

.routine-chip.pending .r-chip-dot {
  background: var(--crit);
}

.r-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.r-chip-val {
  font-weight: 700;
}

/* Matriz de Mercadológicos */
.routines-matrix-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}

.matrix-table {
  width: 100%;
  min-width: 600px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}

.matrix-table th {
  background: var(--surface-2);
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.matrix-table th.th-sector {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface-2);
}

.matrix-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.matrix-table td.td-sector {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.matrix-table tr:hover td {
  background: var(--surface-2);
}

.matrix-table tr:hover td.td-sector {
  background: var(--surface-2);
}

.matrix-status-cell {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.matrix-status-cell.ok {
  background: var(--good-bg);
  color: var(--good-text);
}

.matrix-status-cell.crit {
  background: var(--crit-bg);
  color: var(--crit-text);
}

.matrix-status-cell.muted {
  color: var(--text-muted);
  font-size: 11px;
}

/* ---------- Attention cards ---------- */
.attention-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.attn-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--crit);
  border-radius: 10px;
  padding: 11px 14px;
  box-shadow: var(--shadow);
}

.attn-card.warn {
  border-left-color: var(--warn);
}

.attn-card.destaque {
  border-left-color: var(--good);
}

.attn-tag {
  grid-row: span 2;
  align-self: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.attn-card:not(.warn):not(.destaque) .attn-tag {
  background: var(--crit-bg);
  color: var(--crit-text);
}

.attn-card.warn .attn-tag {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.attn-card.destaque .attn-tag {
  background: var(--good-bg);
  color: var(--good-text);
}

.attn-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13.5px;
  margin: 0;
}

.attn-body {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.no-alerts-card {
  background: var(--good-bg);
  border: 1px solid var(--good);
  color: var(--good-text);
  padding: 14px 18px;
  border-radius: 10px;
  font-weight: 500;
}

/* ---------- Legend ---------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.legend i.good { background: var(--good); }
.legend i.warn { background: var(--warn); }
.legend i.crit { background: var(--crit); }

/* ---------- Table ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  background: var(--surface);
  container-type: inline-size;
}

table {
  border-collapse: collapse;
  width: 100%;
}

thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:last-of-type td {
  border-bottom: none;
}

tr.total-row td {
  background: var(--surface-2);
  font-weight: 700;
  border-top: 2px solid var(--border-strong);
}

tr.total-row .cell-sub, tr.total-row .cell-meta {
  font-weight: 500;
}

.store-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.expand-btn {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
  padding: 0;
  transition: background-color 0.15s ease;
}

.expand-btn:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.expand-btn svg {
  width: 12px;
  height: 12px;
  transition: transform 0.15s ease;
}

.expand-btn[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.cell-value {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
}

.cell-value.crit {
  color: var(--crit-text) !important;
}

.cell-value.good {
  color: var(--text-primary);
}

.cell-meta {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 1px;
  white-space: nowrap;
  min-height: 16px;
  line-height: 16px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.cell-sub {
  color: var(--text-secondary);
  font-size: 11px;
  margin-top: 1px;
}

/* Progress bar */
.bar-track {
  position: relative;
  width: 95px;
  height: 5px;
  border-radius: 999px;
  background: var(--surface-3);
  margin-top: 5px;
}

.bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  border-radius: 999px;
  background: var(--good);
}

.bar-fill.warn { background: var(--warn); }
.bar-fill.crit { background: var(--crit); }

.bar-marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--text-primary);
  opacity: 0.45;
}

/* Status dots */
.status-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  white-space: nowrap;
  min-height: 16px;
  line-height: 16px;
}

.status-row.empty {
  min-height: 16px;
  line-height: 16px;
  margin-top: 2px;
  visibility: hidden;
  user-select: none;
}

.mom-row {
  display: flex;
  align-items: center;
  margin-top: 3px;
  min-height: 18px;
  line-height: 18px;
  white-space: nowrap;
}

.mom-row.empty {
  min-height: 18px;
  line-height: 18px;
  visibility: hidden;
  user-select: none;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}

.status-dot.good { background: var(--good); }
.status-dot.warn { background: var(--warn); }
.status-dot.crit { background: var(--crit); }
.status-dot.purple, .status-dot.transformados { background: #8b5cf6; }

.status-text {
  font-size: 11.5px;
  font-weight: 600;
}

.status-text.good { color: var(--good-text); }
.status-text.warn { color: var(--warn-text); }
.status-text.crit { color: var(--crit-text); }

/* Detail row */
.detail-row td {
  background: var(--surface-2);
  padding: 0;
  border-bottom: 1px solid var(--border);
}

.detail-row[hidden] {
  display: none;
}

.detail-inner {
  padding: 14px 16px 18px 46px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dept-section {
  width: 100%;
}

.dept-section + .dept-section {
  border-top: 1px solid var(--border-strong);
  padding-top: 14px;
}

:root[data-theme="dark"] .dept-section + .dept-section {
  border-top: 1px solid rgba(255, 255, 255, 0.20);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .dept-section + .dept-section {
    border-top: 1px solid rgba(255, 255, 255, 0.20);
  }
}

.detail-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.dept-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dept-chip {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 12.5px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.dept-chip-perdas {
  border-left: 2px solid var(--accent);
}

.dept-chip-consumo {
  border-left: 2px solid #e0872c;
}

.dept-chip-transformados {
  border-left: 2px solid #8b5cf6;
}

.dept-chip-estoquenegativo {
  border-left: 2px solid #ef4444;
}

.dept-chip-empty {
  color: var(--text-muted);
  cursor: default;
  border-style: dashed;
}

.dept-chip:hover:not(.dept-chip-empty) {
  background: var(--surface-2);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.dept-chip:active:not(.dept-chip-empty) {
  transform: translateY(0) scale(0.98);
}

.dept-chip .dept-info {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.dept-chip .dept-name {
  color: var(--text-secondary);
}

.dept-chip .dept-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dept-chip .dept-value {
  font-weight: 600;
  color: var(--text-primary);
}

.dept-chip .dept-icon-link {
  display: inline-flex;
  align-items: center;
  opacity: 0.45;
  margin-left: 2px;
  transition: opacity 0.15s, transform 0.15s;
}

.dept-chip:hover:not(.dept-chip-empty) .dept-icon-link {
  opacity: 1;
  color: var(--accent);
  transform: scale(1.15);
}

/* Modal de Itens por Setor */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 22, 19, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 12px;
  box-sizing: border-box;
}

.modal-backdrop[hidden] {
  display: none !important;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-dialog {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  width: 95vw;
  max-width: 1040px;
  height: min(86vh, 760px);
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 56px -12px rgba(0, 0, 0, 0.35);
  animation: modalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.modal-header {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.modal-title-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.modal-close-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.modal-close-btn:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border);
}

/* Modal Summary Strip */
.modal-summary-bar {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
}

.modal-summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-summary-item .m-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.modal-summary-item .m-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Modal Toolbar */
.modal-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  gap: 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.search-box .search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px 7px 34px;
  font-size: 13px;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: all 0.15s;
}

.search-box input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.modal-toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* View Toggle Buttons */
.view-toggle-wrap {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.view-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.view-btn:hover {
  color: var(--text-primary);
}

.view-btn.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Mobile sort dropdown */
.mobile-sort-wrap {
  display: none;
}

.mobile-sort-wrap select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  color: var(--text-primary);
  outline: none;
  font-family: inherit;
}

.filter-count {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Modal Body, Table Wrap & Cards Wrap */
.modal-body {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--surface);
  overflow: hidden;
}

.modal-table-wrap {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-cards-wrap {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 16px;
  background: var(--surface-2);
  box-sizing: border-box;
}

.modal-cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Responsive Product Card */
.mobile-item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, transform 0.15s;
}

.mobile-item-card:hover {
  border-color: var(--border-strong);
}

.m-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.m-card-title-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.m-card-desc {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
}

.m-card-code {
  font-size: 11.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text-muted);
  font-weight: 600;
}

.m-card-metrics {
  display: grid;
  grid-template-columns: 1.1fr 0.8fr 1.1fr;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: 8px;
}

.m-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.m-metric-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.m-metric-val {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.m-metric-val.crit {
  color: var(--crit-text);
}

.modal-table {
  width: 100%;
  min-width: 680px;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.modal-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.modal-table th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface-2);
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  box-shadow: inset 0 -1px 0 var(--border-strong), inset 0 1px 0 var(--border);
  white-space: nowrap;
}

.th-sortable {
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}

.th-sortable:hover {
  background: var(--surface-3);
  color: var(--text-primary);
}

.th-sortable.active {
  color: var(--accent);
  background: var(--surface-3);
}

.th-content {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.th-content.right {
  justify-content: flex-end;
  width: 100%;
}

.sort-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  opacity: 0.4;
  transition: opacity 0.15s, transform 0.15s;
}

.th-sortable:hover .sort-icon {
  opacity: 0.8;
}

.th-sortable.active .sort-icon {
  opacity: 1;
  color: var(--accent);
}

.modal-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.modal-table tr:hover td {
  background: var(--surface-2);
}

.modal-table td.code-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.modal-table td.desc-cell {
  font-weight: 600;
  color: var(--text-primary);
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  min-width: 220px;
  line-height: 1.35;
}

.badge-pct {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
}

.badge-pct.good {
  background: var(--good-bg);
  color: var(--good-text);
}

.badge-pct.warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.badge-pct.crit {
  background: var(--crit-bg);
  color: var(--crit-text);
}

.badge-pct.blue {
  background: var(--accent-soft);
  color: var(--accent);
}

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

.val-negative {
  color: var(--accent) !important;
}

.val-positive {
  color: var(--crit-text) !important;
}

.badge-subtipo {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--text-secondary);
  vertical-align: middle;
  margin-left: 6px;
  text-transform: uppercase;
}

.pill.orange {
  background: rgba(224, 135, 44, 0.15);
  color: #e0872c;
}

.pill.purple {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
}

.code-badge {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-3);
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
}

.code-badge.purple {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
}

.name-bold {
  vertical-align: middle;
}

/* Transformed Items Flow & Mobile Cards */
.trans-card {
  border-left: 3px solid #8b5cf6;
}

.trans-flow {
  display: flex;
  align-items: center;
  gap: 12px;
}

.trans-node {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface-2);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.trans-node.destination {
  border-color: rgba(139, 92, 246, 0.35);
  background: rgba(139, 92, 246, 0.05);
}

.trans-node-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.trans-node.destination .trans-node-label {
  color: #8b5cf6;
}

.trans-node-qtde {
  margin-top: 5px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.trans-metric-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.trans-qtde-val {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.trans-qtde-val.highlighted {
  color: #8b5cf6;
}

.trans-connector {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8b5cf6;
  flex: none;
}

@media (max-width: 600px) {
  .trans-flow {
    flex-direction: column;
    align-items: stretch;
  }
  .trans-connector {
    transform: rotate(90deg);
    padding: 2px 0;
  }
}

.modal-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.modal-footer-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.modal-footer-hint kbd {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

@media (max-width: 768px) {
  .modal-backdrop {
    padding: 8px;
  }

  .modal-dialog {
    width: 100%;
    height: calc(100vh - 16px);
    max-height: calc(100vh - 16px);
    border-radius: 14px;
  }

  .modal-header {
    padding: 12px 16px 10px;
  }

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

  .modal-summary-bar {
    grid-template-columns: repeat(2, 1fr);
    padding: 8px 14px;
    gap: 8px;
  }

  .modal-summary-item .m-label {
    font-size: 9.5px;
  }

  .modal-summary-item .m-val {
    font-size: 13px;
  }

  .modal-toolbar {
    padding: 8px 14px;
    gap: 8px;
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    max-width: 100%;
    width: 100%;
  }

  .modal-toolbar-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }

  .mobile-sort-wrap {
    display: block;
  }

  /* Na visão de tabela em mobile, permite rolagem horizontal suave sem cortar conteúdo */
  .modal-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-table {
    min-width: 620px;
  }

  .modal-cards-wrap {
    padding: 10px 12px;
  }

  .modal-footer {
    padding: 10px 16px;
  }

  .modal-footer-hint {
    display: none;
  }

  .btn-primary {
    width: 100%;
    text-align: center;
    padding: 10px 20px;
  }
}

/* Empty state */
.empty-box {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-box p {
  margin: 8px 0 0;
  font-size: 14px;
}

/* Footer note */
footer.note {
  margin-top: 36px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

@media (max-width: 1024px) {
  .summary {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 860px) {
  /* Expansão de quebras e perdas em telas menores / mobile */
  .detail-inner {
    padding: 12px 14px 16px 14px;
    position: sticky;
    left: 0;
    width: var(--table-wrap-width, 100cqw);
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .dept-section {
    width: 100%;
    margin-bottom: 12px;
  }

  .dept-chips-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .dept-chip {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    padding: 10px 14px;
  }

  .dept-chip .dept-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
  }

  .dept-chip .dept-name {
    white-space: normal;
    word-break: break-word;
  }

  .dept-chip .dept-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 10px;
  }
}

@media (max-width: 860px) {
  .topbar {
    gap: 14px;
  }
  .topbar-main-row {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
  }
  .topbar-controls {
    width: 100%;
    justify-content: flex-start;
    gap: 8px;
    flex-wrap: wrap;
  }

  /* Acompanhamento das Rotinas Mobile */
  .routines-section .section-head,
  .routines-section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .routines-summary-badges {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
  }

  .routine-summary-badge {
    font-size: 11px;
    padding: 4px 8px;
  }

  .routines-cards-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 580px) {
  .topbar-main-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .user-profile-widget {
    width: 100%;
    justify-content: space-between;
  }
  .summary {
    grid-template-columns: 1fr;
  }
  .date-nav-group {
    width: 100%;
    justify-content: space-between;
  }
  .date-nav-group .date-input {
    flex: 1;
    text-align: center;
  }
  #btn-topbar-checklists {
    flex: 1;
    justify-content: center;
  }
}

/* =======================================================
   Checklists Operacionais Manuais (Rotinas Acompanhamento)
   ======================================================= */
.routines-checklists-container {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.checklist-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.checklist-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.checklist-card-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.checklist-card-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.checklist-tag-days {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 6px;
}

.checklist-progress-badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.checklist-progress-badge.all-ok {
  background: var(--good-bg);
  color: var(--good-text);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.checklist-progress-badge.has-pendente {
  background: var(--crit-bg);
  color: var(--crit-text);
  border: 1px solid rgba(227, 118, 114, 0.3);
}

.checklist-progress-badge.waiting {
  background: var(--surface-3);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.checklist-chips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.checklist-store-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: all 0.15s ease;
}

.checklist-store-chip.ok {
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.05);
}

.checklist-store-chip.pendente {
  border-color: rgba(227, 118, 114, 0.35);
  background: var(--crit-bg);
}

.checklist-store-chip.aguardando {
  border-style: dashed;
}

.chip-store-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip-status-tag {
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.chip-status-tag.ok {
  color: var(--good);
}

.chip-status-tag.pendente {
  color: var(--crit-text);
}

.chip-status-tag.aguardando {
  color: var(--text-muted);
}

/* Modal de Gestão e Apontamento */
.checklist-modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  padding: 0 16px;
  gap: 8px;
}

.checklist-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.checklist-tab-btn:hover {
  color: var(--text-primary);
}

.checklist-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--surface);
}

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

.checklist-date-nav-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.checklist-header-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.checklist-date-nav-group {
  box-shadow: none;
  background: var(--surface-2);
  border-color: var(--border);
}

.checklist-date-nav-group .btn-nav:hover {
  background: var(--surface-3);
  color: var(--text-primary);
}

.btn-checklist-today {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  box-shadow: none;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-checklist-today:hover {
  background: var(--surface-3);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-checklist-today.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.checklist-routine-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.checklist-routine-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: normal !important;
  text-transform: none !important;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  max-width: 480px;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.checklist-routine-select:hover {
  border-color: var(--border-strong);
}

.checklist-routine-select.routine-nao-cobrada {
  color: var(--crit) !important;
  border-color: var(--crit) !important;
}

.checklist-routine-select option {
  text-transform: none !important;
  letter-spacing: normal !important;
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 500;
  padding: 4px 6px;
}

.checklist-routine-select option.opt-nao-cobrado {
  color: var(--crit) !important;
  font-weight: 600;
}

[data-theme="light"] .checklist-routine-select.routine-nao-cobrada,
[data-theme="light"] .checklist-routine-select option.opt-nao-cobrado {
  color: #c23b3b !important;
}

[data-theme="dark"] .checklist-routine-select.routine-nao-cobrada,
[data-theme="dark"] .checklist-routine-select option.opt-nao-cobrado {
  color: #e37672 !important;
}

.checklist-stores-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}

.checklist-entry-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.checklist-entry-row:hover {
  border-color: var(--border-strong);
}

.checklist-entry-store {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  min-width: 140px;
}

.checklist-entry-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-point {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.btn-point:hover {
  background: var(--surface-3);
  color: var(--text-primary);
}

.btn-point.ok.active {
  background: var(--good);
  color: #fff;
  border-color: var(--good);
}

.btn-point.pendente.active {
  background: var(--crit);
  color: #fff;
  border-color: var(--crit);
}

.btn-point.clear {
  padding: 5px 8px;
  color: var(--text-muted);
}

.checklist-entry-obs {
  flex: 1;
  min-width: 180px;
}

.input-obs {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 12px;
  padding: 6px 10px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

.input-obs:focus {
  border-color: var(--accent);
  background: var(--surface);
}

/* Configuração / Cadastro */
.checklist-config-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 768px) {
  .checklist-config-layout {
    grid-template-columns: 1fr;
  }
}

.checklist-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

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

.form-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.weekdays-select-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.day-check-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.day-check-label input {
  cursor: pointer;
}

.stores-select-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  background: var(--surface-2);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.checklist-registered-list h4 {
  font-size: 13px;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.routines-list-mini {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
}

.routine-mini-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.routine-mini-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.routine-mini-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.routine-mini-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.routine-mini-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-mini-action {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 7px;
  cursor: pointer;
  color: var(--text-secondary);
}

.btn-mini-action:hover {
  background: var(--surface-3);
  color: var(--text-primary);
}

.btn-mini-action.danger:hover {
  background: var(--crit-bg);
  color: var(--crit-text);
  border-color: var(--crit);
}

/* =======================================================
   Checklist Modal - Estilos Responsivos para Celular
   ======================================================= */
.checklist-modal-dialog {
  max-width: 820px;
}

.checklist-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
}

@media (max-width: 680px) {
  #checklist-management-modal {
    padding: 6px;
  }

  .checklist-modal-dialog {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    height: calc(100vh - 12px) !important;
    max-height: calc(100vh - 12px) !important;
    border-radius: 12px;
  }

  #checklist-management-modal .modal-header {
    padding: 12px 14px 10px;
  }

  #checklist-management-modal .modal-header h3 {
    font-size: 15px;
  }

  #checklist-management-modal .modal-subtitle {
    font-size: 11.5px;
  }

  .checklist-modal-body {
    padding: 10px 10px !important;
  }

  .checklist-modal-tabs {
    padding: 0 6px;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .checklist-tab-btn {
    font-size: 11.5px;
    padding: 8px 10px;
    white-space: nowrap;
    gap: 4px;
  }

  .checklist-apontar-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
  }

  .checklist-routine-select-wrap {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  .checklist-routine-select-wrap select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    font-size: 12.5px;
    padding: 7px 8px;
  }

  .checklist-stores-grid {
    padding-right: 0;
    gap: 10px;
  }

  /* Card individual de cada loja no celular */
  .checklist-entry-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
    box-sizing: border-box;
    width: 100%;
  }

  .checklist-entry-store {
    font-size: 13.5px;
    font-weight: 700;
    min-width: 0;
    width: 100%;
  }

  .checklist-entry-actions {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .checklist-entry-actions .btn-point.ok {
    flex: 1;
    justify-content: center;
    padding: 8px 6px;
    font-size: 12px;
    white-space: nowrap;
  }

  .checklist-entry-actions .btn-point.pendente {
    flex: 1;
    justify-content: center;
    padding: 8px 6px;
    font-size: 12px;
    white-space: nowrap;
  }

  .checklist-entry-actions .btn-point.clear {
    flex: 0 0 34px;
    justify-content: center;
    padding: 8px 0;
    font-size: 14px;
  }

  .checklist-entry-obs {
    width: 100%;
    min-width: 0;
  }

  .input-obs {
    width: 100%;
    box-sizing: border-box;
    font-size: 12px;
    padding: 7px 10px;
  }

  .checklist-config-layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .stores-select-grid {
    grid-template-columns: 1fr;
  }
}

/* =======================================================
   Alternador de Modo de Visão (Diário vs Mensal) & Topbar
   ======================================================= */
.view-mode-pill-group {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
  box-shadow: var(--shadow);
}

.view-mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.view-mode-pill:hover:not(.active) {
  color: var(--text-primary);
  background: var(--surface-3);
}

.view-mode-pill.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  font-weight: 700;
}

.month-nav-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px 6px;
  box-shadow: var(--shadow);
}

.month-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 28px 5px 11px;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20' fill='none' stroke='%237c8d85' stroke-width='2.2'%3E%3Cpath d='M6 8l4 4 4-4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.month-select:hover {
  background-color: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.month-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(122, 168, 217, 0.25);
}

.month-select option,
select option {
  background-color: var(--surface-2);
  color: var(--text-primary);
  font-size: 13px;
  padding: 8px 12px;
}

:root[data-theme="dark"] .month-select option,
:root[data-theme="dark"] select option {
  background-color: #1c2622;
  color: #edf3f0;
}

:root[data-theme="light"] .month-select option,
:root[data-theme="light"] select option {
  background-color: #ffffff;
  color: #16221e;
}

/* Simetria perfeita entre pills de meta e pills de mês anterior nos cards do topo (.tile) */
.tile .pill,
.tile .pill-mom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  height: 24px;
  box-sizing: border-box;
  margin-top: 0;
  line-height: 1.25;
  white-space: nowrap;
}

.tile .pill {
  border: 1px solid transparent;
}

/* Pills de Comparativo Mês Anterior (MoM) */
.pill-mom {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  margin-top: 0;
  white-space: nowrap;
  line-height: 1.3;
}

.pill-mom.up {
  color: var(--good-text);
  background: var(--good-bg);
  border-color: rgba(34, 197, 94, 0.25);
}

.pill-mom.down {
  color: var(--crit-text);
  background: var(--crit-bg);
  border-color: rgba(239, 68, 68, 0.25);
}

/* No comparativo por loja da tabela, mantém as pílulas MoM compactas */
tbody td .pill-mom {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  height: auto;
  gap: 3px;
  border-radius: 999px;
}

/* =======================================================
   Rotinas Mensais (Matriz Calendário por Loja)
   ======================================================= */
.routines-monthly-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.routine-cal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-left: 4px solid var(--accent);
  transition: transform 0.15s, box-shadow 0.15s;
}

.routine-cal-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.routine-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.routine-cal-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.routine-cal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.routine-cal-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.routine-cal-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.routine-cal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
}

.routine-cal-table th,
.routine-cal-table td {
  padding: 6px 4px;
  border: 1px solid var(--border);
  min-width: 30px;
  max-width: 34px;
  vertical-align: middle;
}

.routine-cal-table th.col-routine-name,
.routine-cal-table td.col-routine-name {
  min-width: 160px;
  max-width: 190px;
  width: 180px;
  text-align: left;
  padding: 6px 10px;
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  border-right: 2px solid var(--border-strong);
  overflow: hidden;
  box-sizing: border-box;
}

.routine-col-name-title {
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 165px;
}

.routine-col-name-sub {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 165px;
  display: block;
  margin-top: 2px;
}

.routine-cal-table th.col-routine-name {
  background: var(--surface-3);
  font-weight: 700;
  color: var(--text-secondary);
}

.routine-cal-table .th-day {
  background: var(--surface-3);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 10px;
  line-height: 1.2;
}

.routine-cal-table .th-day.weekend {
  background: rgba(0, 0, 0, 0.04);
}

:root[data-theme="dark"] .routine-cal-table .th-day.weekend {
  background: rgba(255, 255, 255, 0.04);
}

.th-day-num {
  font-weight: 700;
  display: block;
  font-size: 12px;
  color: var(--text-primary);
}

.th-day-name {
  font-size: 9px;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Células de Status */
.cal-cell {
  font-weight: 700;
  font-size: 12px;
  cursor: default;
  transition: background 0.15s ease;
}

.cal-cell.ok {
  color: var(--good);
  background: rgba(34, 197, 94, 0.08);
}

.cal-cell.warn {
  color: var(--warn-text);
  background: rgba(234, 179, 8, 0.12);
}

.cal-cell.crit {
  color: var(--crit-text);
  background: rgba(239, 68, 68, 0.12);
}

.cal-cell.aguardando,
.cal-cell.waiting {
  color: #0284c7;
  background: rgba(14, 165, 233, 0.14);
}

:root[data-theme="dark"] .cal-cell.aguardando,
:root[data-theme="dark"] .cal-cell.waiting {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.18);
}

.cal-cell.future {
  color: var(--text-muted);
  opacity: 0.35;
}

.cal-cell.nao_aplica {
  color: var(--text-muted);
  opacity: 0.2;
}

.cal-cell.neutral {
  color: var(--text-muted);
}

.cal-cell:hover {
  filter: brightness(1.15);
}

/* =======================================================
   Parâmetros Modal (Configurar Rotinas, Lojas e Mercadológicos)
   ======================================================= */
.params-modal-dialog {
  max-width: 860px;
  width: 95%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.params-modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  flex: 1 1 auto;
}

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

.params-tab-title {
  margin: 0 0 4px 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.params-tab-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  max-width: 580px;
}

.params-bulk-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-bulk-action {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-bulk-action:hover {
  background: var(--surface-3);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.params-toggle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}

.params-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--good);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: all 0.15s ease;
}

.params-card.inactive {
  border-left-color: var(--text-muted);
  opacity: 0.65;
}

.params-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.params-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.params-card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.params-card-id {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Switch iOS Style */
.switch-btn {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}

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

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--surface-3);
  border: 1px solid var(--border);
  transition: .2s ease;
  border-radius: 22px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .2s ease;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.switch-btn input:checked + .switch-slider {
  background-color: var(--good);
  border-color: var(--good);
}

.switch-btn input:checked + .switch-slider:before {
  transform: translateX(20px);
}

@media (max-width: 680px) {
  #params-management-modal {
    padding: 6px;
  }

  .params-modal-dialog {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    height: calc(100vh - 12px) !important;
    max-height: calc(100vh - 12px) !important;
    border-radius: 12px;
  }

  .params-modal-body {
    padding: 10px 10px !important;
  }

  .params-toggle-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Modal de Comparativo Diário das Lojas Lado a Lado (Matriz KPI)
   ========================================================================== */
.modal-dialog-xl {
  max-width: 1280px;
  width: 96%;
  max-height: 92vh;
}

.kpi-matrix-tabs-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.kpi-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.kpi-tab-btn:hover {
  background: var(--surface-3);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.kpi-tab-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.kpi-tab-btn svg {
  width: 14px;
  height: 14px;
}

.kpi-matrix-summary {
  grid-template-columns: repeat(4, 1fr);
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}

.kpi-matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.kpi-matrix-table th,
.kpi-matrix-table td {
  padding: 10px 14px;
  font-size: 12.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.kpi-matrix-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  z-index: 10;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-strong);
}

.kpi-matrix-table thead th:first-child,
.kpi-matrix-table tbody td:first-child,
.kpi-matrix-table tfoot td:first-child {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 5;
  font-weight: 600;
  border-right: 1px solid var(--border);
}

.kpi-matrix-table thead th:first-child {
  z-index: 15;
  background: var(--surface-2);
}

.kpi-matrix-table thead th:last-child,
.kpi-matrix-table tbody td:last-child,
.kpi-matrix-table tfoot td:last-child {
  background: var(--surface-2);
  font-weight: 700;
  border-left: 2px solid var(--border-strong);
}

.kpi-matrix-table tbody tr:hover td {
  background-color: var(--surface-2);
}

.kpi-matrix-table tbody tr:hover td:first-child {
  background-color: var(--surface-2);
}

.kpi-matrix-table tbody tr:hover td:last-child {
  background-color: var(--surface-3);
}

.kpi-matrix-table tfoot {
  position: sticky;
  bottom: 0;
  z-index: 12;
}

.kpi-matrix-table tfoot tr.tfoot-total td {
  background: var(--surface-2);
  color: var(--text-primary);
  font-weight: 700;
  border-top: 2px solid var(--border-strong);
}

.kpi-matrix-table tfoot tr.tfoot-media td {
  background: var(--surface-3);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
}

.kpi-matrix-val.crit,
.kpi-matrix-val.below-media {
  color: var(--crit-text) !important;
  font-weight: 700;
}

.kpi-matrix-cell-sub {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

.kpi-matrix-cell-sub.crit {
  color: var(--crit-text) !important;
  font-weight: 600;
}

.kpi-matrix-cell-sub.good {
  color: var(--good-text) !important;
  font-weight: 600;
}

@media (max-width: 820px) {
  .kpi-matrix-summary {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==============================================================================
   Widget de Perfil do Usuário e Botão de Logout no Topbar
   ============================================================================== */
.user-profile-widget {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.user-avatar-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #2563eb;
  color: #ffffff;
  font-family: 'Archivo', sans-serif;
  font-weight: 700;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.user-info-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.user-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role-tag {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.user-role-tag.master {
  color: #c084fc;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(192, 132, 252, 0.4);
}

.user-role-tag.admin {
  color: #60a5fa;
  font-weight: 600;
}

.user-role-tag.gerente,
.user-role-tag.gerente-regional {
  color: #fbbf24;
  font-weight: 600;
}

[data-theme="light"] .user-role-tag.gerente,
[data-theme="light"] .user-role-tag.gerente-regional {
  color: #d97706;
}

.user-role-tag.gerente-loja {
  color: #2dd4bf;
  font-weight: 600;
}

[data-theme="light"] .user-role-tag.gerente-loja {
  color: #0f766e;
}

.user-role-tag.fiscal {
  color: #818cf8;
  font-weight: 600;
}

[data-theme="light"] .user-role-tag.fiscal {
  color: #4338ca;
}

.pill.master {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.35);
  font-weight: 700;
}

[data-theme="light"] .user-role-tag.master {
  color: #7e22ce;
  text-shadow: none;
}

[data-theme="light"] .pill.master {
  background: rgba(168, 85, 247, 0.12);
  color: #7e22ce;
  border-color: rgba(168, 85, 247, 0.3);
}

.pill.admin {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.35);
  font-weight: 700;
}

[data-theme="light"] .pill.admin {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  border-color: rgba(59, 130, 246, 0.3);
}

.pill.gerente,
.pill.gerente-regional {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
  font-weight: 700;
}

[data-theme="light"] .pill.gerente,
[data-theme="light"] .pill.gerente-regional {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
  border-color: rgba(245, 158, 11, 0.3);
}

.pill.gerente-loja {
  background: rgba(20, 184, 166, 0.15);
  color: #2dd4bf;
  border: 1px solid rgba(20, 184, 166, 0.35);
  font-weight: 700;
}

[data-theme="light"] .pill.gerente-loja {
  background: rgba(13, 148, 136, 0.12);
  color: #0f766e;
  border-color: rgba(13, 148, 136, 0.3);
}

.pill.fiscal {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.35);
  font-weight: 700;
}

[data-theme="light"] .pill.fiscal {
  background: rgba(99, 102, 241, 0.12);
  color: #4338ca;
  border-color: rgba(99, 102, 241, 0.3);
}

.pill.user,
.pill.usuario {
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-secondary);
  border: 1px solid rgba(148, 163, 184, 0.3);
  font-weight: 600;
}

[data-theme="light"] .pill.user,
[data-theme="light"] .pill.usuario {
  background: rgba(100, 116, 139, 0.1);
  color: #475569;
  border-color: rgba(100, 116, 139, 0.25);
}

/* Abas no Modal de Usuário */
.user-modal-tabs {
  display: flex;
  gap: 12px;
  border-bottom: 1px solid var(--border-soft);
  padding: 0 20px 8px 20px;
  margin-top: 6px;
}

.btn-modal-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 4px 4px 0 0;
}

.btn-modal-tab:hover {
  color: var(--text-primary);
}

.btn-modal-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* Cards do Guia de Permissões de Acesso */
.roles-guide-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0;
}

.role-guide-card {
  border: 1px solid var(--border-soft);
  background: var(--surface-secondary, rgba(255, 255, 255, 0.02));
  border-radius: 10px;
  padding: 12px 16px;
  transition: border-color 0.2s ease;
}

.role-guide-card.master {
  border-left: 3px solid #c084fc;
}

.role-guide-card.admin {
  border-left: 3px solid #60a5fa;
}

.role-guide-card.gerente {
  border-left: 3px solid #fbbf24;
}

.role-guide-card.user {
  border-left: 3px solid #94a3b8;
}

.role-guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.role-guide-tag {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.role-guide-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.role-guide-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.35;
}

.role-guide-list li .icon-check {
  color: #10b981;
  font-weight: bold;
  flex-shrink: 0;
}

.role-guide-list li .icon-cross {
  color: #ef4444;
  font-weight: bold;
  flex-shrink: 0;
}

.role-guide-list li.highlight {
  color: var(--text-primary);
  font-weight: 500;
}

.role-guide-list li.denied {
  color: var(--text-muted);
  opacity: 0.85;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  border-left: 1px solid var(--border);
  margin-left: 6px;
  transition: all 0.15s ease;
}

.btn-logout:hover {
  color: var(--crit-text);
  background: var(--crit-bg);
}

/* ==============================================================================
   Modal de Administração (Usuários & Empresas)
   ============================================================================== */
.admin-modal-body {
  padding: 20px 24px 24px;
  overflow-y: auto;
  flex: 1;
}

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

.admin-table-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.admin-user-filter-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.admin-user-filter-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.admin-user-filter-select {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  height: 32px;
  border-radius: 6px;
  min-width: 170px;
  background: var(--surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.admin-user-filter-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.admin-data-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  background: var(--surface);
}

.admin-data-table th {
  background: var(--surface-2);
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.admin-data-table td {
  padding: 11px 12px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-data-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-data-table tbody tr:hover {
  background: var(--surface-2);
}

.admin-actions-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.admin-btn-action {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 4px 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.admin-btn-action:hover {
  background: var(--surface-3);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.admin-btn-action.crit:hover {
  background: var(--crit-bg);
  color: var(--crit-text);
  border-color: rgba(239, 68, 68, 0.3);
}

.admin-company-tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  margin: 1px;
  white-space: nowrap;
}

/* ==============================================================================
   Formulários e Caixas de Entrada Harmonizadas (Modais Admin & Sistema)
   ============================================================================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 4px;
}

.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.form-control {
  width: 100%;
  height: 42px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 0 14px;
  font-size: 13.5px;
  color: var(--text-primary);
  font-family: inherit;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.form-control::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
  font-size: 13px;
}

.form-control:hover {
  border-color: var(--text-muted);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  background-color: var(--surface);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
}

/* Custom Select Dropdown Harmonizado (Garantido sem repetição de ícones) */
select.form-control {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 38px;
  cursor: pointer;
  background-color: var(--surface-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat !important;
  background-position: calc(100% - 14px) center !important;
  background-size: 14px 14px !important;
}

select.form-control:focus {
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%233b82f6' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat !important;
  background-position: calc(100% - 14px) center !important;
  background-size: 14px 14px !important;
}

/* Modal de Formulário com Cabeçalho e Rodapé Fixos (Botões Cancelar e Salvar sempre visíveis) */
.modal-dialog.modal-dialog-form {
  height: auto !important;
  max-height: min(90vh, 740px) !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.modal-form-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

.modal-form-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer.admin-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.12);
}

/* Opções do select */
select.form-control option {
  background: var(--surface);
  color: var(--text-primary);
  padding: 10px;
}

/* Grid de Seleção de Empresas Autorizadas */
.admin-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 4px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border);
  border-radius: 10px;
}

[data-theme="light"] .admin-checkbox-grid {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.admin-checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.15s ease;
}

.admin-checkbox-item:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.admin-checkbox-item:has(input:checked) {
  background: rgba(37, 99, 235, 0.14);
  border-color: var(--accent);
  color: #60a5fa;
  box-shadow: 0 0 0 1px var(--accent);
}

[data-theme="light"] .admin-checkbox-item:has(input:checked) {
  background: rgba(37, 99, 235, 0.08);
  border-color: var(--accent);
  color: var(--accent);
}

.admin-checkbox-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Checkbox Toggle para Ativo */
.admin-checkbox-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  padding: 6px 0;
}

.admin-checkbox-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  width: 17px;
  height: 17px;
  cursor: pointer;
}

/* Botões Harmonizados de Modais */
.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text-secondary);
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-secondary:hover {
  background: var(--surface-3);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-primary {
  background: #2563eb;
  color: #ffffff;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  background: #1d4ed8;
  filter: brightness(1.05);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.form-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.35;
  margin-top: 2px;
}

/* ==============================================================================
   LOGOTIPOS DA EMPRESA (MODAL ADMIN & BRAND)
   ============================================================================== */
.company-logos-form-group {
  margin-top: 6px;
  margin-bottom: 12px;
}

.company-logo-upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 480px) {
  .company-logo-upload-grid {
    grid-template-columns: 1fr;
  }
}

.company-logo-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.logo-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 22px;
}

.logo-theme-tag {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 4px;
}

.logo-theme-tag.light {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.logo-theme-tag.dark {
  background: #1e293b;
  color: #94a3b8;
  border: 1px solid #334155;
}

.btn-clear-logo {
  background: none;
  border: none;
  color: var(--crit);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  transition: opacity 0.15s ease;
}

.btn-clear-logo:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.logo-preview-box {
  height: 84px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  overflow: hidden;
  position: relative;
  transition: border-color 0.15s ease;
}

.logo-preview-box.light-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
}

.logo-preview-box.dark-box {
  background: #0b1320;
  border: 1px solid #1e293b;
}

.logo-fallback-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Archivo', sans-serif;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(36, 79, 120, 0.3);
  user-select: none;
}

.logo-img-preview {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.btn-upload-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-upload-logo:hover {
  background: var(--surface-3);
  border-color: var(--accent);
  color: var(--accent);
}

.company-logo-avatar-thumb {
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px;
  vertical-align: middle;
  margin-right: 6px;
  display: inline-block;
}

/* =======================================================
   Indicadores de Carregamento (Loading Bar & Overlay)
   ======================================================= */
.top-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #4dc191, var(--accent));
  background-size: 200% 100%;
  z-index: 99999;
  transition: width 0.25s ease, opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

.top-progress-bar.active {
  opacity: 1;
  width: 75%;
  animation: shimmerProgress 1.5s infinite linear;
}

.top-progress-bar.done {
  width: 100%;
  opacity: 0;
  transition: width 0.15s ease, opacity 0.3s ease 0.15s;
}

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

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 14, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.loading-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.loading-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 22px 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: 440px;
  width: 90%;
  animation: slideUpFade 0.25s ease-out;
}

@keyframes slideUpFade {
  from {
    transform: translateY(12px) scale(0.97);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.loading-spinner-ring {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3.5px solid var(--surface-3);
  border-top-color: var(--accent);
  border-right-color: #4dc191;
  animation: spinRing 0.8s infinite linear;
  flex-shrink: 0;
}

@keyframes spinRing {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.loading-title {
  font-family: 'Archivo', sans-serif;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.loading-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Pulsação e mini-spinner no botão quando estiver carregando */
.view-mode-pill.loading {
  opacity: 0.75;
  pointer-events: none;
}

.view-mode-pill.loading svg {
  animation: spinRing 0.9s infinite linear;
}





