:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-input: #252833;
  --border: #2d3140;
  --text: #e1e4ed;
  --text-muted: #8b8fa3;
  --primary: #6366f1;
  --primary-hover: #5558e6;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --orange: #f97316;
  --blue: #3b82f6;
  --radius: 6px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Navbar */
.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.nav-brand a { color: var(--text); font-weight: 700; font-size: 1.1rem; }
.nav-brand a:hover { text-decoration: none; }
.nav-links { display: flex; gap: 1rem; flex: 1; }
.nav-link { color: var(--text-muted); font-size: 0.9rem; }
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-user { display: flex; align-items: center; gap: 0.75rem; font-size: 0.85rem; color: var(--text-muted); }

/* Container */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; flex: 1; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.card h2 { margin-bottom: 0.75rem; font-size: 1.1rem; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.btn:hover { background: var(--border); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }
.btn-block { display: block; width: 100%; text-align: center; }

/* Forms */
.form { }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.25rem; font-size: 0.85rem; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.9rem;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-inline { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.form-inline input, .form-inline select { width: auto; }

/* Tables */
.table-container { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.table th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
.table tr:hover { background: rgba(99,102,241,0.04); }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}
.badge-sm { font-size: 0.7rem; padding: 0.1rem 0.35rem; }

/* Status badges */
.badge-pending_review { background: #f59e0b22; color: var(--yellow); border: 1px solid #f59e0b44; }
.badge-approved { background: #3b82f622; color: var(--blue); border: 1px solid #3b82f644; }
.badge-in_progress { background: #6366f122; color: var(--primary); border: 1px solid #6366f144; }
.badge-completed { background: #22c55e22; color: var(--green); border: 1px solid #22c55e44; }
.badge-blocked { background: #ef444422; color: var(--red); border: 1px solid #ef444444; }
.badge-rejected { background: #ef444422; color: var(--red); border: 1px solid #ef444444; }
.badge-archived { background: #64748b22; color: #94a3b8; border: 1px solid #64748b44; }

/* Priority badges */
.badge-critical { background: #ef444422; color: var(--red); border: 1px solid #ef444444; }
.badge-high { background: #f9731622; color: var(--orange); border: 1px solid #f9731644; }
.badge-medium { background: #f59e0b22; color: var(--yellow); border: 1px solid #f59e0b44; }
.badge-low { background: #3b82f622; color: var(--blue); border: 1px solid #3b82f644; }
.badge-not_worth_time { background: #64748b22; color: #94a3b8; border: 1px solid #64748b44; }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error { background: #ef444422; border: 1px solid #ef444444; color: var(--red); }
.alert-success { background: #22c55e22; border: 1px solid #22c55e44; color: var(--green); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; text-align: center; }
.stat-number { font-size: 2rem; font-weight: 700; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }
.stat-pending .stat-number { color: var(--yellow); }
.stat-progress .stat-number { color: var(--primary); }
.stat-done .stat-number { color: var(--green); }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 768px) { .grid-2 { grid-template-columns: 1fr; } }

/* Page header */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.page-header h1 { margin: 0; }

/* Lists */
.task-list-simple { list-style: none; }
.task-list-simple li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; }
.task-list-simple li:last-child { border-bottom: none; }
.guild-list { list-style: none; }
.guild-list li { padding: 0.5rem 0; display: flex; justify-content: space-between; align-items: center; }

/* Info list */
.info-list { font-size: 0.9rem; }
.info-list dt { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.5rem; }
.info-list dd { margin-left: 0; }

/* Comments */
.comments { }
.comment { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: none; }
.comment-header { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.25rem; font-size: 0.85rem; }
.comment p { font-size: 0.9rem; }

/* History */
.history-list { list-style: none; font-size: 0.85rem; }
.history-list li { padding: 0.35rem 0; border-bottom: 1px solid var(--border); }
.history-list code { background: var(--bg-input); padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.8rem; }

/* Filters */
.filters { margin-bottom: 1rem; }
.filter-form { }
.filter-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.filter-row select, .filter-row input[type="text"] {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.85rem;
}

/* Pagination */
.pagination { display: flex; gap: 0.25rem; justify-content: center; margin-top: 1rem; }

/* Quick links */
.quick-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Auth container */
.auth-container { max-width: 400px; margin: 3rem auto; }
.auth-container h1 { margin-bottom: 0.5rem; }
.auth-container p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* Error page */
.error-page { text-align: center; margin-top: 3rem; }
.error-page h1 { margin-bottom: 0.5rem; }
.error-page p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* Colors */
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

/* Nav role badge */
.nav-role-badge { background: var(--primary); color: #fff; padding: 0.15rem 0.5rem; border-radius: 9999px; font-size: 0.7rem; text-transform: capitalize; }

/* Project grid */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.project-card h3 { margin-bottom: 0.25rem; }
.project-card-actions { margin-top: 0.75rem; display: flex; gap: 0.5rem; }

/* Role tier info */
.role-tier-info ul li { padding: 0.2rem 0; }
.role-tier-info .badge { min-width: 80px; text-align: center; display: inline-block; }

/* Discord button */
.btn-discord {
  background: #5865F2;
  border-color: #5865F2;
  color: #fff;
  font-size: 1rem;
  padding: 0.75rem 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.btn-discord:hover { background: #4752c4; border-color: #4752c4; text-decoration: none; }

/* Admin login toggle */
.admin-login-toggle { margin-top: 1rem; }
.admin-login-toggle summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
  list-style: none;
}
.admin-login-toggle summary::-webkit-details-marker { display: none; }
.admin-login-toggle summary::before { content: ''; }

/* Board header */
.board-header { margin-bottom: 1rem; }
.board-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.board-controls h1 { margin: 0; font-size: 1.5rem; }
.board-project-filter select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.85rem;
}
.board-view-toggle { margin-left: auto; display: flex; gap: 0.25rem; }

/* Kanban board */
.kanban-board {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: calc(100vh - 180px);
  align-items: flex-start;
}

.kanban-column {
  min-width: 280px;
  max-width: 320px;
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}

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

.kanban-column-count {
  background: var(--bg-input);
  color: var(--text-muted);
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
}

.kanban-column-body {
  padding: 0.5rem;
  overflow-y: auto;
  max-height: calc(100vh - 260px);
  min-height: 60px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Kanban card */
.kanban-card {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  overflow: hidden;
}
.kanban-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(99,102,241,0.2);
}

.kanban-card-priority-border {
  width: 4px;
  flex-shrink: 0;
}
.kanban-card-priority-critical { background: var(--red); }
.kanban-card-priority-high { background: var(--orange); }
.kanban-card-priority-medium { background: var(--yellow); }
.kanban-card-priority-low { background: var(--blue); }
.kanban-card-priority-not_worth_time { background: #64748b; }

.kanban-card-content {
  padding: 0.6rem 0.75rem;
  flex: 1;
  min-width: 0;
}

.kanban-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}

.kanban-card-id {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}

.kanban-card-title {
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 0.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.kanban-card-meta {
  display: flex;
  gap: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.kanban-card-category { font-weight: 500; }

.kanban-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.25rem;
}

.kanban-card-project {
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 9999px;
  border: 1px solid;
  font-weight: 500;
}

.kanban-card-assignee {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* Drag feedback */
.kanban-card-ghost {
  opacity: 0.4;
  background: var(--primary);
  border-color: var(--primary);
}
.kanban-card-ghost .kanban-card-content { visibility: hidden; }
.kanban-card-ghost .kanban-card-priority-border { visibility: hidden; }

.kanban-card-dragging {
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
  transform: rotate(2deg);
}

.kanban-card-loading {
  opacity: 0.5;
  pointer-events: none;
}

/* Task detail panel (slide-out) */
.task-detail-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.task-detail-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.task-detail-panel {
  position: fixed;
  top: 0;
  right: -520px;
  width: 500px;
  max-width: 90vw;
  height: 100%;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transition: right 0.25s ease;
}
.task-detail-panel.open {
  right: 0;
}

.task-detail-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.task-detail-panel-header h2 {
  font-size: 1rem;
  margin: 0;
}

.task-detail-close {
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.2rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.task-detail-close:hover { color: var(--text); }

.task-detail-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

/* Detail panel content */
.detail-title-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.4rem 0.5rem;
  margin-bottom: 0.75rem;
}
.detail-title-input:hover { border-color: var(--border); }
.detail-title-input:focus { border-color: var(--primary); outline: none; }

.detail-fields {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.detail-field {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.detail-field-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 70px;
  flex-shrink: 0;
}
.detail-field select {
  flex: 1;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.85rem;
}
.detail-field select:focus { outline: none; border-color: var(--primary); }

.detail-description {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
  margin-bottom: 0.5rem;
  white-space: pre-wrap;
}

.detail-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 1rem 0 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.detail-comments-list { }
.detail-comment {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.detail-comment:last-child { border-bottom: none; }
.detail-comment-header {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.8rem;
  margin-bottom: 0.15rem;
}
.detail-comment-body { font-size: 0.85rem; }

.detail-comment-form textarea {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.85rem;
  resize: vertical;
  min-height: 60px;
}
.detail-comment-form textarea:focus { outline: none; border-color: var(--primary); }

.detail-history-list {
  list-style: none;
  font-size: 0.8rem;
}
.detail-history-list li {
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.detail-history-list code {
  background: var(--bg-input);
  padding: 0.05rem 0.2rem;
  border-radius: 3px;
  font-size: 0.75rem;
}

.detail-open-full {
  display: block;
  text-align: center;
  margin-top: 1rem;
  font-size: 0.85rem;
}

/* Footer */
.footer { text-align: center; padding: 1rem; color: var(--text-muted); font-size: 0.8rem; border-top: 1px solid var(--border); }

/* Board page: wider container */
body:has(.kanban-board) .container { max-width: 100%; padding: 1rem 1.5rem; }
body:has(.kanban-board) .footer { display: none; }

/* Mobile: columns scroll horizontally */
@media (max-width: 768px) {
  .kanban-column { min-width: 260px; width: 260px; }
  .task-detail-panel { width: 100%; max-width: 100%; }
  .board-controls { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .board-view-toggle { margin-left: 0; }
}
