:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --surface3: #2a2f45;
  --border: #2e3352;
  --text: #e2e8f0;
  --text-muted: #8892a4;
  --accent: #6c63ff;
  --accent-hover: #5a52e0;
  --urgent: #ef4444;
  --high: #f97316;
  --medium: #eab308;
  --low: #22c55e;
  --done: #22c55e;
  --in-progress: #f97316;
  --open: #6c63ff;
  --archived: #64748b;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-inner { display: flex; align-items: baseline; gap: 12px; }
.header-right  { display: flex; align-items: center; gap: 12px; }
.header-email  { color: var(--text-muted); font-size: 13px; }
.logo { font-weight: 700; font-size: 16px; color: var(--accent); }
.subtitle { color: var(--text-muted); font-size: 13px; }

.btn-sm { padding: 5px 12px; font-size: 12px; }

main { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* Stats */
.stats-bar { display: flex; gap: 16px; margin-bottom: 24px; }
.stat {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat span { display: block; font-size: 28px; font-weight: 700; color: var(--accent); }
.stat label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }

/* Toolbar */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.filters { display: flex; align-items: center; gap: 12px; }

select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
}

.toggle-label {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-muted); font-size: 13px; cursor: pointer;
  user-select: none;
}
.toggle-label input { cursor: pointer; accent-color: var(--accent); }

/* Buttons */
.btn-primary {
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); padding: 8px 16px;
  cursor: pointer; font-size: 13px; font-weight: 600;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 16px; cursor: pointer; font-size: 13px;
  transition: border-color .15s;
}
.btn-secondary:hover { border-color: var(--text-muted); color: var(--text); }

.btn-danger {
  background: rgba(239,68,68,.15); color: var(--urgent);
  border: 1px solid rgba(239,68,68,.3); border-radius: var(--radius);
  padding: 8px 16px; cursor: pointer; font-size: 13px; font-weight: 600;
  transition: background .15s;
}
.btn-danger:hover { background: rgba(239,68,68,.25); }

/* Kanban board */
.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  align-items: start;
}
.board.show-archived {
  grid-template-columns: repeat(4, 1fr);
}

.loading, .empty { color: var(--text-muted); text-align: center; padding: 48px; grid-column: 1/-1; }

/* Columns */
.column {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 120px;
}

.column-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}
.column-label {
  font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: .07em;
}
.column-label.col-open        { color: var(--open); }
.column-label.col-in_progress { color: var(--in-progress); }
.column-label.col-done        { color: var(--done); }
.column-label.col-archived    { color: var(--archived); }

.column-count {
  background: var(--surface2); color: var(--text-muted);
  border-radius: 20px; padding: 1px 8px;
  font-size: 11px; font-weight: 600;
}

.column-cards {
  padding: 10px; display: flex; flex-direction: column; gap: 8px;
  min-height: 60px; transition: background .15s;
  border-radius: 0 0 var(--radius) var(--radius);
}
.column-cards.drag-over { background: rgba(108,99,255,.07); }

.column-empty {
  text-align: center; color: var(--border);
  font-size: 12px; padding: 20px 0;
  border: 1px dashed var(--border); border-radius: 6px;
}

/* Task cards */
.task-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, opacity .15s;
}
.task-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.task-card.dragging { opacity: 0.35; cursor: grabbing; }

.card-top {
  display: flex; align-items: flex-start; gap: 8px; margin-bottom: 4px;
}
.task-priority-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0; margin-top: 5px;
}
.priority-urgent { background: var(--urgent); }
.priority-high   { background: var(--high); }
.priority-medium { background: var(--medium); }
.priority-low    { background: var(--low); }

.task-title { font-weight: 600; font-size: 13px; flex: 1; line-height: 1.4; }

.task-desc {
  color: var(--text-muted); font-size: 12px;
  margin: 4px 0 8px 16px;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}

.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px;
}
.task-assignee { color: var(--text-muted); font-size: 11px; }
.priority-badge {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
}
.priority-badge.priority-urgent { color: var(--urgent); }
.priority-badge.priority-high   { color: var(--high); }
.priority-badge.priority-medium { color: var(--medium); }
.priority-badge.priority-low    { color: var(--low); }

/* Card actions (shown on hover) */
.card-actions {
  display: none; align-items: center; gap: 4px;
  margin-top: 10px; padding-top: 8px;
  border-top: 1px solid var(--border);
}
.task-card:hover .card-actions { display: flex; }

.btn-move {
  background: var(--surface3); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 4px;
  padding: 3px 8px; cursor: pointer; font-size: 11px; font-weight: 500;
  transition: all .15s; white-space: nowrap;
}
.btn-move:hover { color: var(--accent); border-color: var(--accent); background: rgba(108,99,255,.1); }

.btn-card-delete {
  background: transparent; border: 1px solid transparent;
  color: var(--text-muted); border-radius: 4px;
  padding: 3px 7px; cursor: pointer; font-size: 12px;
  transition: all .15s; margin-left: auto;
}
.btn-card-delete:hover { color: var(--urgent); border-color: rgba(239,68,68,.4); background: rgba(239,68,68,.1); }

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

.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; width: 560px; max-width: 95vw;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
}
.confirm-modal { width: 360px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 16px; cursor: pointer; padding: 4px;
}

.modal-body {
  padding: 20px 24px;
  display: flex; flex-direction: column; gap: 12px;
}
.modal-body label {
  font-size: 12px; color: var(--text-muted);
  font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
}
.modal-body input, .modal-body textarea, .modal-body select {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius); padding: 8px 10px; font-size: 14px;
}
.modal-body textarea { resize: vertical; }
.modal-row { display: flex; gap: 12px; }
.modal-row > div { flex: 1; display: flex; flex-direction: column; gap: 6px; }

.modal-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-top: 1px solid var(--border);
}
.modal-footer-right { display: flex; gap: 8px; }

.confirm-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.confirm-sub { color: var(--text-muted); font-size: 13px; }

/* ── Notes section (task modal) ─────────────────────────────────────────── */
.notes-section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.notes-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
}

.note-item {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.note-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.note-from {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.note-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.note-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
}

/* ── Auth pages ─────────────────────────────────────────────────────────── */
body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}

.auth-logo {
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
  margin-bottom: 24px;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.auth-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
}

.auth-hint {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 11px;
}

.auth-error {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.3);
  color: var(--urgent);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

.auth-links {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.auth-links a { color: var(--accent); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
.auth-sep { margin: 0 6px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.field input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 11px;
  font-size: 14px;
  width: 100%;
  transition: border-color .15s;
}
.field input:focus { outline: none; border-color: var(--accent); }

.btn-full {
  width: 100%;
  padding: 10px;
  font-size: 14px;
  margin-top: 4px;
}
.btn-primary:disabled {
  opacity: .6;
  cursor: not-allowed;
}

@media (max-width: 900px) {
  .board, .board.show-archived { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .board, .board.show-archived { grid-template-columns: 1fr; }
  .stats-bar { flex-wrap: wrap; }
  .modal-row { flex-direction: column; }
  .auth-card { padding: 28px 20px; }
}
