* { box-sizing: border-box; }

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --surface: #ffffff;
  --bg: #f6f7fb;
  --ink: #1e2233;
  --ink-muted: #6b7280;
  --border: #e5e7eb;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warn: #d97706;
  --warn-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #2563eb;
  --info-light: #dbeafe;
  --elevation-1: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --elevation-2: 0 4px 8px rgba(16, 24, 40, 0.06), 0 2px 4px rgba(16, 24, 40, 0.08);
  --elevation-3: 0 12px 24px rgba(16, 24, 40, 0.10), 0 4px 8px rgba(16, 24, 40, 0.06);
  --radius: 14px;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
  font-size: 18px;
  vertical-align: middle;
  line-height: 1;
}

/* ---------- animations ---------- */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes backdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes pulseGood {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.45); }
  70% { box-shadow: 0 0 0 10px rgba(22, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}
@keyframes spin { to { transform: rotate(360deg); } }

.fade-in { animation: fadeSlideUp 0.35s ease both; }
.pop-in { animation: popIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }

/* ---------- layout basics ---------- */
.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top left, #eef2ff, #f6f7fb 55%);
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--elevation-1);
  transition: box-shadow 0.2s ease;
}
.login-card { width: 340px; box-shadow: var(--elevation-3); }
h1 { font-size: 22px; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 16px; font-weight: 700; margin: 0 0 12px; }
p.sub { color: var(--ink-muted); font-size: 13px; margin: 0 0 20px; }

