:root {
  --ink: #1a1f2c;
  --muted: #6b7280;
  --line: rgba(255,255,255,.55);
  --accent: #2f6fed;
  --accent-hover: #2563eb;
  --danger: #e11d48;
  --glass: rgba(255,255,255,.55);
  --glass-strong: rgba(255,255,255,.78);
  --card: rgba(255,255,255,.92);
  --shadow: 0 8px 24px rgba(15, 23, 42, .12);
  --p1: #ef4444;
  --p2: #f97316;
  --p3: #eab308;
  --p4: #3b82f6;
  --top-h: 56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Manrope, system-ui, sans-serif;
  color: var(--ink);
  background: #1e293b;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

#app { min-height: 100vh; position: relative; }

.board-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-color: #334155;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: background-image .4s ease;
}
.board-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15,23,42,.18), rgba(15,23,42,.08) 40%, rgba(15,23,42,.22));
  pointer-events: none;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  z-index: 1;
  background:
    radial-gradient(900px 500px at 20% 0%, #93c5fd55, transparent 60%),
    linear-gradient(160deg, #0f172a, #1e3a5f 55%, #0f172a);
}
.login-card {
  width: min(420px, 100%);
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.brand {
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.03em;
  margin: 0 0 6px;
}
.brand span { color: var(--accent); }
.sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: .02em; }
.field input, .field select, .field textarea, .input {
  width: 100%;
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  padding: 11px 12px;
  background: #fff;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(47, 111, 237, .15);
}
.btn {
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  transition: background .15s, transform .15s, box-shadow .15s;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn.ghost {
  background: rgba(255,255,255,.55);
  color: var(--ink);
  border: 1px solid rgba(255,255,255,.7);
  backdrop-filter: blur(8px);
}
.btn.danger { background: var(--danger); }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 8px; }
.err { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 1.2em; }
.auth-list { display: grid; gap: 8px; }
.auth-option {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 1px solid #dbe3ee;
  border-radius: 14px;
  padding: 12px;
  background: #fff;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.auth-option.active:hover {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(47,111,237,.12);
  transform: translateY(-1px);
}
.auth-option.disabled { opacity: .45; cursor: not-allowed; }
.auth-option.active {
  border-color: #93c5fd;
  background: linear-gradient(180deg, #f8fbff, #fff);
}
.auth-ico {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: #111827; color: #fff;
  font-weight: 800; font-size: 16px;
}
.auth-option.disabled .auth-ico { background: #94a3b8; }
.auth-meta { display: grid; gap: 2px; }
.auth-meta b { font-size: 14px; }
.auth-meta small { color: var(--muted); font-size: 12px; }
.auth-go { color: var(--accent); font-weight: 800; font-size: 13px; }

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: var(--top-h) 1fr;
  min-height: 100vh;
}
.top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  height: var(--top-h);
  background: rgba(255,255,255,.42);
  backdrop-filter: blur(18px) saturate(1.2);
  border-bottom: 1px solid rgba(255,255,255,.35);
}
.top .brand { font-size: 18px; margin: 0; text-shadow: 0 1px 0 rgba(255,255,255,.4); }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 999px;
  color: #334155;
  font-weight: 700;
  font-size: 13px;
  transition: background .2s, color .2s;
}
.nav a.active, .nav a:hover {
  background: rgba(255,255,255,.72);
  color: var(--accent);
}
.who { display: flex; align-items: center; gap: 8px; color: #334155; font-size: 13px; font-weight: 600; }
.main {
  padding: 14px 12px 28px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
  padding: 0 4px;
}
.toolbar h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
  flex: 1;
  color: #fff;
  text-shadow: 0 1px 8px rgba(0,0,0,.35);
}
.page-panel .toolbar h1 { color: var(--ink); text-shadow: none; }

.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(300px, 320px);
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 4px 10px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}
.board::-webkit-scrollbar { height: 8px; }
.board::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.45);
  border-radius: 999px;
}

.column {
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.15);
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--top-h) - 70px);
  box-shadow: 0 10px 30px rgba(15,23,42,.1);
  min-height: 0;
}
.column-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 8px;
  flex-shrink: 0;
}
.column-h h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .01em;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #111827;
}
.col-count {
  font-size: 12px;
  color: #64748b;
  font-weight: 700;
  margin-left: 2px;
}
.add-task {
  margin: 0 10px 10px;
  width: calc(100% - 20px);
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  text-align: left;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(47,111,237,.28);
  transition: background .15s, transform .15s;
}
.add-task:hover { background: var(--accent-hover); }
.add-task:active { transform: translateY(1px); }

.cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 8px 12px;
  overflow-y: auto;
  min-height: 80px;
  flex: 1;
}
.cards::-webkit-scrollbar { width: 6px; }
.cards::-webkit-scrollbar-thumb {
  background: rgba(100,116,139,.35);
  border-radius: 999px;
}

