:root {
  --bg: #1a1a2e;
  --bg2: #16213e;
  --bg3: #0f3460;
  --card: #1e2a4a;
  --card-hover: #253456;
  --text: #e0e0e0;
  --text2: #94a3b8;
  --accent: #e94560;
  --green: #4ade80;
  --yellow: #fbbf24;
  --orange: #fb923c;
  --red: #ef4444;
  --blue: #60a5fa;
  --purple: #a78bfa;
  --border: #334155;
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── Header ────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.employee-tabs {
  display: flex;
  gap: 4px;
  margin-left: 16px;
}

.employee-tab {
  padding: 6px 14px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
}

.employee-tab:hover { background: var(--bg3); color: var(--text); }
.employee-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.header-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn:hover { background: var(--card-hover); }
.btn-accent { background: var(--accent); border-color: var(--accent); }
.btn-accent:hover { opacity: .85; }
.btn-green { background: #166534; border-color: #166534; }
.btn-green:hover { opacity: .85; }
.lang-toggle {
  padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: transparent; color: var(--text2); cursor: pointer;
  font-size: 12px; font-weight: 600; letter-spacing: .5px;
  transition: all .15s;
}
.lang-toggle:hover { background: var(--card-hover); color: var(--text); }
.btn-comment { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-comment:hover { background: var(--card-hover); border-color: var(--blue); }

/* ── Subtask components ── */
.subtask-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:2px; }
.subtask-counter { font-size:12px; color:var(--text2); font-weight:500; }
.subtask-progress-bar { height:3px; background:var(--border); border-radius:2px; margin:6px 0 8px; overflow:hidden; }
.subtask-progress-fill { height:100%; border-radius:2px; transition:width .3s ease; }
.subtask-progress-fill.partial { background:var(--blue); }
.subtask-progress-fill.complete { background:var(--green); }
.subtask-list { margin:0; padding:0; }
.subtask-item {
  display:flex; align-items:center; gap:10px; padding:7px 6px;
  border-radius:6px; transition:background .15s;
}
.subtask-item:hover { background:var(--card-hover); }
.subtask-item + .subtask-item { border-top:1px solid var(--border); }
.subtask-check {
  appearance:none; -webkit-appearance:none;
  width:18px; height:18px; min-width:18px; max-width:18px;
  box-sizing:border-box; display:inline-block; flex:0 0 18px;
  border:2px solid var(--border); border-radius:4px;
  cursor:pointer; transition:all .2s;
  position:relative; background:transparent;
  margin:0; padding:0;
}
.subtask-check:checked { background:var(--green); border-color:var(--green); }
.subtask-check:checked::after {
  content:'✓'; position:absolute; top:-1px; left:2px;
  font-size:12px; color:#000; font-weight:bold;
}
.subtask-check:hover { border-color:var(--blue); }
.subtask-name { flex:1; font-size:13px; cursor:pointer; transition:color .15s; line-height:1.3; }
.subtask-name:hover { color:var(--blue); }
.subtask-name.done { text-decoration:line-through; color:var(--text2); }
.subtask-status { font-size:10px; padding:2px 6px; border-radius:4px; background:var(--card-hover); color:var(--text2); white-space:nowrap; }
.parent-breadcrumb {
  display:flex; align-items:center; gap:8px; padding:10px 14px;
  margin-bottom:12px; background:var(--blue); border:none;
  border-radius:8px; font-size:13px; font-weight:500; color:#fff;
  cursor:pointer; transition:background .15s;
}
.parent-breadcrumb:hover { background:#2563eb; }
.btn:disabled, .btn-done:disabled, .btn-accent:disabled {
  opacity: .45; cursor: not-allowed; pointer-events: none;
}
.btn.loading::after {
  content: ''; display: inline-block; width: 12px; height: 12px;
  border: 2px solid transparent; border-top-color: currentColor;
  border-radius: 50%; animation: spin .6s linear infinite; margin-left: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-done {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border); background: transparent;
  color: var(--text2); font-size: 13px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s, background .15s, border-color .15s;
}
.card:hover .btn-done { opacity: 1; }
.btn-done:hover { background: #166534; border-color: #166534; color: #fff; }

.stats {
  font-size: 12px;
  color: var(--text2);
  display: flex;
  gap: 12px;
}

.stats span { white-space: nowrap; }
.stats .overdue { color: var(--red); }
.stats .open { color: var(--yellow); }

/* ─── Search ────────────────────────────────────────── */
.search-bar {
  padding: 0 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding-top: 8px;
  padding-bottom: 8px;
}

.search-input {
  flex: 1;
  max-width: 400px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.search-input:focus { border-color: var(--accent); }

.filter-chips {
  display: flex;
  gap: 4px;
}

.chip {
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 11px;
  cursor: pointer;
  transition: all .15s;
}

.chip:hover { background: var(--bg3); }
.chip.active { background: var(--bg3); border-color: var(--blue); color: var(--blue); }
.member-chip-inline { display: none; }

/* ─── Main Layout ───────────────────────────────────── */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── Kanban Board ──────────────────────────────────── */
.board {
  flex: 1;
  display: flex;
  gap: 12px;
  padding: 16px;
  overflow-x: auto;
  overflow-y: hidden;
}

.column {
  min-width: 280px;
  max-width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.column-header {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.column-header .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.column-header .count {
  margin-left: auto;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  color: var(--text2);
}

.column-cards {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.column-cards::-webkit-scrollbar { width: 4px; }
.column-cards::-webkit-scrollbar-track { background: transparent; }
.column-cards::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ─── Cards ─────────────────────────────────────────── */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all .15s;
}

.card:hover { background: var(--card-hover); border-color: var(--blue); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.card-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 6px;
}

.card-detail {
  font-size: 11px;
  color: var(--text2);
  line-height: 1.4;
  margin: 4px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.tag-assignee { background: #1e3a5f; color: var(--blue); }
.tag-deadline { background: #3b1e1e; color: var(--orange); }
.tag-deadline.overdue { background: #5c1e1e; color: var(--red); }
.tag-prio-critical { background: #5c1e1e; color: var(--red); }
.tag-prio-high { background: #5c3b1e; color: var(--orange); }
.tag-prio-medium { background: #3b3b1e; color: var(--yellow); }
.tag-prio-low { background: #1e3b1e; color: var(--green); }
.tag-sources { background: #2d1e5c; color: var(--purple); }
.tag-created { background: #1e2e3b; color: var(--text2); }

.detail-created {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 8px;
}

/* ─── Detail Panel ──────────────────────────────────── */
.detail-panel {
  width: 420px;
  flex-shrink: 0;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .2s;
}

.detail-panel.hidden { width: 0; border: none; }

.detail-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.detail-title-wrap { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.detail-title-input {
  font-size: 15px; font-weight: 600; width: 100%;
  border: 1px solid transparent; border-radius: 4px;
  padding: 2px 6px; background: transparent; color: var(--text);
  font-family: inherit;
}
.detail-title-input:focus { border-color: #4A90D9; background: var(--card-bg); outline: none; }
.save-btn {
  padding: 3px 10px; background: #4A90D9; color: white;
  border: none; border-radius: 4px; cursor: pointer;
  font-size: 12px; align-self: flex-start;
}
.save-btn:hover { background: #3A7BC8; }
.save-btn.hidden { display: none; }
.show-older-btn { width:100%;padding:8px;margin-top:4px;background:var(--column-bg);border:1px dashed var(--border);border-radius:8px;color:var(--muted);font-size:12px;cursor:pointer;transition:all .15s; }
.show-older-btn:hover { background:var(--card-bg);color:var(--text); }

.detail-close {
  cursor: pointer;
  padding: 4px;
  color: var(--text2);
  font-size: 18px;
}

.detail-close:hover { color: var(--text); }

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.detail-body::-webkit-scrollbar { width: 4px; }
.detail-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 11px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}

.field-value {
  font-size: 13px;
  line-height: 1.5;
}

.field select, .field input, .field textarea {
  width: 100%;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.field select:focus, .field input:focus, .field textarea:focus {
  border-color: var(--accent);
}

.field textarea {
  min-height: 60px;
  max-height: 300px;
  resize: none;
  overflow-y: hidden;
  line-height: 1.5;
  transition: height 0.1s ease;
}
.field textarea.scrollable { overflow-y: auto; }

.detail-actions {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ─── History Timeline ──────────────────────────────── */
.timeline {
  padding-left: 16px;
  border-left: 2px solid var(--border);
}

.timeline-item {
  position: relative;
  padding: 4px 0 12px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text2);
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -21px;
  top: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.timeline-item.active::before { background: var(--blue); }

/* ─── Detail Panel Layout ─────────────────────────── */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.field-grid .field { margin-bottom: 0; }


.section-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
}
.section-toggle:hover label { color: var(--text); cursor: pointer; }
.section-toggle .arrow {
  font-size: 9px;
  transition: transform .15s;
  color: var(--text2);
}
.section-toggle .arrow.open { transform: rotate(90deg); }


/* ─── Modal ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay.hidden { display: none; }
#inviteLinkBox.hidden, #noTeamsMsg.hidden { display: none; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 440px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px;
}

.modal h3 {
  font-size: 16px;
  margin-bottom: 16px;
}

.modal .field { margin-bottom: 12px; }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ─── Empty State ───────────────────────────────────── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text2);
}

.empty-state .icon { font-size: 48px; opacity: .5; }
.empty-state p { font-size: 14px; }

/* ─── Hamburger Button ─────────────────────────────────── */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

/* ─── Mobile Status Tabs ───────────────────────────────── */
.status-tabs {
  display: none;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.status-tabs-inner {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}
.status-tabs-inner::-webkit-scrollbar { display: none; }
.status-tab {
  flex: 0 0 auto;
  padding: 10px 12px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.status-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.status-tab-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.status-tab-count {
  font-size: 10px;
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 8px;
  margin-left: 4px;
  color: var(--text2);
}

/* ─── Mobile Task List ─────────────────────────────────── */
.mobile-list {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  flex-direction: column;
}
.mobile-list .card {
  margin-bottom: 8px;
  padding: 12px 14px;
}
.mobile-list .card-title { font-size: 15px; }
.mobile-list .card-detail { font-size: 13px; }
.mobile-list .tag { font-size: 11px; padding: 3px 8px; }
.mobile-list .btn-done { opacity: 1; width: 28px; height: 28px; font-size: 14px; }

/* ─── FAB Button ───────────────────────────────────────── */
.fab-btn {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(233,69,96,.4);
  z-index: 40;
  align-items: center;
  justify-content: center;
  transition: transform .15s;
}
.fab-btn:active { transform: scale(.92); }

/* ─── Drawer (Mobile Menu) ─────────────────────────────── */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 60;
}
.drawer-overlay.open { display: block; }
.drawer {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  z-index: 61;
  transform: translateX(-100%);
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-header h3 { font-size: 16px; font-weight: 600; }
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.drawer-item {
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .15s;
  color: var(--text);
}
.drawer-item:hover { background: var(--bg3); }
.drawer-item.active { background: var(--accent); color: #fff; }
.drawer-item-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text2);
}
.drawer-item.active .drawer-item-count { color: rgba(255,255,255,.7); }
.drawer-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* ─── Detail Overlay (for mobile) ──────────────────────── */
.detail-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 50;
}
.detail-overlay.open { display: block; }

/* ─── Responsive: Tablet (768-1023px) ──────────────────── */
@media (max-width: 1023px) {
  .column { min-width: 220px; max-width: 260px; }
  .employee-tabs { display: none; }
  .stats { display: none; }
  .hamburger-btn { display: block; }
  .detail-panel {
    position: fixed;
    right: 0; top: 0; bottom: 0;
    width: 380px;
    z-index: 51;
    transform: translateX(100%);
    transition: transform .25s ease;
  }
  .detail-panel:not(.hidden) { transform: translateX(0); }
  .detail-panel.hidden { width: 380px; transform: translateX(100%); border: none; }
}

/* ─── Responsive: Mobile (<768px) ──────────────────────── */
@media (max-width: 767px) {
  .header { padding: 8px 12px; gap: 10px; }
  .header h1 { font-size: 16px; }
  .employee-tabs { display: none; }
  .stats { display: none; }
  .header-actions .btn { display: none; }
  .hamburger-btn { display: block; }

  .search-bar { padding: 8px 12px; flex-wrap: wrap; gap: 6px; }
  .search-input { max-width: none; width: 100%; font-size: 14px; padding: 9px 12px; }
  .filter-chips { gap: 4px; overflow-x: auto; scrollbar-width: none; width: 100%; }
  .filter-chips::-webkit-scrollbar { display: none; }
  .chip { font-size: 11px; padding: 6px 10px; flex-shrink: 0; }
  .chip-desktop-only { display: none; }
  #memberFilter { display: none !important; }
  .member-chip-inline { display: inline-flex !important; }

  /* Hide desktop columns but keep .main so fixed detail-panel can render */
  .main { height: 0; min-height: 0; overflow: visible; padding: 0; flex: 0; }
  .main .column { display: none; }
  .status-tabs { display: block; }
  .mobile-list { display: flex; }
  .fab-btn { display: flex; }

  /* Detail panel as bottom sheet */
  .detail-panel {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    top: auto;
    width: 100%;
    height: 85vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    z-index: 51;
    transform: translateY(100%);
    transition: transform .25s ease;
  }
  .detail-panel:not(.hidden) { transform: translateY(0); }
  .detail-panel.hidden { width: 100%; height: 85vh; transform: translateY(100%); border: none; }
  .detail-panel::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 8px auto 0;
  }
  .detail-header { padding: 10px 16px 14px; }
  .field-grid { gap: 8px; }
  .field select, .field input, .field textarea { padding: 9px 10px; font-size: 14px; }

  .modal { width: calc(100vw - 32px); max-width: 440px; }

}

/* Small phones */
@media (max-width: 374px) {
  .status-tab { font-size: 11px; padding: 8px 4px; }
  .chip { font-size: 10px; padding: 5px 8px; }
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 10000;
  opacity: 0;
  transition: transform .3s, opacity .3s;
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast.success { background: #166534; color: #bbf7d0; }
.toast.error { background: #991b1b; color: #fecaca; }

/* ─── Drag & Drop ─────────────────────────── */
.card[draggable="true"] { cursor: grab; }
.card[draggable="true"]:active { cursor: grabbing; }
.card.dragging { opacity: 0.35; border-style: dashed; pointer-events: none; }
.column-cards.drag-over { background: rgba(96, 165, 250, 0.07); outline: 2px dashed var(--blue); outline-offset: -2px; border-radius: var(--radius); }
.drop-indicator { height: 2px; background: var(--blue); border-radius: 2px; margin: 2px 4px; pointer-events: none; }
