/* ===== LK RASTREANDO – ESTILOS COMPLETOS + RESPONSIVIDADE ===== */

/* ─── SPINNERS ─── */
@keyframes lk-spin { to { transform: rotate(360deg); } }
.lk-spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: lk-spin .8s linear infinite;
  margin: 40px auto;
}
.lk-spinner-sm {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: lk-spin .6s linear infinite;
  vertical-align: middle;
}

/* ─── VARIÁVEIS ─── */
:root {
  --primary:        #32c5d2;
  --primary-dark:   #26a0ab;
  --primary-light:  #e8f8f9;
  --sidebar-bg:     #2b3643;
  --sidebar-hover:  #374857;
  --sidebar-active: #1a242f;
  --sidebar-text:   #a6b0c0;
  --sidebar-active-text: #ffffff;
  --header-bg:      #2b3643;
  --body-bg:        #f1f3fa;
  --card-bg:        #ffffff;
  --border:         #e5e9ef;
  --text:           #3d4a5c;
  --text-muted:     #8899a6;
  --danger:         #e7505a;
  --warning:        #f4d03f;
  --success:        #27ae60;
  --purple:         #8e44ad;
  --sidebar-w:      235px;
  --sidebar-w-col:  56px;
  --header-h:       56px;
  --radius:         10px;
  --shadow:         0 2px 8px rgba(0,0,0,0.06);
  --shadow-md:      0 6px 24px rgba(0,0,0,0.10);
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
  background: var(--body-bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }
.hidden { display: none !important; }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c9c9c9; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #999; }

/* ════════════════════════════════════════
   LOGIN
════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(135deg, #1a242f 0%, #2b3643 55%, #32c5d2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-box {
  background: white;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.35);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .brand { font-size: 28px; font-weight: 800; color: var(--primary); letter-spacing: -1px; }
.login-logo .brand span { color: var(--sidebar-bg); }
.login-logo p { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.login-box h4 { color: var(--text); font-size: 17px; font-weight: 700; margin-bottom: 20px; }
.login-box .form-control {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}
.login-box .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(50,197,210,0.18);
}
.btn-login {
  background: var(--primary);
  border: none;
  color: white;
  font-weight: 700;
  padding: 13px;
  border-radius: 8px;
  font-size: 15px;
  width: 100%;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-login:hover { background: var(--primary-dark); }
.btn-login:active { opacity: 0.85; }
.login-error { color: var(--danger); font-size: 12px; margin-top: 8px; }
.login-footer { text-align: center; margin-top: 24px; color: var(--text-muted); font-size: 11px; }

/* ════════════════════════════════════════
   HEADER
════════════════════════════════════════ */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--header-bg);
  display: flex;
  align-items: center;
  z-index: 1100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  padding: 0 8px 0 0;
}
.header-logo {
  width: var(--sidebar-w);
  display: flex;
  align-items: center;
  padding: 0 16px;
  flex-shrink: 0;
  min-width: 0;
  gap: 10px;
}
.header-logo .brand-name {
  color: white;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.5px;
  white-space: nowrap;
}
.header-logo .brand-name span { color: var(--primary); }
.sidebar-toggle {
  background: none;
  border: none;
  color: #8899a6;
  font-size: 18px;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  flex-shrink: 0;
}
.sidebar-toggle:hover { color: white; background: rgba(255,255,255,0.1); }
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 8px;
}
.header-icon-btn {
  position: relative;
  background: none;
  border: none;
  color: #8899a6;
  font-size: 16px;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.header-icon-btn:hover { color: white; background: rgba(255,255,255,0.08); }
.header-badge {
  position: absolute;
  top: 4px; right: 4px;
  background: var(--danger);
  color: white;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  pointer-events: none;
}
.header-clock {
  color: #8899a6;
  font-size: 11px;
  padding: 0 8px;
  font-family: 'Courier New', monospace;
  white-space: nowrap;
}
.header-user {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.2s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.header-user:hover { background: rgba(255,255,255,0.08); }
.header-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.header-user .uname {
  color: #d0d6e0;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* Dropdown usuário */
.user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: white;
  border-radius: 10px;
  box-shadow: 0 10px 36px rgba(0,0,0,0.18);
  min-width: 190px;
  padding: 8px 0;
  display: none;
  z-index: 2200;
}
.user-dropdown.show { display: block; }
.user-dropdown a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text);
  font-size: 13px;
  transition: background 0.15s;
}
.user-dropdown a:hover { background: #f5f7fa; }
.user-dropdown a i { width: 16px; color: var(--text-muted); }
.user-dropdown .divider { border-top: 1px solid var(--border); margin: 4px 0; }

/* Dropdown notificações */
.notif-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: white;
  border-radius: 10px;
  box-shadow: 0 10px 36px rgba(0,0,0,0.18);
  width: 320px;
  display: none;
  z-index: 2200;
}
.notif-dropdown.show { display: block; }
.notif-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.notif-list { max-height: 300px; overflow-y: auto; }
.notif-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #f5f7fa;
  cursor: pointer;
  transition: background 0.15s;
}
.notif-item:hover { background: #f8f9fb; }
.notif-item.unread { background: #f0fbfc; }
.notif-item .notif-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}
.notif-icon.danger { background: #fde8e9; color: var(--danger); }
.notif-icon.warning { background: #fef9e7; color: #f39c12; }
.notif-icon.info { background: var(--primary-light); color: var(--primary); }
.notif-text { font-size: 12px; color: var(--text); line-height: 1.4; }
.notif-text strong { font-size: 12.5px; }
.notif-time { color: var(--text-muted); font-size: 11px; margin-top: 3px; }

/* ════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  height: calc(100dvh - var(--header-h));
  background: var(--sidebar-bg);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1050;
  transition: width 0.25s ease, transform 0.28s ease;
  -webkit-overflow-scrolling: touch;
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); }

/* Collapsed (desktop) */
.sidebar.collapsed { width: var(--sidebar-w-col); }

/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1040;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* Sidebar menu */
.sidebar-menu { list-style: none; padding: 8px 0; }
.sidebar-item { position: relative; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.sidebar-link:hover { background: var(--sidebar-hover); color: white; }
.sidebar-link.active { background: var(--sidebar-active); color: white; border-left: 3px solid var(--primary); }
.sidebar-link i {
  width: 18px;
  font-size: 14px;
  flex-shrink: 0;
  text-align: center;
}
.sidebar-link .link-text { font-size: 12.5px; font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sidebar-link .arrow { font-size: 10px; transition: transform 0.2s; margin-left: auto; flex-shrink: 0; }
.sidebar-link.open .arrow { transform: rotate(90deg); }
.sidebar-link .badge-new {
  background: var(--danger);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Submenu */
.sidebar-submenu { list-style: none; background: var(--sidebar-active); display: none; }
.sidebar-submenu.open { display: block; }
.sidebar-submenu li a {
  display: block;
  padding: 8px 18px 8px 48px;
  color: var(--sidebar-text);
  font-size: 12px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-submenu li a:hover { color: white; background: rgba(255,255,255,0.04); }
.sidebar-submenu li a.active { color: var(--primary); }

/* Collapsed sidebar */
.sidebar.collapsed .link-text,
.sidebar.collapsed .arrow,
.sidebar.collapsed .badge-new { display: none; }
.sidebar.collapsed .sidebar-submenu { display: none !important; }
.sidebar.collapsed .sidebar-link { padding: 13px; justify-content: center; gap: 0; }
.sidebar.collapsed .sidebar-link i { margin: 0; width: auto; }

/* ════════════════════════════════════════
   MAIN CONTENT
════════════════════════════════════════ */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  padding: 20px;
  min-height: calc(100vh - var(--header-h));
  min-height: calc(100dvh - var(--header-h));
  transition: margin-left 0.25s ease;
  overflow-x: hidden;
}
.main-content.expanded { margin-left: var(--sidebar-w-col); }

/* Page title */
.page-title {
  font-size: 20px;
  font-weight: 700;
  color: #3d4a5c;
  margin-bottom: 18px;
}

/* ════════════════════════════════════════
   STAT CARDS
════════════════════════════════════════ */
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card:active { transform: translateY(0); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
  flex-shrink: 0;
}
.stat-icon.blue   { background: linear-gradient(135deg,#36a2eb,#1e6fcf); }
.stat-icon.red    { background: linear-gradient(135deg,#e7505a,#c0392b); }
.stat-icon.green  { background: linear-gradient(135deg,#36c6d3,#26a0ab); }
.stat-icon.purple { background: linear-gradient(135deg,#9b59b6,#7d3c98); }
.stat-icon.orange { background: linear-gradient(135deg,#f39c12,#d68910); }
.stat-icon.teal   { background: linear-gradient(135deg,#1abc9c,#148f77); }
.stat-info .stat-num {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-info .stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* ════════════════════════════════════════
   PORTLET (CARD)
════════════════════════════════════════ */
.portlet {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}
.portlet-header {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.portlet-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #5b9bd5;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.portlet-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.btn-tool {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 7px;
  border-radius: 4px;
  font-size: 13px;
  transition: color 0.2s;
}
.btn-tool:hover { color: var(--text); }
.portlet-body { padding: 18px; }
.portlet-body.no-pad { padding: 0; }

/* Portlet tabs */
.portlet-tabs { display: flex; border-bottom: 2px solid var(--border); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.portlet-tab {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.portlet-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ════════════════════════════════════════
   PIE STATUS CHARTS
════════════════════════════════════════ */
.pie-stat-row {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px;
}
.pie-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 110px;
}
.pie-canvas-wrap { position: relative; width: 88px; height: 88px; }
.pie-canvas-wrap canvas { width: 88px !important; height: 88px !important; }
.pie-label-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  pointer-events: none;
}
.pie-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
}

/* ════════════════════════════════════════
   FEEDS / LISTS
════════════════════════════════════════ */
.feeds-list { list-style: none; }
.feed-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f5f7fa;
}
.feed-item:last-child { border-bottom: none; }
.feed-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}
.feed-icon.success { background: #e8f9f0; color: var(--success); }
.feed-icon.danger  { background: #fde8e9; color: var(--danger); }
.feed-icon.warning { background: #fef9e7; color: #f39c12; }
.feed-icon.info    { background: var(--primary-light); color: var(--primary); }
.feed-info { flex: 1; min-width: 0; }
.feed-info .feed-title {
  font-size: 12.5px;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.feed-info .feed-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }

/* ════════════════════════════════════════
   TABLES – scrollable no mobile
════════════════════════════════════════ */
.table-responsive-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 500px;
}
.data-table th {
  background: #f8f9fb;
  padding: 10px 14px;
  text-align: left;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f2f4f7;
  color: var(--text);
}
.data-table tr:hover td { background: #f8fafe; }
.data-table .actions { display: flex; gap: 4px; }

/* Portlet body com tabela */
.portlet-body.no-pad .data-table { min-width: 0; }
.portlet-body.no-pad { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ════════════════════════════════════════
   BADGES / STATUS
════════════════════════════════════════ */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-status.online      { background: #e8f9f0; color: var(--success); }
.badge-status.offline     { background: #fde8e9; color: var(--danger); }
.badge-status.warning     { background: #fef9e7; color: #f39c12; }
.badge-status.aberto      { background: #e8f3fc; color: #2980b9; }
.badge-status.finalizado  { background: #e8f9f0; color: var(--success); }
.badge-status.cancelado   { background: #fde8e9; color: var(--danger); }
.badge-status.pendente    { background: #fef9e7; color: #f39c12; }
.badge-status.info        { background: var(--primary-light); color: var(--primary); }
.badge-status.instalado   { background: #e8f9f0; color: var(--success); }
.badge-status.estoque     { background: #f1f3fa; color: var(--text-muted); }
.badge-status.manutenção  { background: #fef9e7; color: #f39c12; }
.badge-status.ativo       { background: #e8f9f0; color: var(--success); }
.badge-status.inativo     { background: #fde8e9; color: var(--danger); }
.badge-status.em-analise  { background: #fef9e7; color: #f39c12; }
.badge-status.resolvido   { background: #e8f9f0; color: var(--success); }
.badge-status.em-andamento{ background: var(--primary-light); color: var(--primary); }
.badge-status.aprovado    { background: #e8f9f0; color: var(--success); }
.badge-status.aprovado-restricao { background: #fef9e7; color: #f39c12; }
.badge-status.realizada   { background: #e8f9f0; color: var(--success); }
.badge-status.agendada    { background: var(--primary-light); color: var(--primary); }
.badge-status.concluida   { background: #e8f9f0; color: var(--success); }
.badge-status.planejada   { background: #f1f3fa; color: var(--text-muted); }
.badge-status.emitida     { background: #e8f9f0; color: var(--success); }
.badge-status.vencido     { background: #fde8e9; color: var(--danger); }
.badge-status.comodato    { background: var(--primary-light); color: var(--primary); }
.badge-status.plataforma  { background: #e8f9f0; color: var(--success); }

/* ════════════════════════════════════════
   ACTION BUTTONS
════════════════════════════════════════ */
.btn-action {
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  white-space: nowrap;
}
.btn-action:hover { opacity: 0.78; }
.btn-action.edit    { background: #e8f3fc; color: #2980b9; }
.btn-action.delete  { background: #fde8e9; color: var(--danger); }
.btn-action.view    { background: #e8f9f0; color: var(--success); }
.btn-action.primary { background: var(--primary); color: white; }

/* ════════════════════════════════════════
   TOOLBAR & BUTTONS
════════════════════════════════════════ */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.toolbar-left  { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn-primary-custom {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-primary-custom:hover { background: var(--primary-dark); }
.btn-primary-custom:active { opacity: 0.85; }
.btn-secondary-custom {
  background: white;
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-secondary-custom:hover { border-color: var(--primary); color: var(--primary); }

/* Inputs de busca / filtros */
.search-input {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px 8px 34px;
  font-size: 12.5px;
  outline: none;
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238899a6' width='14' height='14'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E") no-repeat 10px center;
  transition: border-color 0.2s;
  width: 100%;
  max-width: 240px;
  -webkit-appearance: none;
}
.search-input:focus { border-color: var(--primary); }
select.filter-select {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 8px 28px 8px 10px;
  font-size: 12.5px;
  outline: none;
  cursor: pointer;
  background: white;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238899a6' width='14' height='14'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
select.filter-select:focus { border-color: var(--primary); }

/* ════════════════════════════════════════
   FORM
════════════════════════════════════════ */
.form-section { margin-bottom: 22px; }
.form-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.form-label-custom { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 5px; display: block; }
.form-control-custom {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
  background: white;
  -webkit-appearance: none;
  color: var(--text);
}
.form-control-custom:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(50,197,210,0.12); }
.form-check-input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }
.form-check-label { font-size: 13px; cursor: pointer; }

/* ════════════════════════════════════════
   VEHICLE GRID & CARDS
════════════════════════════════════════ */
.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.vehicle-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.vehicle-card:hover  { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.vehicle-card:active { transform: translateY(0); }
.vehicle-card.online  { border-left-color: var(--success); }
.vehicle-card.offline { border-left-color: var(--danger); }
.vehicle-card.warning { border-left-color: #f39c12; }
.vehicle-card .vc-plate { font-size: 14px; font-weight: 800; color: var(--text); margin-bottom: 4px; letter-spacing: 1px; }
.vehicle-card .vc-name  { font-size: 11.5px; color: var(--text-muted); margin-bottom: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vehicle-card .vc-status { display: flex; align-items: center; gap: 6px; font-size: 11.5px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.online  { background: var(--success); animation: pulse-dot 1.5s infinite; }
.status-dot.offline { background: var(--danger); }
.status-dot.warning { background: #f39c12; }
@keyframes pulse-dot {
  0%,100% { opacity:1; transform:scale(1); }
  50%      { opacity:0.6; transform:scale(1.2); }
}
.vehicle-card .vc-speed      { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.vehicle-card .vc-ignition   { font-size: 11px; margin-top: 4px; }
.vehicle-card .vc-ignition.on  { color: var(--success); }
.vehicle-card .vc-ignition.off { color: var(--danger); }
.vehicle-card .vc-addr       { font-size: 10.5px; color: var(--text-muted); margin-top: 4px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ════════════════════════════════════════
   MONITORING LAYOUT
════════════════════════════════════════ */
.monitoring-layout {
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: 16px;
  height: calc(100vh - var(--header-h) - 80px);
  min-height: 400px;
}
.monitoring-list {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.monitoring-list-header { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.monitoring-list-header input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
  outline: none;
  -webkit-appearance: none;
}
.monitoring-list-header input:focus { border-color: var(--primary); }
.monitoring-vehicles { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.mv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #f5f7fa;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.mv-item:hover    { background: #f8fafe; }
.mv-item.selected { background: var(--primary-light); }
.mv-item .mv-status { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.mv-item .mv-plate  { font-size: 12px; font-weight: 700; }
.mv-item .mv-info   { font-size: 10.5px; color: var(--text-muted); line-height: 1.4; }
.monitoring-map-wrap { border-radius: var(--radius); overflow: hidden; }
#main-monitoring-map { height: 100%; min-height: 400px; background: #e8edf3; }

/* ════════════════════════════════════════
   FINANCE CARDS
════════════════════════════════════════ */
.finance-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.finance-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--border);
}
.finance-card.income  { border-top-color: var(--success); }
.finance-card.expense { border-top-color: var(--danger); }
.finance-card.balance { border-top-color: var(--primary); }
.finance-card.overdue { border-top-color: #f39c12; }
.finance-card .fc-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin-bottom: 6px; }
.finance-card .fc-value { font-size: 20px; font-weight: 800; color: var(--text); word-break: break-all; }
.finance-card .fc-sub   { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ════════════════════════════════════════
   CHARTS
════════════════════════════════════════ */
.chart-wrap { position: relative; min-height: 280px; }
.chart-wrap canvas { max-height: 340px; }

/* ════════════════════════════════════════
   MAP EMBEDS
════════════════════════════════════════ */
#monitoring-map, #route-map, #fence-map, #history-map { border-radius: var(--radius); overflow: hidden; background: #e8edf3; }

/* ════════════════════════════════════════
   NOTICES / ALERTS
════════════════════════════════════════ */
.notice-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  flex-wrap: wrap;
  gap: 10px;
}
.notice-bar.info    { background: #e8f3fc; border-left: 4px solid #2980b9; color: #1a5276; }
.notice-bar.warning { background: #fef9e7; border-left: 4px solid #f39c12; color: #7d6608; }
.notice-bar.danger  { background: #fde8e9; border-left: 4px solid var(--danger); color: #922b21; }

/* ════════════════════════════════════════
   VIDEO MONITORING
════════════════════════════════════════ */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.video-card {
  background: #1a242f;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16/9;
  position: relative;
  cursor: pointer;
}
.video-placeholder {
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.3);
  gap: 10px;
}
.video-placeholder i { font-size: 36px; }
.video-placeholder span { font-size: 12px; }
.video-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  padding: 20px 14px 10px;
  color: white;
  font-size: 12px;
  font-weight: 600;
}
.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  color: var(--danger);
}
.live-dot::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse-dot 1s infinite;
}

/* ════════════════════════════════════════
   BIRTHDAY LIST
════════════════════════════════════════ */
.birthday-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f5f7fa;
}
.birthday-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.birthday-info .b-name { font-size: 13px; font-weight: 600; }
.birthday-info .b-date { font-size: 11px; color: var(--text-muted); }

/* ════════════════════════════════════════
   MODAL
════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 16px;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.modal-box {
  background: white;
  border-radius: 14px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.3);
  -webkit-overflow-scrolling: touch;
}
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}
.modal-head h5 { font-size: 15px; font-weight: 700; color: var(--text); }
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
}
.modal-close:hover { color: var(--text); background: #f5f7fa; }
.modal-body-inner { padding: 20px; }
.modal-footer-inner {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  background: white;
  z-index: 1;
}

/* ════════════════════════════════════════
   TIMELINE
════════════════════════════════════════ */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 18px; }
.timeline-dot { position: absolute; left: -21px; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--primary); border: 2px solid white; box-shadow: 0 0 0 2px var(--primary); }
.timeline-item .tl-time { font-size: 10px; color: var(--text-muted); margin-bottom: 3px; }
.timeline-item .tl-text { font-size: 12.5px; color: var(--text); }
.timeline-item .tl-sub  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ════════════════════════════════════════
   TOAST
════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: calc(100vw - 32px);
}
.toast-msg {
  background: white;
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  border-left: 4px solid var(--primary);
  animation: slideInRight 0.3s ease;
  min-width: 240px;
  max-width: 340px;
}
.toast-msg.success { border-left-color: var(--success); }
.toast-msg.error   { border-left-color: var(--danger); }
.toast-msg.warning { border-left-color: #f39c12; }
.toast-msg i { font-size: 16px; flex-shrink: 0; }
.toast-msg.success i { color: var(--success); }
.toast-msg.error   i { color: var(--danger); }
.toast-msg.warning i { color: #f39c12; }
.toast-msg.info    i { color: var(--primary); }
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ════════════════════════════════════════
   LOADING
════════════════════════════════════════ */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  flex-direction: column;
  gap: 12px;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════
   DATATABLES
════════════════════════════════════════ */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  outline: none;
  -webkit-appearance: none;
}
.dataTables_wrapper .dataTables_filter input:focus { border-color: var(--primary); }
.dataTables_paginate .paginate_button { padding: 4px 10px !important; border-radius: 5px !important; font-size: 12px !important; }
.dataTables_paginate .paginate_button.current { background: var(--primary) !important; border-color: var(--primary) !important; color: white !important; }

/* ════════════════════════════════════════
   UTILITIES
════════════════════════════════════════ */
.ms-1 { margin-left: 4px; }
.ms-2 { margin-left: 8px; }
.ms-3 { margin-left: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-3 { margin-bottom: 12px; }
.me-1 { margin-right: 4px; }
.me-2 { margin-right: 8px; }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.text-muted { color: var(--text-muted) !important; }
.text-center { text-align: center; }
.text-end { text-align: right; }
.w-100 { width: 100%; }

/* Row / Col compatibilidade básica */
.row { display: flex; flex-wrap: wrap; margin: -7px; }
.row.g-3 { gap: 14px; margin: 0; }
.row.g-3 > [class^="col"] { padding: 0; }
.col-12  { flex: 0 0 100%; max-width: 100%; }
.col-sm-3{ flex: 0 0 calc(25% - 0px); max-width: 25%; }
.col-sm-4{ flex: 0 0 calc(33.333% - 0px); max-width: 33.333%; }
.col-sm-6{ flex: 0 0 calc(50% - 0px); max-width: 50%; }
.col-lg-4{ flex: 0 0 calc(33.333% - 0px); max-width: 33.333%; }
.col-lg-6{ flex: 0 0 calc(50% - 0px); max-width: 50%; }
.col-lg-7{ flex: 0 0 calc(58.333% - 0px); max-width: 58.333%; }
.col-lg-8{ flex: 0 0 calc(66.666% - 0px); max-width: 66.666%; }
.col-lg-5{ flex: 0 0 calc(41.666% - 0px); max-width: 41.666%; }
.col-lg-3{ flex: 0 0 calc(25% - 0px); max-width: 25%; }

/* ════════════════════════════════════════
   ★ RESPONSIVIDADE – TABLET  (≤1024px)
════════════════════════════════════════ */
@media (max-width: 1024px) {
  .header-clock { display: none; }
  .monitoring-layout { grid-template-columns: 240px 1fr; }
  .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6,
  .col-lg-7, .col-lg-8 { flex: 0 0 100%; max-width: 100%; }
  .row.g-3 { flex-direction: column; }
}

/* ════════════════════════════════════════
   ★ RESPONSIVIDADE – MOBILE  (≤768px)
════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Sidebar vira overlay */
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
    z-index: 1200;
    box-shadow: none;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
  }
  .sidebar.collapsed { transform: translateX(-100%); }

  /* Main sem margin */
  .main-content,
  .main-content.expanded { margin-left: 0 !important; padding: 14px 12px; }

  /* Header logo menor */
  .header-logo { width: auto; padding: 0 12px; }
  .header-logo .brand-name { font-size: 14px; }
  .header-user .uname { display: none; }
  .header-user i.fa-angle-down { display: none; }

  /* Page title menor */
  .page-title { font-size: 17px; }

  /* Stat cards em grid 2 colunas */
  .row.g-3 { gap: 10px; }
  .col-sm-3, .col-sm-4, .col-sm-6,
  .col-lg-3, .col-lg-4, .col-lg-5,
  .col-lg-6, .col-lg-7, .col-lg-8,
  .col-12 { flex: 0 0 100%; max-width: 100%; }

  /* Stat card grid automático */
  .stat-card .stat-num { font-size: 24px; }

  /* Monitoring stacked */
  .monitoring-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .monitoring-list { height: 240px; }
  #main-monitoring-map { min-height: 300px; }

  /* Toolbar empilhado */
  .toolbar { flex-direction: column; align-items: flex-start; }
  .toolbar-right { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .search-input { max-width: 100%; width: 100%; }
  select.filter-select { width: 100%; }

  /* Vehicle grid – 2 colunas no mobile */
  .vehicle-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .vehicle-card { padding: 12px; }
  .vehicle-card .vc-plate { font-size: 12px; }

  /* Finance summary 2 col */
  .finance-summary { grid-template-columns: 1fr 1fr; }
  .finance-card .fc-value { font-size: 17px; }

  /* Pie charts 2x2 */
  .pie-stat-row { gap: 10px; padding: 12px; }
  .pie-stat { min-width: calc(50% - 10px); }
  .pie-canvas-wrap { width: 76px; height: 76px; }
  .pie-canvas-wrap canvas { width: 76px !important; height: 76px !important; }
  .pie-label-center { font-size: 15px; }

  /* Charts menores */
  .chart-wrap { min-height: 220px; }
  .chart-wrap canvas { max-height: 260px; }

  /* Notif dropdown ocupa tela toda no mobile */
  .notif-dropdown { width: calc(100vw - 20px); right: -80px; }
  .user-dropdown { right: -10px; }

  /* Modal fullscreen no mobile */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-box { border-radius: 16px 16px 0 0; max-height: 92vh; max-height: 92dvh; }

  /* Toast na parte inferior */
  .toast-container { bottom: 12px; right: 10px; left: 10px; }
  .toast-msg { min-width: 0; max-width: 100%; width: 100%; }

  /* Tabelas com scroll */
  .portlet-body.no-pad { overflow-x: auto; }
  .data-table { min-width: 540px; }

  /* Video grid 1 col */
  .video-grid { grid-template-columns: 1fr; }

  /* Notice bar empilhada */
  .notice-bar { flex-direction: column; align-items: flex-start; }

  /* Fence/route map menor */
  #fence-map, #route-map, #history-map { height: 260px !important; min-height: 260px; }
}

/* ════════════════════════════════════════
   ★ RESPONSIVIDADE – MOBILE PEQUENO (≤420px)
════════════════════════════════════════ */
@media (max-width: 420px) {
  .login-box { padding: 28px 20px; }
  .login-logo .brand { font-size: 24px; }
  .vehicle-grid { grid-template-columns: 1fr; }
  .finance-summary { grid-template-columns: 1fr; }
  .stat-card .stat-num { font-size: 22px; }
  .stat-icon { width: 44px; height: 44px; font-size: 18px; }
  .header-icon-btn { padding: 8px 7px; font-size: 15px; }
  .pie-stat { min-width: calc(50% - 8px); }
}

/* ════════════════════════════════════════
   ★ RESPONSIVIDADE – LARGE (≥1400px)
════════════════════════════════════════ */
@media (min-width: 1400px) {
  .vehicle-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
  .monitoring-layout { grid-template-columns: 300px 1fr; }
}

/* ════════════════════════════════════════
   PRINT
════════════════════════════════════════ */
@media print {
  .sidebar, .app-header, .toast-container, .btn-primary-custom, .btn-secondary-custom { display: none !important; }
  .main-content { margin: 0 !important; padding: 0 !important; }
  .portlet { box-shadow: none; border: 1px solid #ddd; }
}
