*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  width: 100%;
  min-width: 100%;
}

body {
  font-family: var(--font-family);
  background: var(--bg-page);
  color: var(--text-primary);
  margin: 0;
  width: 100%;
  min-width: 100%;
  min-height: 100vh;
}

a {
  text-decoration: none;
  color: inherit;
}

.dashboard-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100vw;
  max-width: 100vw;
  overflow-x: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 1040;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand-mobile {
  border: none;
  padding: 0;
}

.sidebar-brand a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-brand img {
  width: auto;
  height: 40px;
  max-width: 110px;
  flex-shrink: 0;
  object-fit: contain;
}

.sidebar-brand-text .brand-title {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
}

.sidebar-brand-text .brand-sub {
  font-size: 9px;
  color: var(--sidebar-text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sidebar-brand-text .brand-tag {
  font-size: 9px;
  color: var(--accent-green);
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0 12px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 2px;
}

.nav-divider {
  height: 1px;
  background: var(--sidebar-border, rgba(255,255,255,.08));
  margin: 8px 16px;
}

.nav-section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 16px;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav-section-toggle:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.nav-section-toggle-left {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.nav-section-toggle-left i {
  font-size: 13px;
  width: 16px;
  text-align: center;
}

.nav-chevron {
  font-size: 11px;
  transition: transform 0.2s ease;
  opacity: 0.7;
}

.nav-section.open .nav-chevron {
  transform: rotate(180deg);
}

.nav-submenu {
  display: none;
  padding: 2px 0 4px;
}

.nav-section.open .nav-submenu {
  display: block;
}

.nav-item-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 20px;
  font-size: 13px;
  color: var(--sidebar-text);
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.nav-item-link i {
  font-size: 14px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.nav-item-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  border-left-color: var(--accent-green);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-footer .nav-item-link {
  padding-left: 0;
  color: #f87171;
}

.sidebar-footer .nav-item-link:hover {
  color: #fca5a5;
  background: transparent;
}

/* Main content area */
.main-content {
  flex: 1 1 0;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#navbar-container,
.page-content {
  width: 100%;
}

body.role-super-admin #navbar-container,
body.role-super-admin .page-content,
body.role-super-admin #footer-container,
body.role-super-admin .top-navbar {
  width: 100%;
  max-width: none;
}

#footer-container {
  margin-top: auto;
  width: 100%;
}

/* Top navbar */
.top-navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  height: var(--navbar-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: var(--shadow-sm);
}

.navbar-brand-mobile {
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-brand-mobile img {
  width: auto;
  height: 32px;
  max-width: 88px;
  object-fit: contain;
}

.navbar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.navbar-brand-text .brand-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
}

.navbar-brand-text .brand-sub {
  font-size: 8px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.navbar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.35rem;
  color: var(--text-primary);
  padding: 0.25rem;
  cursor: pointer;
}

.navbar-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.navbar-search i {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.navbar-search input {
  width: 100%;
  padding: 7px 12px 7px 34px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: var(--bg-page);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.navbar-search input:focus {
  border-color: var(--accent-green);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
}

.navbar-icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.navbar-icon-btn:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

.navbar-icon-btn .badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--accent-red);
  border-radius: 50%;
  border: 2px solid #fff;
}

.navbar-profile {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  background: transparent;
  margin-left: 0.5rem;
}

.navbar-profile:hover {
  background: var(--bg-page);
}

.navbar-profile img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.navbar-profile-info {
  text-align: left;
  line-height: 1.2;
}

.navbar-profile-info .name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.navbar-profile-info .role {
  font-size: 10px;
  color: var(--text-muted);
}

/* Cards */
.dash-card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.dash-card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dash-card-header h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.dash-card-body {
  padding: 14px 16px;
}

.dash-card-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.dash-card-footer a {
  font-size: 12px;
  color: var(--accent-green);
  font-weight: 500;
}

.dash-card-footer a:hover {
  color: var(--accent-green-dark);
}

/* Metric cards */
.metrics-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  margin-bottom: 18px;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.metrics-row::-webkit-scrollbar {
  height: 4px;
}

.metric-card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-color);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 160px;
  min-width: 160px;
  overflow: visible;
  white-space: normal;
}

.metric-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.metric-icon.green { background: var(--metric-green-bg); color: var(--accent-green); }
.metric-icon.blue { background: var(--metric-blue-bg); color: var(--accent-blue); }
.metric-icon.purple { background: var(--metric-purple-bg); color: var(--accent-purple); }
.metric-icon.orange { background: var(--metric-orange-bg); color: var(--accent-orange); }
.metric-icon.red { background: var(--metric-red-bg); color: var(--accent-red); }

.metric-info {
  min-width: 0;
  flex: 1 1 auto;
  overflow: visible;
}

.metric-info .metric-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  line-height: 1.25;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

.metric-info .metric-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
  line-height: 1.2;
  min-height: 1.2em;
  white-space: nowrap;
}

.metric-info .metric-change {
  font-size: 10px;
  margin-top: 2px;
  line-height: 1.2;
}

.metric-change.positive { color: var(--accent-green); }
.metric-change.neutral { color: var(--text-muted); }

/* Quick action cards */
.quick-actions-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  margin-bottom: 18px;
  overflow-x: auto;
}

