/* ── Design tokens ──────────────────────────────────────────── */
:root {
  --blue:        #3b82f6;
  --blue-dark:   #2563eb;
  --blue-light:  #eff6ff;
  --red:         #ef4444;
  --red-light:   #fef2f2;
  --red-border:  #fecaca;
  --orange:      #f97316;
  --green:       #16a34a;
  --green-light: #f0fdf4;
  --text:        #0f172a;
  --text-2:      #475569;
  --text-3:      #94a3b8;
  --border:      #e2e8f0;
  --border-2:    #cbd5e1;
  --bg:          #f1f5f9;
  --card:        #ffffff;
  --nav-h:       56px;
  --radius-sm:   6px;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow-sm:   0 1px 3px rgba(15,23,42,.06);
  --shadow:      0 1px 4px rgba(15,23,42,.07), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md:   0 4px 12px rgba(15,23,42,.08), 0 1px 3px rgba(15,23,42,.05);
  --shadow-lg:   0 16px 32px rgba(15,23,42,.12), 0 4px 8px rgba(15,23,42,.06);
  --t:           140ms ease;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; }
button { font-family: inherit; cursor: pointer; }

/* ── Navbar ─────────────────────────────────────────────────── */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 0;
}
.navbar-brand {
  font-size: 1rem; font-weight: 700; color: var(--blue);
  letter-spacing: -.01em; margin-right: 32px; flex-shrink: 0;
}
.navbar-center { flex: 1; display: flex; gap: 2px; }
.navbar-right { display: flex; align-items: center; gap: 8px; margin-left: 16px; }

.nav-link {
  display: inline-flex; align-items: center;
  padding: 6px 12px; border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 500; color: var(--text-2);
  transition: background var(--t), color var(--t);
}
.nav-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-link.active { color: var(--blue); background: var(--blue-light); }
.nav-admin { color: var(--red); }
.nav-admin:hover { background: var(--red-light); color: var(--red); }
.nav-admin.active { background: var(--red-light); color: var(--red); }
.nav-logout {
  padding: 6px 10px; color: var(--text-3); font-size: 1rem;
  border-radius: var(--radius-sm);
}
.nav-logout:hover { color: var(--text); background: var(--bg); }

.nav-user {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 5px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--card);
  transition: background var(--t), border-color var(--t);
  text-decoration: none;
}
.nav-user:hover { background: var(--bg); border-color: var(--border-2); text-decoration: none; }
.nav-user.active { border-color: var(--blue); }
.nav-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--blue);
  color: #fff; font-size: .75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.nav-username { font-size: .8rem; font-weight: 500; color: var(--text-2); }

/* ── Flash messages ─────────────────────────────────────────── */
.flash-container {
  position: fixed; top: calc(var(--nav-h) + 12px); right: 20px;
  z-index: 400; display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.flash {
  padding: 10px 16px; border-radius: var(--radius); font-size: .875rem;
  box-shadow: var(--shadow-md); pointer-events: all;
  max-width: 360px; border: 1px solid transparent;
  animation: flashIn .2s ease;
}
.flash-success { background: var(--green-light); color: var(--green); border-color: #bbf7d0; }
.flash-error   { background: var(--red-light); color: var(--red); border-color: var(--red-border); }
.flash-info    { background: var(--blue-light); color: var(--blue-dark); border-color: #bfdbfe; }
@keyframes flashIn { from { opacity:0; transform:translateX(12px); } to { opacity:1; transform:none; } }

/* ── Layout ─────────────────────────────────────────────────── */
.main-content {
  max-width: 1200px; margin: 0 auto;
  padding: calc(var(--nav-h) + 28px) 24px 56px;
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; gap: 16px;
}
.page-header h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  font-size: .875rem; font-weight: 500; white-space: nowrap;
  transition: background var(--t), border-color var(--t), box-shadow var(--t);
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--bg); border-color: var(--border-2); text-decoration: none; box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: #fff; }
.btn-danger  { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #b84b25; border-color: #b84b25; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); box-shadow: none; }
.btn-ghost:hover { background: var(--bg); border-color: var(--border); color: var(--text); box-shadow: none; }
.btn-sm { height: 30px; padding: 0 12px; font-size: .8125rem; }
.btn-full { width: 100%; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block; margin-bottom: 6px;
  font-size: .8125rem; font-weight: 600; color: var(--text-2);
}
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  font-size: .9rem; color: var(--text); background: var(--card);
  transition: border-color var(--t), box-shadow var(--t);
  font-family: inherit;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(55,138,221,.15);
}
.form-row-right { display: flex; justify-content: flex-end; margin-top: 8px; }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: .875rem; margin-bottom: 16px; border: 1px solid transparent; }
.alert-error { background: var(--red-light); color: var(--red); border-color: var(--red-border); }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-3); margin-bottom: 20px;
}

