/* style.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700;800&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
  /* HSL Color System */
  --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
  
  /* Glassmorphism Variables */
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-bg-hover: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.06);
  --glass-shadow-large: 0 16px 48px 0 rgba(31, 38, 135, 0.12);
  --glass-blur: blur(12px);

  /* Solid Colors */
  --text-main: #1e293b;
  --text-muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: rgba(79, 70, 229, 0.1);
  --accent: #06b6d4;
  --accent-light: rgba(6, 182, 212, 0.1);

  /* Priorities Colors */
  --priority-high-bg: #fee2e2;
  --priority-high-text: #991b1b;
  --priority-high-border: #fca5a5;
  
  --priority-medium-bg: #ffedd5;
  --priority-medium-text: #9a3412;
  --priority-medium-border: #fed7aa;
  
  --priority-low-bg: #ecfdf5;
  --priority-low-text: #065f46;
  --priority-low-border: #a7f3d0;

  /* Status Colors */
  --status-open-bg: #e0f2fe;
  --status-open-text: #0369a1;
  --status-progress-bg: #faf5ff;
  --status-progress-text: #6b21a8;
  --status-spare-bg: #fff7ed;
  --status-spare-text: #c2410c;
  --status-approve-bg: #fef3c7;
  --status-approve-text: #92400e;
  --status-done-bg: #f0fdf4;
  --status-done-text: #166534;
  --status-inspect-bg: #fdf2f8;
  --status-inspect-text: #9d174d;
  --status-closed-bg: #f1f5f9;
  --status-closed-text: #475569;

  /* Categories Gradient/Borders */
  --cat-building: #ec4899;
  --cat-engineer: #3b82f6;
  --cat-finance: #10b981;
  --cat-service: #f59e0b;
  --cat-security: #ef4444;
  --cat-maid: #8b5cf6;
  --cat-office: #6366f1;
  --cat-undefined: #64748b;

  --border-radius-sm: 8px;
  --border-radius-md: 16px;
  --border-radius-lg: 24px;
  --transition-speed: 0.3s;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Outfit', 'Sarabun', 'Inter', sans-serif;
  color: var(--text-main);
  background: var(--bg-gradient);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* Background floating bubbles */
.bg-bubbles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.bg-bubbles li {
  position: absolute;
  list-style: none;
  display: block;
  width: 40px;
  height: 40px;
  background-color: rgba(255, 255, 255, 0.15);
  bottom: -160px;
  border-radius: 50%;
  animation: square 25s infinite linear;
}

.bg-bubbles li:nth-child(1) { left: 10%; width: 80px; height: 80px; animation-delay: 0s; }
.bg-bubbles li:nth-child(2) { left: 20%; width: 130px; height: 130px; animation-delay: 2s; animation-duration: 17s; }
.bg-bubbles li:nth-child(3) { left: 25%; animation-delay: 4s; }
.bg-bubbles li:nth-child(4) { left: 40%; width: 90px; height: 90px; animation-duration: 22s; }
.bg-bubbles li:nth-child(5) { left: 70%; width: 120px; height: 120px; }
.bg-bubbles li:nth-child(6) { left: 80%; width: 150px; height: 150px; animation-delay: 3s; }
.bg-bubbles li:nth-child(7) { left: 32%; width: 160px; height: 160px; animation-delay: 7s; }
.bg-bubbles li:nth-child(8) { left: 55%; animation-delay: 15s; animation-duration: 40s; }
.bg-bubbles li:nth-child(9) { left: 25%; width: 40px; height: 40px; animation-delay: 2s; animation-duration: 40s; }
.bg-bubbles li:nth-child(10) { left: 90%; width: 100px; height: 100px; animation-delay: 11s; }

@keyframes square {
  0% { transform: translateY(0) rotate(0deg); opacity: 0.1; }
  100% { transform: translateY(-1000px) rotate(600deg); opacity: 0; }
}

/* Scrollbar Styles */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.02);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

/* Glassmorphism General Classes */
.glass-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  border-radius: var(--border-radius-md);
  transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease, background var(--transition-speed) ease;
}

