﻿/* ============================================
   ZENITH — Global Stylesheet
   Design: Ultra Minimalist, Monochrome 2026
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0a0a0a;
  --card: #1a1a1a;
  --text: #ffffff;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --border: rgba(37, 99, 235, 0.12);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --muted: #555;
  --muted-light: #888;
  --sidebar-w: 240px;
  --sidebar-collapsed: 72px;
  --topbar-h: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(37,99,235,0.3); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(37,99,235,0.5); }

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
}

.logo-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  opacity: 1;
  transition: opacity var(--transition);
}

.logo-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text);
  line-height: 1;
}

.logo-tagline {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: uppercase;
  line-height: 1;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .profile-info {
  opacity: 0;
  pointer-events: none;
  width: 0;
  overflow: hidden;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted-light);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.25s ease;
  white-space: nowrap;
  position: relative;
}

.nav-item svg { flex-shrink: 0; }

.nav-item:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}

.nav-item.active {
  color: var(--accent);
  background: rgba(37,99,235,0.1);
}

.nav-item.active svg { stroke: var(--accent); }

/* Tooltip for collapsed sidebar */
.sidebar.collapsed .nav-item::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 200;
}

.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

.sidebar-bottom {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.25s;
  white-space: nowrap;
}

.sidebar-profile:hover { background: rgba(255,255,255,0.05); }

.profile-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity var(--transition);
}

.profile-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.profile-role {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ============ AVATAR ============ */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
  display: block;
  border: 2px solid rgba(37,99,235,0.2);
  transition: border-color 0.25s;
}

.avatar:hover { border-color: rgba(37,99,235,0.5); }

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

/* fallback for broken images */
.avatar img[src=""],
.avatar img:not([src]) {
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
}

.avatar-sm { width: 32px; height: 32px; }
.avatar-xs { width: 28px; height: 28px; }
.avatar-lg { width: 64px; height: 64px; }
.avatar-xl { width: 80px; height: 80px; }

/* ============ MAIN CONTENT ============ */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

.main-content.expanded { margin-left: var(--sidebar-collapsed); }

/* ============ TOPBAR ============ */
.topbar {
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
}

.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
  flex-shrink: 0;
}

.hamburger:hover { background: rgba(255,255,255,0.06); }

.search-wrap {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px 9px 38px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.25s;
}

.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-color: rgba(37,99,235,0.4); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.icon-btn {
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--muted-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s;
  position: relative;
}

.icon-btn:hover { color: var(--text); border-color: var(--border); background: rgba(255,255,255,0.04); }

.notif-btn .badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  border: 1.5px solid var(--bg);
}

.avatar-dropdown {
  position: relative;
  cursor: pointer;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 160px;
  padding: 6px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all 0.25s ease;
  z-index: 200;
}

.dropdown-menu.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.dropdown-item {
  display: block;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted-light);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.dropdown-item:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.dropdown-danger { color: #ef4444 !important; }
.dropdown-danger:hover { background: rgba(239,68,68,0.1) !important; }

.dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}

/* ============ PAGE CONTENT ============ */
.page-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ============ DASHBOARD GRID ============ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 30% 1fr;
  gap: 24px;
  align-items: start;
}
  gap: 24px;
  align-items: start;
}

.left-col, .right-col {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ============ WELCOME ============ */
.welcome-section {
  padding: 8px 0;
}

.welcome-sub {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.welcome-title {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 12px;
}

.welcome-desc {
  font-size: 14px;
  color: var(--muted-light);
  line-height: 1.6;
}

/* ============ KPI CARDS ============ */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.kpi-card:hover {
  transform: scale(1.008);
  border-color: rgba(37,99,235,0.25);
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.kpi-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
}

.kpi-badge.positive {
  color: #22c55e;
  background: rgba(34,197,94,0.1);
}

.kpi-badge.negative {
  color: #ef4444;
  background: rgba(239,68,68,0.1);
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
}

.kpi-sub {
  font-size: 11px;
  color: var(--muted);
}

/* ============ QUICK ACTIONS ============ */
.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.btn:hover { transform: scale(1.008); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--muted-light);
  border: 1px solid var(--border-subtle);
}

.btn-ghost:hover { color: var(--text); border-color: var(--border); background: rgba(255,255,255,0.04); }

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-danger {
  background: rgba(239,68,68,0.1);
  color: #ef4444;
  border: 1px solid rgba(239,68,68,0.2);
}

.btn-danger:hover { background: rgba(239,68,68,0.2); }

/* ============ CARDS ============ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.3s ease;
}

.card:hover { border-color: rgba(37,99,235,0.2); }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.card-sub {
  font-size: 13px;
  color: var(--muted);
}

/* ============ CHART ============ */
.chart-card { }

.chart-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  padding: 3px;
  border-radius: var(--radius-sm);
}