/* ── Auth ────────────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-box {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 36px 32px; width: 100%; max-width: 400px; box-shadow: var(--shadow-md);
}
.auth-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 24px; letter-spacing: -.02em; }
.auth-link { margin-top: 18px; text-align: center; font-size: .875rem; color: var(--text-2); }

/* ── View toggle (dashboard) ──────────────────────────────── */
.view-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.view-btn {
  width: 36px; height: 32px; display: flex; align-items: center; justify-content: center;
  background: var(--card); border: none; color: var(--text-3);
  transition: background var(--t), color var(--t); cursor: pointer;
}
.view-btn:hover { background: var(--bg); color: var(--text-2); }
.view-btn.active { background: var(--blue-light); color: var(--blue); }
.view-btn + .view-btn { border-left: 1px solid var(--border); }

/* ── Dashboard grid ─────────────────────────────────────────── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(295px, 1fr));
  gap: 16px;
}
.project-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow); transition: box-shadow var(--t), border-color var(--t), transform var(--t);
  cursor: pointer; text-decoration: none; color: var(--text);
}
.project-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-2); transform: translateY(-1px); text-decoration: none; color: var(--text); }
.project-card.has-problems { border-left: 3px solid var(--red); }
.project-card.all-done { opacity: .8; }

.project-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.project-card-title { font-size: .95rem; font-weight: 700; color: var(--text); line-height: 1.3; }
.project-card-objectives {
  font-size: .82rem; color: var(--text-2); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.project-card-tasks { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.task-chip {
  font-size: .78rem; padding: 3px 8px; border-radius: 4px;
  display: flex; align-items: center; gap: 5px; overflow: hidden;
}
.task-chip-problem { background: var(--red-light); color: var(--red); }
.task-chip-progress { background: var(--bg); color: var(--text-2); }
.task-chip-more { color: var(--text-3); font-style: italic; background: none; padding-left: 4px; }
.task-chip-ok { color: var(--green); background: var(--green-light); }
.chip-content { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-prio { font-weight: 800; flex-shrink: 0; font-size: .85em; }

/* Circle checkbox in chips */
.chip-cb {
  flex-shrink: 0; width: 12px; height: 12px; border-radius: 50%;
  border: 1.5px solid currentColor; opacity: .4;
  transition: opacity var(--t); display: flex; align-items: center; justify-content: center;
}

