/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --primary: #4F46E5;
  --primary-dark: #4338CA;
  --primary-light: #EEF2FF;
  --primary-hover: #6366F1;
  --success: #10B981;
  --success-bg: #ECFDF5;
  --warning: #F59E0B;
  --warning-bg: #FFFBEB;
  --danger: #EF4444;
  --danger-bg: #FEF2F2;
  --info: #3B82F6;
  --info-bg: #EFF6FF;
  --gray-50: #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;
  --sidebar-w: 248px;
  --header-h: 56px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow: 0 1px 4px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans Thai', sans-serif;
  --transition: 150ms ease;
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--gray-50); color: var(--gray-800); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
ul { list-style: none; }

/* ── Splash ─────────────────────────────────────────────────────────────── */
.splash {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; animation: pulse 1.2s ease infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── Toast ──────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius); font-size: .875rem;
  color: #fff; box-shadow: var(--shadow-md); max-width: 320px;
  animation: slideIn .2s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.info    { background: var(--primary); }
@keyframes slideIn { from{transform:translateX(120%);opacity:0} to{transform:none;opacity:1} }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: auto;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  background: #1E1B4B;
  color: #C7D2FE;
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  z-index: 200;
  overflow-y: auto;
}
.sidebar-header {
  padding: 20px 20px 16px;
  padding-top: max(20px, calc(env(safe-area-inset-top) + 12px));
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-logo {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--primary); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo svg { width: 20px; height: 20px; }
.sidebar-title { font-size: 1rem; font-weight: 700; color: #fff; }
.sidebar-subtitle { font-size: .72rem; color: #818CF8; }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: .7rem; font-weight: 600; color: #4C4B8F; text-transform: uppercase; letter-spacing: .08em; padding: 10px 10px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 7px; cursor: pointer;
  font-size: .875rem; color: #A5B4FC; transition: background var(--transition), color var(--transition);
  position: relative; border: none; background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(99,102,241,.15); color: #E0E7FF; }
.nav-item.active { background: rgba(99,102,241,.25); color: #fff; font-weight: 600; }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 3px; border-radius: 3px; background: var(--primary-hover);
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .8; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto; background: var(--primary); color: #fff;
  font-size: .7rem; font-weight: 700; padding: 1px 6px; border-radius: 10px;
}
.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex; flex-direction: column; gap: 2px;
}
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 7px;
  font-size: .85rem; color: #A5B4FC;
}
.user-chip .user-chip-info { flex: 1; min-width: 0; }
.user-chip .user-chip-name { color: #E0E7FF; font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .user-chip-role { font-size: .7rem; color: #6366F1; }
.lang-toggle {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  font-size: .8rem; cursor: pointer; color: #818CF8; border: none;
  background: transparent; border-radius: 6px; width: 100%;
  transition: background var(--transition);
}
.lang-toggle:hover { background: rgba(99,102,241,.12); }
.lang-toggle svg { width: 17px; height: 17px; flex-shrink: 0; }

/* ── Mobile header ──────────────────────────────────────────────────────── */
.mobile-header {
  display: none; position: fixed; top: 0; left: 0; right: 0;
  height: calc(var(--header-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: #1E1B4B; z-index: 150;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  align-items: center; gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.mobile-header .mobile-title { color: #fff; font-weight: 700; font-size: 1rem; flex: 1; }
.btn-menu {
  background: none; border: none; padding: 6px; color: #C7D2FE;
  display: flex; align-items: center; justify-content: center;
}
.btn-menu svg { width: 24px; height: 24px; }
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 190;
}
.sidebar-overlay.open { display: block; }

/* ── Mobile Bottom Nav ───────────────────────────────────────────────────── */
.mobile-bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(58px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #1E1B4B;
  border-top: 1px solid rgba(255,255,255,.08);
  z-index: 150;
  align-items: stretch;
}
.mbn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; background: none; border: none; cursor: pointer;
  color: #6366F1; font-size: .65rem; font-family: inherit; font-weight: 500;
  padding: 6px 2px; transition: color var(--transition), background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.mbn-item svg { width: 22px; height: 22px; }
.mbn-item.active { color: #fff; }
.mbn-item.active svg { filter: drop-shadow(0 0 4px rgba(99,102,241,.6)); }
.mbn-create-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mbn-create-btn {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--primary); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 12px rgba(79,70,229,.55);
  transition: transform var(--transition);
}
.mbn-create-btn svg { width: 22px; height: 22px; color: #fff; }
.mbn-create-wrap:active .mbn-create-btn { transform: scale(.92); }

/* ── Main content ────────────────────────────────────────────────────────── */
.main {
  grid-column: 2;
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.page-header {
  padding: 28px 32px 0;
  display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap;
}
.page-title { font-size: 1.35rem; font-weight: 700; color: var(--gray-900); }
.page-sub { font-size: .85rem; color: var(--gray-500); margin-top: 2px; }
.page-content { padding: 20px 32px 32px; flex: 1; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm); font-size: .875rem;
  font-weight: 500; border: none; transition: all var(--transition);
  cursor: pointer; white-space: nowrap; line-height: 1;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #FECACA; }
.btn-danger:hover { background: #FEE2E2; }
.btn-ghost { background: transparent; color: var(--gray-600); padding: 6px 10px; }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }
.btn-sm { padding: 5px 11px; font-size: .8rem; }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── FAB (Create button) ─────────────────────────────────────────────────── */
.fab {
  position: fixed; bottom: 24px; right: 24px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  box-shadow: var(--shadow-lg); cursor: pointer; font-size: 1.6rem;
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--transition), background var(--transition);
  z-index: 100;
}
.fab:hover { background: var(--primary-dark); transform: scale(1.06); }

/* ── Filter bar ─────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 16px 32px 0;
}
.filter-bar .search-box {
  flex: 1; min-width: 200px; max-width: 320px;
  position: relative;
}
.filter-bar .search-box svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--gray-400); pointer-events: none;
}
.filter-bar .search-box input {
  width: 100%; padding: 8px 10px 8px 34px;
  border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  font-size: .875rem; background: #fff; outline: none;
  transition: border-color var(--transition);
}
.filter-bar .search-box input:focus { border-color: var(--primary); }
.filter-select {
  padding: 7px 10px; border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  font-size: .85rem; background: #fff; outline: none; cursor: pointer;
  color: var(--gray-700);
}
.filter-select:focus { border-color: var(--primary); }
.filter-tabs {
  display: flex; gap: 4px; background: var(--gray-100);
  padding: 4px; border-radius: 8px;
}
.filter-tab {
  padding: 5px 14px; border-radius: 6px; border: none; background: transparent;
  font-size: .85rem; cursor: pointer; color: var(--gray-500);
  transition: all var(--transition); white-space: nowrap;
}
.filter-tab.active { background: #fff; color: var(--gray-900); font-weight: 600; box-shadow: var(--shadow-sm); }

/* ── Task list ──────────────────────────────────────────────────────────── */
.task-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.task-card {
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
  padding: 14px 18px; cursor: pointer; display: flex; align-items: center; gap: 14px;
  transition: box-shadow var(--transition), border-color var(--transition);
  text-decoration: none; color: inherit;
}
.task-card:hover { box-shadow: var(--shadow); border-color: var(--gray-300); }
.task-card-main { flex: 1; min-width: 0; }
.task-card-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-number { font-size: .78rem; font-weight: 600; color: var(--gray-400); white-space: nowrap; }
.task-title { font-size: .935rem; font-weight: 600; color: var(--gray-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-card-meta { display: flex; align-items: center; gap: 10px; margin-top: 5px; flex-wrap: wrap; }
.task-meta-item { font-size: .78rem; color: var(--gray-500); display: flex; align-items: center; gap: 4px; }
.task-meta-item svg { width: 13px; height: 13px; }
.task-card-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.avatar-group { display: flex; }
.avatar-group .avatar { margin-left: -6px; border: 2px solid #fff; }
.avatar-group .avatar:first-child { margin-left: 0; }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px; font-size: .75rem; font-weight: 600;
  white-space: nowrap;
}
.badge-open     { background: var(--info-bg);    color: var(--info); }
.badge-in_progress { background: var(--warning-bg); color: #B45309; }
.badge-resolved { background: var(--success-bg); color: #065F46; }
.badge-closed   { background: var(--gray-100);   color: var(--gray-500); }
.badge-high   { background: #FEF2F2; color: #B91C1C; }
.badge-medium { background: var(--warning-bg);  color: #92400E; }
.badge-low    { background: var(--primary-light); color: #3730A3; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── Avatar ─────────────────────────────────────────────────────────────── */
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: #fff;
  flex-shrink: 0; overflow: hidden;
}
.avatar-sm { width: 26px; height: 26px; font-size: .68rem; }
.avatar-lg { width: 42px; height: 42px; font-size: .9rem; }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; text-align: center; color: var(--gray-400);
}
.empty-state svg { width: 56px; height: 56px; margin-bottom: 16px; opacity: .4; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.empty-state p { font-size: .875rem; }

/* ── Task detail ─────────────────────────────────────────────────────────── */
.task-detail { max-width: 860px; }
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: .83rem; color: var(--gray-400); margin-bottom: 18px;
}
.breadcrumb a { color: var(--gray-500); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb svg { width: 14px; height: 14px; }
.detail-header { margin-bottom: 20px; }
.detail-number { font-size: .82rem; font-weight: 600; color: var(--gray-400); margin-bottom: 4px; }
.detail-title { font-size: 1.4rem; font-weight: 700; color: var(--gray-900); line-height: 1.35; }
.detail-title[contenteditable="true"] { outline: none; border-bottom: 2px solid var(--primary); padding-bottom: 2px; }
.detail-meta-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1px; background: var(--gray-200); border: 1px solid var(--gray-200);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 20px;
}
.meta-cell {
  background: #fff; padding: 12px 16px;
}
.meta-cell-label { font-size: .72rem; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.meta-cell-value { font-size: .875rem; color: var(--gray-700); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.status-select-btn {
  background: none; border: none; cursor: pointer; padding: 0;
  display: flex; align-items: center; gap: 6px;
}
.detail-description {
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
  padding: 16px; margin-bottom: 20px; min-height: 80px;
  font-size: .9rem; color: var(--gray-700); line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
}
.detail-description.editable:focus { outline: 2px solid var(--primary); }
.section-title {
  font-size: .85rem; font-weight: 700; color: var(--gray-600);
  text-transform: uppercase; letter-spacing: .06em;
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.section-title svg { width: 15px; height: 15px; }

/* ── Actions bar ─────────────────────────────────────────────────────────── */
.action-bar {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px;
  padding: 12px 16px; background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}

/* ── Attachments ─────────────────────────────────────────────────────────── */
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.attachment-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; background: var(--gray-100); border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); font-size: .8rem; color: var(--gray-700);
  text-decoration: none; transition: background var(--transition);
}
.attachment-chip:hover { background: var(--gray-200); }
.attachment-chip svg { width: 14px; height: 14px; color: var(--gray-400); }
.attachment-img {
  width: 80px; height: 80px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--gray-200); cursor: pointer;
}

/* ── Comments ────────────────────────────────────────────────────────────── */
.comments { display: flex; flex-direction: column; gap: 0; }
.comment-item {
  display: flex; gap: 12px; padding: 14px 0;
  border-bottom: 1px solid var(--gray-100);
}
.comment-item:last-child { border-bottom: none; }
.comment-body { flex: 1; min-width: 0; }
.comment-header {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px;
}
.comment-author { font-weight: 600; font-size: .875rem; color: var(--gray-800); }
.comment-dept { font-size: .75rem; color: var(--gray-400); }
.comment-time { font-size: .75rem; color: var(--gray-400); margin-left: auto; }
.comment-content {
  font-size: .875rem; color: var(--gray-700); line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}
.comment-content .mention { color: var(--primary); font-weight: 600; }
.comment-images { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.comment-img {
  width: 90px; height: 90px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--gray-200); cursor: pointer; transition: opacity var(--transition);
}
.comment-img:hover { opacity: .85; }

/* ── Comment input ───────────────────────────────────────────────────────── */
.comment-input-box {
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
  padding: 12px 14px; margin-top: 16px; position: relative;
}
.comment-input-row { display: flex; gap: 10px; align-items: flex-start; }
.comment-textarea {
  flex: 1; border: none; outline: none; resize: none; font-size: .875rem;
  line-height: 1.6; min-height: 40px; max-height: 200px; color: var(--gray-800);
  background: transparent;
}
.comment-textarea::placeholder { color: var(--gray-400); }
.comment-actions {
  display: flex; align-items: center; gap: 6px; margin-top: 8px;
  padding-top: 8px; border-top: 1px solid var(--gray-100);
  flex-wrap: wrap;
}
.pending-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pending-file {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 8px; background: var(--primary-light); border-radius: 20px;
  font-size: .78rem; color: var(--primary);
}
.pending-file button { background: none; border: none; cursor: pointer; padding: 0; line-height: 1; color: var(--primary); font-size: .85rem; }
.pending-img-preview { width: 50px; height: 50px; object-fit: cover; border-radius: 6px; border: 1px solid var(--gray-200); }

/* ── Mention dropdown ────────────────────────────────────────────────────── */
.mention-dropdown {
  position: absolute; background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  max-height: 200px; overflow-y: auto; z-index: 1000; width: 220px;
}
.mention-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer; font-size: .85rem;
  transition: background var(--transition);
}
.mention-item:hover, .mention-item.selected { background: var(--primary-light); }
.mention-item .mention-name { font-weight: 600; color: var(--gray-800); }
.mention-item .mention-dept { font-size: .75rem; color: var(--gray-400); }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 20px; backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 560px;
  max-height: 90vh; overflow: hidden; display: flex; flex-direction: column;
  animation: modalIn .18s ease;
}
.modal-lg { max-width: 700px; }
@keyframes modalIn { from{opacity:0;transform:scale(.96) translateY(8px)} to{opacity:1;transform:none} }
.modal-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 700; color: var(--gray-900); }
.modal-body { flex: 1; overflow-y: auto; padding: 20px 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--gray-100);
  display: flex; justify-content: flex-end; gap: 8px;
}
.btn-close {
  background: none; border: none; cursor: pointer; padding: 4px;
  color: var(--gray-400); border-radius: 4px;
}
.btn-close:hover { background: var(--gray-100); color: var(--gray-700); }
.btn-close svg { width: 18px; height: 18px; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .82rem; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.form-label .required { color: var(--danger); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); font-size: .875rem; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  color: var(--gray-800); background: #fff;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.form-textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
.form-error { font-size: .8rem; color: var(--danger); margin-top: 4px; }
.form-hint { font-size: .78rem; color: var(--gray-400); margin-top: 4px; }

/* ── Multi-user select ───────────────────────────────────────────────────── */
.user-select { border: 1px solid var(--gray-200); border-radius: var(--radius-sm); overflow: hidden; }
.user-select-search {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  border-bottom: 1px solid var(--gray-100);
}
.user-select-search svg { width: 14px; height: 14px; color: var(--gray-400); flex-shrink: 0; }
.user-select-search input { border: none; outline: none; font-size: .85rem; flex: 1; color: var(--gray-800); }
.user-select-list { max-height: 200px; overflow-y: auto; }
.user-select-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  cursor: pointer; transition: background var(--transition);
}
.user-select-item:hover { background: var(--gray-50); }
.user-select-item input[type="checkbox"] { accent-color: var(--primary); }
.user-select-item-info { flex: 1; min-width: 0; }
.user-select-name { font-size: .85rem; font-weight: 500; color: var(--gray-800); }
.user-select-dept { font-size: .75rem; color: var(--gray-400); }
.selected-users { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.selected-user-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 8px; background: var(--primary-light); border-radius: 20px;
  font-size: .8rem; color: var(--primary); font-weight: 500;
}
.selected-user-chip button { background: none; border: none; cursor: pointer; color: var(--primary); font-size: .85rem; padding: 0; line-height: 1; }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1E1B4B 0%, #312E81 50%, #3730A3 100%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: var(--radius-lg); padding: 40px;
  width: 100%; max-width: 400px; box-shadow: var(--shadow-lg);
}
.login-logo { display: flex; align-items: center; justify-content: center; margin-bottom: 28px; }
.login-logo-inner {
  width: 52px; height: 52px; background: var(--primary); border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
}
.login-logo-inner svg { width: 30px; height: 30px; }
.login-title { font-size: 1.4rem; font-weight: 800; color: var(--gray-900); text-align: center; margin-bottom: 4px; }
.login-subtitle { font-size: .85rem; color: var(--gray-500); text-align: center; margin-bottom: 28px; }
.login-tabs {
  display: flex; background: var(--gray-100); padding: 4px;
  border-radius: 8px; margin-bottom: 24px;
}
.login-tab {
  flex: 1; padding: 7px; border: none; border-radius: 6px; font-size: .875rem;
  cursor: pointer; background: transparent; color: var(--gray-500); font-weight: 500;
  transition: all var(--transition);
}
.login-tab.active { background: #fff; color: var(--gray-900); font-weight: 600; box-shadow: var(--shadow-sm); }
.login-footer { text-align: center; margin-top: 20px; font-size: .8rem; color: var(--gray-400); }
.login-lang { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.login-lang button { background: none; border: none; font-size: .8rem; cursor: pointer; color: var(--gray-400); }
.login-lang button.active { color: var(--primary); font-weight: 600; }

/* ── Users page ──────────────────────────────────────────────────────────── */
.users-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 16px; }
.user-card {
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
}
.user-card-header { display: flex; align-items: center; gap: 12px; }
.user-card-info { flex: 1; min-width: 0; }
.user-card-name { font-weight: 700; font-size: .95rem; color: var(--gray-900); }
.user-card-email { font-size: .78rem; color: var(--gray-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dept-badge { padding: 3px 9px; background: var(--gray-100); border-radius: 20px; font-size: .75rem; color: var(--gray-600); }
.role-badge { padding: 3px 9px; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.role-badge.admin { background: #FEF3C7; color: #92400E; }
.role-badge.user  { background: var(--primary-light); color: var(--primary-dark); }
.user-card-actions { display: flex; gap: 6px; }

/* ── Image lightbox ──────────────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 900; cursor: pointer;
}
.lightbox img { max-width: 95vw; max-height: 95vh; border-radius: 6px; }

/* ── Status change dropdown ──────────────────────────────────────────────── */
.status-menu {
  position: absolute; top: 100%; left: 0; margin-top: 4px;
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); z-index: 300; min-width: 180px; overflow: hidden;
}
.status-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; cursor: pointer; font-size: .875rem;
  transition: background var(--transition);
}
.status-menu-item:hover { background: var(--gray-50); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; width: var(--sidebar-w); }
  .sidebar.open { transform: none; }
  .mobile-header { display: flex; }
  .mobile-bottom-nav { display: flex; }
  .main { grid-column: 1; padding-top: calc(var(--header-h) + env(safe-area-inset-top)); }
  .page-header { padding: 20px 16px 0; }
  .page-content { padding: 16px 16px calc(58px + env(safe-area-inset-bottom) + 16px); }
  .filter-bar { padding: 12px 16px 0; }
  .filter-bar .search-box { min-width: 120px; }
  .detail-meta-grid { grid-template-columns: 1fr 1fr; }
  .fab { display: none; }
  .modal { margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; position: fixed; bottom: 0; left: 0; right: 0; max-height: 90vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .users-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .task-card-right { display: none; }
  .detail-meta-grid { grid-template-columns: 1fr; }
  .filter-tabs { display: none; }
}

/* ── Unread badge ────────────────────────────────────────────────────────── */
.unread-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; border-radius: 9px;
  background: var(--danger); color: #fff;
  font-size: .68rem; font-weight: 700; padding: 0 5px;
  flex-shrink: 0;
}
.task-card.has-unread { border-left: 3px solid var(--primary); }
.task-card.has-unread .task-title { font-weight: 700; }

/* SSE connection indicator */
.sse-dot {
  width: 7px; height: 7px; border-radius: 50%; display: inline-block;
  margin-left: 4px; background: var(--gray-300);
  transition: background .5s;
}
.sse-dot.connected { background: var(--success); }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.ml-auto { margin-left: auto; }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .78rem; }
.text-muted { color: var(--gray-400); }
.font-bold { font-weight: 700; }
.hidden { display: none !important; }
.relative { position: relative; }
.w-full { width: 100%; }
.divider { height: 1px; background: var(--gray-100); margin: 16px 0; }
