* { box-sizing: border-box; }

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --surface-soft: #eef2ff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #dbe4f0;
  --line-strong: #c7d2e3;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #c2410c;
  --warning-soft: #ffedd5;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 12px 30px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.12);
  --radius: 16px;
}

html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top, #ffffff 0%, var(--bg) 48%, #eef3ff 100%);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
form { margin: 0; }
label { display: block; font-weight: 600; margin-bottom: 8px; color: var(--text); }
input, select, textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  padding: 11px 13px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.02);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}
textarea { min-height: 120px; resize: vertical; }

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px;
}
.container.narrow { max-width: 760px; }
.app-shell { padding-bottom: 40px; }

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.board-header { align-items: flex-start; }
.brand h1 { margin: 0; font-size: 2.2rem; letter-spacing: -0.03em; }
.brand p { margin: 8px 0 0; color: var(--muted); max-width: 760px; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
}
.actions { display: flex; gap: 12px; align-items: center; }
.actions.wrap { flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 10px 14px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.btn-sm { padding: 8px 11px; font-size: 0.9rem; }

.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid.two { grid-template-columns: 2fr 1fr; }
@media (max-width: 900px) { .grid.two { grid-template-columns: 1fr; } }

.card {
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
}
.card h2, .card h3 { margin-top: 0; }

.hero-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 18px;
}
.hero-panel h2 { margin: 0 0 8px; font-size: 1.5rem; }
.hero-panel p { margin: 0; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.metric-card {
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.metric { font-size: 2rem; font-weight: 800; margin-top: 8px; letter-spacing: -0.03em; }
.accent-blue { background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%); }
.accent-orange { background: linear-gradient(180deg, #fff7ed 0%, #ffffff 100%); }

.notice {
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.notice.success {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}
.notice.error {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}
.error-box {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: 14px;
  border-radius: 12px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.section-stack { display: grid; gap: 16px; }
.filter-bar {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(2, minmax(180px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}
.filter-field { min-width: 0; }
.filter-grow { min-width: 240px; }
.filter-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 960px) { .filter-bar { grid-template-columns: 1fr; } }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: .82rem;
  font-weight: 700;
  border: 1px solid var(--line-strong);
  background: var(--surface-muted);
  color: var(--text);
}
.badge.subtle { background: #fff; color: var(--muted); }
.badge.pending { background: #e5e7eb; color: #374151; }
.badge.running { background: #dbeafe; color: #1d4ed8; }
.badge.blocked { background: #fee2e2; color: #b91c1c; }
.badge.done { background: #dcfce7; color: #15803d; }
.badge.high { background: #ffedd5; color: #c2410c; }
.badge.medium { background: #e2e8f0; color: #475569; }
.badge.low { background: #f1f5f9; color: #475569; }
.badge.user { background: #e0e7ff; color: #4338ca; }
.badge.assistant { background: #dcfce7; color: #166534; }
.muted { color: var(--muted); }

.board-section { margin-top: 20px; }
.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(280px, 1fr));
  gap: 18px;
  align-items: start;
}
.kanban-column {
  border-radius: 20px;
  background: rgba(241, 245, 249, 0.9);
  border: 1px solid var(--line);
  padding: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.65);
}
.kanban-column-head { padding: 6px 6px 14px; }
.kanban-column-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.kanban-column h3 { margin: 0; font-size: 1rem; }
.column-count {
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line-strong);
  font-weight: 700;
  color: var(--muted);
}
.kanban-dropzone {
  min-height: 220px;
  display: grid;
  gap: 12px;
  transition: background-color .18s ease, border-color .18s ease;
  border-radius: 14px;
}
.kanban-dropzone.drag-over {
  background: rgba(37, 99, 235, 0.08);
  outline: 2px dashed rgba(37, 99, 235, 0.35);
  outline-offset: 4px;
}
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid transparent;
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
}
.kanban-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.kanban-card.dragging {
  opacity: 0.45;
  transform: rotate(1deg);
  cursor: grabbing;
}
.kanban-card.drag-disabled {
  cursor: default;
}
.kanban-card.priority-high { border-left-color: #f97316; }
.kanban-card.priority-medium { border-left-color: #64748b; }
.kanban-card.priority-low { border-left-color: #94a3b8; }
.kanban-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.kanban-card-title-group { min-width: 0; }
.issue-key-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.issue-key,
.issue-key-page .issue-key {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.issue-key-page { margin-bottom: 8px; }
.kanban-card-title {
  display: inline-block;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}
.kanban-card-title:hover { color: var(--primary); text-decoration: none; }
.kanban-card-desc {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.5;
}
.drag-handle {
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 1.2rem;
  cursor: grab;
}
.kanban-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.kanban-card-stats {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.86rem;
}
.kanban-card-stats strong {
  color: var(--text);
}
.kanban-meta {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
}
.kanban-meta div {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: start;
}
.kanban-meta dt {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #94a3b8;
}
.kanban-meta dd {
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}
.kanban-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.task-list { display: grid; gap: 12px; }
.task-item {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) .7fr .7fr .9fr 1.2fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
}
.task-main { min-width: 0; }
.task-main strong, .task-main .muted { overflow-wrap: anywhere; }
.task-row-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 980px) {
  .task-item { grid-template-columns: 1fr; }
  .task-row-actions { justify-content: flex-start; }
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
@media (max-width: 800px) { .form-grid { grid-template-columns: 1fr; } }

.timeline { display: grid; gap: 12px; }
.timeline-item {
  border-left: 3px solid var(--line-strong);
  padding-left: 14px;
}
.timeline-head {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(100%, 420px);
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
}
.auth-brand { margin-bottom: 20px; }

.empty-state,
.empty-inline {
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  padding: 20px;
  background: var(--surface-muted);
  color: #475569;
}
.drag-disabled-note {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.88rem;
}
.empty-state h3,
.empty-inline h3 { margin-top: 0; }
.board-empty { text-align: center; }

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
@media (max-width: 700px) {
  .meta-grid { grid-template-columns: 1fr; }
}
.note-stack p,
.timeline-item p {
  margin-bottom: 0;
  overflow-wrap: anywhere;
}
.top-gap { margin-top: 16px; }
.footer-note { margin-top: 20px; color: var(--muted); font-size: .92rem; }

@media (max-width: 1280px) {
  .kanban-board { grid-template-columns: repeat(2, minmax(280px, 1fr)); }
}
@media (max-width: 900px) {
  .container { padding: 18px; }
  .hero-panel, .board-header { flex-direction: column; align-items: stretch; }
  .kanban-board { grid-template-columns: 1fr; }
}