.chart-tab {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
}

.chart-tab.active {
  background: var(--accent);
  color: #fff;
}

.chart-tab:hover:not(.active) { color: var(--text); }

.chart-wrap {
  height: 220px;
  position: relative;
}

/* ============ TABLE ============ */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: 12px 12px;
  color: var(--text);
  border-bottom: 1px solid rgba(255,255,255,0.03);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td { background: rgba(255,255,255,0.02); }

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.text-muted { color: var(--muted) !important; font-size: 13px; }

/* ============ STATUS BADGES ============ */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.status-active {
  color: #22c55e;
  background: rgba(34,197,94,0.1);
}

.status-pending {
  color: #f59e0b;
  background: rgba(245,158,11,0.1);
}

.status-inactive {
  color: #ef4444;
  background: rgba(239,68,68,0.1);
}

.status-blue {
  color: var(--accent);
  background: rgba(37,99,235,0.1);
}

/* ============ PAGE HEADER ============ */
.page-header {
  margin-bottom: 28px;
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--muted);
}

.page-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ============ FILTER BAR ============ */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-search {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
  position: relative;
}

.filter-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.filter-search input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px 9px 38px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.25s;
}

.filter-search input::placeholder { color: var(--muted); }
.filter-search input:focus { border-color: rgba(37,99,235,0.4); }

.filter-select {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  color: var(--muted-light);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.25s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.filter-select:focus { border-color: rgba(37,99,235,0.4); }

/* ============ FORM ELEMENTS ============ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-light);
}

.form-input {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.25s;
  width: 100%;
}

.form-input::placeholder { color: var(--muted); }
.form-input:focus { border-color: rgba(37,99,235,0.4); }

/* ============ PROGRESS BAR ============ */
.progress-wrap {
  background: rgba(255,255,255,0.06);
  border-radius: 20px;
  height: 6px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 20px;
  transition: width 0.8s ease;
}

/* ============ SECTION GRID ============ */
.section-grid {
  display: grid;
  gap: 24px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ============ METRIC CARD ============ */
.metric-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.metric-card:hover {
  transform: scale(1.008);
  border-color: rgba(37,99,235,0.25);
}

.metric-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  margin-bottom: 10px;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1;
  margin-bottom: 6px;
}

.metric-sub {
  font-size: 13px;
  color: var(--muted-light);
}

/* ============ ANIMATIONS ============ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.4s ease forwards;
  opacity: 0;
}

/* ============ MOBILE OVERLAY ============ */
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 90;
  backdrop-filter: blur(4px);
}

.mobile-overlay.active { display: block; }

/* ============ DIVIDER ============ */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 20px 0;
}

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ============ TOOLTIP ============ */
[data-tip] {
  position: relative;
}

[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  z-index: 300;
}


/* ============ PROFILE PHOTO ============ */
.profile-photo-container {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--border);
  transition: all 0.3s ease;
}

.profile-photo-container:hover {
  border-color: var(--accent);
}

.profile-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-photo-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: pointer;
}

.profile-photo-container:hover .profile-photo-overlay {
  opacity: 1;
}

.avatar-photo {
  border-radius: 50%;
  object-fit: cover;
}

.avatar-xs-photo {
  width: 28px;
  height: 28px;
}

.avatar-sm-photo {
  width: 32px;
  height: 32px;
}