/* Interactive chips */
.chip-interactive { cursor: pointer; transition: background var(--t), opacity var(--t), transform var(--t); }
.chip-interactive:hover { transform: translateX(2px); }
.chip-interactive:hover .chip-cb { opacity: 1; }
.chip-interactive:hover .chip-cb::after { content: '✓'; font-size: .5rem; font-weight: 800; }
.chip-interactive:hover.task-chip-problem { background: #f0b8a3; }
.chip-interactive:hover.task-chip-progress { background: #e2e6ea; }
.chip-interactive:active { transform: scale(.97); }
.chip-urgent.task-chip-problem { border-left: 2px solid #f97316; }
.chip-urgent.task-chip-progress { background: #fff7ed; border-left: 2px solid #f97316; }

/* Chip acknowledging state */
.chip-acking { opacity: .55; pointer-events: none; }
.chip-done {
  background: var(--green-light) !important; color: var(--green) !important;
  text-decoration: line-through; opacity: .7;
}

.project-card-footer {
  display: flex; align-items: center; gap: 8px;
  padding-top: 10px; border-top: 1px solid var(--border); margin-top: auto;
  font-size: .78rem;
}
.card-open-link { margin-left: auto; color: var(--blue); font-size: .8rem; white-space: nowrap; }
.card-open-link:hover { text-decoration: underline; }

/* Progress bar */
.project-progress {
  flex: 1; height: 5px; background: var(--border); border-radius: 99px; overflow: hidden;
}
.project-progress-fill {
  height: 100%; background: var(--blue); border-radius: 99px;
  transition: width .4s ease;
}
.progress-full    { background: var(--green); }
.progress-problem { background: var(--red); }
.progress-label { font-size: .72rem; color: var(--text-3); white-space: nowrap; }

/* ── Dashboard table ─────────────────────────────────────────── */
.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table thead { background: var(--bg); border-bottom: 1px solid var(--border); }
.data-table th {
  padding: 10px 16px; text-align: left; font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-3);
  white-space: nowrap;
}
.th-center { text-align: center; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg); }
.data-table .row-problem td:first-child { border-left: 3px solid var(--red); padding-left: 13px; }
.data-table .row-ok { opacity: .7; }
.td-name { max-width: 200px; }
.td-objectives { max-width: 300px; color: var(--text-2); }
.td-center { text-align: center; }
.td-action { text-align: right; white-space: nowrap; }

/* ── Project list ────────────────────────────────────────────── */
.project-list { display: flex; flex-direction: column; gap: 8px; }
.project-list-item {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow-sm); transition: box-shadow var(--t);
}
.project-list-item:hover { box-shadow: var(--shadow); }
.project-list-item.project-archived { opacity: .6; }
.project-list-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.project-list-name { font-weight: 600; font-size: .9rem; color: var(--text); }
.project-list-objectives { font-size: .8rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-list-badges { display: flex; gap: 6px; flex-shrink: 0; }
.archives-link { margin-top: 20px; text-align: right; font-size: .8125rem; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 9px; border-radius: 99px; font-size: .72rem; font-weight: 700;
  white-space: nowrap; letter-spacing: .01em;
}
.badge-problem { background: var(--red); color: #fff; }
.badge-gray    { background: #f1f3f5; color: var(--text-2); border: 1px solid var(--border); }
.badge-ok      { background: var(--green-light); color: var(--green); border: 1px solid #bbf7d0; }
.badge-admin   { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.badge-user    { background: var(--blue-light); color: var(--blue-dark); border: 1px solid #bfdbfe; }
.badge-owner   { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.badge-write   { background: var(--blue-light); color: var(--blue-dark); border: 1px solid #bfdbfe; }
.badge-read    { background: #f1f3f5; color: var(--text-2); border: 1px solid var(--border); }

/* ── Project page header ─────────────────────────────────────── */
.project-header { margin-bottom: 24px; }
.project-header-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 10px; }

.project-title { font-size: 1.5rem; font-weight: 800; line-height: 1.2; letter-spacing: -.02em; }
.project-title[data-editable] { cursor: text; border-radius: var(--radius-sm); padding: 2px 6px; margin: -2px -6px; }
.project-title[data-editable]:hover { background: var(--blue-light); }

.project-objectives {
  font-size: .9rem; color: var(--text-2); line-height: 1.65; white-space: pre-wrap;
  min-height: 26px; padding: 4px 0; border-radius: var(--radius-sm);
}
.project-objectives[data-editable] { cursor: text; padding: 4px 8px; margin: 0 -8px; }
.project-objectives[data-editable]:hover { background: var(--blue-light); }
.placeholder { color: var(--text-3); font-style: italic; }

/* ── Task columns ────────────────────────────────────────────── */
.task-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 720px) { .task-columns { grid-template-columns: 1fr; } }

.task-col {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow);
}
.task-col-problems { border-top: 3px solid var(--red); }

.col-title {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-3); margin-bottom: 14px;
}
.col-title-problems { color: var(--red); }

/* ── Task items ──────────────────────────────────────────────── */
.task-list { display: flex; flex-direction: column; gap: 1px; margin-bottom: 12px; }

.task-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 8px; border-radius: var(--radius);
  cursor: pointer; transition: background var(--t);
}
.task-item:hover { background: var(--bg); }
.task-item.task-done .task-title-text { text-decoration: line-through; color: var(--text-3); }

.task-item.task-problem:not(.task-done) {
  background: var(--red-light);
  border: 1px solid var(--red-border); border-radius: var(--radius);
}
.task-item.task-problem:not(.task-done):hover { background: #fae7e0; }

.task-title-text {
  flex: 1; font-size: .875rem; cursor: pointer; line-height: 1.45;
  display: flex; align-items: baseline; gap: 6px;
}
.task-title-text:hover { color: var(--blue); }
.task-item.task-done .task-title-text:hover { color: var(--text-3); }

.problem-icon { font-size: .8em; flex-shrink: 0; }
.file-indicator { font-size: .75em; opacity: .6; }

/* ── Custom checkbox ─────────────────────────────────────────── */
.checkbox-wrap {
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer; padding: 2px;
}
.checkbox-wrap input[type=checkbox] { display: none; }
.checkmark {
  width: 20px; height: 20px; border: 2px solid var(--border-2);
  border-radius: 5px; background: var(--card); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t);
}
.checkbox-wrap:hover .checkmark { border-color: var(--blue); background: var(--blue-light); }
.checkmark::after {
  content: ''; display: none; width: 5px; height: 9px;
  border: 2px solid #fff; border-top: none; border-left: none;
  transform: rotate(45deg) translate(0, -1px);
}
.checkbox-wrap input:checked ~ .checkmark { background: var(--blue); border-color: var(--blue); }
.checkbox-wrap input:checked ~ .checkmark::after { display: block; }

.checkmark-problem { border-color: var(--red); }
.checkbox-wrap:hover .checkmark-problem { border-color: var(--red); background: var(--red-light); }
.checkbox-wrap input:checked ~ .checkmark-problem { background: var(--red); border-color: var(--red); }
.checkbox-wrap.readonly { font-size: .9rem; cursor: default; }

/* ── Inline add task ──────────────────────────────────────────── */
.btn-add-task {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 8px 8px; border: none; background: none;
  color: var(--blue); font-size: .8125rem; font-weight: 500; cursor: pointer;
  border-radius: var(--radius); text-align: left;
  border: 1px dashed transparent;
  transition: background var(--t), border-color var(--t);
}
.btn-add-task:hover { background: var(--blue-light); border-color: #bfdbfe; }
.btn-add-problem { color: var(--red); }
.btn-add-problem:hover { background: var(--red-light); border-color: var(--red-border); }

.inline-add { display: flex; gap: 8px; align-items: center; padding: 6px 0; flex-wrap: wrap; }
.inline-input {
  flex: 1; height: 34px; padding: 0 10px; border: 1px solid var(--blue);
  border-radius: var(--radius-sm); font-size: .875rem; min-width: 160px;
  font-family: inherit;
}
.inline-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(55,138,221,.15); }

/* ── Project sections ────────────────────────────────────────── */
.project-section {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.section-title {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-3); margin-bottom: 14px;
}
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }

/* ── File list ───────────────────────────────────────────────── */
.file-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; min-height: 20px; }
.file-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 10px; transition: border-color var(--t);
}
.file-item:hover { border-color: var(--border-2); }
.file-thumb { width: 58px; height: 58px; object-fit: cover; border-radius: var(--radius-sm); cursor: zoom-in; }
.file-name { font-size: .78rem; color: var(--text-2); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-doc-link { font-size: .85rem; color: var(--blue); display: flex; align-items: center; gap: 6px; }
.btn-file-delete {
  background: none; border: none; color: var(--text-3); cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 0 2px; transition: color var(--t);
}
.btn-file-delete:hover { color: var(--red); }
.file-empty { font-size: .82rem; color: var(--text-3); font-style: italic; padding: 2px 0; }
.file-upload-zone { display: flex; align-items: center; gap: 12px; }
.upload-hint { font-size: .75rem; color: var(--text-3); }

/* ── Share ───────────────────────────────────────────────────── */
.share-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.share-item {
  display: flex; align-items: center; gap: 10px; font-size: .875rem;
  padding: 8px 10px; background: var(--bg); border-radius: var(--radius); border: 1px solid var(--border);
}
.share-target { flex: 1; font-weight: 500; }
.share-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.share-form select { flex: 1; min-width: 110px; height: 34px; width: auto; font-size: .85rem; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(15,23,42,.5); align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card); border-radius: var(--radius-lg); width: 100%;
  max-width: 540px; max-height: 92vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: modalIn .18s ease;
  border: 1px solid var(--border);
}
.modal-large { max-width: 660px; }
@keyframes modalIn { from { opacity:0; transform:scale(.97) translateY(8px); } to { opacity:1; transform:none; } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--card); z-index: 1;
}
.modal-header h2 { font-size: 1rem; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px; border-radius: 50%; background: none; border: none;
  font-size: 1.3rem; color: var(--text-3); display: flex; align-items: center; justify-content: center;
  transition: background var(--t), color var(--t); line-height: 1;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 18px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px; border-top: 1px solid var(--border);
  position: sticky; bottom: 0; background: var(--card);
}

/* ── Task modal ──────────────────────────────────────────────── */
.task-status-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 44px; border-radius: var(--radius);
  border: 2px dashed var(--border-2); background: var(--bg);
  font-size: .9rem; font-weight: 600; color: var(--text-2);
  cursor: pointer; transition: all var(--t);
}
.task-status-btn:hover { border-color: var(--blue); background: var(--blue-light); color: var(--blue); }
.task-status-todo:hover { border-color: var(--blue); }
.task-status-done {
  background: var(--green-light); border-color: #bbf7d0; color: var(--green); border-style: solid;
}
.task-status-done:hover { background: #dcfce7; border-color: #86efac; color: var(--green); }
.task-status-problem-done {
  background: var(--green-light); border-color: #bbf7d0; color: var(--green); border-style: solid;
}

.task-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.task-meta-date { font-size: .78rem; color: var(--text-3); margin-left: auto; }
.field-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); margin-bottom: 6px; }
.task-title-edit { font-size: 1rem; font-weight: 700; width: 100%; }
.task-type-select { height: 30px; padding: 0 10px; font-size: .82rem; border-radius: var(--radius-sm); width: auto; border: 1px solid var(--border-2); }
.task-modal-files { display: flex; flex-wrap: wrap; gap: 10px; }
.task-modal-file {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 10px;
}
.task-modal-thumb { width: 54px; height: 54px; object-fit: cover; border-radius: var(--radius-sm); cursor: zoom-in; }
.modal-upload-zone { display: flex; align-items: center; gap: 12px; }
.modal-actions { display: flex; justify-content: space-between; align-items: center; padding-top: 6px; }
.loading { text-align: center; color: var(--text-3); padding: 32px; font-size: .9rem; }