.quick-action-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 12px 10px;
  text-align: center;
  transition: box-shadow 0.2s, border-color 0.2s;
  flex: 1 1 0;
  min-width: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.quick-action-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent-green);
}

.quick-action-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--metric-green-bg);
  color: var(--accent-green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.quick-action-card span {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}

/* Activity feed */
.activity-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--metric-green-bg);
  color: var(--accent-green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.activity-text {
  font-size: 0.8rem;
  color: var(--text-primary);
  line-height: 1.4;
}

.activity-text strong {
  font-weight: 600;
}

.activity-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Announcements */
.announcement-item {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-color);
}

.announcement-item:last-child {
  border-bottom: none;
}

.announcement-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

.announcement-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Tables */
.dash-table {
  width: 100%;
  font-size: 0.82rem;
}

.dash-table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.dash-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.dash-table tr:last-child td {
  border-bottom: none;
}

.growth-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-green);
}

/* Status list */
.status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.82rem;
}

.status-item:last-child {
  border-bottom: none;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent-green);
}

.status-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-green);
}

/* Support links */
.support-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.82rem;
  color: var(--text-primary);
  transition: color 0.15s;
}

.support-link:last-child {
  border-bottom: none;
}

.support-link:hover {
  color: var(--accent-green);
}

.support-link .ticket-badge {
  font-size: 0.7rem;
  background: var(--metric-orange-bg);
  color: var(--accent-orange);
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-weight: 600;
}

/* Map legend */
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.75rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

/* Footer */
.dash-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
  margin-top: auto;
  width: 100%;
  align-self: stretch;
  position: relative;
}

.dash-footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  text-align: center;
}

.dash-footer p {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.dash-footer-inner .footer-copy,
.dash-footer-inner .footer-tag {
  text-align: center;
}

.dash-footer-inner {
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* Dashboard body layout */
.dashboard-body {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.dashboard-main {
  flex: 1;
  min-width: 0;
}

.dashboard-aside {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Stub page */
.page-content {
  padding: 16px 20px;
  flex: 1;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}

.stub-card .card-body {
  padding: 3rem 1.5rem;
}

.stub-icon {
  font-size: 2.5rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* Offcanvas mobile sidebar */
.offcanvas-sidebar {
  background: var(--sidebar-bg) !important;
  width: var(--sidebar-width) !important;
}

.offcanvas-sidebar .btn-close {
  filter: invert(1);
}

/* Responsive */
@media (max-width: 1199.98px) {
  .dashboard-body {
    flex-direction: column;
  }

  .dashboard-aside {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .dashboard-aside > .dash-card {
    flex: 1 1 280px;
  }
}

@media (max-width: 1199.98px) {
  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0;
  }

  .navbar-toggle {
    display: flex;
  }
}

@media (max-width: 767.98px) {
  .top-navbar {
    padding: 0 12px;
  }

  .navbar-search {
    display: none;
  }

  .navbar-profile-info {
    display: none;
  }

  .page-content {
    padding: 12px;
  }

  .dash-footer-inner {
    flex-direction: column;
    text-align: center;
  }
}