:root {
  --text: #37352f;
  --text-light: #787774;
  --bg: #ffffff;
  --bg-sidebar: #fbfbfa;
  --bg-column: #f7f7f5;
  --border: #e9e9e7;
  --accent: #2383e2;
  --accent-hover: #1a6fc4;
  --danger: #eb5757;
  --danger-bg: #fdecec;
  --success: #2f9e44;
  --success-bg: #ebfbee;
  --radius: 8px;
  --shadow-card: 0 1px 2px rgba(15, 15, 15, 0.08), 0 0 0 1px rgba(15, 15, 15, 0.04);
  --shadow-modal: 0 12px 28px rgba(15, 15, 15, 0.18), 0 2px 4px rgba(15, 15, 15, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
}

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

button { font-family: inherit; cursor: pointer; }

/* ---------- Auth pages ---------- */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-sidebar);
}
.auth-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 40px;
  width: 100%;
  max-width: 380px;
}
.auth-logo { font-size: 22px; font-weight: 600; margin-bottom: 12px; }
.auth-card h1 { font-size: 20px; margin: 0 0 20px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-light); font-weight: 500; }
.auth-form input {
  font-size: 15px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  color: var(--text);
}
.auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(35, 131, 226, 0.18); }
.auth-switch { margin-top: 18px; font-size: 13px; color: var(--text-light); }
.auth-hint { margin-top: 12px; font-size: 12px; color: var(--text-light); line-height: 1.5; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 500;
  background: var(--bg-column);
  color: var(--text);
}
.btn:hover { background: var(--border); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: #fbd5d5; }
.btn-block { width: 100%; }
.btn-small { padding: 4px 10px; font-size: 12px; }

/* ---------- Alerts ---------- */
.alert { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 10px;
}
.sidebar-logo { font-size: 16px; font-weight: 600; padding: 6px 10px 16px; }
.sidebar-nav { margin-bottom: 18px; }
.sidebar-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-light); padding: 0 10px 6px; }
.sidebar-link {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 2px;
}
.sidebar-link:hover { background: var(--border); text-decoration: none; }
.sidebar-link.active { background: var(--border); font-weight: 600; }
.sidebar-empty { font-size: 12px; color: var(--text-light); padding: 0 10px; }

.sidebar-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
}
.sidebar-user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { font-size: 11px; color: var(--text-light); }
.sidebar-logout { color: var(--text-light); font-size: 16px; padding: 4px; }
.sidebar-logout:hover { color: var(--danger); text-decoration: none; }

.main-content { flex: 1; padding: 24px 32px; min-width: 0; }

.empty-state { color: var(--text-light); padding: 40px; text-align: center; font-size: 15px; }

/* ---------- Board ---------- */
.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.board-header h1 { font-size: 24px; margin: 0; }

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.board-column {
  background: var(--bg-column);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 200px;
}
.board-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 10px;
}
.board-column-title { font-weight: 600; font-size: 13px; }
.board-column-count {
  font-size: 12px;
  color: var(--text-light);
  background: var(--border);
  border-radius: 10px;
  padding: 1px 8px;
}
.board-column-cards { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.board-column-cards.drag-over { outline: 2px dashed var(--accent); outline-offset: 2px; border-radius: 6px; }

.task-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-card);
  padding: 10px 12px;
  cursor: pointer;
}
.task-card:hover { box-shadow: 0 2px 6px rgba(15,15,15,0.12), 0 0 0 1px rgba(15,15,15,0.06); }
.task-card.dragging { opacity: 0.4; }

.task-priority {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 10px;
  margin-bottom: 6px;
}
.priority-low { background: #e8f0fe; color: #1a56db; }
.priority-medium { background: #fff4e0; color: #b76e00; }
.priority-high { background: var(--danger-bg); color: var(--danger); }

.task-title { font-size: 14px; font-weight: 500; margin-bottom: 6px; line-height: 1.4; }
.task-due { font-size: 12px; color: var(--text-light); margin-bottom: 6px; }
.task-due.overdue { color: var(--danger); font-weight: 600; }
.task-footer { font-size: 12px; color: var(--text-light); display: flex; justify-content: space-between; }

/* ---------- Modal ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,15,15,0.45);
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  border: none;
  background: transparent;
  font-size: 20px;
  color: var(--text-light);
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal h2 { margin: 0 0 16px; font-size: 19px; }
.modal-field { margin-bottom: 14px; }
.modal-field label { display: block; font-size: 12px; color: var(--text-light); font-weight: 600; margin-bottom: 4px; }
.modal-field input, .modal-field select, .modal-field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
}
.modal-field textarea { resize: vertical; min-height: 70px; }
.modal-row { display: flex; gap: 12px; }
.modal-row .modal-field { flex: 1; }
.modal-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; }
.modal-actions-right { display: flex; gap: 8px; }

.modal-section-title { font-size: 13px; font-weight: 600; margin: 22px 0 10px; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.03em; }

.comment-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.comment-item { background: var(--bg-column); border-radius: 6px; padding: 8px 10px; }
.comment-meta { font-size: 11px; color: var(--text-light); margin-bottom: 3px; }
.comment-text { font-size: 13px; white-space: pre-wrap; }

.log-list { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-light); }
.log-item-time { color: var(--text); font-weight: 500; }

.comment-form { display: flex; gap: 8px; }
.comment-form textarea { flex: 1; min-height: 40px; }

/* ---------- Admin tables ---------- */
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.admin-table th { color: var(--text-light); font-weight: 600; font-size: 12px; }
.admin-table select, .admin-table input[type="text"] { padding: 5px 7px; border: 1px solid var(--border); border-radius: 5px; font-size: 13px; }
.admin-table-actions { display: flex; gap: 6px; white-space: nowrap; }
.row-pending { background: #fff9e8; }

.inline-form { display: flex; gap: 8px; margin-bottom: 18px; }
.inline-form input[type="text"] { padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; width: 240px; }
.inline-form-tight { display: flex; gap: 6px; align-items: center; }

@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; }
  .sidebar { width: 200px; }
  .main-content { padding: 18px; }
}