.glass-panel:hover {
  background: var(--glass-bg-hover);
  box-shadow: var(--glass-shadow-large);
}

/* 1. Login Page */
#login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
  position: relative;
}

.login-card {
  width: 420px;
  padding: 40px;
  text-align: center;
}

.login-logo {
  margin-bottom: 24px;
}

.login-logo .icon {
  font-size: 3rem;
  color: var(--primary);
  filter: drop-shadow(0 4px 6px rgba(79, 70, 229, 0.2));
}

.login-logo h1 {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.8rem;
  color: var(--primary);
  margin-top: 8px;
  letter-spacing: 0.5px;
}

.login-logo p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 8px;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-wrapper {
  position: relative;
}

.input-wrapper i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  font-family: 'Sarabun', sans-serif;
  font-size: 0.95rem;
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.8);
  color: var(--text-main);
  outline: none;
  transition: all var(--transition-speed);
}

.form-input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  border-radius: var(--border-radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--primary) 0%, #4338ca 100%);
  color: #fff;
  font-family: 'Sarabun', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
  transition: all var(--transition-speed);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
  filter: brightness(1.05);
}

.btn-primary:active {
  transform: translateY(0);
}

.login-error {
  margin-top: 15px;
  padding: 10px;
  background: rgba(239, 68, 68, 0.1);
  border-left: 4px solid #ef4444;
  color: #b91c1c;
  border-radius: 4px;
  font-size: 0.85rem;
  display: none;
  text-align: left;
}

.login-hint {
  margin-top: 24px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.02);
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  border: 1px dashed rgba(0, 0, 0, 0.05);
}

/* 2. Dashboard Shell Layout */
#dashboard-screen {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

.mobile-top-bar {
  display: none !important;
}

/* Sidebar */
.sidebar {
  width: 280px;
  height: 100vh;
  padding: 30px 20px;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--glass-border);
  border-radius: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 35px;
  padding-left: 8px;
}

.sidebar-brand .icon {
  font-size: 2rem;
  color: var(--primary);
}

.sidebar-brand h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.sidebar-brand span {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  display: block;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  margin-bottom: 30px;
}

.user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 1.2rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.user-info {
  flex-grow: 1;
  overflow: hidden;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
  margin-top: 3px;
  font-weight: 500;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

#menu-profile {
  display: none !important;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-speed);
}

.nav-item a i {
  font-size: 1.15rem;
  width: 20px;
  text-align: center;
}

.nav-item a:hover {
  background: rgba(255, 255, 255, 0.4);
  color: var(--text-main);
}

.nav-item.active a {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

.logout-container {
  margin-top: auto;
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.15);
  border-radius: var(--border-radius-sm);
  color: #dc2626;
  font-family: 'Sarabun', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.btn-logout:hover {
  background: #dc2626;
  color: #fff;
}

/* Main Content Area */
.main-content {
  flex-grow: 1;
  margin-left: 280px;
  padding: 40px;
  min-height: 100vh;
  width: calc(100vw - 280px);
  max-width: calc(100vw - 280px);
  overflow-x: hidden;
}

.content-panel {
  display: none;
  animation: fadeIn 0.4s ease-in-out forwards;
}

.content-panel.active {
  display: block;
}

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

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.page-title h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
}

.page-title p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.header-actions {
  display: flex;
  gap: 12px;
}

/* General button helper */
.btn-action {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--border-radius-sm);
  font-family: 'Sarabun', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-speed);
  border: 1px solid var(--glass-border);
}

.btn-action.primary {
  background: var(--primary);
  color: #fff;
  border: none;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
}

.btn-action.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(79, 70, 229, 0.3);
}

.btn-action.secondary {
  background: var(--glass-bg);
  color: var(--text-main);
}

.btn-action.secondary:hover {
  background: var(--glass-bg-hover);
  transform: translateY(-1px);
}

