@charset "UTF-8";
/* ============================================================
   SiteFlow ERP — styles.css
   Dark blue construction management theme
   ============================================================ */

/* ---------- CSS Variables (Design Tokens) ---------- */
:root {
  --sidebar-w: 260px;
  --topbar-h: 64px;

  /* Brand Colors */
  --primary:       #3B82F6;
  --primary-dark:  #1D4ED8;
  --primary-light: #60A5FA;
  --accent:        #06B6D4;

  /* Sidebar */
  --sidebar-bg:    #0D1B3E;
  --sidebar-bg2:   #0A1628;
  --sidebar-hover: rgba(59,130,246,0.15);
  --sidebar-active:#1E3A8A;
  --sidebar-text:  rgba(255,255,255,0.75);
  --sidebar-active-text: #ffffff;

  /* Background */
  --bg:           #0F172A;
  --bg-card:      #1E293B;
  --bg-card2:     #263145;
  --bg-hover:     #2D3B55;

  /* Text */
  --text-primary:  #F1F5F9;
  --text-secondary:#94A3B8;
  --text-muted:    #64748B;

  /* Borders */
  --border:        rgba(255,255,255,0.08);
  --border-light:  rgba(255,255,255,0.05);

  /* Glass / translucent surfaces (topbar, dropdowns) */
  --glass-bg:      rgba(30,41,59,0.85);

  /* Status Colors */
  --success:       #22C55E;
  --warning:       #F59E0B;
  --danger:        #EF4444;
  --info:          #3B82F6;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(59,130,246,0.3);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Transitions */
  --transition: 0.2s ease;
  --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Noto Sans Thai', 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.6;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }
ul { list-style: none; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }
/* Thumb is white-on-transparent, tuned for a dark page -- on a light-theme
   page (white/near-white background) it's nearly invisible, so users can't
   see there's more to scroll (e.g. a wide table cut off on the right). */
body.light-theme::-webkit-scrollbar-thumb,
body.light-theme *::-webkit-scrollbar-thumb {
  background: rgba(15,23,42,0.22) !important;
}
body.light-theme::-webkit-scrollbar-thumb:hover,
body.light-theme *::-webkit-scrollbar-thumb:hover {
  background: rgba(15,23,42,0.35) !important;
}

/* ── When page is inside an iframe (sub-module view) ── */
/* Hide sidebar & topbar so only the content area shows */
html.in-iframe .sidebar,
html.in-iframe .topbar,
html.in-iframe header.topbar {
  display: none !important;
}

html.in-iframe .main-content {
  margin-left: 0 !important;
  padding-left: 0 !important;
  width: 100% !important;
}

html.in-iframe body {
  min-height: auto;
}


/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg2) 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  border-right: 1px solid var(--border);
  transition: transform var(--transition-slow);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  flex-shrink: 0;
  filter: drop-shadow(0 2px 8px rgba(59,130,246,0.5));
}

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

.logo-name {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}

.logo-sub {
  font-size: 9px;
  font-weight: 600;
  color: var(--primary-light);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.sidebar-toggle {
  color: var(--sidebar-text);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  display: flex;
}
.sidebar-toggle:hover { background: var(--sidebar-hover); color: #fff; }

/* Nav */
.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; overflow-x: hidden; }

.nav-list { padding: 0 8px; }

.nav-item { margin: 2px 0; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
  cursor: pointer;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-link.active {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  box-shadow: 0 4px 12px rgba(59,130,246,0.4);
}

.nav-link.active .nav-icon { color: #fff; }

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--sidebar-text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
}

.nav-link:hover .nav-icon, .nav-link.active .nav-icon { color: #fff; }

.nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-arrow {
  font-size: 16px;
  color: rgba(255,255,255,0.3);
  transition: transform var(--transition), color var(--transition);
  line-height: 1;
}

.nav-link:hover .nav-arrow { color: rgba(255,255,255,0.6); }

.nav-arrow-down { transform: rotate(90deg); }

/* Submenu */
.sub-nav {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-slow);
  padding-left: 12px;
}

.sub-nav.open { max-height: 1500px; }

.sub-nav-item { margin: 2px 0; }

.sub-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border-left: 2px solid transparent;
  color: rgba(255,255,255,0.65);
  font-size: 13.5px;
  font-weight: 400;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
}

.sub-nav-link:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
  border-left: 2px solid rgba(255,255,255,0.3);
  transform: translateX(4px);
}

.sub-nav-link.active {
  background: rgba(59,130,246,0.15);
  color: #60A5FA;
  border-left: 2px solid #3B82F6;
  font-weight: 500;
}

