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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3345;
  --text: #e1e4ed;
  --text2: #8b90a0;
  --primary: #6c8cff;
  --primary-hover: #5a7af0;
  --danger: #ff6b6b;
  --danger-hover: #e55a5a;
  --success: #4ecdc4;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

.hidden { display: none !important; }

.screen { min-height: 100vh; }

/* Auth */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
}

.auth-card h1 {
  text-align: center;
  font-size: 28px;
  margin-bottom: 24px;
  color: var(--primary);
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--primary);
  color: white;
}

#auth-form input {
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

#auth-form input:focus { border-color: var(--primary); }

#auth-form button[type="submit"] {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

#auth-form button[type="submit"]:hover { background: var(--primary-hover); }

.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  min-height: 20px;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 32px;
}

.header-left h1 {
  font-size: 20px;
  color: var(--primary);
}

nav { display: flex; gap: 4px; }

.nav-btn {
  padding: 8px 16px;
  background: transparent;
  border: none;
  color: var(--text2);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.nav-btn:hover { background: var(--surface2); color: var(--text); }
.nav-btn.active { background: var(--surface2); color: var(--primary); }

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

#current-user { color: var(--text2); font-size: 14px; }

#logout-btn {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

#logout-btn:hover { border-color: var(--danger); color: var(--danger); }

/* Main */
main { padding: 24px; }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.view-header h2 { font-size: 22px; }

/* Buttons */
.btn-primary {
  padding: 8px 18px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}

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

.btn-secondary {
  padding: 8px 18px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.btn-secondary:hover { background: var(--border); }

.btn-danger {
  padding: 8px 18px;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

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

/* Backlog */
.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 800px;
}

.ticket-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.ticket-card:hover {
  border-color: var(--primary);
  background: var(--surface2);
}

.ticket-card-body { flex: 1; min-width: 0; }

.ticket-card-title {
  font-weight: 500;
  margin-bottom: 4px;
  word-break: break-word;
}

.ticket-card-meta {
  font-size: 12px;
  color: var(--text2);
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.ticket-card-desc {
  font-size: 13px;
  color: var(--text2);
  margin-top: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60px;
  overflow: hidden;
}

.ticket-card-images {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.ticket-card-images img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.ticket-id {
  font-size: 11px;
  color: var(--text2);
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

.assignee-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--primary);
  color: white;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.accept-btn {
  padding: 6px 14px;
  background: var(--success);
  color: #111;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.accept-btn:hover { opacity: 0.85; }

.return-btn {
  padding: 4px 10px;
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 11px;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.return-btn:hover { border-color: var(--danger); color: var(--danger); }

/* Board */
.board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 24px;
  min-height: calc(100vh - 180px);
  align-items: flex-start;
}

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

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

.column-name {
  font-weight: 600;
  font-size: 14px;
  background: none;
  border: none;
  color: var(--text);
  cursor: text;
  padding: 2px 4px;
  border-radius: 4px;
  flex: 1;
  min-width: 0;
}

.column-name:focus {
  outline: none;
  background: var(--surface2);
}

.column-count {
  font-size: 12px;
  color: var(--text2);
  background: var(--surface2);
  padding: 1px 7px;
  border-radius: 10px;
  flex-shrink: 0;
}

.column-delete {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.column-delete:hover { color: var(--danger); background: var(--surface2); }

.column-body {
  padding: 8px;
  flex: 1;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.column-body .ticket-card {
  padding: 10px 12px;
  flex-direction: column;
  gap: 6px;
}

.column-body .ticket-card-images img {
  width: 36px;
  height: 36px;
}

.sortable-ghost {
  opacity: 0.4;
  background: var(--primary) !important;
}

.sortable-chosen {
  box-shadow: 0 4px 16px rgba(108, 140, 255, 0.3);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h3 { font-size: 18px; }

.modal-close {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.modal-close:hover { color: var(--text); background: var(--surface2); }

#ticket-form label {
  display: block;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 6px;
  margin-top: 14px;
}

#ticket-form label:first-of-type { margin-top: 0; }

#ticket-form input[type="text"],
#ticket-form textarea,
#ticket-form select {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: vertical;
}

#ticket-form input:focus,
#ticket-form textarea:focus,
#ticket-form select:focus {
  border-color: var(--primary);
}

.image-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text2);
  font-size: 13px;
}

.image-upload-area:hover,
.image-upload-area.dragover {
  border-color: var(--primary);
  background: rgba(108, 140, 255, 0.05);
  color: var(--primary);
}

.image-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.image-preview-item {
  position: relative;
  width: 80px;
  height: 80px;
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.image-preview-item .remove-img {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  padding: 0;
}

.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  gap: 8px;
}

.modal-actions-right {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
}

.lightbox img {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
}

/* Empty state */
.empty-state {
  color: var(--text2);
  text-align: center;
  padding: 40px 20px;
  font-size: 14px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text2); }

/* Responsive */
@media (max-width: 768px) {
  header { flex-direction: column; gap: 8px; padding: 10px 16px; }
  .header-left { flex-direction: column; gap: 8px; }
  main { padding: 16px; }
  .column { min-width: 260px; }
}
