:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #222633;
  --border: #2a2f3d;
  --text: #e8eaed;
  --text-muted: #8b92a5;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --radius: 10px;
  --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

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

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-icon {
  color: var(--accent);
  font-size: 1.2rem;
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem 0.25rem 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  margin-right: 0.25rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
}

.user-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #2d3344;
}

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

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

.btn-danger {
  background: transparent;
  color: #f87171;
  border: 1px solid #7f1d1d;
}

.btn-danger:hover {
  background: rgba(127, 29, 29, 0.25);
}

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

.btn-ghost:hover {
  color: var(--text);
}

.board {
  display: flex;
  gap: 1rem;
  padding: 1.25rem;
  overflow-x: auto;
  min-height: calc(100vh - 65px);
  align-items: flex-start;
}

.column {
  flex: 0 0 260px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 90px);
}

.column-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.column-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.column-body {
  padding: 0.75rem;
  overflow-y: auto;
  flex: 1;
  min-height: 120px;
  transition: background 0.15s;
}

.column-body.drag-over {
  background: rgba(124, 58, 237, 0.08);
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.6rem;
  cursor: grab;
  box-shadow: var(--card-shadow);
  border-left: 3px solid var(--phase-color, var(--accent));
  transition: transform 0.1s, opacity 0.1s;
}

.card:active {
  cursor: grabbing;
}

.card.dragging {
  opacity: 0.45;
}

.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  line-height: 1.3;
}

.card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.6rem;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.ticket-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.ticket-link:hover {
  text-decoration: underline;
}

.card-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.card-badge.local {
  color: #a78bfa;
}

.card-badge.project {
  color: #38bdf8;
}

.card-requester {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-project {
  border-left-width: 4px;
  background: linear-gradient(135deg, var(--bg) 0%, #1a2030 100%);
}

.card-project-tag {
  font-size: 0.68rem;
  color: #38bdf8;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.progress-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  margin-bottom: 0.25rem;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.progress-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.4rem;
}

.modal-wide {
  width: min(640px, 100%);
}

.modal-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.modal-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 1rem;
}

.tab-panel.active {
  display: flex;
}

.subtask-list,
.comment-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.subtask-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.subtask-item label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  cursor: pointer;
  font-size: 0.9rem;
}

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

.subtask-delete {
  padding: 0.1rem 0.4rem;
  font-size: 1.1rem;
}

.comment-item {
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.comment-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.comment-body {
  font-size: 0.88rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.inline-add {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.inline-add input,
.inline-add textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.6rem 0.75rem;
  font: inherit;
}

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}

.checkbox-field input {
  margin-top: 0.15rem;
  accent-color: var(--accent);
}

.empty-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.linked-cards {
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.linked-cards ul {
  margin-top: 0.35rem;
  padding-left: 1.1rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(560px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field span {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field input,
.field textarea,
.field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.6rem 0.75rem;
  font: inherit;
  resize: vertical;
}

.field input:disabled,
.field textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.modal-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

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

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: var(--card-shadow);
  z-index: 100;
}

.toast.hidden {
  display: none;
}

.toast.error {
  border-color: #ef4444;
  color: #fca5a5;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  color: var(--text-muted);
}