.avatar-photo-main {
  width: 36px;
  height: 36px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.info-value {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

/* ============ MODAL ============ */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 16px;
  /* Override body flex */
  width: 100vw;
  height: 100vh;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 440px;
  animation: fadeIn 0.25s ease;
  position: relative;
  z-index: 501;
  max-height: 90vh;
  overflow-y: auto;
  /* Reset any inherited flex sizing */
  flex-shrink: 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
}

/* Prevent multiple modals showing at once */
.modal-backdrop:not(.open) {
  display: none !important;
}

/* ── iOS / Mobile base fixes ── */
input, select, textarea, button { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
img, video, canvas, svg { max-width: 100%; }
.page-content, .table-wrap, .modal { -webkit-overflow-scrolling: touch; }

/* ============================================================
   RESPONSIVE — Mobile First
   Breakpoints: 1100 | 900 | 768 | 480 | landscape
   ============================================================ */

/* Tablet landscape */
@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* Tablet portrait */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .page-header-row { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-actions { width: 100%; flex-wrap: wrap; }
}

/* Mobile */
@media (max-width: 768px) {
  html { overflow-x: hidden; }
  body { overflow-x: hidden; min-width: 0; }

  /* Sidebar */
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; z-index: 200; }
  .sidebar.mobile-open { transform: translateX(0); }

  /* Main content */
  .main-content { margin-left: 0 !important; width: 100%; min-width: 0; max-width: 100vw; }

  /* Topbar */
  .hamburger { display: flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .search-wrap { flex: 1; max-width: none; min-width: 0; }
  .search-input { font-size: 16px; }
  .topbar-actions { gap: 6px; flex-shrink: 0; }
  .icon-btn { min-width: 44px; min-height: 44px; width: 44px; height: 44px; }

  /* Page content */
  .page-content { padding: 16px; box-sizing: border-box; width: 100%; }

  /* Page header */
  .page-header { margin-bottom: 20px; }
  .page-header-row { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-title { font-size: 24px; }
  .page-actions { width: 100%; flex-wrap: wrap; gap: 8px; }
  .page-actions .btn { flex: 1; min-width: 120px; justify-content: center; }

  /* Dashboard grid */
  .dashboard-grid { grid-template-columns: 1fr; gap: 16px; }
  .welcome-title { font-size: 22px; }

  /* KPI */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-value { font-size: 20px; }
  .kpi-card { padding: 14px; }

  /* Quick actions */
  .quick-actions { gap: 8px; }
  .quick-actions .btn { flex: 1; min-width: 0; justify-content: center; }

  /* Grids */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; gap: 16px; }

  /* Cards */
  .card { padding: 16px; }
  .card-header { margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }

  /* Chart */
  .chart-wrap { height: 180px; }

  /* Tables — horizontal scroll with negative margin trick */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 520px; }
  .data-table th, .data-table td { padding: 10px 8px; font-size: 13px; }

  /* Buttons — touch friendly */
  .btn { min-height: 44px; padding: 10px 16px; }
  .btn-sm { min-height: 36px; padding: 7px 12px; }

  /* Filters */
  .filter-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .filter-search { max-width: 100%; }
  .filter-search input { height: 44px; font-size: 16px; }
  .filter-select { width: 100%; height: 44px; font-size: 16px; }

  /* Form inputs — 16px prevents iOS zoom */
  .form-input { font-size: 16px; min-height: 44px; }
  textarea.form-input { min-height: auto; }

  /* Modals — bottom sheet on mobile */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-width: 100%; width: 100%; border-radius: var(--radius) var(--radius) 0 0; max-height: 92vh; animation: slideUp 0.3s ease; }

  /* Metric cards */
  .metric-card { padding: 16px; }
  .metric-value { font-size: 22px; }

  /* Section grid */
  .section-grid { gap: 16px; }

  /* Settings */
  .profile-section { flex-direction: column; align-items: center; }
  .profile-form { grid-template-columns: 1fr !important; }
  .apps-grid { grid-template-columns: 1fr !important; }

  /* Pagination */
  .pagination { flex-wrap: wrap; justify-content: center; gap: 8px; }
  .pagination-info { width: 100%; text-align: center; }
}

/* Small mobile */
@media (max-width: 480px) {
  .topbar { padding: 0 10px; }
  .page-content { padding: 12px; }
  .search-wrap { display: none; }

  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-card { padding: 12px; }
  .kpi-value { font-size: 18px; }
  .kpi-label { font-size: 10px; }

  .quick-actions { flex-direction: column; }
  .quick-actions .btn { width: 100%; }

  .page-title { font-size: 20px; }
  .welcome-title { font-size: 20px; }
  .chart-wrap { height: 160px; }
  .metric-value { font-size: 20px; }

  .geo-list { width: 100% !important; }
  .geo-item { width: 100% !important; }
}

/* Landscape phone */
@media (max-width: 768px) and (orientation: landscape) {
  .topbar { height: 52px; }
  .page-content { padding: 10px 12px; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .chart-wrap { height: 140px; }
  .modal { max-height: 95vh; }
}

/* Slide-up animation for mobile modals */
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