.sub-icon { color: rgba(255,255,255,0.5); display: flex; }
.sub-nav-link:hover .sub-icon, .sub-nav-link.active .sub-icon { color: var(--primary-light); }

/* ─── Sidebar Section Headers ─── */
.nav-section-header {
  padding: 16px 14px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28);
  user-select: none;
  pointer-events: none;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: 4px;
}
.nav-section-header:first-of-type { border-top: none; margin-top: 0; }

/* ─── "Coming Soon" Badge on Nav ─── */
.nav-badge-new {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(99,102,241,0.35), rgba(139,92,246,0.35));
  color: #A78BFA;
  border: 1px solid rgba(139,92,246,0.3);
  flex-shrink: 0;
  white-space: nowrap;
}

/* ─── Muted "Coming Soon" Nav Link ─── */
.nav-link-coming {
  opacity: 0.72;
  cursor: not-allowed;
}
.nav-link-coming:hover {
  opacity: 0.9;
  background: rgba(99,102,241,0.08) !important;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.user-profile:hover { background: var(--sidebar-hover); }

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { display: block; font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: 11px; color: var(--sidebar-text); }
.user-menu-btn { color: rgba(255,255,255,0.4); padding: 4px; display: flex; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: calc(100% - var(--sidebar-w));
  transition: margin-left var(--transition-slow);
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  height: var(--topbar-h);
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.mobile-menu-btn {
  display: none;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.mobile-menu-btn:hover { background: var(--bg-card); color: var(--text-primary); }

.breadcrumb { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 14px; }
.breadcrumb-home { color: var(--primary-light); font-weight: 500; }
.breadcrumb-sep { color: var(--primary-light); opacity: 0.6; }
.breadcrumb-current { color: var(--text-primary); font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 8px 14px;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.search-box input { background: none; border: none; outline: none; color: var(--text-primary); font-size: 13px; width: 200px; }
.search-box input::placeholder { color: var(--text-muted); }
.search-box.inline { border-radius: var(--radius-sm); }

.topbar-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all var(--transition);
}
.topbar-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--primary); }

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: var(--danger);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg);
}

.topbar-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  cursor: pointer;
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.3);
}

/* ============================================================
   PAGE CONTAINER
   ============================================================ */
.page-container { flex: 1; }

.page {
  display: none;
  padding: 28px 28px 48px;
  animation: fadeIn 0.3s ease;
}

.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Module iframe page (fills main content minus topbar) ── */
#page-module {
  padding: 0 !important;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

#page-module.active {
  display: flex;
  flex-direction: column;
}

#moduleFrame {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background-color: var(--bg);
}


/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title { font-size: 24px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.5px; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 12px rgba(59,130,246,0.4);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #5B9AF7, var(--primary));
  box-shadow: 0 6px 18px rgba(59,130,246,0.55);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover { background: var(--bg-card); border-color: var(--primary); color: var(--primary); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #C0392B);
  color: #fff;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover { border-color: rgba(59,130,246,0.2); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
  flex-wrap: wrap;
}

.card-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }

.card-actions { display: flex; gap: 8px; align-items: center; }

.card-body { padding: 20px 22px; }
.card-body.p0 { padding: 0; }

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}
.kpi-card:hover { border-color: rgba(59,130,246,0.3); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-card::before {
  content: '';
  position: absolute;
  top: 15px;
  bottom: 15px;
  right: 0;
  width: 5px;
  border-radius: 5px 0 0 5px;
}
.kpi-card#kpi-active-projects { box-shadow: 0 8px 24px rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.15); }
.kpi-card#kpi-active-projects::before { background: var(--primary); }

.kpi-card#kpi-budget { box-shadow: 0 8px 24px rgba(6,182,212,0.12); border-color: rgba(6,182,212,0.15); }
.kpi-card#kpi-budget::before { background: var(--accent); }

.kpi-card#kpi-workers { box-shadow: 0 8px 24px rgba(139,92,246,0.12); border-color: rgba(139,92,246,0.15); }
.kpi-card#kpi-workers::before { background: #8B5CF6; }

.kpi-card#kpi-issues { box-shadow: 0 8px 24px rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.15); }
.kpi-card#kpi-issues::before { background: var(--warning); }

.kpi-card#kpi-invoiced { box-shadow: 0 8px 24px rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.15); }
.kpi-card#kpi-invoiced::before { background: var(--primary); }

.kpi-card#kpi-remaining { box-shadow: 0 8px 24px rgba(139,92,246,0.12); border-color: rgba(139,92,246,0.15); }
.kpi-card#kpi-remaining::before { background: #8B5CF6; }

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 22px;
}

