/* ================================================================
   4ROOMS-Workdesk — Main Stylesheet
   Font: DM Sans + DM Mono | Theme: Clean Light
   ================================================================ */

:root {
  --accent:        #c26b26;
  --accent-light:  #fdf4ec;
  --accent-hover:  #a35820;
  --bg:            #f8f9fc;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --border-light:  #f1f5f9;
  --text-primary:  #0f172a;
  --text-secondary:#334155;
  --text-muted:    #94a3b8;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:     0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:     0 12px 40px rgba(0,0,0,.12);
  --radius:        10px;
  --radius-sm:     6px;
  --radius-lg:     14px;
}

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

html { font-size: 15px; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
button, input, select, textarea { font-family: inherit; }

/* ================================================================
   NAVBAR
   ================================================================ */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  height: 56px;
}
.nav-inner {
  max-width: 1440px; margin: 0 auto;
  display: flex; align-items: center; gap: 0;
  padding: 0 24px; height: 100%;
}
.nav-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 600;
  color: var(--text-primary); margin-right: 32px;
}
.nav-logo {
  width: 28px; height: 28px; background: var(--accent); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.nav-links { display: flex; align-items: center; gap: 2px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: var(--text-muted);
  transition: all .15s;
}
.nav-link:hover { background: var(--bg); color: var(--text-primary); }
.nav-link.active { color: var(--accent); background: var(--accent-light); }
.nav-right { margin-left: auto; position: relative; display: flex; align-items: center; gap: 12px; }
.nav-clock {
  font-family: 'DM Mono', monospace;
  font-size: 12px; color: var(--text-muted);
  letter-spacing: .02em;
  white-space: nowrap;
}
.nav-user {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border-radius: 24px;
  border: 1px solid var(--border); transition: background .15s;
}
.nav-user:hover { background: var(--bg); }
.nav-user-info { line-height: 1.2; }
.nav-user-name  { display: block; font-size: 13px; font-weight: 500; }
.nav-user-role  { display: block; font-size: 11px; color: var(--text-muted); }
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  min-width: 160px; padding: 6px; z-index: 200;
}
.dropdown-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-secondary); transition: background .15s;
}
.dropdown-item:hover { background: var(--bg); }
.dropdown-item-active { color: var(--accent); font-weight: 500; }
.dropdown-item-danger { color: #dc2626; }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

.nav-dropdown { position: relative; }
.integrations-dropdown {
  position: absolute; left: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  min-width: 170px; padding: 6px; z-index: 200;
}
.integrations-dropdown .dropdown-item svg { flex-shrink: 0; }

/* ================================================================
   AVATARS
   ================================================================ */
.avatar {
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 600; color: #fff; flex-shrink: 0; user-select: none;
}
.avatar-xs  { width: 22px; height: 22px; font-size: 9px; }
.avatar-sm  { width: 28px; height: 28px; font-size: 11px; border: 2px solid #fff; }
.avatar     { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg  { width: 48px; height: 48px; font-size: 16px; }
.avatar-xl  { width: 64px; height: 64px; font-size: 22px; }

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: none; transition: all .15s; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost   { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger  { background: #dc2626; color: #fff; }
.btn-sm      { padding: 5px 12px; font-size: 13px; }

/* ================================================================
   PAGE LAYOUT
   ================================================================ */
.page-wrap {
  max-width: 1440px; margin: 0 auto;
  padding: 28px 24px 48px;
}
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px; gap: 16px;
}
.page-title    { font-size: 22px; font-weight: 600; margin: 0 0 2px; }
.page-subtitle { font-size: 14px; color: var(--text-muted); margin: 0; }
.section       { margin-bottom: 36px; }
.section-title { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin: 0 0 14px; text-transform: uppercase; letter-spacing: .04em; font-size: 12px; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.section-header .section-title { margin: 0; }
.section-link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500; color: var(--accent);
  text-decoration: none; padding: 4px 8px; border-radius: 6px;
  transition: background-color .15s;
}
.section-link:hover { background: var(--accent-light); }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px;
  box-shadow: var(--shadow-sm);
}

/* ================================================================
   BOARDS GRID
   ================================================================ */

/* View toggle buttons */
/* Board column selection (create board modal) */
.board-columns-select {
  display: flex; flex-wrap: wrap; gap: 6px;
}
/* Dashboard KPIs */
.dashboard-kpi-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 24px;
}
.dashboard-kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 18px;
  text-align: center;
}
.dashboard-kpi.kpi-danger { border-color: #fecaca; background: #fef2f2; }
.dashboard-kpi.kpi-warning { border-color: #fde68a; background: #fffbeb; }
.dashboard-kpi-value {
  font-size: 26px; font-weight: 700; font-family: 'DM Mono', monospace;
  line-height: 1; margin-bottom: 4px; color: var(--text-primary);
}
.dashboard-kpi.kpi-danger .dashboard-kpi-value { color: #dc2626; }
.dashboard-kpi.kpi-warning .dashboard-kpi-value { color: #a16207; }
.dashboard-kpi-label { font-size: 11px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }

@media (max-width: 768px) {
  .dashboard-kpi-row { grid-template-columns: repeat(3, 1fr); }
  .dashboard-kpi-value { font-size: 20px; }
}
@media (max-width: 480px) {
  .dashboard-kpi-row { grid-template-columns: repeat(2, 1fr); }
}

.board-col-option {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 20px;
  border: 1.5px solid var(--border);
  font-size: 12px; font-weight: 500; color: var(--text-secondary);
  cursor: pointer; transition: all .15s; user-select: none;
}
.board-col-option:hover { border-color: var(--accent); }
.board-col-option:has(input:checked) {
  background: var(--accent-light); border-color: var(--accent); color: var(--accent);
}
.board-col-option input[type="checkbox"] {
  width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer;
}
.board-col-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}

.view-toggle { display: flex; gap: 2px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; }
.view-btn {
  width: 30px; height: 28px; border: none; background: transparent; border-radius: 4px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all .15s;
}
.view-btn:hover { color: var(--text-primary); }
.view-btn.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

/* Board container — mode-based layout */
.boards-container[data-mode="grid"] {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px;
}
.boards-container[data-mode="compact"] {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px;
}
.boards-container[data-mode="list"] {
  display: flex; flex-direction: column; gap: 8px;
}

.board-card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--shadow-sm); transition: all .2s; cursor: pointer;
}
.board-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #f0c9a0; }
.board-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.board-icon {
  width: 40px; height: 40px; background: var(--accent-light); color: var(--accent);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.board-card-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.board-owner-badge {
  font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 20px;
  background: var(--accent-light); color: var(--accent);
}
.board-creator-tag { font-size: 11px; color: var(--text-muted); }

/* Dashboard board filters */
.dash-filter-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px; padding: 8px 0;
}
.dash-filter-chip {
  display: flex; align-items: center; gap: 5px; cursor: pointer;
  font-size: 12px; font-weight: 500; color: var(--text-secondary);
  padding: 4px 10px; border: 1.5px solid var(--border); border-radius: 20px;
  transition: all .15s; user-select: none;
}
.dash-filter-chip:hover { border-color: var(--accent); color: var(--accent); }
.dash-filter-chip:has(input:checked) { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.dash-filter-chip input { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }
.dash-filter-col-wrap { position: relative; }
.dash-filter-col-btn {
  display: flex; align-items: center; gap: 4px; cursor: pointer;
  font-size: 12px; font-weight: 500; color: var(--text-secondary);
  padding: 4px 10px; border: 1.5px solid var(--border); border-radius: 20px;
  background: none; transition: all .15s;
}
.dash-filter-col-btn:hover { border-color: var(--accent); color: var(--accent); }
.dash-filter-col-list {
  position: absolute; top: 100%; left: 0; z-index: 50; margin-top: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 8px; min-width: 180px; max-height: 260px; overflow-y: auto;
}
.dash-filter-clear {
  background: none; border: none; cursor: pointer; font-size: 16px;
  color: var(--text-muted); padding: 2px 6px; border-radius: 50%;
  transition: all .15s; line-height: 1;
}
.dash-filter-clear:hover { background: #fef2f2; color: #dc2626; }
.dash-filter-count { font-size: 11px; color: var(--text-muted); }
.dash-filter-search {
  font-size: 12px; font-family: inherit; font-weight: 500; color: var(--text-primary);
  padding: 4px 10px; border: 1.5px solid var(--border); border-radius: 20px;
  background: var(--surface); outline: none; transition: all .15s;
  width: 180px; margin-left: auto;
}
.dash-filter-search::placeholder { color: var(--text-muted); }
.dash-filter-search:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }

/* Favorite star button */
.board-edit-btn {
  background: none; border: none; cursor: pointer; padding: 4px;
  color: #94a3b8; line-height: 0; border-radius: 4px; transition: color .2s, background .2s;
}
.board-edit-btn:hover { color: #3b82f6; background: rgba(59,130,246,.1); }

.fav-star {
  background: none; border: none; cursor: pointer; padding: 2px;
  color: #d1d5db; line-height: 0; flex-shrink: 0; transition: color .2s, transform .15s;
  margin-left: auto;
}
.fav-star svg { fill: currentColor; }
.fav-star:hover { color: #f59e0b; transform: scale(1.15); }
.fav-star.is-fav { color: #f59e0b; }

.board-name { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.board-task-counts { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.board-task-count { font-size: 12px; color: var(--text-muted); font-family: 'DM Mono', monospace; }
.board-task-count strong { color: var(--accent); }
.board-task-count-sep { color: var(--border); font-size: 12px; }
.board-creator-line { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }

/* Compact mode: smaller cards, hide description and column pills */
.boards-container[data-mode="compact"] .board-card { padding: 14px; }
.boards-container[data-mode="compact"] .board-icon { width: 32px; height: 32px; font-size: 12px; border-radius: 6px; }
.boards-container[data-mode="compact"] .board-card-header { margin-bottom: 6px; }
.boards-container[data-mode="compact"] .board-name { font-size: 14px; margin: 0 0 2px; }
.boards-container[data-mode="compact"] .board-task-counts { margin-bottom: 0; }
.boards-container[data-mode="compact"] .board-desc { display: none; }
.boards-container[data-mode="compact"] .board-columns-preview { display: none; }
.boards-container[data-mode="compact"] .board-creator-line { margin-bottom: 0; }

/* List mode: horizontal row layout */
.boards-container[data-mode="list"] .board-card {
  padding: 12px 20px;
  display: flex; align-items: center; gap: 14px;
  border-radius: var(--radius);
}
.boards-container[data-mode="list"] .board-card:hover { transform: none; }
.boards-container[data-mode="list"] .board-card-header { margin-bottom: 0; flex-shrink: 0; }
.boards-container[data-mode="list"] .board-card-badges { display: none; }
.boards-container[data-mode="list"] .board-icon { width: 32px; height: 32px; font-size: 11px; border-radius: 6px; }
.boards-container[data-mode="list"] .board-name { font-size: 14px; margin: 0; white-space: nowrap; }
.boards-container[data-mode="list"] .board-task-counts { margin: 0; flex-shrink: 0; }
.boards-container[data-mode="list"] .board-desc {
  font-size: 12px; margin: 0; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.boards-container[data-mode="list"] .board-columns-preview { display: none; }
.boards-container[data-mode="list"] .board-creator-line {
  margin: 0; flex-shrink: 0; font-size: 11px; order: 99; margin-left: auto;
  white-space: nowrap;
}
.board-desc { font-size: 13px; color: var(--text-muted); margin: 0 0 14px; line-height: 1.4; min-height: 18px; white-space: pre-wrap; }
.board-columns-preview { display: flex; flex-wrap: wrap; gap: 6px; }
.col-pill {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 20px; padding: 2px 8px; font-size: 11px;
}
.col-pill-name { color: var(--text-secondary); }
.col-pill-count { font-weight: 600; color: var(--text-primary); font-family: 'DM Mono', monospace; }

/* ================================================================
   TASK LIST TABLE (dashboard + reports)
   ================================================================ */
.task-list-table-wrap, .report-table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.task-list-table { width: 100%; border-collapse: collapse; }
.task-list-table th {
  text-align: left; padding: 10px 16px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted);
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.task-list-table td { padding: 10px 16px; font-size: 13px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.task-list-table tr:last-child td { border-bottom: none; }
.task-list-table tbody tr:hover { background: #fffaf5; }
.task-title-cell { font-weight: 500; max-width: 260px; }
.board-tag {
  display: inline-block; background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 6px; font-size: 11px; color: var(--text-secondary);
}
.column-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500;
  background: color-mix(in srgb, var(--col-color) 12%, transparent);
  color: var(--col-color);
}

/* ================================================================
   KANBAN BOARD
   ================================================================ */
.board-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  gap: 16px;
}
.board-header-left  { display: flex; align-items: center; gap: 12px; }
.board-header-right { display: flex; align-items: center; gap: 10px; }
.back-link {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px; color: var(--text-muted);
  transition: all .15s;
}
.back-link:hover { background: var(--bg); color: var(--text-primary); }
.board-title    { font-size: 18px; font-weight: 600; margin: 0; }
.board-subtitle { font-size: 13px; color: var(--text-muted); margin: 0; white-space: pre-wrap; }
.board-member-list { display: flex; }
.board-member-list .avatar-sm { margin-left: -8px; }
.board-member-list .avatar-sm:first-child { margin-left: 0; }

/* ================================================================
   FILTER BAR
   ================================================================ */
.filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
}
.filter-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-group {
  position: relative;
  flex-shrink: 0;
}
.filter-control {
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
  cursor: pointer;
  height: 32px;
}
.filter-control:focus,
.filter-control.active { border-color: var(--accent); }
.filter-input {
  cursor: text;
  width: 180px;
  padding-left: 30px;
}
.filter-search {
  position: relative;
}
.filter-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
select.filter-control {
  padding-right: 24px;
  appearance: auto;
}
input[type="date"].filter-control {
  width: 130px;
}
.filter-columns-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-weight: 500;
  color: var(--text-secondary);
}
.filter-columns-count {
  font-size: 10px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 0 5px;
  min-width: 16px;
  height: 16px;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.filter-columns-count.visible { display: inline-flex; }
.filter-columns-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 300;
  min-width: 180px;
}
.filter-column-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .1s;
}
.filter-column-option:hover { background: var(--bg); }
.filter-column-option input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.filter-clear-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}
.filter-clear-btn:hover { background: #fef2f2; color: #dc2626; }
.filter-result-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
  white-space: nowrap;
  font-family: 'DM Mono', monospace;
}
.task-card.filter-hidden { display: none !important; }
.kanban-column.filter-hidden-column { display: none !important; }

.kanban-board-wrap {
  position: relative;
  flex: 1; min-height: 0;
  overflow: hidden;
}
.kanban-board {
  display: flex; gap: 14px; align-items: flex-end;
  padding: 0 24px 20px; overflow-x: auto; overflow-y: hidden;
  max-width: 100vw;
  /* Flip vertically so the scrollbar appears at the top */
  transform: scaleY(-1);
  /* Firefox scrollbar */
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
/* Flip each column back to normal orientation */
.kanban-board > * { transform: scaleY(-1); }
/* Webkit scrollbar — always visible when content overflows */
.kanban-board::-webkit-scrollbar { height: 10px; }
.kanban-board::-webkit-scrollbar-track { background: var(--border-light); border-radius: 5px; margin: 0 16px; }
.kanban-board::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 5px; }
.kanban-board::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Scroll arrow buttons — always visible when board overflows */
.board-scroll-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 10; width: 32px; height: 32px;
  border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg); color: var(--text-secondary);
  cursor: pointer; display: none; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  font-size: 18px; line-height: 1; transition: opacity .2s, background .2s;
}
.board-scroll-btn:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }
.board-scroll-btn.scroll-left { left: 6px; }
.board-scroll-btn.scroll-right { right: 6px; }
.board-scroll-btn.visible { display: flex; }

.kanban-column {
  flex-shrink: 0; width: 280px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  display: flex; flex-direction: column; max-height: calc(100vh - 155px);
}
.column-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  background: var(--bg); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.column-header-left { display: flex; align-items: center; gap: 8px; }
.column-dot  { width: 8px; height: 8px; border-radius: 50%; }
.column-name { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.column-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; background: var(--border); border-radius: 20px;
  font-size: 11px; font-weight: 600; color: var(--text-muted); padding: 0 4px;
  font-family: 'DM Mono', monospace;
}
.column-menu-btn {
  width: 24px; height: 24px; border: none; background: transparent;
  border-radius: 4px; cursor: pointer; font-size: 16px; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.column-menu-btn:hover { background: var(--border); color: var(--text-primary); }
.column-delete-btn:hover { background: #fef2f2; color: #dc2626; }
.column-delete-btn.hidden { display: none; }

/* Locked column (Complete) */
.kanban-column.column-locked .column-header {
  background: #f0fdf4; border-bottom-color: #bbf7d0;
}
.kanban-column.column-locked .column-name { color: #16a34a; }
.kanban-column.column-locked { border-color: #bbf7d0; }

/* Column drag & drop */
.column-header[draggable="true"] { cursor: grab; }
.column-header[draggable="true"]:active { cursor: grabbing; }
.kanban-column.column-dragging {
  opacity: .4;
  transform: rotate(1deg);
  transition: opacity .15s, transform .15s;
}
.kanban-column.column-drop-target {
  border: 2px dashed var(--accent);
  background: var(--accent-light);
  border-radius: var(--radius-lg);
}

.task-list {
  flex: 1; overflow-y: auto; padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 60px;
}
.task-list::-webkit-scrollbar { width: 5px; }
.task-list::-webkit-scrollbar-track { background: transparent; }
.task-list::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.task-list:hover::-webkit-scrollbar-thumb { background: #cbd5e1; }
.task-list:hover::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.task-list.drag-over { background: var(--accent-light); border-radius: var(--radius); }
/* Live drop-position indicator: a thin accent bar above the card the dragged
   item would land in front of, or at the bottom of the list when dropping
   at the end. Uses box-shadow so it doesn't change layout (no reflow). */
.task-card.drop-before { box-shadow: 0 -3px 0 0 var(--accent), var(--shadow-sm); }
.task-list.drop-at-end > .task-card:last-of-type { box-shadow: 0 3px 0 0 var(--accent), var(--shadow-sm); }
.task-list.drop-at-end:empty::after,
.task-list.drop-at-end .column-empty { border-color: var(--accent); color: var(--accent); }
.column-empty {
  text-align: center; padding: 20px; font-size: 12px; color: var(--text-muted);
  border: 1.5px dashed var(--border); border-radius: 8px; margin: 4px 0;
}

/* ================================================================
   TASK CARDS
   ================================================================ */
.task-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
  cursor: pointer; transition: all .15s;
  box-shadow: var(--shadow-sm);
  user-select: none;
}
.task-card.no-drag { cursor: default; }

.task-card:hover { border-color: #f0c9a0; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.task-card.dragging { opacity: .5; transform: rotate(1.5deg); }
.task-card.drag-placeholder {
  border: 2px dashed var(--accent); background: var(--accent-light);
  opacity: .6;
}
.task-card-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.task-code {
  display: inline-block; font-family: 'DM Mono', monospace; font-size: 10px; font-weight: 500;
  color: var(--text-muted); background: var(--bg); border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 4px; letter-spacing: 0.5px; margin-bottom: 2px;
  user-select: all; cursor: text;
}
.task-title    { font-size: 13px; font-weight: 500; margin: 0 0 4px; line-height: 1.4; }
.task-desc {
  font-size: 12px; color: var(--text-muted); margin: 0 0 10px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; text-overflow: ellipsis;
}
.task-desc ul, .task-desc ol { margin: 2px 0; padding-left: 16px; }
.task-desc li { margin-bottom: 0; }
.task-desc a { color: var(--accent); }
.task-desc p { margin: 0; }
.task-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.task-assignee { display: flex; align-items: center; gap: 5px; }
.task-assignee-name { font-size: 11px; color: var(--text-muted); }
.task-unassigned    { font-size: 11px; color: var(--text-muted); font-style: italic; }
.task-actions { display: flex; gap: 2px; }
.task-action-btn {
  width: 22px; height: 22px; border: none; background: transparent;
  border-radius: 4px; cursor: pointer; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s;
}
.task-card:hover .task-action-btn { opacity: 1; }
.task-action-btn:hover { background: var(--bg); }

/* ================================================================
   PRIORITY BADGES
   ================================================================ */
.priority-badge {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.badge-low      { background: #f0fdf4; color: #16a34a; }
.badge-medium   { background: #fefce8; color: #ca8a04; }
.badge-high     { background: #fff7ed; color: #ea580c; }
.badge-critical { background: #fef2f2; color: #dc2626; }
.project-badge {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  font-size: 10px; font-weight: 600;
  background: color-mix(in srgb, var(--proj-color) 15%, transparent);
  color: var(--proj-color);
  max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.badge-admin    { background: var(--accent-light); color: var(--accent); font-size: 11px; padding: 3px 8px; border-radius: 20px; font-weight: 600; }
.badge-member   { background: var(--bg); color: var(--text-muted); font-size: 11px; padding: 3px 8px; border-radius: 20px; font-weight: 500; border: 1px solid var(--border); }

/* ================================================================
   DEADLINE BADGES
   ================================================================ */
.deadline-badge {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  font-size: 10px; font-weight: 600;
}
.due-normal { background: #f1f5f9; color: #64748b; }
.due-soon   { background: #fff7ed; color: #ea580c; }
.due-today  { background: #fef9c3; color: #a16207; }
.overdue    { background: #fef2f2; color: #dc2626; }
.completed-ontime { background: #f0fdf4; color: #16a34a; }
.completed-late   { background: #fef2f2; color: #dc2626; }

/* ================================================================
   MODALS
   ================================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; backdrop-filter: blur(2px);
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 520px;
  max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
  animation: slideUp .15s ease;
}
.modal-sm { max-width: 380px; }
.modal-lg { max-width: 80vw; }
.modal-preview { max-width: 90vw; max-height: 95vh; }
.modal-preview .modal-body { padding: 12px; }
.modal-preview img, .modal-preview video { max-height: 80vh; }
.modal-preview iframe { width: 100%; height: 82vh; border: none; border-radius: 8px; }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 14px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; margin: 0; }
.modal-close {
  width: 30px; height: 30px; border: none; background: transparent;
  border-radius: 6px; cursor: pointer; font-size: 18px; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; transition: background .15s;
}
.modal-close:hover { background: var(--bg); }
.modal-header { flex-shrink: 0; }
.modal > form { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px; align-items: center;
  padding: 14px 22px; border-top: 1px solid var(--border); flex-shrink: 0;
}

/* ================================================================
   FORMS
   ================================================================ */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 5px; }
.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; margin-bottom: 0 !important; }
.form-check input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; margin: 0; }
.form-check span { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.form-control {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 14px; color: var(--text-primary);
  background: var(--surface); outline: none; transition: border-color .15s;
}
.form-control:focus { border-color: var(--accent); }
textarea.form-control { resize: vertical; }
.password-wrap { position: relative; }
.password-wrap .form-control { padding-right: 38px; }
.password-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  padding: 4px; display: flex; align-items: center; justify-content: center;
  border-radius: 4px; transition: color .15s;
}
.password-toggle:hover { color: var(--text-primary); }
select.form-control { cursor: pointer; }

/* Multi-assign dropdown (same pattern as column filter) */
.assign-dd-wrap { position: relative; }
.assign-dd-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 13px; font-weight: 500;
  color: var(--text-muted); background: var(--surface);
  cursor: pointer; transition: border-color .15s;
}
.assign-dd-btn:hover { border-color: var(--accent); }
.assign-dd-btn span {
  flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.assign-dd-btn span.has-selection { color: var(--text-primary); }
.assign-dd-list {
  position: fixed;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 6px; z-index: 99999;
  max-height: 220px; overflow-y: auto;
  /* Width set by JS to match button */
}

/* ================================================================
   RICH TEXT EDITOR
   ================================================================ */
.rich-editor-wrap {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color .15s;
}
.rich-editor-wrap:focus-within { border-color: var(--accent); }
.rich-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.rich-btn {
  width: 28px; height: 28px;
  border: none; background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--text-secondary);
  transition: all .1s;
}
.rich-btn:hover { background: var(--surface); color: var(--text-primary); }
.rich-btn:active { background: var(--accent-light); color: var(--accent); }
.rich-divider {
  width: 1px; height: 18px;
  background: var(--border);
  margin: 0 3px;
}
.rich-editor {
  min-height: 80px;
  max-height: 200px;
  overflow-y: auto;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  outline: none;
  background: var(--surface);
}
.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}
.rich-editor ul, .rich-editor ol {
  margin: 4px 0; padding-left: 20px;
}
.rich-editor li { margin-bottom: 2px; }
.rich-editor a { color: var(--accent); text-decoration: underline; }

/* ================================================================
   RICH CONTENT (rendered descriptions)
   ================================================================ */
.rich-content {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.rich-content ul, .rich-content ol {
  margin: 4px 0;
  padding-left: 20px;
}
.rich-content li { margin-bottom: 2px; }
.rich-content a {
  color: var(--accent);
  text-decoration: underline;
}
.rich-content a:hover { color: var(--accent-hover); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group-full { grid-column: 1 / -1; }

/* ================================================================
   TASK DETAIL PANEL
   ================================================================ */
.task-detail { padding: 0; }
.task-detail-header { padding: 20px 22px 16px; border-bottom: 1px solid var(--border); }
.task-detail-meta {
  display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px;
}
.task-detail-body { display: grid; grid-template-columns: 1fr 220px; gap: 0; }
.task-detail-main { padding: 20px 22px; border-right: 1px solid var(--border); }
.task-detail-sidebar { padding: 20px 18px; }
.task-detail-section { margin-bottom: 20px; }
.task-detail-section h4 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: 0 0 8px; }
.task-desc-text { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }
.activity-log { display: flex; flex-direction: column; gap: 10px; }
.activity-item { display: flex; gap: 8px; align-items: flex-start; }
.activity-content { font-size: 12px; color: var(--text-secondary); line-height: 1.4; }
.activity-content strong { color: var(--text-primary); }
.activity-time { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.sidebar-item { margin-bottom: 16px; }
.sidebar-item label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); display: block; margin-bottom: 5px; }
.sidebar-assignee { display: flex; align-items: center; gap: 8px; }
.sidebar-assignee-name { font-size: 13px; font-weight: 500; }

/* ================================================================
   BOARD MEMBERS MODAL
   ================================================================ */
.members-section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-muted);
  margin: 0 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.members-list {
  display: flex; flex-direction: column; gap: 6px;
}
.member-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: var(--radius-sm);
  transition: background .1s;
}
.member-row:hover { background: var(--bg); }
.member-info {
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
}
.member-name {
  font-size: 13px; font-weight: 500; color: var(--text-primary);
  display: flex; align-items: center; gap: 6px;
}
.member-email {
  font-size: 11px; color: var(--text-muted);
}
.member-creator-badge {
  font-size: 9px; font-weight: 600; text-transform: uppercase;
  padding: 1px 6px; border-radius: 10px;
  background: var(--accent-light); color: var(--accent);
}
/* ================================================================
   ARCHIVED TASKS LIST
   ================================================================ */
.archived-list {
  display: flex; flex-direction: column; gap: 8px;
}
.archived-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.archived-item-checkbox { flex-shrink: 0; display: flex; align-items: center; cursor: pointer; }
.archived-item-checkbox input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
.archived-item-main { flex: 1; min-width: 0; }
.archived-item-title { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.archived-item-actions { display: flex; gap: 6px; flex-shrink: 0; }

.member-admin-badge {
  font-size: 9px; font-weight: 600; text-transform: uppercase;
  padding: 1px 6px; border-radius: 10px;
  background: #fef9c3; color: #a16207;
}
.member-member-badge {
  font-size: 9px; font-weight: 600; text-transform: uppercase;
  padding: 1px 6px; border-radius: 10px;
  background: var(--bg); color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ================================================================
   TASK HISTORY TIMELINE
   ================================================================ */
.history-timeline {
  display: flex; flex-direction: column; gap: 0;
}
.history-date-group {
  margin-bottom: 8px;
}
.history-date-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-muted);
  padding: 10px 0 6px; border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.history-entry {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 6px 0;
  position: relative;
}
.history-time {
  width: 70px; flex-shrink: 0;
  font-size: 11px; color: var(--text-muted);
  font-family: 'DM Mono', monospace;
  text-align: right;
  padding-top: 2px;
}
.history-dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
  position: relative;
}
.history-entry:not(:last-child) .history-dot::after {
  content: '';
  position: absolute;
  top: 10px; left: 3px;
  width: 2px;
  height: calc(100% + 12px);
  background: var(--border);
}
.history-body {
  flex: 1; min-width: 0;
}
.history-actor {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-secondary);
  margin-bottom: 2px;
}
.history-actor strong { color: var(--text-primary); font-weight: 600; }
.history-action {
  font-size: 12px; color: var(--text-secondary);
  line-height: 1.4;
}
/* History changes comparison table */
.history-changes-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.history-changes-table th {
  text-align: left;
  padding: 5px 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.history-changes-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
  line-height: 1.4;
}
.history-changes-table tr:last-child td { border-bottom: none; }
.history-field-name {
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  width: 80px;
}
.history-old-val {
  color: var(--text-muted);
  text-decoration: line-through;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-new-val {
  color: var(--text-primary);
  font-weight: 500;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.text-muted { color: var(--text-muted); }

/* Activity inline change chips (task detail modal) */
.activity-changes-inline {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 4px;
}
.activity-change-chip {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.activity-field {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .02em;
}

/* ================================================================
   TASK REPORT PAGE
   ================================================================ */
.report-filters {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 22px; margin-bottom: 24px;
}
.report-filter-row {
  display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 14px;
}
.report-filter-group { display: flex; flex-direction: column; gap: 4px; }
.report-filter-group label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.report-filter-group .form-control-sm {
  padding: 6px 10px; font-size: 13px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); height: 34px;
}
.report-filter-group select[multiple] { height: 34px; }
.report-multi-hint { font-size: 11px; color: var(--text-muted); }
.btn-link {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-size: 11px; font-weight: 500; padding: 0; text-decoration: underline;
}
.btn-link:hover { color: var(--accent-dark, #a85a1e); }
.report-filter-actions {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding-top: 14px; border-top: 1px solid var(--border-light);
}
.report-kpi-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px;
}
.report-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.report-detail-table { font-size: 12px; min-width: 1200px; }
.report-detail-table th { font-size: 10px; white-space: nowrap; }
.report-detail-table td { font-size: 12px; max-width: 220px; }
.report-task-link { color: var(--accent); text-decoration: none; font-weight: 500; }
.report-task-link:hover { text-decoration: underline; }
.report-desc { font-size: 11px; color: var(--text-muted); line-height: 1.4; display: block; max-width: 200px; }
.report-status-change { display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
.report-sc-col { font-size: 10px; font-weight: 600; color: var(--text-primary); }
.report-sc-time { font-size: 10px; color: var(--text-muted); }
.report-col-checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.report-col-check-item {
  display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer;
  padding: 4px 6px; border-radius: var(--radius-sm);
}
.report-col-check-item:hover { background: var(--bg); }
.report-col-check-item input { accent-color: var(--accent); cursor: pointer; }

/* ================================================================
   RESPONSIVE — TABLET (≤ 1024px)
   ================================================================ */
@media (max-width: 1024px) {
  .nav-inner { padding: 0 16px; }
  .nav-brand { margin-right: 16px; }
  .page-wrap { padding: 20px 16px 36px; }

  /* KPI row: 2 columns */
  .kpi-row { grid-template-columns: repeat(2, 1fr); }

  /* Task detail: stack sidebar below main */
  .task-detail-body { grid-template-columns: 1fr; }
  .task-detail-main { border-right: none; border-bottom: 1px solid var(--border); }
  .task-detail-sidebar { padding: 16px 22px; }

  /* Board header: tighter */
  .board-header { padding: 12px 16px; }
  .board-header-right { flex-wrap: wrap; }

  /* Filter bar */
  .filter-bar { padding: 10px 16px; }
  .filter-input { width: 150px; }
  input[type="date"].filter-control { width: 120px; }

  /* Kanban board */
  .kanban-board { padding: 0 16px 16px; gap: 12px; }
  .kanban-column { width: 260px; max-height: calc(100vh - 170px); }

  /* History table */
  .history-changes-table { font-size: 10px; }
  .history-old-val, .history-new-val { max-width: 130px; }
}

/* ================================================================
   RESPONSIVE — MOBILE (≤ 768px)
   ================================================================ */
@media (max-width: 768px) {
  html { font-size: 14px; }

  /* Navbar: compact */
  .navbar { height: 50px; }
  .nav-inner { padding: 0 12px; }
  .nav-brand { font-size: 14px; margin-right: 10px; }
  .nav-brand .nav-logo { width: 24px; height: 24px; }
  .nav-links { gap: 0; }
  .nav-link { padding: 5px 8px; font-size: 12px; gap: 4px; }
  .nav-link svg { display: none; }
  .nav-user-info { display: none; }
  .nav-clock { display: none; }
  .nav-user { padding: 3px; border-radius: 50%; }
  .nav-user svg:last-of-type { display: none; }
  .user-dropdown { right: -4px; }

  /* Page layout */
  .page-wrap { padding: 16px 12px 28px; }
  .page-header { flex-direction: column; gap: 12px; margin-bottom: 20px; }
  .page-title { font-size: 18px; }
  .page-subtitle { font-size: 13px; }

  /* Board cards: single column */
  .boards-grid { grid-template-columns: 1fr; gap: 12px; }
  .board-card { padding: 16px; }

  /* KPI row: single column */
  .kpi-row { grid-template-columns: 1fr; gap: 10px; }
  .kpi-card { padding: 14px 16px; }
  .kpi-value { font-size: 24px; }

  /* Users grid: 2 columns then 1 on very small */
  .users-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .user-card { padding: 14px; }

  /* Forms: stack columns */
  .form-row { grid-template-columns: 1fr; gap: 10px; }
  .form-row-3 { grid-template-columns: 1fr; }

  /* Tables: horizontal scroll */
  .task-list-table-wrap, .report-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .task-list-table { min-width: 540px; }
  .task-list-table th, .task-list-table td { padding: 8px 10px; font-size: 12px; }

  /* Modals: full-width with margin */
  .modal { max-width: calc(100vw - 24px); margin: 12px; }
  .modal-sm { max-width: calc(100vw - 24px); }
  .modal-lg { max-width: calc(100vw - 24px); }
  .modal-task { max-width: calc(100vw - 24px); }
  .modal-preview { max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .modal-board-files { max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .bf-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .bf-row { grid-template-columns: 28px 1fr 60px 70px; }
  .bf-row-meta:nth-child(n+5) { display: none; }
  .board-files-toolbar { flex-wrap: wrap; }
  .modal-header { padding: 14px 16px 12px; }
  .modal-header h3 { font-size: 15px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; }

  /* Board header: stack on mobile */
  .board-header {
    flex-direction: column; align-items: flex-start;
    padding: 12px; gap: 10px;
  }
  .board-header-right { width: 100%; justify-content: space-between; }
  .board-title { font-size: 16px; }
  .board-subtitle { font-size: 12px; }

  /* Filter bar: wrap tightly */
  .filter-bar { padding: 8px 12px; }
  .filter-bar-inner { gap: 6px; }
  .filter-input { width: 100%; }
  .filter-search { flex: 1; min-width: 140px; }
  .filter-control { font-size: 11px; height: 30px; padding: 5px 8px; }
  input[type="date"].filter-control { width: 110px; }
  .filter-result-count { font-size: 10px; }

  /* Kanban board: scroll horizontal, narrower columns */
  .kanban-board {
    padding: 0 12px 12px; gap: 10px;
  }
  .kanban-board::-webkit-scrollbar { height: 8px; }
  .kanban-board::-webkit-scrollbar-track { margin: 0 8px; }
  .kanban-column {
    width: 240px;
    max-height: calc(100vh - 200px);
  }
  .column-header { padding: 10px 12px; }
  .column-name { font-size: 12px; }
  .task-list { padding: 8px; gap: 6px; }
  .task-card { padding: 10px; }
  .task-title { font-size: 12px; }
  .task-desc { font-size: 11px; }
  .task-card-footer { gap: 4px; }

  /* Task detail: stack everything */
  .task-detail-body { grid-template-columns: 1fr; }
  .task-detail-main { border-right: none; border-bottom: 1px solid var(--border); padding: 16px; }
  .task-detail-sidebar { padding: 16px; }

  /* History */
  .history-time { width: 55px; font-size: 10px; }
  .history-changes-table { font-size: 10px; }
  .history-changes-table th, .history-changes-table td { padding: 4px 6px; }
  .history-old-val, .history-new-val { max-width: 100px; }

  /* Activity change chips: stack */
  .activity-changes-inline { gap: 3px; }
  .activity-change-chip { font-size: 10px; padding: 2px 6px; }

  /* Rich editor */
  .rich-editor { min-height: 60px; padding: 8px 10px; font-size: 12px; }
  .rich-toolbar { padding: 3px 4px; }
  .rich-btn { width: 26px; height: 26px; font-size: 12px; }

  /* Login page */
  .login-card { padding: 28px 20px; margin: 12px; }
  .login-card h1 { font-size: 20px; }
}

/* ================================================================
   RESPONSIVE — SMALL MOBILE (≤ 480px)
   ================================================================ */
@media (max-width: 480px) {
  /* Nav: just logo + avatar */
  .nav-link span { display: none; }
  .nav-brand span { display: none; }

  /* Kanban: full-width columns */
  .kanban-board { padding: 0 8px 8px; gap: 8px; }
  .kanban-board::-webkit-scrollbar { height: 6px; }
  .kanban-board::-webkit-scrollbar-track { margin: 0 4px; }
  .kanban-column { width: 220px; max-height: calc(100vh - 220px); }

  /* Filter bar: two per row */
  .filter-bar-inner { gap: 4px; }
  .filter-group { flex: 1; min-width: calc(50% - 4px); }
  .filter-search { min-width: 100%; }
  .filter-control { width: 100%; }
  input[type="date"].filter-control { width: 100%; }
  .filter-columns-group { min-width: 100%; }

  /* Users grid: single column */
  .users-grid { grid-template-columns: 1fr; }

  /* Board member avatars: hide on very small */
  .board-member-list { display: none; }

  /* History: compact */
  .history-entry { gap: 6px; }
  .history-time { width: 45px; font-size: 9px; }
  .history-changes-table th:first-child,
  .history-changes-table td.history-field-name { display: none; }
}

/* ================================================================
   USERS GRID
   ================================================================ */
.users-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.user-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; text-align: center;
}
.user-inactive { opacity: .55; }
.user-card-top { position: relative; display: flex; justify-content: center; margin-bottom: 12px; }
.user-card-badge {
  position: absolute; top: 0; right: 0;
  font-size: 10px; padding: 2px 7px; border-radius: 20px; font-weight: 600;
}
.user-slack-icon {
  position: absolute; top: 0; left: 0;
  width: 24px; height: 24px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.user-slack-icon.slack-active { color: #E01E5A; }
.user-slack-icon.slack-inactive { color: var(--border); }
.user-name  { font-size: 15px; font-weight: 600; margin: 0 0 3px; }
.user-email { font-size: 12px; color: var(--text-muted); margin: 0 0 12px; word-break: break-all; }
.user-stats { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; font-size: 11px; color: var(--text-muted); }
.user-card-actions { display: flex; justify-content: center; gap: 8px; }

/* ================================================================
   PROJECTS GRID
   ================================================================ */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.project-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.project-card-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.project-color-dot { width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0; margin-top: 3px; }
.project-card-name { font-size: 15px; font-weight: 600; margin: 0 0 2px; overflow-wrap: break-word; word-break: break-word; }
.project-card-desc {
  font-size: 12px; color: var(--text-muted); margin: 0; line-height: 1.4; white-space: pre-wrap;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow-wrap: break-word; word-break: break-word;
}

/* ================================================================
   CHECKLIST
   ================================================================ */
.checklist-editor {
  border: 1.5px solid var(--border); border-radius: 8px; padding: 10px;
  background: var(--surface);
}
.checklist-editor:focus-within { border-color: var(--accent); }
.checklist-add-row {
  display: flex; gap: 6px; align-items: center; margin-top: 6px;
}
.checklist-add-row .form-control { flex: 1; }
.checklist-form-item {
  display: flex; align-items: center; gap: 8px; padding: 5px 0;
  border-bottom: 1px solid var(--border-light);
}
.checklist-form-item:last-of-type { border-bottom: none; }
.checklist-form-label { flex: 1; font-size: 13px; color: var(--text-primary); }
.checklist-form-input {
  flex: 1; font-size: 13px; color: var(--text-primary);
  border: none; outline: none; background: transparent;
  padding: 2px 0; font-family: inherit;
  border-bottom: 1px solid transparent;
}
.checklist-form-input:focus { border-bottom-color: var(--accent); }
.checklist-form-remove {
  width: 20px; height: 20px; border: none; background: transparent;
  color: var(--text-muted); cursor: pointer; font-size: 14px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
}
.checklist-form-remove:hover { background: #fef2f2; color: #dc2626; }

/* Checklist in detail modal */
.checklist-detail { display: flex; flex-direction: column; gap: 4px; }
.checklist-detail-item {
  display: flex; align-items: flex-start; gap: 8px; padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
}
.checklist-detail-item:last-child { border-bottom: none; }
.checklist-detail-item input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--accent);
  cursor: pointer; flex-shrink: 0; margin-top: 1px;
}
.checklist-detail-item.disabled input[type="checkbox"] {
  cursor: not-allowed; opacity: .5;
}
.checklist-detail-label { font-size: 13px; color: var(--text-primary); flex: 1; line-height: 1.4; }
.checklist-detail-item.checked .checklist-detail-label {
  text-decoration: line-through; color: var(--text-muted);
}
.checklist-detail-time {
  font-size: 10px; color: var(--text-muted); white-space: nowrap; margin-top: 2px;
}

/* Checklist progress on card */
.checklist-progress {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 600; color: var(--text-muted);
  font-family: 'DM Mono', monospace;
}
.checklist-progress.checklist-done { color: #16a34a; }

/* ================================================================
   FILE UPLOAD
   ================================================================ */
.modal-task { max-width: 80vw; }
.file-upload-area { margin-bottom: 8px; }
.file-upload-dropzone {
  border: 2px dashed var(--border); border-radius: 8px; padding: 20px;
  text-align: center; color: var(--text-muted); cursor: default;
  transition: border-color .15s, background .15s;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.file-upload-dropzone:hover,
.file-upload-dropzone.drag-active {
  border-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.file-upload-dropzone svg { color: var(--text-muted); }
.file-upload-dropzone small { font-size: 11px; color: var(--text-muted); }

.file-list { display: flex; flex-direction: column; gap: 4px; }
.file-list-header {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em; margin: 8px 0 4px;
}
.file-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px; background: var(--bg); font-size: 13px;
}
.file-item-pending { border-left: 3px solid var(--accent); }
.file-item-deleted { opacity: .5; border-left: 3px solid #dc2626; }
.file-item-deleted .file-name { text-decoration: line-through; }
.file-icon { font-size: 16px; flex-shrink: 0; line-height: 1; }
.file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
/* Inline-editable filename input. Looks like plain text until focused so it
   blends with the non-editable .file-name in the detail modal. */
.file-name-input {
  flex: 1; min-width: 0;
  padding: 4px 6px; margin: 0;
  border: 1px solid transparent; border-radius: 4px;
  background: transparent; color: var(--text-primary);
  font: inherit; font-weight: 500;
  outline: none;
  text-overflow: ellipsis;
}
.file-name-input:hover { border-color: var(--border); background: var(--surface); }
.file-name-input:focus { border-color: var(--accent); background: var(--surface); }
.file-size { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.file-remove {
  width: 20px; height: 20px; border: none; background: transparent;
  color: var(--text-muted); cursor: pointer; font-size: 14px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
}
.file-remove:hover { background: #fef2f2; color: #dc2626; }

.file-detail-list { display: flex; flex-direction: column; gap: 2px; }
.file-detail-actions-bar {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.file-select-all-label {
  font-size: 12px; color: var(--text-secondary); cursor: pointer;
  display: flex; align-items: center; gap: 4px;
}
.file-detail-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-radius: 6px; border-bottom: 1px solid var(--border);
}
.file-detail-item:last-child { border-bottom: none; }
.file-detail-item:hover { background: var(--bg); }
.file-detail-info { flex: 1; min-width: 0; }
.file-detail-info .file-name { display: block; font-size: 13px; font-weight: 500; }
.file-meta { font-size: 11px; color: var(--text-muted); }
.file-detail-btns { display: flex; gap: 4px; flex-shrink: 0; }
.file-count-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 600; color: var(--text-muted);
  font-family: 'DM Mono', monospace;
}

/* ================================================================
   BOARD FILES MODAL
   ================================================================ */
.modal-board-files { max-width: 90vw; max-height: 92vh; }
.modal-board-files .modal-header { gap: 12px; }
.board-files-toolbar {
  display: flex; align-items: center; gap: 10px; margin-left: auto;
}
.view-toggle-sm { display: flex; gap: 2px; }
.view-toggle-sm .view-btn {
  width: 30px; height: 30px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all .15s;
}
.view-toggle-sm .view-btn:hover { background: var(--bg); color: var(--text-primary); }
.view-toggle-sm .view-btn.active { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

/* Grid mode */
.bf-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px;
}
.bf-card {
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  cursor: pointer; transition: box-shadow .15s, border-color .15s; background: var(--surface);
}
.bf-card:hover { border-color: var(--accent); box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.bf-card-thumb {
  height: 100px; background: var(--bg); display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--border);
}
.bf-thumb-icon { font-size: 32px; line-height: 1; }
.bf-thumb-icon svg { width: 40px; height: 40px; }
.bf-card-info { padding: 10px 12px; }
.bf-card-name {
  font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; margin-bottom: 4px; color: var(--text-primary);
}
.bf-card-meta { font-size: 11px; color: var(--text-muted); line-height: 1.6; }
.bf-card-task {
  font-size: 11px; color: var(--text-secondary); margin-top: 4px;
  display: flex; align-items: center; gap: 4px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0;
}
.bf-card-task .task-code { flex-shrink: 0; }

/* List mode */
.bf-list { display: flex; flex-direction: column; gap: 2px; }
.bf-row {
  display: grid; grid-template-columns: 28px 1fr 50px 70px 110px 80px minmax(0, 130px); gap: 10px;
  align-items: center; padding: 8px 10px; border-radius: 6px; cursor: pointer;
  font-size: 13px; border-bottom: 1px solid var(--border);
}
.bf-row-code {
  font-size: 10px; font-family: 'DM Mono', monospace; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.bf-row:hover { background: var(--bg); }
.bf-row:last-child { border-bottom: none; }
.bf-row-name {
  font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-primary);
}
.bf-row-meta { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ================================================================
   USER TASKS PAGE
   ================================================================ */
.ut-filters {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.ut-task-row {
  display: block;
  padding: 14px 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 8px; cursor: pointer; transition: all .15s;
}
.ut-task-row:hover { border-color: #f0c9a0; box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.ut-task-main { }
.ut-task-badges {
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.ut-task-title {
  font-size: 14px; font-weight: 500; color: var(--text-primary);
  margin-bottom: 6px; line-height: 1.4;
}
.ut-task-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-muted);
  padding-top: 8px; border-top: 1px solid var(--border-light);
}
.ut-assignee-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-secondary); font-weight: 500;
}

/* ================================================================
   KPI CARDS
   ================================================================ */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 22px;
}
.kpi-card.kpi-danger  { border-color: #fecaca; background: #fef2f2; }
.kpi-card.kpi-warning { border-color: #fde68a; background: #fffbeb; }
.kpi-value { font-size: 32px; font-weight: 700; font-family: 'DM Mono', monospace; line-height: 1; margin-bottom: 4px; }
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* ================================================================
   PROGRESS BAR
   ================================================================ */
.progress-bar-wrap { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }

/* ================================================================
   COLOR PICKER
   ================================================================ */
.color-picker-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  display: block; width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  transition: transform .15s; border: 2px solid transparent;
}
.color-swatch.selected, .color-swatch:hover:not(.color-taken .color-swatch) { transform: scale(1.15); border-color: #fff; outline: 2px solid var(--accent); }
.color-taken { cursor: not-allowed; opacity: .25; pointer-events: none; }
.color-taken .color-swatch { cursor: not-allowed; transform: none; }

/* ================================================================
   TOAST
   ================================================================ */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #0f172a; color: #fff; padding: 10px 18px;
  border-radius: 8px; font-size: 13px; z-index: 9999;
  animation: toastIn .2s ease;
  box-shadow: var(--shadow-lg);
}
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ================================================================
   MISC
   ================================================================ */
.empty-state {
  text-align: center; padding: 32px; background: var(--surface);
  border: 1.5px dashed var(--border); border-radius: var(--radius-lg);
  font-size: 14px; color: var(--text-muted);
}
.board-empty-state { padding: 40px 24px; }
.loading-spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .6s linear infinite; margin: 32px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================
   BLOCK UI OVERLAY
   ================================================================ */
.blockui-overlay {
  position: fixed; inset: 0;
  background: rgba(248,249,252,.65);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity .3s ease;
}
.blockui-overlay.visible { opacity: 1; }
.blockui-spinner {
  display: flex; gap: 8px; align-items: center;
}
.blockui-dot {
  width: 10px; height: 10px;
  background: var(--accent);
  border-radius: 50%;
  animation: blockuiBounce .6s ease-in-out infinite alternate;
}
.blockui-dot:nth-child(2) { animation-delay: .15s; }
.blockui-dot:nth-child(3) { animation-delay: .3s; }
@keyframes blockuiBounce {
  0%   { transform: translateY(0); opacity: .4; }
  100% { transform: translateY(-12px); opacity: 1; }
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }
