:root {
  --bg: #f4f6f8;
  --card-bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --column-bg: #f9fafb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-wrap: wrap;
}

.header-left h1 {
  margin: 0;
  font-size: 1.4rem;
}

.subtitle {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-right label {
  font-size: 0.9rem;
  color: var(--muted);
}

select, input, textarea {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 8px 14px;
  transition: background 0.15s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: #e5e7eb;
  color: var(--text);
}
.btn-secondary:hover { background: #d1d5db; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); }

.hidden { display: none !important; }

.stats-bar {
  display: flex;
  gap: 24px;
  padding: 12px 24px;
  color: var(--muted);
  font-size: 0.9rem;
}

.stat strong {
  color: var(--text);
  font-size: 1.1rem;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(260px, 1fr));
  gap: 16px;
  padding: 8px 24px 24px;
  overflow-x: auto;
  min-height: calc(100vh - 160px);
}

.column {
  background: var(--column-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 300px;
}

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--column-bg);
  border-radius: var(--radius) var(--radius) 0 0;
}

.column-count {
  background: var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
}

.column-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 200px;
}

.column-body.drag-over {
  background: rgba(37, 99, 235, 0.08);
  border-radius: 0 0 var(--radius) var(--radius);
}

.story-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  cursor: grab;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.story-card:active { cursor: grabbing; }
.story-card.dragging { opacity: 0.5; }

.story-title {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
}

.story-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.story-points {
  font-size: 0.75rem;
  font-weight: 700;
  background: #dbeafe;
  color: #1e40af;
  padding: 3px 8px;
  border-radius: 999px;
}

.story-assignee {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.story-sprint-tag {
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  width: fit-content;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  padding: 24px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal h2 { margin-top: 0; }

#story-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#story-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
  color: var(--muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.spacer { flex: 1; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #111827;
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  opacity: 0;
  transition: all 0.25s ease;
  z-index: 200;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@media (max-width: 1200px) {
  .board { grid-template-columns: repeat(3, minmax(260px, 1fr)); }
}

@media (max-width: 768px) {
  .app-header { flex-direction: column; align-items: flex-start; }
  .header-right { width: 100%; flex-wrap: wrap; }
  .board { grid-template-columns: repeat(2, minmax(240px, 1fr)); }
  .form-row { grid-template-columns: 1fr; }
}

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