:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1c1f26;
  --text-muted: #6b7280;
  --border: #e2e4e9;
  --primary: #3b6fe0;
  --primary-text: #ffffff;
  --danger: #d64545;
  --success: #2f9e5c;
  --radius: 10px;

  --col-backlog: #8a8f98;
  --col-new: #3b6fe0;
  --col-in_progress: #d99a1f;
  --col-done: #2f9e5c;
  --col-cancelled: #d64545;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b;
    --surface: #1d2026;
    --text: #eceef2;
    --text-muted: #9aa1ac;
    --border: #2c303a;
    --primary: #5b8cf0;
    --primary-text: #0d1117;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body { min-height: 100vh; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

a { color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 15px;
  cursor: pointer;
  min-height: 40px;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-sm { min-height: 32px; padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: default; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--text-muted); }
.field input, .field textarea, .field select {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 15px;
}
.field textarea { resize: vertical; min-height: 80px; }

.error-box {
  background: #fde8e8;
  color: var(--danger);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 12px;
}
@media (prefers-color-scheme: dark) {
  .error-box { background: #3a1f22; }
}

/* ---------- Layout shell ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 17px; margin: 0; }
.topbar nav { display: flex; gap: 6px; align-items: center; }
.topbar nav a, .topbar nav button {
  font-size: 14px;
  text-decoration: none;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
}
.topbar nav a.active { color: var(--primary); font-weight: 600; }

.page { max-width: 1100px; margin: 0 auto; padding: 16px; padding-bottom: 80px; }

/* ---------- Login ---------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-box {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
}
.login-box h1 { font-size: 20px; margin-top: 0; }

/* ---------- Board: mobile tabs ---------- */

.status-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 16px 12px;
  position: sticky;
  top: 49px;
  background: var(--bg);
  z-index: 10;
}
.status-tab {
  flex: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  color: var(--text-muted);
  border-left: 4px solid var(--tab-color, var(--border));
}
.status-tab.active { color: var(--text); font-weight: 600; background: var(--bg); }

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

.board-columns { display: flex; flex-direction: column; gap: 10px; }

.column-header {
  display: none;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  padding: 4px 2px;
}
.column-header .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dot-color); }
.column-header .count { color: var(--text-muted); font-weight: 400; }

.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--card-color, var(--border));
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  margin-bottom: 10px;
}
.task-card:active { transform: scale(0.99); }
.task-card .title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.task-card .meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 13px; color: var(--text-muted); }

.empty-hint {
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px 8px;
  text-align: center;
}

.fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-text);
  border: none;
  font-size: 28px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  cursor: pointer;
  z-index: 30;
}

.add-task-inline { display: none; }

/* ---------- Mobile: only the active column ---------- */

@media (max-width: 879px) {
  .board-column { display: none; }
  .board-column.is-active { display: block; }
}

/* ---------- Desktop: columns side by side ---------- */

@media (min-width: 880px) {
  .status-tabs { display: none; }
  .board-columns {
    flex-direction: row;
    align-items: flex-start;
    overflow-x: auto;
    gap: 14px;
  }
  .board-column { flex: 1 0 220px; min-width: 220px; }
  .column-header { display: flex; }
  .fab { display: none; }
  .add-task-inline { display: inline-flex; align-self: flex-start; }
}

/* ---------- Task detail (full-screen overlay, mobile and desktop) ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 50;
  overflow-y: auto;
}
.overlay-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 5;
}
.overlay-body { max-width: 720px; margin: 0 auto; padding: 16px; padding-bottom: 60px; }

.status-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: var(--pill-color, var(--text-muted));
}

.transition-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }

.task-title-input {
  width: 100%;
  font-size: 20px;
  font-weight: 700;
  border: none;
  background: none;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.task-title-input:focus { outline: none; border-bottom-color: var(--primary); }

.section { margin-top: 22px; }
.section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 8px; }

.row-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .row-fields { grid-template-columns: 1fr; } }

.comment {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.comment:last-child { border-bottom: none; }
.comment .head { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.comment .head strong { color: var(--text); }
.comment .body { white-space: pre-wrap; font-size: 14px; }

.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form textarea { flex: 1; min-height: 44px; }

.attachment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.attachment-row:last-child { border-bottom: none; }
.attachment-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-row .size { color: var(--text-muted); font-size: 12px; }

.muted { color: var(--text-muted); font-size: 13px; }

/* ---------- Modal (create task) ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
}
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
}
.modal {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
@media (min-width: 600px) {
  .modal { border-radius: var(--radius); }
}
.modal h2 { margin-top: 0; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ---------- Users / profile ---------- */

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--border);
  color: var(--text-muted);
  margin-left: 6px;
}