.kpi-blue  { background: rgba(59,130,246,0.15); color: var(--primary); }
.kpi-green { background: rgba(34,197,94,0.15); color: var(--success); }
.kpi-purple{ background: rgba(139,92,246,0.15); color: #A78BFA; }
.kpi-orange{ background: rgba(245,158,11,0.15); color: var(--warning); }

.kpi-body { flex: 1; min-width: 0; }
.kpi-label { display: block; font-size: 12px; color: var(--text-secondary); font-weight: 500; margin-bottom: 3px; }
.kpi-value { display: block; font-size: 28px; font-weight: 800; color: var(--text-primary); line-height: 1.1; letter-spacing: -0.5px; }
.kpi-change { display: block; font-size: 11.5px; margin-top: 3px; font-weight: 600; }
.kpi-change.positive { color: var(--success); }
.kpi-change.negative { color: var(--danger); }

.kpi-sparkline { flex-shrink: 0; opacity: 0.7; }

/* ============================================================
   DASHBOARD GRID
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  margin-bottom: 20px;
}

.dashboard-grid-3 {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  margin-bottom: 20px;
}

.chart-card .card-body { padding: 10px 16px 16px; }

.donut-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-direction: column;
}

.donut-legend { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.donut-legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.donut-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.donut-legend-label { flex: 1; color: var(--text-secondary); }
.donut-legend-value { color: var(--text-primary); font-weight: 600; }

/* ============================================================
   CHIPS / FILTER TABS
   ============================================================ */
.chip {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table thead th {
  padding: 12px 18px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: rgba(59,130,246,0.45);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
/* โหมดสว่าง: --text-muted คอนทราสต์ต่ำเกินไปบนพื้นสว่าง อ่านยาก จึงใช้ --text-secondary แทนเฉพาะโหมดนี้ (โหมดมืดไม่กระทบ) */
body.light-theme .data-table thead th {
  color: var(--text-secondary);
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.03); }

.data-table tbody td {
  padding: 13px 18px;
  color: var(--text-primary);
  vertical-align: middle;
}

/* Progress Bar */
.progress-wrap { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.progress-bar-bg {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s ease;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}
.progress-label { font-size: 12px; font-weight: 600; color: var(--text-primary); min-width: 32px; text-align: right; }

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.badge-green  { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-blue   { background: rgba(59,130,246,0.15); color: var(--primary-light); }
.badge-orange { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-red    { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-gray   { background: rgba(148,163,184,0.15); color: var(--text-secondary); }

/* ============================================================
   ACTIVITY LIST
   ============================================================ */
.activity-list { display: flex; flex-direction: column; gap: 14px; }
.activity-item { display: flex; align-items: flex-start; gap: 12px; }
.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.activity-dot.blue  { background: var(--primary); }
.activity-dot.green { background: var(--success); }
.activity-dot.orange{ background: var(--warning); }
.activity-dot.red   { background: var(--danger); }
.activity-text { flex: 1; }
.activity-main { font-size: 13px; color: var(--text-primary); }
.activity-main strong { color: var(--primary-light); }
.activity-time { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   WEATHER
   ============================================================ */
.weather-main { text-align: center; padding: 8px 0 16px; }
.weather-icon { font-size: 48px; line-height: 1; }
.weather-temp { font-size: 36px; font-weight: 800; color: var(--warning); margin-top: 4px; }
.weather-desc { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.weather-stats { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border-light); padding-top: 12px; }
.weather-stat { display: flex; justify-content: space-between; font-size: 13px; }
.weather-stat span:first-child { color: var(--text-secondary); }
.weather-stat span:last-child { font-weight: 600; color: var(--text-primary); }
.weather-forecast { display: flex; gap: 8px; margin-top: 14px; overflow-x: auto; }
.forecast-day {
  flex: 1;
  min-width: 44px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  text-align: center;
}
.forecast-day .day { font-size: 10px; color: var(--text-muted); font-weight: 600; }
.forecast-day .icon { font-size: 18px; margin: 4px 0; }
.forecast-day .temp { font-size: 11px; font-weight: 600; color: var(--text-primary); }

/* ============================================================
   PROJECT CARDS
   ============================================================ */
.project-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.project-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.project-card.status-active::before { background: linear-gradient(90deg, var(--primary), var(--accent)); }
.project-card.status-done::before   { background: linear-gradient(90deg, var(--success), #16A34A); }
.project-card.status-paused::before { background: linear-gradient(90deg, var(--warning), #D97706); }

.project-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: rgba(59,130,246,0.3); }

.project-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.project-card-name { font-size: 16px; font-weight: 700; color: var(--text-primary); line-height: 1.3; }
.project-card-location { font-size: 12px; color: var(--text-muted); margin-top: 3px; display: flex; align-items: center; gap: 4px; }

.project-card-stats { display: flex; gap: 16px; margin: 14px 0; }
.project-stat { display: flex; flex-direction: column; gap: 1px; }
.project-stat-val { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.project-stat-lbl { font-size: 11px; color: var(--text-muted); }

.project-card-progress { margin: 14px 0 10px; }
.project-card-progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }

.project-card-footer { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; border-top: 1px solid var(--border-light); }
.project-card-manager { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-secondary); }
.mini-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff;
}

/* ============================================================
   KANBAN
   ============================================================ */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
}

.kanban-col {
  min-width: 280px;
  flex: 1;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.col-badge {
  font-size: 13px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
}
.col-badge.todo       { background: rgba(148,163,184,0.15); color: var(--text-secondary); }
.col-badge.inprogress { background: rgba(59,130,246,0.15); color: var(--primary-light); }
.col-badge.review     { background: rgba(245,158,11,0.15); color: var(--warning); }
.col-badge.done       { background: rgba(34,197,94,0.15); color: var(--success); }

.col-count {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--text-secondary);
}

.kanban-cards { padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 200px; }

.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all var(--transition);
}
.kanban-card:hover { border-color: rgba(59,130,246,0.4); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.kanban-card-project { font-size: 11px; color: var(--primary-light); font-weight: 600; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.kanban-card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); line-height: 1.4; margin-bottom: 10px; }
.kanban-card-footer { display: flex; justify-content: space-between; align-items: center; }
.kanban-card-due { font-size: 11.5px; color: var(--text-muted); }
.priority-tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.priority-high   { background: rgba(239,68,68,0.15); color: var(--danger); }
.priority-medium { background: rgba(245,158,11,0.15); color: var(--warning); }
.priority-low    { background: rgba(34,197,94,0.15); color: var(--success); }

/* ============================================================
   GANTT
   ============================================================ */
.gantt-container { overflow-x: auto; }

.gantt-table { width: 100%; border-collapse: collapse; }
.gantt-table th {
  padding: 12px 16px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: left;
}
.gantt-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.gantt-table tbody tr:hover { background: rgba(255,255,255,0.03); }

.gantt-task-name { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.gantt-task-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.gantt-bar-cell { min-width: 400px; padding: 10px 0; }
.gantt-bar-bg { height: 28px; background: rgba(255,255,255,0.05); border-radius: 14px; position: relative; overflow: hidden; }
.gantt-bar-fill {
  height: 100%;
  border-radius: 14px;
  position: absolute;
  top: 0;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  transition: width 1s ease;
}

/* ============================================================
   DOCUMENTS
   ============================================================ */
.doc-filter-bar { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.doc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  transition: all var(--transition);
  cursor: pointer;
}
.doc-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: rgba(59,130,246,0.3); }

.doc-icon { font-size: 40px; margin-bottom: 12px; }
.doc-name { font-size: 14px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; line-height: 1.3; }
.doc-meta { font-size: 12px; color: var(--text-muted); }
.doc-type { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px; margin-top: 8px; }
.doc-type-contract { background: rgba(59,130,246,0.15); color: var(--primary-light); }
.doc-type-drawing  { background: rgba(245,158,11,0.15); color: var(--warning); }
.doc-type-permit   { background: rgba(34,197,94,0.15); color: var(--success); }
.doc-type-report   { background: rgba(139,92,246,0.15); color: #A78BFA; }

/* ============================================================
   PHOTOS GRID
   ============================================================ */
.photo-filter-bar { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.photo-item {
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  aspect-ratio: 4/3;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.photo-item:hover { transform: scale(1.02); box-shadow: var(--shadow-lg); }
.photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  padding: 20px 12px 10px;
  transform: translateY(100%);
  transition: transform var(--transition);
}
.photo-item:hover .photo-overlay { transform: translateY(0); }
.photo-overlay-text { font-size: 12px; color: #fff; font-weight: 500; }
.photo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-card2);
}
.photo-placeholder-icon { font-size: 32px; opacity: 0.6; }
.photo-placeholder-text { font-size: 12px; color: var(--text-muted); }

/* ============================================================
   ISSUES
   ============================================================ */
.issue-stats {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.issue-stat-card {
  flex: 1;
  min-width: 120px;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
}
.issue-stat-card.critical { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.2); }
.issue-stat-card.high     { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.2); }
.issue-stat-card.medium   { background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.2); }
.issue-stat-card.low      { background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.2); }

.issue-stat-num { font-size: 32px; font-weight: 800; }
.issue-stat-card.critical .issue-stat-num { color: var(--danger); }
.issue-stat-card.high .issue-stat-num     { color: var(--warning); }
.issue-stat-card.medium .issue-stat-num   { color: var(--primary-light); }
.issue-stat-card.low .issue-stat-num      { color: var(--success); }
.issue-stat-label { font-size: 13px; color: var(--text-secondary); font-weight: 600; }

.issue-list { display: flex; flex-direction: column; gap: 12px; }

.issue-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  transition: all var(--transition);
  cursor: pointer;
}
.issue-item:hover { border-color: rgba(59,130,246,0.3); transform: translateX(3px); }
.issue-item.critical-border { border-left: 3px solid var(--danger); }
.issue-item.high-border     { border-left: 3px solid var(--warning); }
.issue-item.medium-border   { border-left: 3px solid var(--primary); }
.issue-item.low-border      { border-left: 3px solid var(--success); }

.issue-severity { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sev-icon { font-size: 20px; }
.sev-label { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }

.issue-body { flex: 1; }
.issue-title { font-size: 15px; font-weight: 700; color: var(--text-primary); margin-bottom: 5px; }
.issue-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.issue-meta { display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.issue-meta-item { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }

.issue-actions { display: flex; flex-direction: column; gap: 6px; }

/* ============================================================
   DAILY REPORT
   ============================================================ */
.daily-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

.daily-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition);
  cursor: pointer;
}
.daily-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: rgba(59,130,246,0.3); }

.daily-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.daily-card-date { font-size: 13px; color: var(--text-muted); }
.daily-card-project { font-size: 16px; font-weight: 700; color: var(--text-primary); margin-top: 3px; }
.daily-card-weather { font-size: 24px; }
.daily-card-stats { display: flex; gap: 16px; margin: 12px 0; padding: 12px 0; border-top: 1px solid var(--border-light); border-bottom: 1px solid var(--border-light); }
.daily-stat { display: flex; flex-direction: column; gap: 2px; }
.daily-stat-val { font-size: 18px; font-weight: 700; color: var(--primary); }
.daily-stat-lbl { font-size: 11px; color: var(--text-muted); }
.daily-card-body { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }

/* ============================================================
   RESOURCES
   ============================================================ */
.resource-tabs { display: flex; gap: 6px; margin-bottom: 20px; }

.tab-btn {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.tab-btn.active { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; border-color: var(--primary); box-shadow: 0 4px 12px rgba(59,130,246,0.3); }
.tab-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

.tab-content { display: none; }
.tab-content.active { display: block; }

.machine-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; padding: 20px; }
.machine-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
}
.machine-icon { font-size: 40px; margin-bottom: 10px; }
.machine-name { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.machine-detail { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }

/* ============================================================
   REPORTS
   ============================================================ */
.report-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.report-type-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.report-type-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: rgba(59,130,246,0.4); }
.report-type-icon { font-size: 40px; }
.report-type-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.report-type-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* ============================================================
   SETTINGS
   ============================================================ */
.settings-grid { display: grid; grid-template-columns: 200px 1fr; gap: 20px; }

.settings-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  height: fit-content;
}

