/* ══════════════════════════════════════════════════════════════════════════════
   MY HUB DESK — LAYOUT ENGINE v2.0
   Single source of truth: data-attributes on <html>
     • data-theme="light|dark"
     • data-sidebar="expanded|collapsed"
   ══════════════════════════════════════════════════════════════════════════════ */

/* ─── CSS Variables (Global) ─────────────────────────────────────────────────── */
:root {
  --sidebar-width: 260px;
  --sidebar-bg: linear-gradient(to right, #0f172a, #013e40);
  --transition-speed: 0.3s;
  --transition-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-sidebar="collapsed"] {
  --sidebar-width: 80px;
}

/* ─── App Container ──────────────────────────────────────────────────────────── */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width) !important;
  min-width: var(--sidebar-width) !important;
  max-width: var(--sidebar-width) !important;
  background: var(--sidebar-bg) !important;
  color: #D1D5DB;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 20;
  overflow-x: hidden !important;
  transition: width var(--transition-speed) var(--transition-ease) !important;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  border-bottom: 1px solid #1E293B;
  flex-shrink: 0;
  height: 140px;
}

.sidebar-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: #FFFFFF;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: #D1D5DB;
  font-size: 1.2rem;
  cursor: pointer;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.5rem;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  margin-bottom: 0.25rem;
  color: #D1D5DB;
  font-weight: 500;
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  font-size: 0.875rem;
  letter-spacing: -0.01em;
  transition: all var(--transition-fast, 150ms ease-in-out);
  gap: 0.625rem;
  text-decoration: none;
}

.sidebar-nav-item:hover {
  background-color: #1F2937;
  color: #FFFFFF;
}

/* Active sidebar item glow */
.sidebar-nav-item.active {
  background: var(--gradient-brand);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.15);
}

.sidebar-nav-item .nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s ease;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid #374151;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand-footer {
  padding: 0.75rem 1.25rem;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.3);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: auto;
  word-break: break-word;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-version {
  padding: 0.4rem 1.5rem;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.25);
  letter-spacing: 0.08em;
  font-weight: 500;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
}

