:root {
  color-scheme: dark;
  --bg: #0f0f0f;
  --panel: rgba(20, 20, 20, .86);
  --panel-strong: #191919;
  --card: #242424;
  --line: rgba(255, 255, 255, .1);
  --text: #ffffff;
  --muted: #9a9a9a;
  --soft: #e0e0e0;
  --accent: rgb(104, 223, 127);
  --accent-glow: rgba(104, 223, 127, .45);
  --danger: #ef4444;
  font-family: Poppins, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
main { min-height: calc(100vh - 72px); }
input, textarea, select, button { font: inherit; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 15px;
  color: var(--text);
  background: rgba(255, 255, 255, .055);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(104, 223, 127, .12);
}
select[multiple] { min-height: 112px; }
label { display: grid; gap: 8px; color: var(--soft); font-size: 14px; }

.background-grid {
  position: fixed;
  inset: -100%;
  z-index: -2;
  background-image:
    repeating-linear-gradient(to right, rgba(255,255,255,.035) 0 1px, transparent 1px 80px),
    repeating-linear-gradient(to bottom, rgba(255,255,255,.035) 0 1px, transparent 1px 80px);
  animation: gridDrift 30s linear infinite;
}
.vignette {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at top left, #0f0f0f 0%, transparent 40%),
    radial-gradient(circle at top right, #0f0f0f 0%, transparent 40%),
    radial-gradient(circle at bottom left, #0f0f0f 0%, transparent 40%),
    radial-gradient(circle at bottom right, #0f0f0f 0%, transparent 40%),
    radial-gradient(circle at center, rgba(104, 223, 127, .07), transparent 58%);
}
@keyframes gridDrift {
  from { transform: translate(0, 0); }
  to { transform: translate(80px, 80px); }
}

.topbar {
  position: sticky;
  top: 14px;
  z-index: 5;
  display: grid;
  grid-template-columns: 230px minmax(220px, 1fr) auto;
  gap: 18px;
  align-items: center;
  width: min(1280px, calc(100% - 36px));
  min-height: 66px;
  margin: 14px auto 0;
  padding: 12px 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(15, 15, 15, .78);
  box-shadow: 0 16px 44px rgba(0, 0, 0, .42);
  backdrop-filter: blur(10px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; color: var(--text); }
.brand img { display: block; width: auto; height: 34px; object-fit: contain; }
.brand.large { margin-bottom: 30px; }
.brand.large img { height: 46px; }
.brand-mark { display: none; }
.search input { height: 44px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.avatar, .mini-avatar, .team-logo {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  color: #0f0f0f;
  background: var(--accent);
  font-weight: 700;
}
.avatar { width: 40px; height: 40px; }
.mini-avatar { width: 26px; height: 26px; font-size: 11px; }
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  padding: 0 20px;
  color: var(--text);
  background: rgba(255, 255, 255, .06);
  cursor: pointer;
  font-weight: 600;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease, color .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary {
  color: #0f0f0f;
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 18px rgba(104, 223, 127, .48);
}
.btn.danger { border-color: rgba(239,68,68,.55); background: rgba(239,68,68,.9); }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.icon-link { color: var(--muted); font-size: 14px; }
.permission-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid rgba(104,223,127,.32);
  border-radius: 999px;
  padding: 0 12px;
  color: var(--accent);
  background: rgba(104,223,127,.08);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.ghost {
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}
.flash {
  position: fixed;
  top: 92px;
  right: 18px;
  z-index: 20;
  max-width: 420px;
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(20, 20, 20, .95);
  border: 1px solid var(--line);
  box-shadow: 0 16px 44px rgba(0,0,0,.35);
}
.flash.success { border-color: rgba(104,223,127,.65); }
.flash.error { border-color: rgba(239, 68, 68, .65); }
.muted { color: var(--muted); }
.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 12px;
  font-weight: 700;
}

.auth-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}
.auth-panel, .panel {
  width: min(100%, 470px);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 30px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .38);
  backdrop-filter: blur(10px);
}
.auth-panel h1 { margin: 0 0 20px; font-size: 42px; line-height: 1; font-weight: 600; }
.stack-form { display: grid; gap: 16px; }
.auth-links { display: flex; justify-content: space-between; gap: 14px; margin-top: 18px; color: var(--muted); font-size: 14px; }
.auth-links a:hover, .icon-link:hover { color: var(--accent); }

.dashboard {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 54px 0 60px;
}
.dash-hero {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 22px;
  margin-bottom: 28px;
}
.dash-hero h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(42px, 6vw, 88px);
  line-height: .94;
  font-weight: 600;
}
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.panel { width: 100%; }
.wide-panel { width: 100%; overflow: hidden; }
.panel h2, .projects-section h2 { margin: 0 0 16px; font-weight: 600; }
.inline-form { display: grid; grid-template-columns: 1fr 56px auto; gap: 8px; margin-bottom: 16px; }
.inline-form.compact { grid-template-columns: 1fr auto; margin: 8px 0 18px 52px; }
.team-create-form { margin-bottom: 16px; }
.team-create-form input[type="color"] {
  min-height: 44px;
  padding: 6px;
}
.team-list { display: grid; gap: 8px; }
.team-row { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 16px; background: rgba(255,255,255,.05); }
.team-row small { display: block; color: var(--muted); }
.team-logo { width: 40px; height: 40px; font-size: 12px; }
.table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}
.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: middle;
}
.admin-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.permission-form {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto;
  gap: 8px;
}
.team-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.team-admin-card { padding: 16px; }
.member-list { display: grid; gap: 8px; margin-top: 12px; }
.member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 14px;
  padding: 10px;
  background: rgba(255,255,255,.05);
}
.member-row small { display: block; color: var(--muted); }
.projects-section { margin-top: 32px; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.project-card {
  position: relative;
  min-height: 148px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  background: #151515;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.project-card:hover {
  transform: translateY(-3px);
  border-color: rgba(104,223,127,.62);
  box-shadow: 0 0 34px rgba(104,223,127,.16);
}
.project-card strong, .project-card small { position: relative; display: block; }
.project-card strong { font-size: 20px; margin-bottom: 8px; }
.project-card small { color: #d5d5d5; }
.project-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 78% 20%, rgba(104,223,127,.22), transparent 26%),
    repeating-linear-gradient(to right, rgba(255,255,255,.035) 0 1px, transparent 1px 46px),
    repeating-linear-gradient(to bottom, rgba(255,255,255,.035) 0 1px, transparent 1px 46px);
  opacity: .9;
}