.settings-menu { display: flex; flex-direction: column; gap: 2px; }
.settings-menu-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.settings-menu-item:hover { background: var(--sidebar-hover); color: var(--text-primary); }
.settings-menu-item.active { background: rgba(59,130,246,0.15); color: var(--primary-light); font-weight: 600; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: all var(--transition);
  outline: none;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.form-input::placeholder { color: var(--text-muted); }

.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  outline: none;
  transition: all var(--transition);
}
.form-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }

.select-input {
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: all var(--transition);
}
.select-input:focus { border-color: var(--primary); }
.select-input option, select option { background-color: var(--bg-card); color: var(--text-primary); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 300;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-slow);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(59,130,246,0.1);
}
.modal.open { opacity: 1; pointer-events: all; transform: translate(-50%, -50%) scale(1); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.modal-close { color: var(--text-muted); font-size: 18px; padding: 4px 8px; border-radius: 6px; transition: all var(--transition); }
.modal-close:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 24px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: slideInToast 0.3s ease, fadeOutToast 0.3s ease 2.7s forwards;
  min-width: 300px;
  max-width: 400px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--primary); }
.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-text { font-size: 13.5px; color: var(--text-primary); font-weight: 500; }

@keyframes slideInToast {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOutToast {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(100%); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.mobile-open { transform: translateX(0); }

  .main-content { margin-left: 0; width: 100%; }

  .mobile-menu-btn { display: flex; }

  .search-box { display: none; }

  .page { padding: 16px 16px 40px; }

  .page-header { flex-direction: column; align-items: flex-start; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  .kanban-board { overflow-x: auto; }

  .form-row { grid-template-columns: 1fr; }

  .settings-grid { grid-template-columns: 1fr; }
  .settings-sidebar { display: none; }

  .project-cards-grid { grid-template-columns: 1fr; }

  .gantt-bar-cell { min-width: 250px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 22px; }
}

/* ============================================================
   STAR BACKGROUND (decorative)
   ============================================================ */
body::before {
  content: '';
  position: fixed;
  top: 0; left: var(--sidebar-w); right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(59,130,246,0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(6,182,212,0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.page-container { position: relative; z-index: 1; }

/* Star rating */
.stars { color: var(--warning); font-size: 14px; letter-spacing: 1px; }

/* Supplier rating */
.rating-bar { display: inline-flex; gap: 2px; }

/* ============================================================
   SETTINGS EXTRA STYLING
   ============================================================ */
.switch-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}
.switch-wrap:last-child {
  border-bottom: none;
}
.switch-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.switch-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.switch-control {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}
.switch-control input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-hover);
  transition: .3s;
  border-radius: 24px;
  border: 1px solid var(--border);
}
.switch-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .3s;
  border-radius: 50%;
}
.switch-control input:checked + .switch-slider {
  background-color: var(--primary);
  border-color: var(--primary-light);
}
.switch-control input:checked + .switch-slider:before {
  transform: translateX(22px);
  background-color: #ffffff;
}

/* Permissions table styling */
.permission-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}
.permission-table th, .permission-table td {
  padding: 12px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.permission-table th {
  color: var(--text-secondary);
  font-weight: 600;
  background: var(--bg-hover);
}
.permission-table th:first-child, .permission-table td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 140px;
}
.permission-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* ============================================================
   THEME OVERRIDES
   ============================================================ */