.card {
  background: var(--card);
  border: 1px solid rgba(226,232,240,.9);
  border-radius: 12px;
  padding: 10px 10px 10px 8px;
  box-shadow: 0 2px 8px rgba(15,23,42,.06);
  cursor: grab;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  animation: cardIn .25s ease;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 6px 8px;
  align-items: start;
}
.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(15,23,42,.12);
}
.card.dragging { opacity: .5; cursor: grabbing; }
.cards.drop-target {
  outline: 2px dashed rgba(47,111,237,.55);
  outline-offset: -4px;
  border-radius: 10px;
}
.card-check {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border: 1.5px solid #cbd5e1;
  border-radius: 50%;
  background: #fff;
  padding: 0;
  display: grid;
  place-items: center;
  color: transparent;
  transition: border-color .15s, background .15s, color .15s;
}
.card-check:hover {
  border-color: #22c55e;
  color: #22c55e;
}
.card-check svg { width: 11px; height: 11px; }
.card-main { min-width: 0; }
.card-title {
  margin: 0 0 8px;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.35;
  color: #111827;
  word-break: break-word;
}
.card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 6px;
  padding: 3px 7px;
  line-height: 1.2;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag-ico {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: currentColor;
  opacity: .85;
  flex-shrink: 0;
}
.prio-tag {
  background: #f1f5f9;
  color: #475569;
}
.prio-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 1.5px;
  height: 10px;
}
.prio-bars i {
  width: 2.5px;
  border-radius: 1px;
  background: currentColor;
  opacity: .25;
}
.prio-bars i.on { opacity: 1; }
.prio-bars i:nth-child(1) { height: 4px; }
.prio-bars i:nth-child(2) { height: 6px; }
.prio-bars i:nth-child(3) { height: 8px; }
.prio-bars i:nth-child(4) { height: 10px; }
.prio-tag.p1 { color: var(--p1); background: #fee2e2; }
.prio-tag.p2 { color: #c2410c; background: #ffedd5; }
.prio-tag.p3 { color: #a16207; background: #fef9c3; }
.prio-tag.p4 { color: #1d4ed8; background: #dbeafe; }

.age {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  background: #f1f5f9;
  border-radius: 6px;
  padding: 3px 7px;
}
.age-ico {
  width: 12px;
  height: 12px;
  position: relative;
  flex-shrink: 0;
}
.age-ico svg {
  width: 12px;
  height: 12px;
  display: block;
}
.age-ico .hand {
  transform-origin: 6px 6.5px;
  animation: tickHand 2s linear infinite;
}
.avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 800;
  color: #fff;
  margin-left: auto;
  flex-shrink: 0;
  letter-spacing: -.02em;
  box-shadow: 0 0 0 2px #fff;
}
.code-mini {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  color: #94a3b8;
  font-weight: 600;
}

.panel {
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.page-panel {
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid #e8eef5;
  font-size: 14px;
}
.table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.role-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #e8f1ff;
  color: var(--accent);
}
.role-admin { background: #ffe4e6; color: #be123c; }
.role-lead { background: #ffedd5; color: #c2410c; }
.role-member { background: #e8f1ff; color: #1f6feb; }
.role-viewer { background: #f1f5f9; color: #64748b; }

.bg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.bg-tile {
  aspect-ratio: 16/10;
  border-radius: 12px;
  border: 2px solid transparent;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(15,23,42,.12);
  transition: transform .15s, border-color .15s;
}
.bg-tile:hover { transform: scale(1.02); }
.bg-tile.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,111,237,.25);
}
.bg-tile span {
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
}

.overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .48);
  display: grid;
  place-items: end center;
  z-index: 50;
  padding: 0;
  animation: fadeIn .18s ease;
}
.modal {
  width: min(920px, 100%);
  max-height: min(94vh, 900px);
  background: #fff;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,.2);
  display: grid;
  grid-template-rows: auto 1fr;
  animation: slideUp .22s ease;
  overflow: hidden;
}
.modal-h {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid #e8eef5;
}
.modal-h h2 { margin: 4px 0 0; font-size: 20px; letter-spacing: -.02em; }
.modal-body {
  display: grid;
  grid-template-columns: 1.4fr .9fr;
  min-height: 0;
}
.chat, .side {
  padding: 16px 18px 18px;
  overflow: auto;
}
.side { border-left: 1px solid #e8eef5; background: #f8fafc; }
.msgs { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; min-height: 160px; }
.msg {
  background: #fff;
  border: 1px solid #e8eef5;
  border-radius: 12px;
  padding: 10px 12px;
  animation: cardIn .25s ease;
}
.msg-h { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; font-size: 12px; color: var(--muted); }
.msg-h b { color: var(--ink); }
.msg-body { white-space: pre-wrap; font-size: 14px; line-height: 1.45; }
.atts { display: grid; gap: 8px; margin-top: 8px; }
.atts img, .atts video {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid #e8eef5;
  background: #000;
}
.composer { display: grid; gap: 8px; }
.composer textarea { min-height: 72px; resize: vertical; }
.composer-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.side .field { margin-bottom: 12px; }
.prio-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.prio-btn {
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  padding: 10px 6px;
  background: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  gap: 6px;
}
.prio-btn.active {
  border-color: currentColor;
  box-shadow: 0 0 0 3px rgba(0,0,0,.04);
}
.link-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  font-size: 13px; color: var(--muted); margin-top: 4px;
}
.link-row a { color: var(--accent); font-family: "JetBrains Mono", monospace; font-weight: 600; text-decoration: none; }
.copy {
  border: 0; background: #e8f1ff; color: var(--accent);
  border-radius: 8px; padding: 4px 8px; font-weight: 700; font-size: 12px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}
.form-grid .full { grid-column: 1 / -1; }
.actions { display: flex; gap: 8px; justify-content: flex-end; padding: 0 16px 16px; }
.empty {
  color: #64748b;
  font-size: 13px;
  padding: 22px 8px;
  text-align: center;
  font-weight: 600;
}

@keyframes tickHand {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-width: 860px) {
  .modal-body { grid-template-columns: 1fr; }
  .side { border-left: 0; border-top: 1px solid #e8eef5; }
  .who span { display: none; }
  .column { max-height: none; }
  .board { align-items: start; overflow-y: auto; }
}
@media (max-width: 430px) {
  .board { grid-auto-columns: minmax(270px, 88vw); }
  .top { padding: 0 10px; }
  .main { padding: 10px 8px 20px; }
  .form-grid { grid-template-columns: 1fr; }
}
