:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eceef3;
  --border: #dde0e7;
  --text: #1d2130;
  --muted: #6b7185;
  --primary: #4f7cff;
  --primary-dark: #3a63db;
  --danger: #d9434b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 2px 8px rgba(20, 24, 40, .06);
  --shadow-lg: 0 10px 40px rgba(20, 24, 40, .22);
  --p-low: #8a94a8;
  --p-medium: #3b82f6;
  --p-high: #f59e0b;
  --p-urgent: #e5484d;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 14px; margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.loading, .empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---------- controls */
input[type=text], input[type=password], input[type=search], input[type=date], select, textarea {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(79, 124, 255, .35); border-color: var(--primary); }
input:disabled { background: var(--surface-2); color: var(--muted); }
textarea { resize: vertical; }
input[type=color] { width: 60px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.input-sm { padding: 6px 8px; width: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #f0c4c6; }
.btn-danger:hover { background: #fdeeee; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; padding: 10px; }
.icon-btn {
  border: 0; background: transparent; cursor: pointer; font-size: 18px; line-height: 1; color: var(--muted);
  padding: 4px 8px; border-radius: 6px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.link-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; }
.link-btn:hover { color: var(--danger); }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); margin-right: 4px; }
.prio-low { background: #eef0f4; color: #5b6478; }
.prio-medium { background: #e6efff; color: #2860d8; }
.prio-high { background: #fff3dc; color: #a86200; }
.prio-urgent { background: #fde6e7; color: #c42a31; }
.role-admin { background: #ece6ff; color: #6034d0; }
.role-member { background: #e6f5ec; color: #227447; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 600;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatars { display: inline-flex; }
.avatars .avatar { margin-left: -6px; border: 2px solid var(--surface); }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; display: inline-block; }

/* ---------- forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.field-hint { font-size: 12px; color: var(--muted); }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.form-error { color: var(--danger); font-size: 13px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 12px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; }

/* ---------- login */
.login-page { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 28px; display: flex; flex-direction: column; gap: 16px;
}
.login-top { display: flex; justify-content: space-between; align-items: center; }

/* ---------- shell */
.shell { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px;
  height: 56px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--text); }
.logo:hover { text-decoration: none; }
.logo img { width: 26px; height: 26px; }
.nav { display: flex; gap: 4px; overflow-x: auto; }
.nav-link { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.nav-link:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav-link.active { background: #e8eeff; color: var(--primary); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang-switch button { font: inherit; font-size: 12px; font-weight: 600; border: 0; background: var(--surface); color: var(--muted); padding: 5px 9px; cursor: pointer; }
.lang-switch button.active { background: var(--primary); color: #fff; }
.user-wrap { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 0; background: none; cursor: pointer; font: inherit; color: var(--text); padding: 4px; border-radius: 8px; }
.user-btn:hover { background: var(--surface-2); }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; display: flex; flex-direction: column;
}
.user-menu a, .user-menu button { text-align: left; padding: 8px 10px; border-radius: 6px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; }
.user-menu a:hover, .user-menu button:hover { background: var(--surface-2); text-decoration: none; }

.main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; }
.main-board { max-width: none; display: flex; flex-direction: column; padding-bottom: 16px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { flex: 1; }
.section-title { margin: 28px 0 12px; color: var(--muted); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar select, .toolbar input[type=search] { width: auto; min-width: 200px; }

/* ---------- projects */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.project-card {
  display: flex; flex-direction: column; gap: 10px; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; color: var(--text); border: 1px solid transparent;
}
.project-card:hover { text-decoration: none; border-color: var(--primary); }
.project-card.archived { opacity: .65; }
.project-card-head { display: flex; align-items: center; gap: 8px; }
.project-card h3 { font-size: 16px; }
.clamp { margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 99px; }
.project-meta { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.project-meta .avatars { margin-left: auto; }

/* ---------- board */
.board-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.board-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 200px; }
.board-title .back { font-size: 20px; color: var(--muted); padding: 0 4px; }
.board-title .back:hover { text-decoration: none; color: var(--text); }
.board-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.board-tools input[type=search] { width: 180px; }
.board-desc { margin: 0 0 8px; }
.board {
  flex: 1; display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding: 8px 2px 16px;
  scroll-snap-type: x proximity;
}
.column {
  flex: 0 0 290px; background: var(--surface-2); border-radius: 12px; padding: 10px; display: flex; flex-direction: column;
  max-height: calc(100vh - 170px); scroll-snap-align: start;
}
.column-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; }
.column-title { font-weight: 700; }
.column[data-kind=done] .column-title::before { content: "✓ "; color: #2f9e5b; }
.count { font-size: 12px; color: var(--muted); background: var(--surface); border-radius: 99px; padding: 0 8px; }
.column-head .icon-btn { margin-left: auto; }
.card-list { display: flex; flex-direction: column; gap: 8px; min-height: 40px; overflow-y: auto; padding: 2px; }
.card {
  background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); padding: 10px 12px; cursor: pointer;
  border-left: 4px solid var(--p-medium); user-select: none;
}
.card:hover { box-shadow: 0 2px 10px rgba(20, 24, 40, .14); }
.card:focus-visible { outline: 2px solid var(--primary); }
.prio-edge-low { border-left-color: var(--p-low); }
.prio-edge-medium { border-left-color: var(--p-medium); }
.prio-edge-high { border-left-color: var(--p-high); }
.prio-edge-urgent { border-left-color: var(--p-urgent); }
.card-title { font-weight: 500; margin-bottom: 8px; word-break: break-word; }
.card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.due.overdue { color: var(--danger); font-weight: 600; }
.card-ghost { opacity: .35; }
.card-drag { transform: rotate(2deg); }
.add-task { margin-top: 8px; }
.add-task-btn { width: 100%; text-align: left; border: 0; background: none; color: var(--muted); padding: 8px; border-radius: 8px; cursor: pointer; font: inherit; }
.add-task-btn:hover { background: rgba(0, 0, 0, .05); color: var(--text); }
.add-task-form { display: flex; flex-direction: column; gap: 6px; }
.add-column {
  flex: 0 0 220px; border: 2px dashed var(--border); background: none; border-radius: 12px; padding: 14px;
  color: var(--muted); font: inherit; cursor: pointer;
}
.add-column:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(15, 18, 30, .45); display: flex;
  align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal { width: 100%; max-width: 520px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); }
.modal-wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px; }
.task-title-input { font-size: 18px; font-weight: 600; }
.task-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.task-section { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); border-radius: 4px; }
.task-section.dropping, .doc-area.dropping { outline: 2px dashed var(--primary); outline-offset: 4px; background: #f3f6ff; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.section-head h3 { flex: 1; }
.task-section > h3 { margin-bottom: 10px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.thumb { position: relative; width: 120px; height: 120px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-del {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .55); color: #fff; cursor: pointer; font-size: 16px; line-height: 1;
}
.file-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li { display: flex; align-items: center; gap: 10px; }
.file-list li a { word-break: break-all; }
.comments { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 14px; }
.comment { display: flex; gap: 10px; }
.comment-main { flex: 1; min-width: 0; }
.comment-head { display: flex; gap: 8px; align-items: baseline; }
.comment-head .link-btn { margin-left: auto; }
.comment-body { white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; }

/* ---------- tables */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfc; }
.table tr:last-child td { border-bottom: 0; }
.table tr.inactive { opacity: .55; }
.table .actions { text-align: right; }
.doc-name { display: flex; gap: 10px; align-items: flex-start; }
.doc-name a { word-break: break-word; font-weight: 500; }
.file-icon { font-size: 20px; line-height: 1.2; }
.user-cell { display: inline-flex; align-items: center; gap: 8px; }
.show-sm { display: none; }
.doc-area { border-radius: var(--radius); min-height: 120px; }

/* ---------- profile */
.profile { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.card-box { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }

/* ---------- toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  background: #1d2130; color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow-lg); max-width: calc(100% - 32px);
}
.toast-error { background: var(--danger); }

/* ---------- small screens */
@media (max-width: 760px) {
  .topbar { gap: 8px; padding: 8px 10px 0; height: auto; flex-wrap: wrap; }
  .topbar .nav { order: 3; width: 100%; padding-bottom: 6px; }
  .topbar .nav-link { flex: 1; text-align: center; }
  .logo-text, .user-btn-name { display: none; }
  .nav-link { padding: 6px 8px; }
  .main { padding: 16px 12px 40px; }
  .task-grid { grid-template-columns: 1fr 1fr; }
  .hide-sm { display: none; }
  .show-sm { display: block; }
  .column { flex-basis: 84vw; max-height: none; }
  .board-tools { width: 100%; }
  .board-tools input[type=search] { flex: 1 1 100%; width: auto; }
  .board-tools select { flex: 1 1 40%; }
  .board-tools .btn { flex: 1; }
  .toolbar select, .toolbar input[type=search] { min-width: 0; flex: 1; }
  .modal-backdrop { padding: 12px 8px; }
  .modal-body { padding: 14px; }
  .comment-form { flex-direction: column; align-items: stretch; }
}
