:root {
  --accent:      #573cfa;
  --accent-rgb:  87, 60, 250;
  --bg:          #050508;
  --bg-card:     #0d0d16;
  --bg-elevated: #13131f;
  --border:      rgba(255, 255, 255, 0.07);
  --text:        #cbd5e1;
  --text-bright: #f1f5f9;
  --text-muted:  #475569;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Rubik', system-ui, sans-serif;
  min-height: 100vh;
}
a { color: inherit; }
img { max-width: 100%; display: block; }

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

.app-sidebar {
  width: 250px; flex-shrink: 0;
  background: var(--bg-card); border-right: 1px solid var(--border);
  padding: 1.5rem 1rem; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.app-brand {
  display: flex; align-items: center; gap: .65rem;
  padding: .5rem; margin-bottom: 1.75rem; text-decoration: none;
}
.app-brand-icon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: .95rem;
  box-shadow: 0 4px 14px -4px rgba(var(--accent-rgb), .6);
}
.app-brand-text { font-size: 1.05rem; font-weight: 800; color: #fff; letter-spacing: -.01em; }
.app-brand-text em { font-style: normal; color: var(--accent); }

.app-nav { display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.app-nav-link {
  display: flex; align-items: center; gap: .75rem; padding: .65rem .85rem;
  border-radius: 9px; color: #94a3b8; text-decoration: none; font-size: .88rem; font-weight: 600;
  transition: background .15s, color .15s;
}
.app-nav-link:hover { background: rgba(255,255,255,.04); color: #fff; }
.app-nav-link.active { background: rgba(var(--accent-rgb), .15); color: #fff; }
.app-nav-link i { width: 18px; text-align: center; color: var(--accent); }

.app-user { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; display: flex; align-items: center; gap: .65rem; }
.app-user-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.app-user-name { color: #fff; font-weight: 700; font-size: .84rem; }
.app-user-role { font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.app-user-role.owner { color: #fbbf24; }
.app-user-role.developer { color: #38bdf8; }
.app-user-logout { margin-left: auto; color: #64748b; text-decoration: none; font-size: .95rem; transition: color .15s; }
.app-user-logout:hover { color: #f87171; }

.app-content { flex: 1; padding: 2.25rem 2.5rem; min-width: 0; }

.app-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.75rem; }
.app-page-title { font-size: 1.6rem; font-weight: 800; color: #fff; letter-spacing: -.01em; margin: 0 0 .3rem; }
.app-page-sub { color: #64748b; font-size: .88rem; margin: 0; }

/* ── Karty i statystyki ───────────────────────────────────────────────── */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; }
.card-pad { padding: 1.5rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.stat-tile { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 1.25rem 1.5rem; }
.stat-tile-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: .7rem; }
.stat-tile-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: #64748b; font-weight: 700; }
.stat-tile-icon {
  width: 32px; height: 32px; border-radius: 9px; background: rgba(var(--accent-rgb), .12);
  display: flex; align-items: center; justify-content: center; color: var(--accent); font-size: .85rem; flex-shrink: 0;
}
.stat-tile-value { font-size: 1.55rem; font-weight: 800; color: #fff; letter-spacing: -.02em; }
.stat-tile-sub { margin-top: .3rem; font-size: .72rem; color: #475569; }

/* ── Przyciski ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .6rem 1.1rem; border-radius: 9px; font-size: .85rem; font-weight: 700; font-family: inherit;
  cursor: pointer; border: 1px solid transparent; text-decoration: none; transition: filter .15s, background .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.12); }
.btn-ghost { background: rgba(255,255,255,.04); border-color: var(--border); color: #cbd5e1; }
.btn-ghost:hover { background: rgba(255,255,255,.08); }
.btn-danger { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.3); color: #f87171; }
.btn-danger:hover { background: rgba(248,113,113,.2); }
.btn-sm { padding: .4rem .8rem; font-size: .78rem; }
.btn-icon { padding: .5rem; width: 36px; height: 36px; }

/* ── Formularze ───────────────────────────────────────────────────────── */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-size: .8rem; font-weight: 700; color: #94a3b8; margin-bottom: .4rem; }
.field-row { display: flex; gap: .8rem; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 160px; }
.input, .select, .textarea {
  width: 100%; background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 9px;
  color: #e2e8f0; padding: .6rem .85rem; font-size: .85rem; font-family: inherit; outline: none;
  transition: border-color .2s; appearance: none;
}
.select {
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0l5 6 5-6z' fill='%2364748b'/></svg>");
  background-repeat: no-repeat; background-position: right .9rem center; padding-right: 2.2rem;
}
.select option { background: #13131f; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); }
.textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
.checkbox-list { display: flex; flex-direction: column; gap: .5rem; max-height: 200px; overflow-y: auto; }
.checkbox-item { display: flex; align-items: center; gap: .55rem; font-size: .84rem; color: #cbd5e1; }
.checkbox-item input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* ── Odznaki / tagi ───────────────────────────────────────────────────── */
.tag { display: inline-flex; align-items: center; gap: .3rem; font-size: .68rem; font-weight: 700; padding: .2rem .55rem; border-radius: 6px; white-space: nowrap; }
.priority-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.empty-state { padding: 3rem 1.5rem; text-align: center; color: #64748b; }
.empty-state i { font-size: 1.6rem; display: block; margin-bottom: .6rem; opacity: .45; }

/* ── Pasek postępu ────────────────────────────────────────────────────── */
.progress-bar { height: 8px; border-radius: 5px; background: rgba(255,255,255,.06); overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 5px; background: var(--accent); transition: width .3s; }

/* ── Tablica Kanban ───────────────────────────────────────────────────── */
.board-toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.25rem; }
.board-toolbar form { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; flex: 1; }
.board-toolbar .select, .board-toolbar .input { width: auto; min-width: 150px; }
.board-toolbar .input { min-width: 200px; }

.board-cols { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: .5rem; align-items: flex-start; }
.board-col {
  flex: 0 0 302px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
  display: flex; flex-direction: column; max-height: calc(100vh - 235px);
}
.board-col-head { padding: .9rem 1rem; display: flex; align-items: center; gap: .55rem; font-weight: 700; color: #fff; font-size: .86rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.board-col-head i { color: var(--accent); }
.board-col-count { margin-left: auto; font-size: .68rem; color: #64748b; background: rgba(255,255,255,.05); padding: .12rem .5rem; border-radius: 6px; }
.board-col-cards { padding: .7rem; display: flex; flex-direction: column; gap: .6rem; overflow-y: auto; flex: 1; min-height: 70px; transition: background .15s; border-radius: 0 0 14px 14px; }
.board-col-cards.drag-over { background: rgba(var(--accent-rgb), .07); }
.board-col-empty { font-size: .74rem; color: #334155; text-align: center; padding: 1rem .5rem; }

.task-card {
  background: var(--bg-elevated); border: 1px solid var(--border); border-left: 3px solid var(--pc, #64748b);
  border-radius: 10px; padding: .75rem .85rem; cursor: grab; transition: border-color .15s, box-shadow .15s;
  text-decoration: none; display: block;
}
.task-card:hover { border-color: rgba(255,255,255,.2); box-shadow: 0 4px 14px -6px rgba(0,0,0,.5); }
.task-card:active { cursor: grabbing; }
.task-card.dragging { opacity: .35; }
.task-card-title { color: #fff; font-weight: 600; font-size: .84rem; line-height: 1.4; margin-bottom: .6rem; }
.task-card-meta { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.task-card-due { font-size: .68rem; color: #64748b; margin-left: auto; white-space: nowrap; }
.task-card-due.overdue { color: #f87171; font-weight: 700; }
.task-card-footer { display: flex; align-items: center; margin-top: .65rem; gap: .5rem; }
.avatar-stack { display: flex; }
.avatar-stack img { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--bg-elevated); margin-left: -8px; }
.avatar-stack img:first-child { margin-left: 0; }
.task-card-comments { margin-left: auto; font-size: .7rem; color: #64748b; display: flex; align-items: center; gap: .3rem; }

/* ── Modal (dodawanie zadania) ───────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 1rem; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 1.75rem; max-width: 460px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal h3 { color: #fff; font-weight: 800; margin: 0 0 1.2rem; font-size: 1.1rem; display: flex; align-items: center; gap: .5rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.3rem; }

/* ── Szczegóły zadania ───────────────────────────────────────────────── */
.task-layout { display: grid; grid-template-columns: 1fr 300px; gap: 1.5rem; align-items: start; }
@media (max-width: 940px) { .task-layout { grid-template-columns: 1fr; } }
.task-main-title { color: #fff; font-size: 1.35rem; font-weight: 800; margin: 0 0 .3rem; }
.task-desc { color: #cbd5e1; font-size: .88rem; line-height: 1.7; white-space: pre-wrap; margin: 1rem 0 0; }
.task-sidebar { display: flex; flex-direction: column; gap: 1.2rem; }
.task-sidebar-field { }
.task-sidebar-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: #64748b; font-weight: 700; margin-bottom: .45rem; display: block; }

.comments-list { margin-top: 1rem; }
.comment { display: flex; gap: .7rem; padding: 1rem 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: none; }
.comment-avatar { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; }
.comment-body { flex: 1; min-width: 0; }
.comment-author { color: #fff; font-weight: 700; font-size: .82rem; }
.comment-time { color: #475569; font-size: .72rem; margin-left: .5rem; font-weight: 400; }
.comment-msg { color: #cbd5e1; font-size: .85rem; margin-top: .3rem; white-space: pre-wrap; line-height: 1.6; }

/* ── Edycje (milestones) ─────────────────────────────────────────────── */
.milestone-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1.1rem; }
.milestone-card { background: var(--bg-card); border: 1px solid var(--border); border-top: 3px solid var(--mc, var(--accent)); border-radius: 16px; padding: 1.4rem; position: relative; }
.milestone-card.is-active { box-shadow: 0 0 0 2px var(--accent); }
.milestone-active-badge {
  position: absolute; top: .9rem; right: .9rem; font-size: .6rem; font-weight: 800; color: var(--accent);
  background: rgba(var(--accent-rgb), .14); padding: .18rem .55rem; border-radius: 6px; text-transform: uppercase; letter-spacing: .04em;
}
.milestone-name { color: #fff; font-weight: 800; font-size: 1.05rem; margin: 0 0 .35rem; }
.milestone-desc { color: #64748b; font-size: .8rem; line-height: 1.5; margin: 0 0 1rem; min-height: 1.2em; }
.milestone-progress-row { display: flex; align-items: center; justify-content: space-between; font-size: .72rem; color: #64748b; margin-bottom: .4rem; }
.milestone-meta { display: flex; align-items: center; gap: .6rem; margin-top: 1.1rem; flex-wrap: wrap; }
.milestone-actions { display: flex; gap: .4rem; margin-top: 1rem; }

/* ── Zespół ──────────────────────────────────────────────────────────── */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.team-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 1.4rem; text-align: center; text-decoration: none; transition: border-color .15s; }
.team-card:hover { border-color: rgba(255,255,255,.2); }
.team-avatar { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto .8rem; }
.team-name { color: #fff; font-weight: 700; font-size: .92rem; }
.team-role { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; margin: .3rem 0 .8rem; }
.team-role.owner { color: #fbbf24; }
.team-role.developer { color: #38bdf8; }
.team-count { font-size: .76rem; color: #64748b; }
.team-count strong { color: #fff; }

/* ── Logowanie / błąd ────────────────────────────────────────────────── */
.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 20px; padding: 3rem 2.5rem; text-align: center; max-width: 420px; width: 100%; }
.auth-card .app-brand { justify-content: center; margin-bottom: 1.5rem; }
.auth-card p { color: #64748b; font-size: .9rem; margin-bottom: 2rem; line-height: 1.6; }
.btn-discord { background: #5865f2; color: #fff; width: 100%; padding: .85rem; font-size: .92rem; }
.btn-discord:hover { filter: brightness(1.1); }

.error-card { text-align: center; max-width: 460px; }
.error-code { font-size: 3.5rem; font-weight: 800; color: var(--accent); line-height: 1; margin-bottom: .5rem; }
.error-msg { color: #94a3b8; font-size: .95rem; line-height: 1.6; margin-bottom: 1.75rem; }

/* ── Dostęp (zarządzanie grupami owner/developer) ───────────────────────── */
.access-search-results { margin-top: .75rem; display: flex; flex-direction: column; gap: .5rem; max-height: 320px; overflow-y: auto; }
.access-search-row { display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem; background: rgba(255,255,255,.03); border: 1px solid var(--border); border-radius: 10px; }
.access-search-row img { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; }
.access-search-name { font-size: .85rem; color: #e2e8f0; font-weight: 600; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.access-search-hint { color: #64748b; font-size: .8rem; padding: .5rem; }

.access-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.access-table th { text-align: left; color: #64748b; font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; padding: .7rem 1rem; border-bottom: 1px solid var(--border); }
.access-table td { padding: .75rem 1rem; border-bottom: 1px solid rgba(255,255,255,.04); vertical-align: middle; }
.access-table tr:last-child td { border-bottom: none; }
.access-user-cell { display: flex; align-items: center; gap: .6rem; }
.access-user-cell img { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; }

@media (max-width: 860px) {
  .app-sidebar { display: none; }
  .app-content { padding: 1.5rem; }
}