/* ─── Sidebar Collapse Button ────────────────────────────────────────────────── */
.sidebar-collapse-btn {
  background: none;
  border: none;
  color: #94A3B8;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover { color: #F1F5F9; background: rgba(255,255,255,0.08); }

/* ─── Sidebar SVG Icon Colors ────────────────────────────────────────────────── */
.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: block;
  transition: opacity 0.15s;
}
.sidebar-nav-item:hover .nav-icon { opacity: 1; }
.sidebar-nav-item.active .nav-icon { stroke: #FFFFFF !important; }

.sidebar-nav-item[data-page="dashboard"]     .nav-icon { stroke: #3B82F6; }
.sidebar-nav-item[data-page="tickets"]       .nav-icon { stroke: #F59E0B; }
.sidebar-nav-item[data-page="assets"]        .nav-icon { stroke: #8B5CF6; }
.sidebar-nav-item[data-page="calendar"]      .nav-icon { stroke: #06B6D4; }
.sidebar-nav-item[data-page="companies"]     .nav-icon { stroke: #10B981; }
.sidebar-nav-item[data-page="users"]         .nav-icon { stroke: #EC4899; }
.sidebar-nav-item[data-page="reports"]       .nav-icon { stroke: #EAB308; }
.sidebar-nav-item[data-page="customization"] .nav-icon { stroke: #94A3B8; }
.sidebar-nav-item[data-page="roles"]         .nav-icon { stroke: #F97316; }

/* ─── Sidebar Collapsed State ────────────────────────────────────────────────── */
[data-sidebar="collapsed"] .nav-label,
[data-sidebar="collapsed"] .sidebar-logo,
[data-sidebar="collapsed"] .sidebar-footer,
[data-sidebar="collapsed"] .sidebar-brand-footer,
[data-sidebar="collapsed"] .sidebar-version,
[data-sidebar="collapsed"] .menu-text,
[data-sidebar="collapsed"] .sidebar-footer-text,
[data-sidebar="collapsed"] .company-name-tag {
  display: none !important;
  opacity: 0 !important;
  width: 0 !important;
  overflow: hidden !important;
}

[data-sidebar="collapsed"] .sidebar-nav-item {
  justify-content: center !important;
  padding: 0.75rem 0 !important;
}

[data-sidebar="collapsed"] .sidebar-header {
  justify-content: center !important;
  padding: 0 !important;
}

/* ─── Main Content ───────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width) !important;
  width: calc(100% - var(--sidebar-width)) !important;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  transition: margin-left var(--transition-speed) var(--transition-ease),
              width var(--transition-speed) var(--transition-ease) !important;
}

/* ─── Topbar ─────────────────────────────────────────────────────────────────── */
.topbar {
  height: 64px;
  flex-shrink: 0;
  background-color: #FFFFFF;
  box-shadow: 0 1px 0 #E5E7EB;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 10;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* ─── Relógio do cabeçalho ───────────────────────────────────────────────────── */
#topbar-clock {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  --clock-bg: #F8FAFC;
  --clock-border: #E2E8F0;
  --clock-text: #0F172A;
  --clock-muted: #64748B;
  --clock-track: #E2E8F0;
}
.jd-clock {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  height: 38px;
  padding: 0 0.95rem 0 0.55rem;
  border-radius: 999px;
  background: var(--clock-bg);
  border: 1px solid var(--clock-border);
  color: var(--clock-text);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  cursor: default;
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.jd-clock[href] { cursor: pointer; }
.jd-clock:hover, .jd-clock:visited, .jd-clock:active { color: var(--clock-text); text-decoration: none; }
/* contorno com o degradê da marca ao passar o mouse */
.jd-clock::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: var(--gradient-brand, linear-gradient(135deg, #8761f6, #377cec, #40c891, #33b7b1, #3495d3));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
#topbar-clock:hover .jd-clock, .jd-clock:focus-visible { box-shadow: 0 6px 18px rgba(55, 124, 236, 0.16); transform: translateY(-1px); outline: none; }
#topbar-clock:hover .jd-clock::before, .jd-clock:focus-visible::before { opacity: 1; }
/* anel dos segundos */
.jd-clock-ring {
  --p: 0;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  background: conic-gradient(#8761f6 0deg, #377cec calc(var(--p) * 180deg), #40c891 calc(var(--p) * 360deg), var(--clock-track) 0);
  display: grid;
  place-items: center;
}
.jd-clock-ring > span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--clock-bg);
  position: relative;
}
.jd-clock-ring > span::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: linear-gradient(135deg, #377cec, #40c891);
}
.jd-clock-ring.jd-clock-beat > span::after { animation: jdClockBeat 0.9s ease-out; }
@keyframes jdClockBeat { 0% { transform: scale(1); } 35% { transform: scale(1.7); } 100% { transform: scale(1); } }
.jd-clock-time b { font-size: 0.98rem; font-weight: 800; letter-spacing: 0.01em; }
.jd-clock-ss { font-size: 0.78rem; font-weight: 600; color: var(--clock-muted); margin-left: 1px; }
.jd-clock-ap { font-size: 0.72rem; font-weight: 700; color: var(--clock-muted); }
.jd-clock-div { width: 1px; height: 16px; background: var(--clock-border); }
.jd-clock-date { font-size: 0.82rem; font-weight: 600; color: var(--clock-muted); }
/* cartão ao passar o mouse */
.jd-clock-pop {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  width: max-content;
  min-width: 250px;
  max-width: 340px;
  padding: 0.85rem 1.1rem 0.8rem;
  border-radius: 14px;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -6px);
  /* ao sair, espera um instante antes de fechar: dá tempo de levar o mouse da hora até o cartão */
  transition: opacity 0.18s ease 0.12s, transform 0.18s ease 0.12s, visibility 0s linear 0.3s;
}
/* ponte invisível no espaço entre a hora e o cartão: o mouse passa por ela sem o cartão fechar */
.jd-clock-pop::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: -14px;
  height: 14px;
}
.jd-clock-pop::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  border-radius: 14px 14px 0 0;
  background: var(--gradient-brand, linear-gradient(135deg, #8761f6, #377cec, #40c891, #33b7b1, #3495d3));
}
#topbar-clock:hover .jd-clock-pop, .jd-clock:focus-visible + .jd-clock-pop {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition-delay: 0.15s, 0.15s, 0s;
}
.jd-clock-pop-day { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; background: linear-gradient(90deg, #377cec, #40c891); -webkit-background-clip: text; background-clip: text; color: transparent; }
.jd-clock-pop-date { font-size: 1.05rem; font-weight: 800; color: #0F172A; margin: 0.2rem 0 0.55rem; }
.jd-clock-pop-meta { font-size: 0.78rem; color: #64748B; line-height: 1.5; }
.jd-clock-pop-cta { margin-top: 0.55rem; padding-top: 0.5rem; border-top: 1px dashed #E2E8F0; font-size: 0.78rem; font-weight: 700; color: #377cec; }
.jd-clock-pop-cta[hidden] { display: none; }
.jd-clock-pop-cta:not([hidden]) { cursor: pointer; }
.jd-clock-pop-cta:not([hidden]):hover { text-decoration: underline; }
[data-theme="dark"] #topbar-clock { --clock-bg: #0F172A; --clock-border: #334155; --clock-text: #F1F5F9; --clock-muted: #94A3B8; --clock-track: #334155; }
[data-theme="dark"] .jd-clock-pop { background: #0F172A; border-color: #334155; box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45); }
[data-theme="dark"] .jd-clock-pop-date { color: #F1F5F9; }
[data-theme="dark"] .jd-clock-pop-meta { color: #94A3B8; }
[data-theme="dark"] .jd-clock-pop-cta { border-color: #334155; color: #60A5FA; }
/* telas médias: só a hora (o título da página precisa de espaço) */
@media (max-width: 1180px) {
  .jd-clock-div, .jd-clock-date, .jd-clock-ss { display: none; }
  .jd-clock { padding-right: 0.8rem; gap: 0.45rem; }
}
@media (prefers-reduced-motion: reduce) {
  .jd-clock, .jd-clock-pop, .jd-clock::before { transition: none; }
  .jd-clock-ring.jd-clock-beat > span::after { animation: none; }
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  letter-spacing: -0.02em;
}

.topbar-user-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.375rem;
  transition: background-color var(--transition-fast, 150ms ease-in-out);
}
.topbar-user-btn:hover {
  background-color: var(--color-surface);
}

/* ─── Theme Toggle Button ────────────────────────────────────────────────────── */
#theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid #CBD5E1;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--color-text-secondary, #6B7280);
}
#theme-toggle-btn:hover {
  background-color: var(--color-surface, #F3F4F6);
  border-color: var(--color-primary, #1E40AF);
}

/* ─── Mobile Menu Toggle ─────────────────────────────────────────────────────── */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  height: 18px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.menu-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background-color: var(--color-text-primary, #111827);
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* ─── Page Content ───────────────────────────────────────────────────────────── */
.page-content {
  flex: 1;
  overflow-y: scroll;
  padding: 2rem;
  background-color: var(--color-bg);
  transition: background-color 0.3s ease;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ─── Period Tabs (Reports) ──────────────────────────────────────────────────── */
.period-tab {
  padding: 0.375rem 0.875rem;
  border: 1px solid #D1D5DB;
  border-radius: 0.375rem;
  background: #F9FAFB;
  color: #374151;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.period-tab:hover {
  background: #E5E7EB;
  color: #111827;
}
.period-tab.active {
  background: #1E3A8A;
  color: #FFFFFF !important;
  border-color: #1E3A8A;
  box-shadow: 0 2px 6px rgba(30,58,138,0.3);
}

/* ─── Corporate Typography ───────────────────────────────────────────────────── */
body, input, textarea, select, button {
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
  letter-spacing: -0.01em;
}

/* ─── Mobile Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close {
    display: block;
  }
  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }
  .menu-toggle {
    display: flex;
  }
  .topbar {
    padding: 0 1rem;
  }
  .page-content {
    padding: 1rem;
  }
}

/* ══════════════════════════════════════════════════════════════════════════════
   DARK MODE — [data-theme="dark"] on <html>
   ══════════════════════════════════════════════════════════════════════════════ */

/* Base surfaces */
[data-theme="dark"],
[data-theme="dark"] body {
  background-color: #0F172A !important;
  color: #F8FAFC !important;
}

[data-theme="dark"] .page-content {
  background-color: #0F172A !important;
}

/* Cards & containers */
[data-theme="dark"] .card,
[data-theme="dark"] .dashboard-card,
[data-theme="dark"] .reports-kpi-card,
[data-theme="dark"] .kpi-card {
  background-color: #1E293B !important;
  border-color: #334155 !important;
  color: #F8FAFC !important;
}
[data-theme="dark"] .kpi-card h3 { color: #94A3B8 !important; }
[data-theme="dark"] .kpi-value { color: #F8FAFC !important; }
[data-theme="dark"] .reports-kpi-card { box-shadow: none !important; }
[data-theme="dark"] .reports-kpi-card .kpi-label,
[data-theme="dark"] .reports-kpi-card .kpi-sub { color: #94A3B8 !important; }
[data-theme="dark"] .reports-kpi-card .kpi-number { color: #F8FAFC !important; }

/* Topbar */
[data-theme="dark"] .topbar {
  background-color: #1E293B !important;
  box-shadow: 0 1px 0 #334155 !important;
}
[data-theme="dark"] .topbar-title { color: #F8FAFC !important; }
[data-theme="dark"] .topbar-user-btn { color: #F8FAFC !important; }
[data-theme="dark"] .topbar-user-btn:hover { background: rgba(255,255,255,0.08) !important; }

/* Theme toggle in dark */
[data-theme="dark"] #theme-toggle-btn {
  border-color: #475569 !important;
  color: #F1F5F9 !important;
}
[data-theme="dark"] #theme-toggle-btn:hover { background: rgba(255,255,255,0.08) !important; }

/* Sidebar collapse button in dark */
[data-theme="dark"] .sidebar-collapse-btn { color: #64748B !important; }
[data-theme="dark"] .sidebar-collapse-btn:hover { color: #F1F5F9 !important; background: rgba(255,255,255,0.08) !important; }

/* Tables */
[data-theme="dark"] .table thead th {
  background-color: #0F172A !important;
  color: #94A3B8 !important;
  border-bottom-color: #334155 !important;
}
[data-theme="dark"] .table tbody tr { border-bottom-color: #334155 !important; }
[data-theme="dark"] .table tbody td { color: #F1F5F9 !important; }
[data-theme="dark"] .table-row:hover { background-color: rgba(255,255,255,0.04) !important; }
[data-theme="dark"] .table-responsive { background-color: #1E293B !important; }
[data-theme="dark"] .table-container { background-color: #1E293B !important; border-color: #334155 !important; }

/* Forms */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background-color: #0F172A !important;
  border-color: #475569 !important;
  color: #F1F5F9 !important;
}
[data-theme="dark"] .form-control::placeholder,
[data-theme="dark"] textarea::placeholder { color: #475569 !important; }
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  border-color: #60A5FA !important;
  box-shadow: 0 0 0 3px rgba(96,165,250,0.18) !important;
}
[data-theme="dark"] .form-label,
[data-theme="dark"] .form-group label { color: #CBD5E1 !important; }
[data-theme="dark"] input[type="date"] { color-scheme: dark; }

/* Modals */
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,0.75) !important; }
[data-theme="dark"] .modal,
[data-theme="dark"] .modal-content {
  background-color: #1E293B !important;
  border: 1px solid #334155 !important;
  color: #F8FAFC !important;
}

/* Dropdowns */
[data-theme="dark"] .dropdown-menu {
  background-color: #1E293B !important;
  border: 1px solid #334155 !important;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4) !important;
}
[data-theme="dark"] .dropdown-item { color: #F1F5F9 !important; }
[data-theme="dark"] .dropdown-item:hover { background: rgba(255,255,255,0.08) !important; }

/* Buttons */
[data-theme="dark"] .btn-secondary {
  background: #334155 !important;
  color: #F1F5F9 !important;
  border-color: #475569 !important;
}
[data-theme="dark"] .btn-secondary:hover { background: #475569 !important; }

/* Typography */
[data-theme="dark"] h1, [data-theme="dark"] h2,
[data-theme="dark"] h3, [data-theme="dark"] h4 { color: #F8FAFC !important; }
[data-theme="dark"] p { color: #CBD5E1 !important; }
[data-theme="dark"] label { color: #CBD5E1 !important; }
[data-theme="dark"] td, [data-theme="dark"] th { color: #F1F5F9 !important; }
[data-theme="dark"] .text-secondary { color: #94A3B8 !important; }
[data-theme="dark"] .text-muted { color: #64748B !important; }
[data-theme="dark"] .meta-label { color: #94A3B8 !important; }
[data-theme="dark"] .meta-value { color: #F1F5F9 !important; }

/* Chat / Reply */
[data-theme="dark"] .chat-bubble-left {
  background: #1E293B !important;
  border-color: #334155 !important;
  color: #F1F5F9 !important;
}
[data-theme="dark"] .reply-box { background-color: #1E293B !important; border-color: #334155 !important; }
[data-theme="dark"] .reply-file-chip { background: #334155 !important; border-color: #475569 !important; color: #F1F5F9 !important; }

/* Period tabs dark */
[data-theme="dark"] .period-tab {
  background: #334155 !important;
  color: #CBD5E1 !important;
  border-color: #475569 !important;
}
[data-theme="dark"] .period-tab:hover { background: #475569 !important; color: #F1F5F9 !important; }
[data-theme="dark"] .period-tab.active {
  background: #1E3A8A !important;
  color: #FFFFFF !important;
  border-color: #1E3A8A !important;
}

/* Custom field cards */
[data-theme="dark"] .custom-field-card,
[data-theme="dark"] .field-type-badge {
  background: #0F172A !important;
  color: #94A3B8 !important;
  border-color: #334155 !important;
}

/* Inline style overrides (force override bg-white in any context) */
[data-theme="dark"] .bg-white,
[data-theme="dark"] .content-wrapper,
[data-theme="dark"] .main-content {
  background-color: #0F172A !important;
  color: #F8FAFC !important;
}
[data-theme="dark"] div[style*="background:#fff"],
[data-theme="dark"] div[style*="background: #fff"],
[data-theme="dark"] div[style*="background:white"],
[data-theme="dark"] div[style*="background: white"] {
  background-color: #1E293B !important;
  color: #F8FAFC !important;
}
[data-theme="dark"] div[style*="background:#F9FAFB"],
[data-theme="dark"] div[style*="background: #F9FAFB"] {
  background-color: #0F172A !important;
  color: #F1F5F9 !important;
}
[data-theme="dark"] p[style*="color:#374151"],
[data-theme="dark"] div[style*="color:#374151"],
[data-theme="dark"] span[style*="color:#374151"] { color: #CBD5E1 !important; }
[data-theme="dark"] p[style*="color:#6B7280"],
[data-theme="dark"] span[style*="color:#6B7280"] { color: #94A3B8 !important; }
[data-theme="dark"] h3[style*="color:#111827"],
[data-theme="dark"] h4[style*="color:#374151"],
[data-theme="dark"] div[style*="color:#111827"] { color: #F8FAFC !important; }

/* Badges stay colored */
[data-theme="dark"] .badge { filter: brightness(0.9); }

/* Avatar */
[data-theme="dark"] .avatar { border-color: #475569 !important; }


/* ══════════════════════════════════════════════════════════════════════════════
   RESPONSIVO — celular e tablet (auditoria 03/11/2026)
   ══════════════════════════════════════════════════════════════════════════════ */
[data-theme="dark"] .menu-toggle span { background-color: #F8FAFC; }
.menu-toggle { min-width: 24px; }

@media (max-width: 768px) {
  /* ☰ com área de toque maior */
  .menu-toggle { width: 40px; height: 40px; padding: 11px 8px; margin-left: -8px; box-sizing: border-box; }
  /* relógio central sobrepunha o título no celular */
  #topbar-clock { display: none !important; }
  .topbar-left { min-width: 0; flex: 1; gap: 0.75rem; }
  .topbar-title { font-size: 1.05rem !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  body.sidebar-mobile-open { overflow: hidden; }
  .sidebar { z-index: 1100; }
  .sidebar-overlay.active { z-index: 1090; }

  /* tabelas largas rolam dentro do card, nunca a página */
  .table-container, .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { max-width: none; }

  /* modais ocupam a largura disponível */
  .modal, .modal-content, .modal-dialog { width: calc(100vw - 2rem) !important; max-width: calc(100vw - 2rem) !important; max-height: calc(100vh - 2rem); overflow-y: auto; }

  /* formulários e botões em linha quebram linha */
  .tickets-filter-bar { flex-wrap: wrap; }
  .tickets-filter-bar > * { min-width: 0 !important; flex: 1 1 100%; }
  .tickets-filter-bar select, .tickets-filter-bar input { width: 100% !important; }
  .tickets-filter-bar > div { width: 100%; }
  .kanban-toolbar-left { width: 100%; }
  .kanban-toolbar-left > select, .kanban-toolbar-left > .form-control { flex: 1 1 140px; width: auto !important; min-width: 0; }
}

/* Detalhe do chamado: conversa e detalhes empilhados em telas estreitas */
@media (max-width: 900px) {
  .td-page { height: auto !important; overflow: visible !important; padding: 1rem !important; }
  .td-cols { flex-direction: column !important; }
  .td-side { width: 100% !important; }
  .td-cols #timeline { max-height: 60vh; min-height: 240px; }
}

@media (max-width: 480px) {
  .page-content { padding: 0.75rem !important; }
  .topbar-right .user-name-display { display: none; }
}

/* Aviso de fatura em atraso (Administrador, ao entrar) */
.jd-overdue { z-index: 1200; }
.jd-overdue-box { max-width: 440px; text-align: center; padding: 1.75rem 1.75rem 1.5rem; border-radius: 16px; }
.jd-overdue-ico { width: 52px; height: 52px; margin: 0 auto 0.9rem; border-radius: 50%; background: #FEF3C7; color: #B45309; font-size: 1.6rem; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.jd-overdue-box h3 { margin: 0 0 0.5rem; font-size: 1.15rem; font-weight: 700; }
.jd-overdue-box p { margin: 0 0 1.25rem; color: var(--color-text-secondary); font-size: 0.92rem; line-height: 1.5; }
.jd-overdue-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.jd-overdue-actions .btn { min-width: 150px; }
[data-theme="dark"] .jd-overdue-box { background: #1E293B; }
[data-theme="dark"] .jd-overdue-ico { background: rgba(245, 158, 11, .18); color: #FBBF24; }

/* Modo minimizado da reunião (rodada 12): a página roda num quadro ao lado da coluna da reunião — menu só com ícones */
[data-in-meeting] #sidebar-toggle-btn { display: none !important; }

/* App Android (rodada 20b): o app tem o próprio cabeçalho, menu e avisos — a página mostra só o conteúdo */
[data-in-app] .sidebar, [data-in-app] .sidebar-overlay, [data-in-app] .topbar { display: none !important; }
[data-in-app] .main-content { margin-left: 0 !important; width: 100% !important; max-width: 100% !important; }
[data-in-app] .page-content { padding-top: 0.85rem !important; }

/* rodada 16: logo do menu "congelada" — o mesmo tamanho em todas as páginas e telas */
.sidebar-header .sidebar-logo {
  display: block;
  flex: 0 0 auto;
  width: 184px !important;
  height: 96px !important;
  max-width: 184px !important;
  max-height: 96px !important;
  object-fit: contain;
  object-position: left center;
}

/* rodada 21: seletor de espaço (empresa conectada), no topo do menu lateral, e a faixa "espaço de suporte" */
.jd-space { margin: 0 0 .75rem; padding-bottom: .75rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.jd-space-btn { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .55rem .75rem; border-radius: .6rem; border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.05); color: #F1F5F9; font: inherit; cursor: pointer; text-align: left; }
.jd-space-btn:hover { background: rgba(255,255,255,.1); }
.jd-space-btn:focus-visible, .jd-space-item:focus-visible { outline: 2px solid #60A5FA; outline-offset: 2px; }
.jd-space-ico { font-size: 1.05rem; flex-shrink: 0; }
.jd-space-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.jd-space-txt strong { font-size: .84rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jd-space-txt small { font-size: .68rem; color: #94A3B8; }
.jd-space-caret { color: #94A3B8; }
.jd-space-list { margin-top: .35rem; display: grid; gap: .2rem; }
.jd-space-item { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .75rem; border: 0; border-radius: .5rem; background: none; color: #D1D5DB;
  font: inherit; text-align: left; cursor: pointer; }
.jd-space-item:hover { background: #1F2937; color: #fff; }
.jd-space-item.is-current { background: rgba(96,165,250,.14); color: #fff; }
[data-sidebar="collapsed"] .jd-space-btn { justify-content: center; padding: .55rem; }
[data-sidebar="collapsed"] .jd-space-list .jd-space-txt { display: none; }
.jd-space-banner { display: flex; align-items: center; justify-content: center; gap: .75rem; flex-wrap: wrap; padding: .5rem 1rem;
  background: linear-gradient(90deg, #0EA5E9, #377CEC); color: #fff; font-size: .85rem; }
.jd-space-back { border: 1px solid rgba(255,255,255,.7); background: rgba(255,255,255,.14); color: #fff; border-radius: 999px; padding: .2rem .8rem;
  font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; }
.jd-space-back:hover { background: rgba(255,255,255,.25); }
.jd-space-back:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
/* rodada 21: limite de chamados do mês (plano Starter) */
.jd-quota { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; padding: .75rem 1rem; border-radius: .75rem;
  background: #FFFBEB; border: 1px solid #FDE68A; color: #78350F; }
.jd-quota.is-full { background: #FEF2F2; border-color: #FECACA; color: #7F1D1D; }
.jd-quota-txt { flex: 1 1 260px; display: flex; flex-direction: column; gap: .15rem; font-size: .85rem; }
.jd-quota-bar { flex: 0 1 160px; height: 8px; border-radius: 999px; background: rgba(0,0,0,.08); overflow: hidden; }
.jd-quota-bar i { display: block; height: 100%; background: #F59E0B; border-radius: inherit; }
.jd-quota.is-full .jd-quota-bar i { background: #EF4444; }
[data-theme="dark"] .jd-quota { background: rgba(245,158,11,.1); border-color: #92400E; color: #FDE68A; }
[data-theme="dark"] .jd-quota.is-full { background: rgba(239,68,68,.1); border-color: #991B1B; color: #FECACA; }

/* rodada 22: alternância Chamados internos / empresa que atende (Chamados e Novo chamado) */
.jd-space-toggle { display: flex; align-items: center; gap: .6rem 1rem; flex-wrap: wrap; margin-bottom: 1rem; padding: .7rem .9rem; border: 1px solid #BFDBFE; background: #F5F9FF; border-radius: 12px; }
.jd-st-label { font-size: .82rem; font-weight: 800; color: #1E3A8A; }
.jd-st-seg { display: inline-flex; padding: 3px; border-radius: 10px; background: #E2E8F0; gap: 3px; flex-wrap: wrap; }
.jd-st-opt { display: inline-flex; align-items: center; gap: .4rem; border: 0; background: transparent; padding: .45rem .85rem; border-radius: 8px; font: inherit; font-size: .85rem; font-weight: 700; color: #334155; cursor: pointer; }
.jd-st-opt:hover:not(.is-on) { background: rgba(255, 255, 255, .6); }
.jd-st-opt.is-on { background: #fff; color: var(--color-primary); box-shadow: 0 1px 3px rgba(15, 23, 42, .15); }
.jd-st-opt:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.jd-st-hint { font-size: .78rem; color: #475569; flex-basis: 100%; }
@media (min-width: 900px) { .jd-st-hint { flex-basis: auto; } }
[data-theme="dark"] .jd-space-toggle { background: rgba(37, 99, 235, .1); border-color: rgba(147, 197, 253, .3); }
[data-theme="dark"] .jd-st-label { color: #BFDBFE; }
[data-theme="dark"] .jd-st-seg { background: #0F172A; }
[data-theme="dark"] .jd-st-opt { color: #CBD5E1; }
[data-theme="dark"] .jd-st-opt.is-on { background: #1E293B; color: #93C5FD; }
[data-theme="dark"] .jd-st-hint { color: #94A3B8; }
