/* ===== Tokeny ===== */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #dbeafe;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #16a34a;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,.12), 0 8px 10px -6px rgba(0,0,0,.06);

  /* kolory statusów */
  --st-waiting: #6b7280;
  --st-in_progress: #2563eb;
  --st-blocked: #dc2626;
  --st-done: #16a34a;
  --st-wont_fix: #7c3aed;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }

/* ===== Przyciski / pola ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  cursor: pointer; font-weight: 500; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: rgba(0,0,0,.05); }

.input, .select, .textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.textarea.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13.5px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12.5px; color: var(--text-3); }
.req::after { content: " *"; color: var(--danger); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* ===== Układ ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo { width: 28px; height: 28px; border-radius: 7px; background: var(--primary); display: grid; place-items: center; }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a {
  padding: 6px 12px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-chip { font-size: 13.5px; color: var(--text-2); }
.user-chip b { color: var(--text); }
.role-tag { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-3); margin-left: 6px; text-transform: uppercase; letter-spacing: .03em; }

main { padding: 20px; max-width: 1600px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.card-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }

/* ===== Logowanie ===== */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.auth-card h1 { font-size: 20px; }
.form-error { background: var(--danger-soft); color: #991b1b; border: 1px solid #fecaca; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 14px; }
.form-info { background: #fef9c3; color: #713f12; border: 1px solid #fde68a; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 14px; }

/* ===== Filtry ===== */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters .input, .filters .select { width: auto; min-width: 150px; }
.filters .input { min-width: 240px; }

/* ===== Tablica ===== */
.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 14px;
  align-items: start;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
}
@media (max-width: 1180px) { .board { grid-template-columns: repeat(5, 260px); } }
.column {
  background: #eceef2; border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 200px;
  scroll-snap-align: start;
  border: 2px solid transparent;
  transition: border-color .12s, background .12s;
}
.column.drag-over { border-color: var(--primary); background: #e4ebfb; }
.column-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px 8px;
  font-weight: 600; font-size: 14px;
}
.column-head .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--st-color); }
.column-head .count { margin-left: auto; font-size: 12px; color: var(--text-3); background: var(--surface); padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); }
.column-body { padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 60px; }
.column-empty { color: var(--text-3); font-size: 13px; text-align: center; padding: 18px 8px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }

.card {
  background: var(--surface); border-radius: 8px; border: 1px solid var(--border);
  box-shadow: var(--shadow); padding: 10px 12px; cursor: grab;
  border-left: 4px solid var(--st-color);
  transition: box-shadow .12s, transform .12s;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card.dragging { opacity: .5; transform: rotate(1.5deg); }
.card-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.card-id { font-size: 12px; color: var(--text-3); font-weight: 600; font-variant-numeric: tabular-nums; }
.card-title { font-size: 14px; font-weight: 600; line-height: 1.35; word-break: break-word; }
.card-meta { display: flex; gap: 10px; margin-top: 8px; font-size: 12px; color: var(--text-3); flex-wrap: wrap; }
.card-meta .spacer { margin-left: auto; }

/* ===== Odznaki ===== */
.badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  white-space: nowrap;
}
.badge.type-bug { background: #fee2e2; border-color: #fecaca; color: #991b1b; }
.badge.type-feature { background: #dcfce7; border-color: #bbf7d0; color: #166534; }
.badge.pf-android { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.badge.pf-ios { background: #f1f5f9; border-color: #cbd5e1; color: #334155; }
.badge.pf-rc2 { background: #fff7ed; border-color: #fed7aa; color: #9a3412; }
.badge.pf-rcpro { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.badge.pf-rcpro2 { background: #f5f3ff; border-color: #ddd6fe; color: #5b21b6; }
.badge.status { color: #fff; border-color: transparent; background: var(--st-color); }

/* ===== Szczegóły zgłoszenia ===== */
.issue-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.issue-head h1 { font-size: 22px; flex: 1 1 400px; word-break: break-word; }
.issue-head h1 .id { color: var(--text-3); font-weight: 500; margin-right: 8px; }
.issue-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.issue-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
@media (max-width: 960px) { .issue-layout { grid-template-columns: 1fr; } }
.section { margin-bottom: 22px; }
.section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
.section h3 .btn { margin-left: auto; text-transform: none; letter-spacing: 0; }
.prose { white-space: pre-wrap; word-break: break-word; line-height: 1.6; }
.prose.empty { color: var(--text-3); font-style: italic; }

.meta-list { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; font-size: 14px; }
.meta-list dt { color: var(--text-3); white-space: nowrap; }
.meta-list dd { margin: 0; min-width: 0; word-break: break-word; }
.meta-list .select { padding: 6px 10px; }
.sidebar .card-panel { padding: 16px; margin-bottom: 14px; }

.attachments { display: flex; flex-wrap: wrap; gap: 10px; }
.att {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); overflow: hidden; max-width: 100%;
}
.att.img a { display: block; }
.att.img img { width: 180px; height: 130px; object-fit: cover; }
.att.file { padding: 10px 12px; display: flex; align-items: center; gap: 8px; max-width: 320px; }
.att .att-name { font-size: 12.5px; padding: 6px 8px; display: flex; gap: 8px; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); }
.att.file .att-name { border: 0; padding: 0; flex: 1; min-width: 0; }
.att .att-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .att-del { background: none; border: 0; color: var(--text-3); cursor: pointer; padding: 0 2px; font-size: 16px; line-height: 1; }
.att .att-del:hover { color: var(--danger); }

.comment { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); margin-bottom: 10px; }
.comment-head { display: flex; gap: 10px; font-size: 13px; margin-bottom: 4px; }
.comment-head b { color: var(--text); }
.comment-head time { color: var(--text-3); }
.comment-form { display: flex; flex-direction: column; gap: 8px; }
.comment-form .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; max-height: 480px; overflow: auto; }
.timeline li { font-size: 13px; display: grid; grid-template-columns: 10px 1fr; gap: 10px; }
.timeline .tl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); margin-top: 6px; }
.timeline .tl-dot.status_changed { background: var(--primary); }
.timeline .tl-dot.created { background: var(--ok); }
.timeline time { display: block; color: var(--text-3); font-size: 12px; }
.timeline .arrow { color: var(--text-3); margin: 0 4px; }

/* ===== Lista plików w formularzu ===== */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius-sm);
  padding: 16px; text-align: center; color: var(--text-3); font-size: 13.5px; background: var(--surface-2);
  cursor: pointer; transition: border-color .12s, background .12s;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: #eff6ff; color: var(--text-2); }
.dropzone input { display: none; }
.filelist { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.filelist li { display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 6px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.filelist li img { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; }
.filelist li .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist li button { background: none; border: 0; cursor: pointer; color: var(--text-3); font-size: 16px; }
.filelist li button:hover { color: var(--danger); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.form { display: flex; flex-direction: column; gap: 16px; max-width: 860px; }

/* ===== Tabela użytkowników ===== */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.inactive td { color: var(--text-3); }
.table-wrap { overflow-x: auto; }

/* ===== Toasty ===== */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  padding: 10px 14px; border-radius: var(--radius-sm); background: #111827; color: #fff;
  font-size: 14px; box-shadow: var(--shadow-lg); max-width: 360px;
  animation: toast-in .18s ease-out;
}
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.empty-state { text-align: center; color: var(--text-3); padding: 40px 20px; }
kbd { font: 12px ui-monospace, monospace; padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); }

@media (max-width: 720px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .nav a { padding: 6px 8px; font-size: 14px; }
  .user-chip .name { display: none; }
  main { padding: 12px; }
}