/* 3. Overview Panel (Committee / Dashboard View) */
.kpi-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.kpi-card {
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.kpi-card .kpi-icon {
  position: absolute;
  right: 20px;
  top: 20px;
  font-size: 2.2rem;
  opacity: 0.15;
  color: var(--primary);
}

.kpi-card.overdue .kpi-icon { color: #ef4444; }
.kpi-card.done .kpi-icon { color: #10b981; }

.kpi-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-value {
  font-family: 'Outfit', sans-serif;
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 8px;
  line-height: 1;
}

.kpi-trend {
  font-size: 0.8rem;
  margin-top: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.kpi-card.overdue {
  border-left: 4px solid #ef4444;
}

.kpi-card.overdue .kpi-value {
  color: #ef4444;
}

/* Visual Dashboard Charts Section */
.charts-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 25px;
  margin-bottom: 30px;
}

.chart-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.chart-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-wrapper {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 220px;
}

/* Donut Chart SVG design */
.donut-svg {
  width: 180px;
  height: 180px;
  transform: rotate(-90deg);
}

.donut-segment {
  fill: none;
  stroke-width: 18;
  transition: stroke-dasharray 0.5s ease-in-out;
}

.donut-hole {
  fill: transparent;
}

.donut-center-text {
  text-anchor: middle;
  dominant-baseline: middle;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  fill: var(--text-main);
}

.chart-legend {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 15px;
  font-size: 0.85rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

/* Bar Chart styling using pure HTML/CSS Grid */
.bar-chart-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bar-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bar-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 500;
}

.bar-track {
  width: 100%;
  height: 10px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 5px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0; /* Dynamic loading in app.js */
}

/* Search and Filters container */
.filters-panel {
  padding: 20px;
  margin-bottom: 30px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 15px;
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-group label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-select, .filter-input {
  width: 100%;
  padding: 10px 14px;
  font-family: 'Sarabun', sans-serif;
  font-size: 0.85rem;
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition-speed);
}

.filter-select:focus, .filter-input:focus {
  border-color: var(--primary);
}

/* Master list of Tasks Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.tasks-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.tasks-table th {
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.02);
  border-bottom: 2px solid rgba(0, 0, 0, 0.05);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.tasks-table td {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  color: var(--text-main);
  vertical-align: middle;
}

.tasks-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.4);
}

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

/* Badges for priority and status */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

.badge-high { background: var(--priority-high-bg); color: var(--priority-high-text); border: 1px solid var(--priority-high-border); }
.badge-medium { background: var(--priority-medium-bg); color: var(--priority-medium-text); border: 1px solid var(--priority-medium-border); }
.badge-low { background: var(--priority-low-bg); color: var(--priority-low-text); border: 1px solid var(--priority-low-border); }
.badge-undefined { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }

.badge-status {
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.75rem;
}

.badge-open { background: var(--status-open-bg); color: var(--status-open-text); }
.badge-progress { background: var(--status-progress-bg); color: var(--status-progress-text); }
.badge-spare { background: var(--status-spare-bg); color: var(--status-spare-text); }
.badge-approve { background: var(--status-approve-bg); color: var(--status-approve-text); }
.badge-done { background: var(--status-done-bg); color: var(--status-done-text); }
.badge-inspect { background: var(--status-inspect-bg); color: var(--status-inspect-text); }
.badge-closed { background: var(--status-closed-bg); color: var(--status-closed-text); }

.category-tag {
  font-size: 0.8rem;
  font-weight: 500;
  padding-left: 10px;
  position: relative;
  display: inline-block;
}

.category-tag::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.cat-building::before { background: var(--cat-building); }
.cat-engineer::before { background: var(--cat-engineer); }
.cat-finance::before { background: var(--cat-finance); }
.cat-service::before { background: var(--cat-service); }
.cat-security::before { background: var(--cat-security); }
.cat-maid::before { background: var(--cat-maid); }
.cat-office::before { background: var(--cat-office); }
.cat-undefined::before { background: var(--cat-undefined); }

/* Overdue visual text wrapper */
.date-wrapper {
  display: flex;
  flex-direction: column;
}

.date-wrapper .overdue-tag {
  color: #dc2626;
  font-size: 0.7rem;
  font-weight: 700;
  margin-top: 2px;
}

/* 4. Kanban Board Panel */
.kanban-board-wrapper {
  display: flex;
  gap: 15px;
  overflow-x: auto;
  padding-bottom: 20px;
  min-height: calc(100vh - 200px);
  align-items: flex-start;
}

.kanban-column {
  flex: 0 0 300px;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  max-height: 75vh;
}

.kanban-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.03);
}

.column-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.column-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-main);
}