label { display: block; font-size: 12.5px; font-weight: 600; color: #374151; margin-bottom: 6px; margin-top: 14px; }
input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fbfbfe;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: #fff;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  background: var(--primary);
  color: #fff;
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--elevation-1);
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
}
button:hover { background: var(--primary-dark); box-shadow: var(--elevation-2); }
button:active { transform: scale(0.96); }
button.secondary { background: #fff; color: #374151; border: 1.5px solid var(--border); box-shadow: none; }
button.secondary:hover { background: #f9fafb; border-color: #d1d5db; }
button.small { padding: 6px 12px; font-size: 12.5px; margin: 0 6px 0 0; box-shadow: none; }
button.icon-btn { padding: 6px 10px; }
button.danger-outline { background: #fff; color: var(--danger); border: 1.5px solid var(--danger-light); box-shadow: none; }
button.danger-outline:hover { background: var(--danger-light); }

.error { color: var(--danger); font-size: 12.5px; margin-top: 8px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar b { font-weight: 800; letter-spacing: -0.01em; }
.topbar .brand { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.topbar .brand .material-symbols-outlined { color: var(--primary); font-size: 22px; }
.topbar .who { font-size: 13px; color: var(--ink-muted); display: flex; align-items: center; gap: 10px; }
.topbar .who b { color: var(--ink); }
.topbar a { color: var(--danger); text-decoration: none; font-weight: 600; }

main { max-width: 1080px; margin: 24px auto; padding: 0 20px 40px; }

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.col { flex: 1; min-width: 280px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid #f1f3f8; }
th { color: var(--ink-muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: #fafbff; }

/* ---------- chips & badges ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: #f1f2f6;
  color: #4b5563;
}
.chip.role-admin { background: var(--danger-light); color: #991b1b; }
.chip.role-developer { background: var(--info-light); color: #1e40af; }
.chip.role-tester { background: var(--warn-light); color: #92400e; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.todo { background: #e2e8f0; color: #475569; }
.badge.in_progress { background: var(--info-light); color: #1d4ed8; }
.badge.done { background: var(--success-light); color: #15803d; }
.badge.admin { background: var(--danger-light); color: #b91c1c; }
.badge.developer { background: var(--info-light); color: #1d4ed8; }
.badge.tester { background: var(--warn-light); color: #b45309; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; background: #edeef5; padding: 5px; border-radius: 12px; width: fit-content; }
.tabs button {
  background: transparent; color: #4b5563; border: none; margin: 0; box-shadow: none;
  padding: 8px 16px; border-radius: 9px; font-weight: 600;
}
.tabs button.active { background: #fff; color: var(--primary); box-shadow: var(--elevation-1); }
.tabs button:hover:not(.active) { background: rgba(255,255,255,0.6); }

.week-banner {
  background: linear-gradient(135deg, var(--primary-light), #f5f3ff);
  border: 1px solid #e0e4ff;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 20, 35, 0.45);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  animation: backdropIn 0.18s ease both;
  z-index: 100;
}
.modal { width: 380px; max-height: 85vh; overflow-y: auto; animation: popIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; box-shadow: var(--elevation-3); }
.close-x {
  float: right; cursor: pointer; color: #9ca3af; font-size: 18px;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: background 0.15s ease;
}
.close-x:hover { background: #f3f4f6; color: #374151; }

.credential-box {
  background: var(--primary-light); border: 1px dashed #c7d2fe; border-radius: 10px;
  padding: 12px; font-size: 13px; margin-top: 12px; animation: popIn 0.25s ease both;
}

/* ---------- kanban board ---------- */
.board { display: flex; gap: 16px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; }
.board-col { flex: 1; min-width: 280px; background: #eef0f6; border-radius: 16px; padding: 14px; }
.board-col-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding: 0 2px; }
.board-col-head .title { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.board-col-head .count {
  background: #fff; color: #6b7280; font-size: 11.5px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px; box-shadow: var(--elevation-1);
}
.board-col.col-todo .title .dot { background: #94a3b8; }
.board-col.col-in_progress .title .dot { background: var(--info); }
.board-col.col-done .title .dot { background: var(--success); }
.title .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.ticket {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--elevation-1);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  animation: fadeSlideUp 0.3s ease both;
  cursor: pointer;
  position: relative;
}
.ticket:hover { transform: translateY(-2px); box-shadow: var(--elevation-2); }
.ticket.dragging { opacity: 0.4; }
.ticket.just-completed { animation: pulseGood 0.9s ease; }
.drag-handle {
  position: absolute; top: 10px; right: 10px;
  color: #c7c9d6; cursor: grab; font-size: 16px;
}
.drag-handle:active { cursor: grabbing; }
.board-col-body { min-height: 40px; transition: background 0.15s ease; border-radius: 10px; }
.board-col.drag-over .board-col-body { background: rgba(79, 70, 229, 0.06); outline: 2px dashed var(--primary); outline-offset: 4px; }
.ticket-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; padding-right: 20px; }
.ticket-title { font-size: 14px; font-weight: 700; margin: 0 0 8px; line-height: 1.35; }
.ticket-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.ticket-meta .chip .material-symbols-outlined { font-size: 13px; }
.empty-col { color: #9ca3af; font-size: 12.5px; text-align: center; padding: 22px 8px; border: 1.5px dashed #d7d9e4; border-radius: 10px; }

.ticket-popup {
  position: fixed; margin: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--elevation-3); overflow: hidden; z-index: 999;
}
.ticket-popup-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; color: var(--ink); border: none; border-radius: 0;
  box-shadow: none; margin: 0; padding: 10px 14px; font-size: 13px; font-weight: 500;
  justify-content: flex-start; text-align: left;
}
.ticket-popup-item:hover { background: #f4f5fb; }
.ticket-popup-item:active { transform: none; }
.ticket-popup-item.danger { color: var(--danger); }
.ticket-popup-item.danger:hover { background: var(--danger-light); }

/* ---------- toast ---------- */
.toast-root { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 240px; max-width: 320px;
  background: #1e2233; color: #fff;
  padding: 12px 16px; border-radius: 12px;
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--elevation-3);
  display: flex; align-items: center; gap: 8px;
  animation: toastIn 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
.toast.success { background: #14532d; }
.toast.error { background: #7f1d1d; }
.toast .material-symbols-outlined { font-size: 18px; }

/* ---------- attachments ---------- */
.att-thumb { max-width: 100%; border-radius: 10px; display: block; margin-top: 8px; box-shadow: var(--elevation-1); }

/* ---------- notifications ---------- */
#bellIcon { color: #6b7280; transition: color 0.15s ease; }
#bellWrap:hover #bellIcon { color: var(--primary); }
.notif-badge {
  position: absolute; top: -6px; right: -8px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 999px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px #fff;
}
.notif-panel {
  position: absolute; top: 32px; right: -10px;
  width: 320px; max-height: 400px; overflow-y: auto;
  background: var(--surface); border-radius: 14px; box-shadow: var(--elevation-3);
  border: 1px solid var(--border); z-index: 50;
  text-align: left;
}
.notif-panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; font-size: 13px; font-weight: 700; border-bottom: 1px solid var(--border);
}
.notif-panel-head button { margin: 0; }
.notif-item {
  display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid #f4f5f9;
  cursor: pointer; transition: background 0.15s ease;
}
.notif-item:hover { background: #fafbff; }
.notif-item .material-symbols-outlined { color: #9ca3af; margin-top: 1px; }
.notif-item.unread { background: var(--primary-light); }
.notif-item.unread .material-symbols-outlined { color: var(--primary); }
.notif-msg { font-size: 12.5px; font-weight: 500; color: var(--ink); }
.notif-time { font-size: 11px; color: var(--ink-muted); margin-top: 2px; }
.notif-empty { padding: 24px; text-align: center; color: var(--ink-muted); font-size: 13px; }

/* ---------- comments ---------- */
.comment-item { padding: 10px 0; border-bottom: 1px solid #f1f3f8; }
.comment-item:last-child { border-bottom: none; }
.comment-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-muted); margin-bottom: 3px; }
.comment-head b { color: var(--ink); }
.comment-text { font-size: 13.5px; }
.section-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-muted); margin: 18px 0 8px; }

/* ---------- Task Details modal (redesigned: flex header, tabs, no overlap) ---------- */
.details-modal { width: 460px; max-width: 92vw; padding: 0; overflow: hidden; display: flex; flex-direction: column; max-height: 82vh; }
.details-modal-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 18px 20px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.details-modal-title { font-size: 16px; font-weight: 700; margin: 0; line-height: 1.4; word-break: break-word; padding-right: 4px; }
.details-modal-header .close-x { float: none; flex-shrink: 0; margin-top: 2px; }
.details-tabs { margin: 12px 20px 0; flex-shrink: 0; }
.details-modal-body { padding: 4px 20px 20px; overflow-y: auto; flex: 1; }
.details-tab-panel { padding-top: 12px; }
.details-hint { color: #9ca3af; font-size: 12.5px; margin: 4px 0; }
.details-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid #f1f3f8; }
.details-form label:first-child { margin-top: 0; }
.details-inline-row { display: flex; gap: 8px; align-items: flex-start; }
.details-inline-row input { flex: 1; }
.details-inline-row button { margin-top: 0; flex-shrink: 0; }
.details-att-item { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid #f4f5f9; }
.details-att-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.details-att-item button { margin-top: 6px; }

/* ---------- project filter ---------- */
.project-filter { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.project-filter select { width: auto; min-width: 200px; }
