:root {
  color-scheme: light;
  --brand: #6f3d24;
  --brand-dark: #4b2618;
  --brand-soft: #f4ece4;
  --ink: #2b1d16;
  --muted: #715f52;
  --line: #e6dcd2;
  --bg: #f6f1ec;
  --surface: #ffffff;
  --ok: #1f6f43;
  --warn: #b06a1a;
  --danger: #b42318;
  --info: #2f5d9e;
  --radius: 14px;
  --shadow: 0 6px 18px rgba(63, 39, 25, 0.09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

button {
  font-family: inherit;
  font-size: 0.94rem;
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}
button:hover:not(:disabled) { filter: brightness(1.09); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.secondary { background: #ede2d8; color: var(--ink); }
button.ghost { background: transparent; color: var(--brand); padding: 6px 10px; }
button.danger { background: var(--danger); }
button.small { padding: 5px 11px; font-size: 0.84rem; }

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d9cabd;
  font-family: inherit;
  font-size: 0.95rem;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid #c79b7c; border-color: #c79b7c; }
textarea { resize: vertical; min-height: 96px; }
label { display: block; font-weight: 600; font-size: 0.86rem; margin-bottom: 5px; color: #55433a; }
.field { margin-bottom: 14px; }
.field-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small-text { font-size: 0.85rem; }
.center { text-align: center; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- logowanie ---------- */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { background: var(--surface); border-radius: 20px; padding: 30px; width: min(420px, 100%); box-shadow: 0 18px 44px rgba(63, 39, 25, 0.16); }
.login-card h1 { margin: 0 0 4px; font-size: 1.4rem; }
.login-card p.lead { margin: 0 0 22px; color: var(--muted); font-size: 0.92rem; }

/* ---------- szkielet ---------- */
.topbar {
  background: linear-gradient(135deg, var(--brand-dark), #8a5637);
  color: #fff;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand { font-weight: 700; font-size: 1.05rem; letter-spacing: 0.2px; white-space: nowrap; }
.topbar .brand span { opacity: 0.75; font-weight: 400; font-size: 0.82rem; display: block; }
.topbar select {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  min-width: 240px;
  width: auto;
}
.topbar select option { color: var(--ink); }
.topbar .spacer { flex: 1; }
.topbar button.secondary { background: rgba(255, 255, 255, 0.18); color: #fff; }
.role-chip { background: rgba(255, 255, 255, 0.2); border-radius: 999px; padding: 4px 12px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.4px; }
.role-chip.master { background: #f0c419; color: #4a3400; }

.tabs { display: flex; gap: 4px; padding: 0 22px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; position: sticky; top: 61px; z-index: 15; }
.tabs button {
  background: transparent;
  color: var(--muted);
  border-radius: 0;
  padding: 13px 16px;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

main { max-width: 1180px; margin: 0 auto; padding: 22px; }
.panel { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.panel h2 { margin: 0 0 4px; font-size: 1.12rem; }
.panel .lead { margin: 0 0 16px; color: var(--muted); font-size: 0.9rem; }
.panel-empty { color: var(--muted); font-style: italic; padding: 14px 0; }

/* ---------- awatary ---------- */
.avatar {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 0.95rem;
  flex: 0 0 auto; overflow: hidden; text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 30px; height: 30px; font-size: 0.72rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.2rem; }

/* ---------- blog ---------- */
.composer { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: #fffdfb; }
.thread { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; background: var(--surface); overflow: hidden; }
.thread.pinned { border-color: #e0b877; box-shadow: 0 0 0 2px #f7e7c8 inset; }
.post { display: flex; gap: 13px; padding: 16px; }
.post + .post { border-top: 1px solid #f0e8e0; }
.post-body { flex: 1; min-width: 0; }
.post-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.post-author { font-weight: 700; }
.post-role { font-size: 0.72rem; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: 2px 8px; font-weight: 700; }
.post-role.master { background: #fcf0c8; color: #7a5600; }
.post-time { color: var(--muted); font-size: 0.82rem; }
.post-title { font-size: 1.04rem; font-weight: 700; margin: 4px 0 6px; }
.post-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.post-actions { margin-top: 9px; display: flex; gap: 6px; flex-wrap: wrap; }
.replies { background: #fbf7f3; }
.replies .post { padding-left: 44px; }
.reply-box { padding: 14px 16px 16px 44px; background: #fbf7f3; border-top: 1px solid #f0e8e0; }
.attachment-list { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 7px; }
.attachment-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 11px; font-size: 0.83rem; background: #fff;
  color: var(--brand); text-decoration: none;
}
.attachment-chip:hover { background: var(--brand-soft); }

/* ---------- kalendarz ---------- */
.calendar-layout { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 18px; align-items: start; }
.month-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.month-title { font-weight: 700; text-transform: capitalize; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.weekday { font-size: 0.74rem; font-weight: 700; text-align: center; color: #86705f; padding: 4px 0; }
.day {
  aspect-ratio: 1; padding: 0; border-radius: 9px; border: 1px solid transparent;
  background: #f6efe8; color: #43291b; font-weight: 600; font-size: 0.88rem;
  display: grid; place-items: center; position: relative;
}
.day:hover:not(:disabled) { border-color: #d8c0ad; background: #fff8f2; }
.day.dim { background: transparent; color: #c3b3a5; font-weight: 400; }
.day.active { background: var(--brand); color: #fff; }
.day.today { box-shadow: 0 0 0 2px #c79b7c inset; }
.day .dot { position: absolute; bottom: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--ok); }
.day.active .dot { background: #fff; }
.slot-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.slot { background: #efe3d7; color: var(--brand); font-weight: 600; padding: 7px 13px; font-size: 0.86rem; }
.slot.selected { background: var(--brand); color: #fff; }

.meeting-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 11px; background: #fffdfb; }
.meeting-card.past { opacity: 0.62; }
.meeting-when { font-weight: 700; }
.meeting-type { font-size: 0.74rem; background: #e7eef8; color: var(--info); border-radius: 999px; padding: 2px 9px; font-weight: 700; }
.meeting-agenda { white-space: pre-wrap; margin-top: 7px; font-size: 0.9rem; color: #4a382c; }

/* ---------- ustalenia ---------- */
.decision-table { width: 100%; border-collapse: collapse; font-size: 0.89rem; }
.decision-table th { text-align: left; padding: 9px 8px; border-bottom: 2px solid var(--line); color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.4px; }
.decision-table td { padding: 10px 8px; border-bottom: 1px solid #f2ebe4; vertical-align: top; }
.decision-table tr:hover td { background: #fdfaf7; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 0.76rem; font-weight: 700; white-space: nowrap; }
.pill.nowe { background: #eceff3; color: #5a6673; }
.pill.zaakceptowane { background: #e7eef8; color: var(--info); }
.pill.w-realizacji { background: #fdf0dc; color: var(--warn); }
.pill.zrobione { background: #e3f3e9; color: var(--ok); }
.pill.odrzucone { background: #fbe6e4; color: var(--danger); }
.pill.krytyczny { background: #fbe6e4; color: var(--danger); }
.pill.wysoki { background: #fdf0dc; color: var(--warn); }
.pill.sredni { background: #eceff3; color: #5a6673; }
.pill.niski { background: #f1f1f1; color: #7a7a7a; }
.progress-track { background: #efe7df; border-radius: 999px; height: 7px; overflow: hidden; min-width: 70px; }
.progress-fill { background: var(--ok); height: 100%; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 11px; margin-bottom: 16px; }
.stat { background: var(--brand-soft); border-radius: 11px; padding: 12px 14px; }
.stat .value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat .label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }

/* ---------- Gantt ---------- */
.gantt-scroll { overflow-x: auto; padding-bottom: 8px; }
.gantt { min-width: 760px; }
.gantt-row { display: grid; grid-template-columns: 260px 1fr; gap: 12px; align-items: center; padding: 4px 0; }
.gantt-row.header { border-bottom: 2px solid var(--line); padding-bottom: 7px; margin-bottom: 7px; }
.gantt-label { font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; }
.gantt-label .owner { color: var(--muted); font-size: 0.78rem; }
.gantt-track { position: relative; height: 26px; background: #f7f2ed; border-radius: 7px; }
.gantt-months { display: flex; height: 26px; }
.gantt-month { border-left: 1px solid var(--line); font-size: 0.74rem; color: var(--muted); padding-left: 5px; display: flex; align-items: center; overflow: hidden; white-space: nowrap; }
.gantt-bar {
  position: absolute; top: 3px; height: 20px; border-radius: 6px;
  background: #cbb29f; overflow: hidden; min-width: 4px;
  display: flex; align-items: center;
}
.gantt-bar .fill { position: absolute; inset: 0 auto 0 0; background: var(--brand); border-radius: 6px; }
.gantt-bar .bar-text { position: relative; z-index: 1; color: #fff; font-size: 0.71rem; font-weight: 700; padding: 0 7px; text-shadow: 0 1px 2px rgba(0,0,0,0.45); white-space: nowrap; }
.gantt-bar[data-low="1"] .bar-text { color: #5c4636; text-shadow: none; }
.gantt-bar.zrobione .fill { background: var(--ok); }
.gantt-bar.odrzucone { background: #e4d6d4; }
.gantt-bar.odrzucone .fill { background: #c98b84; }
.gantt-bar.ryzyko { background: #f0cfcb; }
.gantt-bar.ryzyko .fill { background: var(--danger); }
.gantt-bar.ryzyko .bar-text { color: #7d2019; text-shadow: none; }
.gantt-milestone {
  position: absolute; top: 4px; width: 18px; height: 18px;
  background: var(--brand); transform: rotate(45deg); border-radius: 3px;
  margin-left: -9px;
}
.gantt-today { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--danger); z-index: 2; }
.gantt-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 14px; font-size: 0.8rem; color: var(--muted); }
.legend-swatch { display: inline-block; width: 13px; height: 13px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; }

/* ---------- tabele admina ---------- */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.admin-table th { text-align: left; padding: 9px 8px; border-bottom: 2px solid var(--line); color: var(--muted); font-size: 0.78rem; text-transform: uppercase; }
.admin-table td { padding: 9px 8px; border-bottom: 1px solid #f2ebe4; vertical-align: middle; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 6px; max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.checkbox-grid label { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; font-size: 0.88rem; }
.checkbox-grid input { width: auto; }

/* ---------- komunikaty i modal ---------- */
.message { margin-top: 12px; font-weight: 600; font-size: 0.9rem; }
.message.error { color: var(--danger); }
.message.success { color: var(--ok); }
.banner { border-radius: 11px; padding: 11px 14px; font-size: 0.88rem; margin-bottom: 14px; }
.banner.warn { background: #fdf3e2; border-left: 4px solid var(--warn); color: #6b4a12; }
.banner.info { background: #edf2fa; border-left: 4px solid var(--info); color: #2c4670; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--brand-dark); color: #fff; padding: 12px 18px; border-radius: 11px; box-shadow: 0 10px 26px rgba(0,0,0,0.24); z-index: 60; max-width: 340px; }
.toast.error { background: var(--danger); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(38, 22, 13, 0.55); display: grid; place-items: center; padding: 20px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 16px; padding: 24px; width: min(560px, 100%); box-shadow: 0 20px 50px rgba(0,0,0,0.3); max-height: 90vh; overflow-y: auto; }
.modal h2 { margin: 0 0 14px; font-size: 1.15rem; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }

@media (max-width: 900px) {
  .calendar-layout { grid-template-columns: 1fr; }
  .gantt-row { grid-template-columns: 150px 1fr; }
  main { padding: 14px; }
  .topbar { padding: 10px 14px; }
  .tabs { padding: 0 10px; top: 0; position: static; }
}

/* statusy projektow */
.pill.planowany { background: #eceff3; color: #5a6673; }
.pill.w-toku { background: #e7eef8; color: var(--info); }
.pill.wstrzymany { background: #fdf0dc; color: var(--warn); }
.pill.zakonczony { background: #e3f3e9; color: var(--ok); }