.column-count {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
}

.column-lock-icon {
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: help;
}

.column-cards-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex-grow: 1;
  min-height: 150px;
  padding: 4px;
}

.column-cards-container.drag-over {
  background: rgba(79, 70, 229, 0.04);
  border-radius: 8px;
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
}

/* Kanban Cards styling */
.kanban-card {
  padding: 16px;
  cursor: grab;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card.dragging {
  opacity: 0.5;
  transform: scale(0.95);
}

.kanban-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kanban-card-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.4;
}

.kanban-card-details {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.kanban-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(0, 0, 0, 0.03);
  padding-top: 8px;
  margin-top: 4px;
}

.kanban-card-assignee {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.kanban-card-assignee-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.kanban-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.btn-card-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid rgba(0, 0, 0, 0.05);
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  transition: all var(--transition-speed);
}

.btn-card-icon:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.btn-card-icon.delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.2);
}

/* Overdue highlights */
.kanban-card.overdue-card {
  border: 1px solid rgba(239, 68, 68, 0.4);
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.08);
}

.kanban-card.overdue-card::after {
  content: 'เกินกำหนด';
  position: absolute;
  top: -8px;
  right: 12px;
  background: #dc2626;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

/* Locked card overlay visual when drag attempts fail */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.shake {
  animation: shake 0.2s ease-in-out 2;
}

/* 5. Logs Panel */
.logs-table-container {
  padding: 24px;
}

.logs-table th {
  background: rgba(0, 0, 0, 0.02);
}

.log-action-text {
  font-weight: 600;
}

.log-timestamp {
  font-family: 'Outfit', sans-serif;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* 6. Admin Panel (User Management) */
.admin-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 25px;
}

.users-list-panel {
  padding: 24px;
}

.user-add-panel {
  padding: 24px;
}

.user-role-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
}