body.light-theme {
  color-scheme: light;
  --bg:           #EAEDF2;
  --bg-card:      #F4F6F9;
  --bg-card2:     #E7EAF0;
  --bg-hover:     #DBDFE6;
  --text-primary:  #0E1521;
  --text-secondary:#3A4454;
  --text-muted:    #52606D;
  --border:        #B6BEC9;
  --border-light:  #C7CDD6;
  --glass-bg:      rgba(244,246,249,0.9);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.07);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.10);
}
body.light-theme::before {
  opacity: 0.1;
}
body.light-theme select,
body.light-theme select:focus,
body.light-theme input {
  color-scheme: light;
}

/* ------------------------------------------------------------
   Light-mode fixes: a handful of pages hardcode dark inline
   colors for selects/modals/popovers that were never made
   theme-aware. These overrides only apply under body.light-theme
   (higher specificity than the page-local rules), so dark mode
   (and cyberpunk) are completely unaffected.
   ------------------------------------------------------------ */
body.light-theme #filterProject {
  background: var(--bg-card2) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}
body.light-theme #filterTrade option {
  background: var(--bg-card);
  color: var(--text-primary);
}
body.light-theme .modal-content {
  background: var(--bg-card);
  border-color: var(--border);
}
body.light-theme .action-dropdown-menu {
  background: var(--bg-card);
  border-color: var(--border);
}
body.light-theme #addMachineryModal > div {
  background: var(--bg-card) !important;
}
body.light-theme #addMachineryModal > div > div:first-child,
body.light-theme #addMachineryModal > div > div:last-child {
  border-color: var(--border) !important;
}
body.light-theme #addMachineryModal > div > div:last-child {
  background: var(--bg-card2) !important;
}
body.light-theme #editMaterialModal > div {
  background: var(--bg-card) !important;
}
body.light-theme #editMaterialModal > div > div:first-child {
  border-color: var(--border) !important;
}
body.light-theme #edit-code {
  background: var(--bg-hover) !important;
}
body.light-theme #dayDetailPopover > div {
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
}
body.light-theme #dayDetailPopover button {
  background: var(--bg-hover) !important;
  color: var(--text-primary) !important;
}
body.light-theme .dark-input-legacy {
  background: var(--bg) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
  color-scheme: light;
}