/* ── Lightbox ────────────────────────────────────────────────── */
.lightbox {
  display: none; position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.9); align-items: center; justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 94vw; max-height: 90vh; object-fit: contain; border-radius: var(--radius); }
.lightbox-close {
  position: absolute; top: 16px; right: 20px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2);
  border-radius: 50%; width: 36px; height: 36px;
  color: #fff; font-size: 1.3rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background var(--t);
}
.lightbox-close:hover { background: rgba(255,255,255,.2); }

/* ── Admin ───────────────────────────────────────────────────── */
.admin-section {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.admin-section > h2 { font-size: .9rem; font-weight: 700; margin-bottom: 18px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.admin-table th {
  text-align: left; padding: 9px 12px; border-bottom: 2px solid var(--border);
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-3); white-space: nowrap;
}
.admin-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: var(--bg); }
.row-disabled { opacity: .5; }
.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.team-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 10px;
}
.team-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.team-header strong { flex: 1; font-size: .9rem; }
.team-members { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; min-height: 26px; }
.team-member {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--card); border: 1px solid var(--border); border-radius: 99px;
  padding: 3px 10px 3px 12px; font-size: .8rem;
}
.btn-remove-member {
  background: none; border: none; color: var(--text-3); cursor: pointer;
  font-size: .9rem; padding: 0; line-height: 1; transition: color var(--t);
}
.btn-remove-member:hover { color: var(--red); }
.team-add-member { display: flex; gap: 8px; align-items: center; }

