/* -----------------------------------------------
   Variaveis
----------------------------------------------- */
:root {
  --sidebar-w:       240px;
  --topbar-h:        56px;
  --sidebar-bg:      #1a1d23;
  --sidebar-text:    #9ca3af;
  --sidebar-hover:   rgba(255,255,255,.06);
  --sidebar-active:  rgba(13,110,253,.18);
  --sidebar-border:  rgba(255,255,255,.07);
  --topbar-bg:       #ffffff;
  --topbar-border:   #e9ecef;
  --content-bg:      #f5f7fa;
  --card-radius:     10px;
  --transition:      .18s ease;
}

/* -----------------------------------------------
   Reset / base
----------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--content-bg); font-family: system-ui, -apple-system, sans-serif; }

a { text-decoration: none; }
a:hover { text-decoration: none; }

/* -----------------------------------------------
   Sidebar
----------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-brand-icon { color: #3b82f6; font-size: 20px; }
.sidebar-brand-text { color: #f9fafb; font-weight: 600; font-size: 15px; letter-spacing: -.01em; }

.sidebar-nav {
  list-style: none;
  padding: 12px 0;
  margin: 0;
  flex: 1;
}
.sidebar-section {
  padding: 14px 20px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  color: #4b5563;
  text-transform: uppercase;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--sidebar-text);
  font-size: 14px;
  transition: background var(--transition), color var(--transition);
  border-left: 2px solid transparent;
  cursor: pointer;
}
.sidebar-link i:first-child { font-size: 16px; flex-shrink: 0; }
.sidebar-link span { flex: 1; }
.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #e5e7eb;
}
.sidebar-link.active {
  background: var(--sidebar-active);
  color: #60a5fa;
  border-left-color: #3b82f6;
}
.sidebar-offline-icon {
  font-size: 11px !important;
  color: #f59e0b;
  margin-left: auto;
}

.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding: 12px 16px;
  flex-shrink: 0;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-avatar {
  width: 32px; height: 32px;
  background: #3b82f6;
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.sidebar-user-name {
  color: #e5e7eb;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.sidebar-user-role {
  color: #6b7280;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.sidebar-logout {
  color: #6b7280;
  font-size: 16px;
  margin-left: auto;
  transition: color var(--transition);
}
.sidebar-logout:hover { color: #ef4444; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 199;
}

/* -----------------------------------------------
   Main wrapper
----------------------------------------------- */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* -----------------------------------------------
   Topbar
----------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 8px;
  flex-shrink: 0;
}
.topbar-toggle {
  background: none;
  border: none;
  font-size: 22px;
  color: #6b7280;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 6px;
}
.topbar-toggle:hover { background: #f3f4f6; }

.breadcrumb { font-size: 13px; }
.breadcrumb-item a { color: #6b7280; }
.breadcrumb-item a:hover { color: #111827; }
.breadcrumb-item.active { color: #111827; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-email { font-size: 13px; color: #9ca3af; }

.badge-offline {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fbbf24;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 6px;
}

/* -----------------------------------------------
   Flash messages
----------------------------------------------- */
.flash-container { padding: 12px 24px 0; }

/* -----------------------------------------------
   Content
----------------------------------------------- */
.content { padding: 24px; flex: 1; }

/* -----------------------------------------------
   Page header
----------------------------------------------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  margin: 0;
}
.page-subtitle {
  font-size: 13px;
  color: #6b7280;
  margin: 2px 0 0;
}

/* -----------------------------------------------
   Cards
----------------------------------------------- */
.card {
  border: 1px solid #e5e7eb;
  border-radius: var(--card-radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #f3f4f6;
  padding: 14px 20px;
  font-weight: 600;
  font-size: 14px;
  color: #374151;
  border-radius: var(--card-radius) var(--card-radius) 0 0;
}

/* Stat cards */
.stat-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: var(--card-radius);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-value { font-size: 24px; font-weight: 700; color: #111827; line-height: 1.2; }
.stat-label { font-size: 12px; color: #6b7280; margin-top: 2px; }
.stat-change { font-size: 11px; margin-top: 4px; }

/* -----------------------------------------------
   Tables
----------------------------------------------- */
.table { font-size: 14px; }
.table thead th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #6b7280;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 16px;
}
.table tbody td { padding: 12px 16px; vertical-align: middle; color: #374151; }
.table-hover tbody tr:hover { background: #f9fafb; }
.table-wrap { overflow-x: auto; }

/* -----------------------------------------------
   Status badges
----------------------------------------------- */
.badge-status { font-size: 11px; font-weight: 500; padding: 3px 8px; border-radius: 20px; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-muted   { background: #f3f4f6; color: #6b7280; }

/* -----------------------------------------------
   Offline state
----------------------------------------------- */
.offline-notice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: #6b7280;
}
.offline-notice i { font-size: 48px; color: #d1d5db; margin-bottom: 16px; }
.offline-notice h5 { color: #374151; margin-bottom: 8px; }

/* -----------------------------------------------
   Login page
----------------------------------------------- */
.login-body {
  min-height: 100vh;
  background: #f5f7fa;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-wrapper { width: 100%; max-width: 400px; padding: 24px; }
.login-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 40px 36px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.login-brand { text-align: center; margin-bottom: 32px; }
.login-brand-name { font-size: 20px; font-weight: 700; color: #111827; margin: 12px 0 4px; }
.login-brand-sub  { font-size: 13px; color: #9ca3af; margin: 0; }
.btn-login { height: 44px; font-weight: 600; }
.login-footer { text-align: center; margin-top: 24px; font-size: 12px; color: #9ca3af; }

/* -----------------------------------------------
   Responsive
----------------------------------------------- */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open {
    display: block;
  }
  .main-wrapper {
    margin-left: 0;
  }
}