/* Settings > User Account: signature pad canvas + preview box, and Org logo
   preview box, were hardcoded to dark navy (#1e293b) with slate borders
   (#475569) directly in the JS-generated markup (app_core.js), so they stayed
   solid dark boxes in light mode with barely-visible placeholder text. */
body.light-theme #profileSigCanvas,
body.light-theme #profileSigPreview,
body.light-theme #orgLogoPreview {
  background: var(--bg-hover) !important;
  border-color: var(--border) !important;
}

/* .form-input/.form-textarea default to background:var(--bg) + border:var(--border).
   In light mode --bg (#EAEDF2) sits almost flush against a white modal/card, and
   --border (#B6BEC9) fails WCAG non-text contrast (~1.75:1) against that background
   — every form field across the whole app (39 files use .form-input) reads as a
   flat, borderless block in light mode. Scoped override here instead of touching
   --bg/--border globally, which are used by many other already-verified elements. */
body.light-theme .form-input,
body.light-theme .form-textarea {
  background: #FFFFFF;
  border-color: #64748B;
}
body.light-theme .form-input:focus,
body.light-theme .form-textarea:focus {
  border-color: var(--primary);
}

body.cyberpunk-theme {
  --primary:       #FF007F;
  --primary-dark:  #99004C;
  --primary-light: #FF66B2;
  --accent:        #00FFFF;
  --sidebar-bg:    #1A0033;
  --sidebar-bg2:   #0D001A;
  --bg:           #050010;
  --bg-card:      #120024;
  --bg-card2:     #21003D;
  --bg-hover:     #33005C;
  --text-primary:  #00FFFF;
  --text-secondary:#FF007F;
  --text-muted:    #A855F7;
  --border:        rgba(0, 255, 255, 0.15);
  --border-light:  rgba(255, 0, 127, 0.15);
  --shadow-glow: 0 0 20px rgba(0,255,255,0.4);
}
body.cyberpunk-theme::before {
  opacity: 0.3;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(255,0,127,0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(0,255,255,0.15) 0%, transparent 50%);
}