/* ── Account page ────────────────────────────────────────────── */
.account-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
  align-items: start;
}
@media (max-width: 700px) { .account-grid { grid-template-columns: 1fr; } }
.account-avatar {
  width: 56px; height: 56px; border-radius: 50%; background: var(--blue);
  color: #fff; font-size: 1.3rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 20px;
}
.card-meta { grid-column: 1 / -1; }
.meta-list { display: flex; flex-direction: column; gap: 12px; }
.meta-list dt { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-bottom: 4px; }
.meta-list dd { display: flex; }

/* ── Misc ────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 24px; color: var(--text-2);
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { margin-bottom: 20px; font-size: .95rem; }
.text-muted { color: var(--text-3); }
.select-sm { height: 32px; padding: 0 8px; font-size: .82rem; width: auto; }

/* ── Color dot & picker ─────────────────────────────────────── */
.color-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.color-picker-wrap { position: relative; flex-shrink: 0; }
.color-picker-btn {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border-2); background: var(--bg);
  cursor: pointer; display: block;
  transition: border-color var(--t), transform var(--t);
}
.color-picker-btn:hover { border-color: var(--text-2); transform: scale(1.1); }
.color-picker-btn.has-color { border-color: transparent; box-shadow: 0 0 0 2px rgba(0,0,0,.15); }
.color-picker-popover {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 200;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 8px; flex-wrap: wrap; gap: 5px; width: 156px;
}
.color-picker-popover.open { display: flex; }
.color-swatch {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; transition: transform var(--t), border-color var(--t);
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem; color: var(--text-3); background: var(--bg);
}
.color-swatch:hover { transform: scale(1.15); border-color: rgba(0,0,0,.2); }
.color-swatch.active { border-color: #111; box-shadow: 0 0 0 1px #111; }

/* ── Priority (task items & modal) ──────────────────────────── */
.task-prio-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%; background: #f97316; color: #fff;
  font-size: .58rem; font-weight: 800; flex-shrink: 0; vertical-align: middle;
}
.btn-priority {
  flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid var(--border-2); background: none;
  font-size: .6rem; font-weight: 800; color: var(--text-3);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--t), background var(--t), color var(--t), border-color var(--t);
}
.task-item:hover .btn-priority { opacity: .5; }
.task-item:hover .btn-priority:hover { opacity: 1; border-color: var(--text-3); }
.btn-priority.is-high { opacity: 1; color: #fff; background: #f97316; border-color: #ea6c08; }
.btn-priority.is-high:hover { background: #ea6c08; }
.task-prio-modal-btn {
  height: 26px; padding: 0 10px; border-radius: 99px; border: 1.5px solid var(--border-2);
  background: none; font-size: .78rem; font-weight: 600; color: var(--text-3); cursor: pointer;
  transition: all var(--t); display: inline-flex; align-items: center; gap: 4px;
}
.task-prio-modal-btn:hover { background: var(--bg); color: var(--text-2); }
.task-prio-modal-btn.is-high { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.task-prio-modal-btn.is-high:hover { background: #ffedd5; }

/* ── Column header (with collapse toggle) ───────────────────── */
.col-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.col-header .col-title { margin-bottom: 0; }
.col-header-left { display: flex; align-items: center; gap: 8px; }
.col-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 18px; padding: 0 5px;
  background: var(--blue); color: #fff;
  font-size: .68rem; font-weight: 700; border-radius: 99px;
  transition: background var(--t);
}
.col-badge-done { background: var(--green) !important; }
.col-badge-problem { background: var(--red); }
.btn-toggle-done {
  background: none; border: none; color: var(--text-3); font-size: .72rem;
  cursor: pointer; padding: 2px 6px; border-radius: var(--radius-sm);
  transition: color var(--t), background var(--t); white-space: nowrap;
}
.btn-toggle-done:hover { color: var(--text-2); background: var(--bg); }
.task-list-empty {
  padding: 18px 12px; text-align: center; color: var(--text-3);
  font-size: .82rem; font-style: italic;
}
.task-list-empty-ok { color: var(--green); font-style: normal; font-weight: 500; }

/* ── Task completion flash ──────────────────────────────────── */
@keyframes taskDoneFlash {
  0%   { background: var(--green-light); }
  55%  { background: var(--green-light); }
  100% { background: transparent; }
}
.task-item.task-done-flash { animation: taskDoneFlash .55s ease forwards; }

/* ── Auto-save status ───────────────────────────────────────── */
.autosave-status { font-size: .75rem; color: var(--text-3); transition: color var(--t); }
.autosave-status.autosave-saving { color: var(--text-3); }
.autosave-status.autosave-saved  { color: var(--green); }
.autosave-status.autosave-error  { color: var(--red); }

/* ── High-priority task tint ────────────────────────────────── */
.task-item.task-prio-high:not(.task-problem):not(.task-done) {
  background: #fff8f0;
  border-left: 3px solid #f97316;
  padding-left: 7px;
}

/* ── Project header layout ──────────────────────────────────── */
.project-header-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.project-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── Drag & drop (project list) ─────────────────────────────── */
.drag-handle {
  color: var(--text-3); cursor: grab; padding: 2px 4px; opacity: .3; flex-shrink: 0;
  font-size: .9rem; line-height: 1; transition: opacity var(--t);
  user-select: none; -webkit-user-select: none;
}
.drag-handle:hover { opacity: .8; }
.project-list-item[draggable=true] { cursor: default; }
.project-list-item.is-dragging { opacity: .35; background: var(--blue-light) !important; }
.project-list-item.drag-target { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(55,138,221,.2); }

/* ── td-progress (table view) ───────────────────────────────── */
.td-progress { display: flex; align-items: center; gap: 8px; justify-content: center; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .navbar { padding: 0 14px; }
  .navbar-center { display: none; }
  .main-content { padding-left: 14px; padding-right: 14px; }
  .project-grid { grid-template-columns: 1fr; }
  .share-form { flex-direction: column; }
  .admin-actions { flex-direction: column; }
  .admin-table { font-size: .78rem; }
  .admin-table td, .admin-table th { padding: 8px; }
  .modal { border-radius: var(--radius); }
  .modal-body { padding: 16px; }
  .topic-header { flex-wrap: wrap; gap: 8px; }
  .topic-progress-wrap { display: none; }
}

/* ── Global progress (project header) ──────────────────────────── */
.project-global-progress {
  display: flex; align-items: center; gap: 10px;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ── Topics container ───────────────────────────────────────────── */
.topics-container { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }

/* ── Topic section ──────────────────────────────────────────────── */
.topic-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow var(--t);
}
.topic-section:hover { box-shadow: var(--shadow-md); }

.topic-section-general {
  background: var(--bg);
  border-style: dashed;
  box-shadow: none;
}
.topic-section-general:hover { box-shadow: var(--shadow-sm); }

/* ── Topic header ───────────────────────────────────────────────── */
.topic-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid transparent;
  transition: background var(--t), border-color var(--t);
  min-height: 48px;
}
.topic-header:hover { background: var(--bg); }
.topic-section.collapsed .topic-header { border-bottom-color: transparent; }
.topic-section:not(.collapsed) .topic-header { border-bottom-color: var(--border); }

.topic-drag-handle {
  color: var(--text-3); cursor: grab; font-size: 1rem;
  opacity: .35; flex-shrink: 0; line-height: 1;
  transition: opacity var(--t);
}
.topic-drag-handle:hover { opacity: .8; }
.topic-section.is-dragging { opacity: .4; background: var(--blue-light) !important; }
.topic-section.drag-over  { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(59,130,246,.2); }

.topic-title {
  flex: 1; font-size: .95rem; font-weight: 700;
  color: var(--text); line-height: 1.3;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
[data-editable-topic] { cursor: text; border-radius: var(--radius-sm); padding: 1px 5px; margin: -1px -5px; }
[data-editable-topic]:hover { background: var(--blue-light); }

/* ── Topic status pill ──────────────────────────────────────────── */
.topic-status {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 10px; border-radius: 99px;
  font-size: .72rem; font-weight: 700; white-space: nowrap;
  border: none; cursor: pointer; flex-shrink: 0;
  transition: all var(--t);
}
.topic-status-progress { background: var(--blue-light); color: var(--blue-dark); }
.topic-status-progress:hover { background: #dbeafe; }
.topic-status-done    { background: var(--green-light); color: var(--green); }
.topic-status-done:hover { background: #dcfce7; }
.topic-status-blocked { background: var(--red-light); color: var(--red); }
.topic-status-blocked:hover { background: #fee2e2; }
span.topic-status { cursor: default; }

/* ── Topic progress ─────────────────────────────────────────────── */
.topic-progress-wrap {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.topic-progress {
  width: 64px; height: 5px; background: var(--border); border-radius: 99px; overflow: hidden;
}
.topic-progress-fill {
  height: 100%; background: var(--blue); border-radius: 99px;
  transition: width .4s ease;
}
.topic-progress-done    { background: var(--green); }
.topic-progress-blocked { background: var(--red); }
.topic-progress-label { font-size: .72rem; color: var(--text-3); white-space: nowrap; }

/* ── Topic header actions ───────────────────────────────────────── */
.topic-header-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.btn-delete-topic {
  width: 26px; height: 26px; padding: 0;
  border-radius: 50%; font-size: .75rem;
  opacity: 0; transition: opacity var(--t), background var(--t), color var(--t);
}
.topic-header:hover .btn-delete-topic { opacity: .5; }
.topic-header:hover .btn-delete-topic:hover { opacity: 1; color: var(--red); border-color: var(--red-border); background: var(--red-light); }

.topic-collapse-btn {
  background: none; border: none; color: var(--text-3); cursor: pointer;
  font-size: .85rem; padding: 4px 6px; border-radius: var(--radius-sm);
  transition: color var(--t), transform var(--t), background var(--t);
  line-height: 1; flex-shrink: 0;
}
.topic-collapse-btn:hover { color: var(--text-2); background: var(--bg); }
.topic-section.collapsed .topic-collapse-btn { transform: rotate(-90deg); }

/* ── Topic body ─────────────────────────────────────────────────── */
.topic-body { padding: 16px; }
.topic-section.collapsed .topic-body { display: none; }

/* ── Add topic bar ──────────────────────────────────────────────── */
.add-topic-bar {
  display: flex; justify-content: flex-start;
  padding: 4px 0 16px;
}
.btn-add-topic {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  border: 1.5px dashed var(--border-2); background: transparent;
  color: var(--text-2); font-size: .875rem; font-weight: 500; cursor: pointer;
  transition: all var(--t);
}
.btn-add-topic:hover {
  background: var(--blue-light); border-color: var(--blue);
  color: var(--blue);
}

/* ── Inline topic title edit ────────────────────────────────────── */
.topic-title-input {
  flex: 1; height: 28px; padding: 0 8px;
  border: 1px solid var(--blue); border-radius: var(--radius-sm);
  font-size: .95rem; font-weight: 700; font-family: inherit;
  min-width: 120px; background: var(--card);
}
.topic-title-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }

/* ── Adjust task-col spacing inside topics ──────────────────────── */
.topic-body .task-columns { margin-bottom: 0; }
.topic-body .task-col { box-shadow: none; border: 1px solid var(--border); }
.topic-section-general .topic-body .task-col { background: var(--card); }