.role-admin { background: #fee2e2; color: #991b1b; }
.role-board { background: #e0f2fe; color: #0369a1; }
.role-team { background: #f0fdf4; color: #166534; }
.role-juristic { background: #f3e8ff; color: #6b21a8; }

/* 7. Modals / Native <dialog> */
dialog {
  margin: auto;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--border-radius-md);
  box-shadow: var(--glass-shadow-large);
  width: 90%;
  max-width: 550px;
  padding: 0;
  outline: none;
  overflow: hidden;
  animation: modalScaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

dialog::backdrop {
  background-color: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-speed);
}

.btn-close-modal:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.form-textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px 14px;
  font-family: 'Sarabun', sans-serif;
  font-size: 0.9rem;
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.8);
  color: var(--text-main);
  outline: none;
  resize: vertical;
  transition: all var(--transition-speed);
}

.form-textarea:focus {
  border-color: var(--primary);
  background: #fff;
}

/* Toast Notification */
.toast-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 24px;
  background: #1e293b;
  color: #fff;
  border-radius: var(--border-radius-sm);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  font-size: 0.9rem;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.toast-notification.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-notification.error {
  background: #ef4444;
}

.toast-notification.success {
  background: #10b981;
}

/* Mobile & Tablet Responsiveness */
@media (max-width: 1024px) {
  .charts-container {
    grid-template-columns: 1fr;
  }
  .filters-panel {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); /* Space for sticky bottom tab bar */
    overflow-x: hidden;
  }

  /* Modify Sidebar on Mobile (Hide visual content but keep container active for bottom tab bar) */
  .sidebar {
    display: block !important;
    position: static;
    width: 0;
    height: 0;
    padding: 0;
    margin: 0;
    border: none !important;
    background: none !important;
    box-shadow: none !important;
    overflow: visible;
  }

  .sidebar-brand,
  .sidebar .user-profile,
  .sidebar .logout-container {
    display: none !important;
  }

  #menu-profile {
    display: flex !important;
  }

  /* Bottom Tab Bar for App Navigation with Safe Area Support */
  .nav-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
    margin: 0;
    z-index: 1000;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.05);
  }

  .nav-item {
    margin-bottom: 0;
    width: auto;
    flex: 1;
    display: flex;
    justify-content: center;
  }

  .nav-item a {
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 0.7rem;
    color: var(--text-muted);
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    text-align: center;
  }

  .nav-item a i {
    font-size: 1.25rem;
    margin-right: 0;
  }

  .nav-item.active a {
    color: var(--primary);
  }

  /* Main Content Layout Adjustments with Safe Area Padding */
  .main-content {
    margin-left: 0;
    padding: calc(env(safe-area-inset-top, 0px) + 72px) 16px calc(env(safe-area-inset-bottom, 0px) + 84px) 16px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Mobile Top Bar Styles */
  .mobile-top-bar {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(56px + env(safe-area-inset-top, 0px));
    padding: calc(env(safe-area-inset-top, 0px) + 0px) 16px 0 16px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: none;
    border-bottom: 1px solid var(--glass-border);
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
  }

  .mobile-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 60%;
  }

  .mobile-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: var(--glass-shadow-small);
  }

  .mobile-user-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-top-actions {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .mobile-btn-action {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 1.15rem;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
  }

  .mobile-btn-action:active {
    background-color: rgba(79, 70, 229, 0.08);
  }

  .mobile-btn-action.logout {
    color: #dc2626;
  }

  .mobile-btn-action.logout:active {
    background-color: rgba(220, 38, 38, 0.08);
  }

  /* Page Header Title and Actions Stacked */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
  }

  .page-title h2 {
    font-size: 1.4rem;
  }

  .header-actions {
    width: 100%;
    display: flex;
    gap: 10px;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .header-actions button {
    flex: 1;
    min-width: 140px;
    font-size: 0.8rem;
    padding: 8px 12px;
  }

  /* Filters, Admin layout, and charts stack vertically */
  .filters-panel {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px;
  }

  .admin-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  /* Compact KPI layout */
  .kpi-container {
    gap: 12px;
    margin-bottom: 20px;
  }

  .kpi-card {
    padding: 16px;
  }

  .kpi-value {
    font-size: 1.6rem;
  }

  /* Form columns grid inside modals stack vertically */
  .modal-grid-2 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Horizontal scroll for table instead of wrapping */
  .tasks-table {
    min-width: 900px;
  }

  .tasks-table th, .tasks-table td {
    padding: 12px 14px;
    font-size: 0.82rem;
  }

  /* Mobile Specific Settings/Navigation Menu on Profile tab */
  .mobile-navigation-list {
    margin: 25px 0;
    text-align: left;
  }

  .mobile-nav-header {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-weight: 600;
    padding-left: 8px;
  }

  .mobile-menu-options {
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    box-shadow: var(--glass-shadow-small);
  }

  .mobile-menu-option-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: background-color 0.2s ease;
  }

  .mobile-menu-option-item:last-child {
    border-bottom: none;
  }

  .mobile-menu-option-item span {
    display: flex;
    align-items: center;
    gap: 14px;
  }

  .mobile-menu-option-item i {
    color: var(--primary);
    font-size: 1.15rem;
    width: 20px;
    text-align: center;
  }

  .mobile-menu-option-item .arrow {
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: transform 0.2s ease;
  }

  .mobile-menu-option-item:active {
    background-color: rgba(0, 0, 0, 0.05);
  }
}

/* Prevent fixed-width Login Card cut-off on tiny screens */
@media (max-width: 480px) {
  .login-card {
    width: 90%;
    max-width: 400px;
    padding: 30px 20px;
  }
}

/* personal change password button link */
.btn-change-password-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-align: left;
  transition: all 0.2s ease;
}

.btn-change-password-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