/* ============================================================
   REPORTS DETAIL MODE STYLING
   ============================================================ */
.report-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 16px;
}
.report-header-left {
  display: flex;
  align-items: center;
}
.report-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.report-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.report-stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}
.report-stat-info {
  display: flex;
  flex-direction: column;
}
.report-stat-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}
.report-stat-label {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Gradient KPI card style (reused for the Reports module, matching the
   NCR/RFI KPI card design). Named report-kpi-* to avoid clashing with the
   existing .kpi-card class used on the main dashboard. */
.report-kpi-card { position: relative; overflow: hidden; border-radius: var(--radius-lg); padding: 20px; box-shadow: 0 10px 20px -8px rgba(0,0,0,0.3); transition: transform .2s; }
.report-kpi-card:hover { transform: translateY(-2px); }
.report-kpi-card.report-kpi-blue   { background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%); }
.report-kpi-card.report-kpi-red    { background: linear-gradient(135deg, #7f1d1d 0%, #ef4444 100%); }
.report-kpi-card.report-kpi-green  { background: linear-gradient(135deg, #064e3b 0%, #10b981 100%); }
.report-kpi-card.report-kpi-amber  { background: linear-gradient(135deg, #78350f 0%, #f59e0b 100%); }
.report-kpi-card.report-kpi-purple { background: linear-gradient(135deg, #4c1d95 0%, #8b5cf6 100%); }
.report-kpi-card.report-kpi-cyan   { background: linear-gradient(135deg, #164e63 0%, #06b6d4 100%); }
.report-kpi-graph { position: absolute; bottom: 0; left: 0; width: 100%; height: 55%; z-index: 0; pointer-events: none; opacity: 0.6; }
.report-kpi-body { position: relative; z-index: 2; display: flex; flex-direction: column; gap: 2px; }
.report-kpi-label { font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.75); }
.report-kpi-value { font-size: 26px; font-weight: 800; color: #ffffff; line-height: 1.1; }
.report-kpi-icon { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); opacity: 0.15; color: #ffffff; z-index: 1; pointer-events: none; }
.report-kpi-icon svg { width: 40px; height: 40px; }
.report-chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}
.report-chart-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}
.report-table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}
.report-table-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.low-stock-alert {
  color: var(--danger);
  font-weight: 600;
  background: rgba(239, 68, 68, 0.15);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
}
.ok-stock-badge {
  color: var(--success);
  font-weight: 600;
  background: rgba(34, 197, 94, 0.15);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
}
.progress-bar-container {
  width: 100%;
  background: var(--border);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-bar-fill-cyan {
  background: var(--cyan);
  height: 100%;
}
.progress-bar-fill-blue {
  background: var(--blue);
  height: 100%;
}

/* ============================================================
   PRINT STYLING (พิมพ์รายงาน)
   ============================================================ */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .sidebar, .topbar, .mobile-menu-btn, .report-detail-header button, .project-selector-wrap, body::before {
    display: none !important;
  }
  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }
  .page {
    display: none !important;
  }
  .page#page-reports {
    display: block !important;
    background: #ffffff !important;
  }
  #reportsGridMode {
    display: none !important;
  }
  #reportsDetailMode {
    display: block !important;
  }
  .report-stat-card, .report-chart-card, .report-table-card, .card {
    background: #ffffff !important;
    border: 1px solid #cccccc !important;
    box-shadow: none !important;
    color: #000000 !important;
  }
  .report-kpi-card { background: #ffffff !important; border: 1px solid #cccccc !important; box-shadow: none !important; }
  .report-kpi-graph, .report-kpi-icon { display: none !important; }
  .report-kpi-label { color: #555555 !important; }
  .report-kpi-value { color: #000000 !important; }
  .report-stat-val, .report-chart-title, .report-table-title, .page-title, th, td, h1, h2, h3, p {
    color: #000000 !important;
  }
  th {
    background: #f0f0f0 !important;
    border-bottom: 2px solid #cccccc !important;
  }
  td {
    border-bottom: 1px solid #e0e0e0 !important;
  }
  /* Simple black and white chart colors for print */
  svg rect {
    stroke: #000000 !important;
  }

  /* Modal Print Settings - Hide it entirely to prevent overlapping with the real report! */
  #reportPreviewModal {
    display: none !important;
  }

  /* Ensure the real report fits on the page */
  #reportsDetailMode {
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
  }

  .report-chart-card, .report-stat-card, .report-kpi-card, .report-table-card, .card {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    margin-bottom: 20px !important;
  }

  /* Force tables to compress and not overflow */
  .data-table-container, .table-responsive, .overflow-x-auto {
    overflow: visible !important;
  }

  table {
    width: 100% !important;
    max-width: 100% !important;
    table-layout: fixed !important;
    word-wrap: break-word !important;
  }

  table th, table td {
    word-wrap: break-word !important;
    white-space: normal !important;
    font-size: 10px !important; /* Smaller font to fit data */
    padding: 4px !important;
  }

  /* Force charts to fit */
  .report-chart-card canvas {
    max-width: 100% !important;
    height: auto !important;
    page-break-inside: avoid !important;
  }

  @page {
    size: A4 landscape;
    margin: 10mm;
  }
}
/* ============================================================
   NEW KPI CARDS (PREMIUM DESIGN)
   ============================================================ */
.kpi-cards-new { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 24px; }
.kpi-card-new { position: relative; overflow: hidden; border-radius: 14px; padding: 26px; min-height: 118px; display: flex; flex-direction: column; justify-content: center; color: white; box-shadow: 0 4px 12px rgba(0,0,0,0.1); border: 1px solid rgba(255,255,255,0.08); transition: transform 0.2s, box-shadow 0.2s; }
.kpi-card-new:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.15); }
.kpi-card-new.blue { background: linear-gradient(135deg, #3B82F6, #2563EB); }
.kpi-card-new.amber { background: linear-gradient(135deg, #F59E0B, #D97706); }
.kpi-card-new.green { background: linear-gradient(135deg, #10B981, #059669); }
.kpi-card-new.purple { background: linear-gradient(135deg, #8B5CF6, #6D28D9); }
.kpi-card-new.cyan { background: linear-gradient(135deg, #06B6D4, #0891B2); }
.kpi-card-new.red { background: linear-gradient(135deg, #EF4444, #DC2626); }
.kpi-graph-bg { position: absolute; bottom: 0; left: 0; right: 0; height: 50%; opacity: 0.6; pointer-events: none; }
.kpi-body { position: relative; z-index: 1; }
.kpi-label-new { font-size: 14px; font-weight: 500; opacity: 0.9; margin-bottom: 10px; display: block; }
.kpi-value-new { font-size: 34px; font-weight: 700; line-height: 1.2; }
.kpi-icon-right { position: absolute; right: 22px; top: 50%; transform: translateY(-50%); opacity: 0.2; width: 58px; height: 58px; }
.kpi-icon-right svg { width: 100%; height: 100%; }

@media (max-width: 1200px) {
  .kpi-cards-new { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .kpi-cards-new { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}
@media (max-width: 480px) {
  .kpi-cards-new { grid-template-columns: 1fr; }
}
