:root {
  --bg: #0b1014;
  --bg-elevated: #121a21;
  --bg-panel: #0f161c;
  --bg-card: #152028;
  --bg-card-hover: #1a2832;
  --border: #243240;
  --border-strong: #355066;
  --text: #e8eef4;
  --text-muted: #8a9aab;
  --accent: #3db8f5;
  --accent-dim: rgba(61, 184, 245, 0.14);
  --accent-hover: #2aa3e0;
  --success: #3ecf8e;
  --warn: #e6b84d;
  --danger: #ef6b6b;
  --radius: 12px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --col-width: 280px;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background:
    radial-gradient(1100px 520px at 8% -12%, rgba(61, 184, 245, 0.09), transparent 55%),
    radial-gradient(800px 420px at 100% 0%, rgba(62, 207, 142, 0.06), transparent 50%),
    var(--bg);
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.muted {
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-sm {
  padding: 0.3rem 0.55rem;
  font-size: 0.875rem;
}

.btn-primary {
  background: var(--accent);
  color: #041018;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

.btn-danger-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--danger);
}

.btn-danger-ghost:hover {
  background: rgba(239, 107, 107, 0.12);
}

/* ---------- Auth ---------- */

.auth-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-card {
  width: min(400px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.65rem;
  font-weight: 600;
}

.brand p {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--accent), #3ecf8e);
  color: #041018;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.brand-mark.sm {
  width: 32px;
  height: 32px;
  font-size: 0.7rem;
  border-radius: 8px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.auth-form label,
.modal-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.auth-form input,
.modal-form input,
.modal-form textarea,
.modal-form select {
  font: inherit;
  color: var(--text);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}

.auth-form input:focus,
.modal-form input:focus,
.modal-form textarea:focus,
.modal-form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.auth-footer {
  margin: 1.1rem 0 0;
  text-align: center;
  font-size: 0.85rem;
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.875rem;
}

.form-success {
  margin: 0;
  color: var(--success);
  font-size: 0.875rem;
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 16, 20, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.brand-inline:hover {
  text-decoration: none;
}

.brand-name {
  font-family: var(--display);
  font-size: 1.15rem;
}

.nav-tabs {
  display: flex;
  gap: 0.25rem;
  margin-left: 0.5rem;
}

.nav-tab {
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
  text-decoration: none;
}

.nav-tab:hover {
  color: var(--text);
  background: var(--bg-elevated);
  text-decoration: none;
}

.nav-tab.active {
  color: var(--text);
  background: var(--accent-dim);
  color: var(--accent);
}

/* ---------- Board ---------- */

.board-page,
.dashboard-page {
  padding: 1rem 1.25rem 2.5rem;
}

.board-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 600;
}

.page-sub {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.board {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: 50vh;
}

.board-loading {
  padding: 2rem;
}

.column {
  flex: 0 0 var(--col-width);
  width: var(--col-width);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 140px);
  min-height: 200px;
}

.column.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.column-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-panel);
  border-radius: var(--radius) var(--radius) 0 0;
  z-index: 2;
}

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

.column-title {
  flex: 1;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.column-count {
  font-size: 0.75rem;
  font-family: var(--mono);
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

.column-menu {
  position: relative;
}

.column-actions {
  display: flex;
  gap: 0.15rem;
}

.column-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 80px;
}

.column-footer {
  padding: 0.45rem 0.55rem 0.65rem;
  border-top: 1px solid transparent;
}

.column-add {
  width: 100%;
  justify-content: flex-start;
  color: var(--text-muted);
  border-style: dashed;
}

.column-ungrouped .column-dot {
  background: var(--text-muted);
}

/* ---------- Task tiles ---------- */

.tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.75rem;
  cursor: grab;
  transition: background 0.12s, border-color 0.12s, transform 0.12s, opacity 0.12s;
  user-select: none;
}

.tile:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.tile:active {
  cursor: grabbing;
}

.tile.dragging {
  opacity: 0.45;
}

.tile.done {
  opacity: 0.65;
}

.tile.done .tile-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.tile-title {
  margin: 0 0 0.4rem;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}

.tile-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.urgency-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.7rem;
  font-family: var(--mono);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid transparent;
}

.urgency-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.tile-due {
  font-family: var(--mono);
}

.tile-due.overdue {
  color: var(--danger);
  font-weight: 600;
}

.tile-due.soon {
  color: var(--warn);
}

.tile-sub {
  font-family: var(--mono);
}

.tile-complete-btn {
  margin-left: auto;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  flex-shrink: 0;
  padding: 0;
}

.tile-complete-btn:hover {
  border-color: var(--success);
  color: var(--success);
  background: rgba(62, 207, 142, 0.1);
}

.tile.done .tile-complete-btn {
  border-color: var(--success);
  color: var(--success);
  background: rgba(62, 207, 142, 0.12);
}

/* ---------- Modal ---------- */

.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0;
  max-width: min(520px, calc(100vw - 2rem));
  width: 100%;
  box-shadow: var(--shadow);
}

.modal.modal-sm {
  max-width: min(400px, calc(100vw - 2rem));
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.15rem 1.25rem 1.25rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: -0.15rem 0 0.15rem;
}

.modal-header h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.2rem 0.45rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 520px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.modal-footer-right {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.subtasks-section {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.subtasks-header h3 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.subtasks-list {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 200px;
  overflow-y: auto;
}

.subtask-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
}

.subtask-item.done .subtask-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.subtask-item input[type="checkbox"] {
  accent-color: var(--success);
  width: 1rem;
  height: 1rem;
}

.subtask-title {
  flex: 1;
  font-size: 0.875rem;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 0.15rem 0;
  min-width: 0;
}

.subtask-title:focus {
  outline: none;
}

.subtask-del {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.15rem 0.3rem;
}

.subtask-del:hover {
  color: var(--danger);
}

.subtask-add {
  display: flex;
  gap: 0.4rem;
}

.subtask-add input {
  flex: 1;
  font: inherit;
  color: var(--text);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
}

/* ---------- Dashboard ---------- */

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}

.stat-card .stat-value {
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.1;
}

.stat-card .stat-label {
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-card.danger .stat-value {
  color: var(--danger);
}

.stat-card.warn .stat-value {
  color: var(--warn);
}

.stat-card.ok .stat-value {
  color: var(--success);
}

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

@media (max-width: 800px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
}

.dash-columns {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.85rem;
}

.dash-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.dash-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.danger-panel {
  border-color: rgba(239, 107, 107, 0.35);
}

.warn-panel {
  border-color: rgba(230, 184, 77, 0.35);
}

.count-badge {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-panel);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
}

.dash-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 320px;
  overflow-y: auto;
}

.dash-list li {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.55rem 0.65rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.dash-list li:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
}

.dash-list .item-title {
  font-size: 0.875rem;
  font-weight: 600;
}

.dash-list .item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.dash-empty {
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 0.5rem 0;
}

.age-chart,
.urgency-bars {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 64px 1fr 36px;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.8rem;
}

.bar-row .bar-label {
  color: var(--text-muted);
  font-family: var(--mono);
}

.bar-track {
  height: 10px;
  background: var(--bg-panel);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  min-width: 0;
  transition: width 0.3s ease;
}

.bar-count {
  font-family: var(--mono);
  text-align: right;
  color: var(--text-muted);
}

.group-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
}

.group-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chip-color, var(--text-muted));
}