.board-shell { padding: 44px 16px 34px; }
.board-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin: 0 auto 26px;
  width: min(1280px, 100%);
}
.board-header h1 { margin: 0; text-transform: uppercase; font-size: 30px; font-weight: 700; }
.board-header p { margin: 6px 0 0; color: var(--muted); }
.member-stack { display: flex; }
.member-stack .avatar { margin-left: -8px; border: 2px solid #111; }
.board {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  min-height: calc(100vh - 190px);
  overflow-x: auto;
  padding-bottom: 18px;
}
.list {
  flex: 0 0 320px;
  max-height: calc(100vh - 190px);
  border-radius: 18px;
  padding: 12px;
  background: rgba(18, 18, 18, .92);
  border: 1px solid var(--line);
  box-shadow: 0 16px 44px rgba(0,0,0,.22);
  backdrop-filter: blur(10px);
}
.list-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 6px 10px; }
.list-title-form { flex: 1; min-width: 0; }
.list-title-input {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 5px 8px;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
}
.list-title-input:focus {
  border-color: rgba(104,223,127,.5);
  background: rgba(255,255,255,.06);
  box-shadow: 0 0 0 3px rgba(104,223,127,.08);
}
.list h2 { margin: 0; font-size: 18px; font-weight: 600; }
.list-attachments {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}
.attachment-upload {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px dashed rgba(104,223,127,.36);
  border-radius: 14px;
  color: var(--accent);
  background: rgba(104,223,127,.07);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}
.attachment-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.attachment-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.attachment-item {
  overflow: hidden;
  margin: 0;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(255,255,255,.045);
}
.attachment-item img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #111;
}
.attachment-item figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 7px 8px;
  color: var(--muted);
  font-size: 11px;
}
.attachment-item figcaption span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cards { display: grid; gap: 8px; min-height: 16px; }
.card {
  position: relative;
  display: grid;
  gap: 8px;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 14px;
  padding: 12px 12px 34px;
  background: var(--card);
  box-shadow: 0 1px 0 rgba(255,255,255,.08);
  cursor: grab;
}
.card-cover {
  display: block;
  width: calc(100% + 24px);
  margin: -12px -12px 4px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 14px 14px 8px 8px;
  background: #111;
}
.card:hover { border-color: rgba(104,223,127,.42); }
.card.dragging { opacity: .45; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.card-task-check {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  color: var(--text);
  cursor: pointer;
}
.card-task-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.card-task-check span {
  overflow-wrap: anywhere;
  font-weight: 700;
}
.card-task-check.done span {
  color: var(--muted);
  text-decoration: line-through;
}
.check-progress {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  background: rgba(255,255,255,.05);
  font-size: 11px;
  font-weight: 700;
}
.check-progress.complete {
  color: #0f0f0f;
  border-color: var(--accent);
  background: var(--accent);
}
.card-meta { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; }
.card-edit {
  position: absolute;
  right: 8px;
  bottom: 8px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
}
.card-edit:hover { color: var(--accent); }
.add-card-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.add-card-form input, .add-list-form input {
  border: 0;
  background: transparent;
  font-weight: 600;
  box-shadow: none;
}
.add-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.add-list-form {
  background: rgba(104,223,127,.1);
  border-color: rgba(104,223,127,.28);
}
.modal {
  width: min(720px, calc(100% - 32px));
  max-height: calc(100dvh - 44px);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  color: var(--text);
  background: #151515;
  overflow: hidden;
}
.modal::backdrop { background: rgba(0,0,0,.65); backdrop-filter: blur(4px); }
.modal h2 { margin: 0; font-weight: 600; }
.modal .stack-form {
  max-height: calc(100dvh - 44px);
  overflow-y: auto;
  padding: 24px;
}
.modal-actions {
  position: sticky;
  bottom: -24px;
  display: flex;
  justify-content: end;
  gap: 10px;
  margin: 8px -24px -24px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: rgba(21, 21, 21, .96);
  backdrop-filter: blur(10px);
}
.field-label {
  color: var(--soft);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}
.card-image-section {
  display: grid;
  gap: 10px;
}
.card-checklist-section {
  display: grid;
  gap: 10px;
}
.checklist-items {
  display: grid;
  gap: 8px;
}
.checklist-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 9px 10px;
  background: rgba(255,255,255,.045);
}
.checklist-row label {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: var(--text);
  cursor: pointer;
}
.checklist-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.checklist-row span {
  overflow-wrap: anywhere;
}
.checklist-row.done span {
  color: var(--muted);
  text-decoration: line-through;
}
.checklist-add-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.card-attachment-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 760px) {
  .topbar { grid-template-columns: 1fr; height: auto; }
  .search, .top-actions { width: 100%; }
  .top-actions { justify-content: space-between; }
  .dash-hero, .board-header { align-items: flex-start; flex-direction: column; }
  .dash-grid { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }
  .inline-form.compact { margin-left: 0; }
  .list { flex-basis: 286px; }
}
