@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;500;600;700;800;900&display=swap');
:root {
  --primary: #1179bf;
  --primary-2: #1686df;
  --accent: #e85d04;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --dark: #0b1020;
  --text: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --white: #ffffff;
  --shadow: 0 20px 60px rgba(11, 16, 32, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100%;
  margin: 0;
  font-family: "Nunito Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--dark);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
code {
  background: #eef6ff;
  color: #0f6ab8;
  padding: 2px 6px;
  border-radius: 7px;
}

.guest-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 15%, rgba(22, 134, 223, .14), transparent 32%),
    linear-gradient(180deg, #fff 0%, #f1f5f9 100%);
}

.guest-shell { width: min(100%, 460px); }
.guest-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 36px;
  box-shadow: var(--shadow);
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.brand-mark span,
.sidebar-logo {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -.06em;
}
.sidebar-logo span { color: var(--primary-2); }

h1 {
  margin: 0 0 12px;
  font-size: clamp(32px, 6vw, 46px);
  line-height: .98;
  letter-spacing: -.06em;
}
h2 {
  margin: 0 0 10px;
  font-size: 22px;
  letter-spacing: -.03em;
}
p { color: var(--muted); line-height: 1.6; }
.lead { margin: 0 0 26px; font-size: 16px; }

.form-stack { display: grid; gap: 16px; }
label { display: grid; gap: 7px; font-weight: 800; font-size: 14px; color: var(--text); }
input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 15px;
  background: #fff;
  color: var(--dark);
  outline: none;
}
input:focus {
  border-color: var(--primary-2);
  box-shadow: 0 0 0 4px rgba(22, 134, 223, .11);
}

.btn {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  cursor: pointer;
  transition: .18s ease;
}
.btn-primary { background: var(--dark); color: #fff; }
.btn-primary:hover { background: #17213a; transform: translateY(-1px); }
.btn-light { background: #fff; border-color: var(--border); color: var(--dark); }
.btn-light:hover { border-color: #b6c2d2; }
.btn.full { width: 100%; min-height: 52px; }

.alert {
  border-radius: 16px;
  padding: 13px 15px;
  margin-bottom: 18px;
  font-size: 14px;
  font-weight: 700;
}
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }

.app-body { background: var(--bg); }
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 26px 20px;
  z-index: 50;
}
.sidebar-logo { display: inline-block; margin-bottom: 28px; }
.sidebar-nav { display: grid; gap: 7px; }
.sidebar-nav a {
  padding: 13px 14px;
  border-radius: 14px;
  color: var(--text);
  font-weight: 800;
  font-size: 14px;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: #eef6ff;
  color: var(--primary);
}
.main-area { min-width: 0; }
.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 28px;
  background: rgba(248, 250, 252, .88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar strong { display: block; }
.topbar span { display: block; color: var(--muted); font-size: 13px; font-weight: 700; }
.mobile-menu-btn {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}
.content { padding: 32px; }
.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}
.eyebrow {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--primary-2);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .14em;
}
.page-heading p { max-width: 760px; margin: 0; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}
.stat-card,
.panel-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 26px;
  box-shadow: 0 10px 30px rgba(11,16,32,.04);
}
.stat-card span { color: var(--muted); font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.stat-card strong { display: block; margin-top: 8px; font-size: 42px; letter-spacing: -.06em; }
.card-grid { display: grid; gap: 18px; }
.card-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel-card.dark { background: var(--dark); border-color: var(--dark); color: #fff; }
.panel-card.dark p { color: #cbd5e1; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    transition: .2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.is-open { transform: translateX(0); }
  .mobile-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { padding: 12px 18px; }
  .content { padding: 22px 18px; }
  .stats-grid, .card-grid.two { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .guest-body { padding: 14px; }
  .guest-card { padding: 26px 20px; border-radius: 22px; }
  .topbar form .btn { padding: 0 14px; }
  .page-heading { display: block; }
  .stat-card, .panel-card { padding: 22px; }
}

/* ==================== CRM v0.2 - Klienci ==================== */
button, input, select, textarea { font: inherit; }
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 15px;
  background: #fff;
  color: var(--dark);
  outline: none;
}
select { min-height: 50px; }
textarea { min-height: 120px; padding-top: 13px; resize: vertical; line-height: 1.55; }
select:focus,
textarea:focus {
  border-color: var(--primary-2);
  box-shadow: 0 0 0 4px rgba(22, 134, 223, .11);
}
.small, small { color: var(--muted); font-size: 12px; font-weight: 700; }
.btn-small { min-height: 38px; padding: 0 14px; font-size: 13px; }
.heading-actions,
.filters-actions,
.sticky-actions,
.action-stack { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters-card { margin-bottom: 18px; }
.filters-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 220px auto;
  gap: 14px;
  align-items: end;
}
.form-panel { display: grid; gap: 18px; }
.form-section { display: grid; gap: 18px; }
.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: 160px 1fr 180px; }
.section-mini-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 4px;
}
.section-mini-heading h2 { margin-bottom: 4px; }
.section-mini-heading p { margin: 0; max-width: 720px; }
.section-mini-heading.compact { align-items: center; margin-bottom: 16px; }
.sticky-actions {
  position: sticky;
  bottom: 16px;
  justify-content: flex-end;
  background: rgba(248, 250, 252, .88);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
  border-radius: 999px;
  padding: 10px;
  box-shadow: 0 20px 50px rgba(11,16,32,.08);
  z-index: 10;
}
.table-card { padding: 0; overflow: hidden; }
.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 17px 18px; border-bottom: 1px solid #eef2f7; text-align: left; vertical-align: middle; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
td strong { display: block; }
td small { display: block; margin-top: 4px; }
tr:last-child td { border-bottom: 0; }
.row-actions { text-align: right; white-space: nowrap; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.badge-active { background: #ecfdf5; color: #047857; }
.badge-blocked { background: #fff7ed; color: #c2410c; }
.badge-archived { background: #f1f5f9; color: #475569; }
.badge-muted { background: #eef6ff; color: var(--primary); }
.empty-state { padding: 42px; text-align: center; }
.empty-state p { margin-left: auto; margin-right: auto; max-width: 520px; }
.client-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.detail-sections { margin-bottom: 18px; }
.details-list { margin: 0; display: grid; gap: 10px; }
.details-list div {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid #eef2f7;
}
.details-list div:last-child { border-bottom: 0; }
.details-list dt { color: var(--muted); font-size: 13px; font-weight: 900; }
.details-list dd { margin: 0; color: var(--text); font-weight: 700; overflow-wrap: anywhere; }
.compact-form { gap: 12px; margin-top: 14px; }
.mini-list { display: grid; gap: 10px; }
.mini-list article {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: #fbfdff;
}
.mini-list span,
.mini-list small { display: block; margin-top: 3px; }
.microcopy-block { font-size: 13px; margin-top: 18px; }
.note-form { display: grid; gap: 12px; margin-bottom: 18px; }
.notes-list { display: grid; gap: 12px; }
.note-card {
  background: #fbfdff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
}
.note-card > div { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.note-card span { color: var(--muted); font-size: 13px; font-weight: 700; }
.note-card p { margin: 12px 0 0; color: var(--text); }
.link-danger {
  padding: 0;
  margin-top: 12px;
  border: 0;
  background: transparent;
  color: var(--danger);
  font-weight: 900;
  cursor: pointer;
}
.timeline-list { display: grid; gap: 12px; }
.timeline-list article {
  position: relative;
  border-left: 3px solid #dbeafe;
  padding: 2px 0 12px 16px;
}
.timeline-list article:last-child { padding-bottom: 0; }
.timeline-list span { display: block; color: var(--muted); font-size: 13px; font-weight: 700; margin-top: 3px; }
.timeline-list p { margin: 6px 0 0; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

@media (max-width: 980px) {
  .filters-form,
  .form-grid.two,
  .form-grid.three,
  .client-detail-grid { grid-template-columns: 1fr; }
  .section-mini-heading { flex-direction: column; }
  .sticky-actions { border-radius: 24px; justify-content: stretch; }
  .sticky-actions .btn { flex: 1; }
  .heading-actions { width: 100%; }
  .heading-actions .btn { flex: 1; }
}

@media (max-width: 760px) {
  .responsive-table table,
  .responsive-table thead,
  .responsive-table tbody,
  .responsive-table th,
  .responsive-table td,
  .responsive-table tr { display: block; }
  .responsive-table thead { display: none; }
  .responsive-table tr {
    border-bottom: 1px solid var(--border);
    padding: 14px;
  }
  .responsive-table td {
    border: 0;
    padding: 8px 0;
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 12px;
  }
  .responsive-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .06em;
  }
  .responsive-table .row-actions { text-align: left; }
  .responsive-table .row-actions::before { display: none; }
  .responsive-table .row-actions .btn { width: 100%; }
  .details-list div { grid-template-columns: 1fr; gap: 3px; }
}

/* ==================== CRM v0.3 - Usługi ==================== */
.services-stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.services-filters-form { grid-template-columns: minmax(180px, 1fr) 220px 190px 190px auto; }
.price-preview {
  min-width: 180px;
  border: 1px solid #dbeafe;
  background: #eef6ff;
  border-radius: 16px;
  padding: 12px 14px;
  text-align: right;
}
.price-preview span,
.calculated-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.price-preview strong { display: block; margin-top: 3px; font-size: 22px; letter-spacing: -.04em; }
.calculated-box {
  min-height: 50px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  align-items: center;
  border: 1px solid var(--border);
  background: #fbfdff;
  border-radius: 14px;
  padding: 10px 14px;
}
.calculated-box strong { color: var(--dark); }
.checkbox-line {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  font-weight: 800;
}
.checkbox-line input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  flex: 0 0 auto;
}
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
}
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-list span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 12px;
  background: #eef6ff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}
.compact-tags { gap: 5px; }
.compact-tags span { min-height: 24px; padding: 0 9px; }
.badge-service-draft { background: #f1f5f9; color: #475569; }
.badge-service-waiting_for_payment { background: #fff7ed; color: #c2410c; }
.badge-service-paid { background: #eef6ff; color: var(--primary); }
.badge-service-pending_activation { background: #fefce8; color: #a16207; }
.badge-service-in_progress { background: #eff6ff; color: #1d4ed8; }
.badge-service-active { background: #ecfdf5; color: #047857; }
.badge-service-expiring { background: #fffbeb; color: #b45309; }
.badge-service-expired { background: #fef2f2; color: #b91c1c; }
.badge-service-suspended { background: #fff7ed; color: #c2410c; }
.badge-service-terminated { background: #f1f5f9; color: #475569; }
.badge-service-cancelled { background: #f1f5f9; color: #475569; }
.badge-service-completed { background: #ecfdf5; color: #047857; }

@media (max-width: 1180px) {
  .services-filters-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .services-filters-form .filters-actions { grid-column: 1 / -1; }
}

@media (max-width: 980px) {
  .services-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .checkbox-grid { grid-template-columns: 1fr; }
  .price-preview { width: 100%; text-align: left; }
}

@media (max-width: 760px) {
  .services-filters-form,
  .services-stats-grid { grid-template-columns: 1fr; }
  .calculated-box { grid-template-columns: 1fr; }
}

/* ==================== CRM v0.3.1 - Zlecenia jednorazowe i archiwum usług ==================== */
.services-filters-form.extended { grid-template-columns: minmax(180px, 1fr) 190px 190px 180px 150px 170px auto; }
.badge-billing-one_time { background: #eef6ff; color: var(--primary); }
.badge-billing-subscription { background: #f3e8ff; color: #7c3aed; }
.badge-billing-renewable { background: #ecfdf5; color: #047857; }
.badge-service-pending_realization { background: #fefce8; color: #a16207; }
.badge-service-waiting_for_client { background: #fff7ed; color: #c2410c; }
.badge-service-archived { background: #f1f5f9; color: #475569; }
.is-archived-row { opacity: .72; }
.service-actions-card .action-stack.horizontal { flex-direction: row; flex-wrap: wrap; gap: 10px; }
.service-section-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.service-section-tabs div {
  border: 1px solid var(--border);
  background: #fbfdff;
  border-radius: 16px;
  padding: 16px;
}
.service-section-tabs strong { display: block; font-size: 26px; line-height: 1; letter-spacing: -.04em; }
.service-section-tabs span { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.service-subsection { border-top: 1px solid var(--border); padding-top: 22px; margin-top: 22px; }
.service-subsection h3 { margin: 0 0 14px; font-size: 18px; letter-spacing: -.02em; }
.status-timeline-list article strong { font-size: 14px; }

@media (max-width: 1280px) {
  .services-filters-form.extended { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .services-filters-form.extended .filters-actions { grid-column: 1 / -1; }
}

@media (max-width: 980px) {
  .service-section-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .services-filters-form.extended { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .service-section-tabs,
  .services-filters-form.extended { grid-template-columns: 1fr; }
  .service-actions-card .action-stack.horizontal { flex-direction: column; }
  .service-actions-card .action-stack.horizontal .btn { width: 100%; }
}

/* ==================== CRM v0.4 - RWD hotfix + Tickety ==================== */
body { overflow-x: hidden; }
img, svg, video { max-width: 100%; height: auto; }
.content,
.main-area,
.panel-card,
.filters-card,
.filters-form,
.form-grid,
.heading-actions,
.filters-actions,
.action-stack,
label,
input,
select,
textarea { min-width: 0; max-width: 100%; }

.filters-card { overflow: hidden; }
.filters-form > * { min-width: 0; }
.filters-actions { justify-content: flex-end; align-self: end; }
.btn { max-width: 100%; }

.form-grid.three.equal { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dashboard-stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dashboard-secondary-grid { margin-top: 18px; }
.tickets-filters-form { grid-template-columns: minmax(200px, 1fr) 220px 190px 170px auto; }

.badge-ticket-new { background: #eef6ff; color: var(--primary); }
.badge-ticket-open { background: #eff6ff; color: #1d4ed8; }
.badge-ticket-waiting_for_client { background: #fff7ed; color: #c2410c; }
.badge-ticket-waiting_for_employee { background: #fefce8; color: #a16207; }
.badge-ticket-in_progress { background: #f3e8ff; color: #7c3aed; }
.badge-ticket-resolved { background: #ecfdf5; color: #047857; }
.badge-ticket-closed { background: #f1f5f9; color: #475569; }
.badge-priority-low { background: #f1f5f9; color: #475569; }
.badge-priority-normal { background: #eef6ff; color: var(--primary); }
.badge-priority-high { background: #fff7ed; color: #c2410c; }
.badge-priority-urgent { background: #fef2f2; color: #b91c1c; }

.ticket-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}
.ticket-thread { min-width: 0; }
.ticket-sidebar { position: sticky; top: 96px; }
.ticket-messages {
  display: grid;
  gap: 14px;
  margin: 18px 0 24px;
}
.ticket-message {
  border: 1px solid var(--border);
  background: #fbfdff;
  border-radius: 18px;
  padding: 18px;
}
.ticket-message.author-client { background: #f8fafc; }
.ticket-message.author-staff { background: #eef6ff; border-color: #dbeafe; }
.ticket-message.is-internal { background: #fff7ed; border-color: #fed7aa; }
.ticket-message-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.ticket-message-meta span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.ticket-message p { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.ticket-reply-form {
  display: grid;
  gap: 14px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 18px;
}
.ticket-internal-toggle { align-self: end; }
.client-ticket-layout { grid-template-columns: minmax(0, 1fr) 320px; }

@media (max-width: 1280px) {
  .tickets-filters-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tickets-filters-form .filters-actions { grid-column: 1 / -1; }
  .dashboard-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
  .ticket-layout,
  .client-ticket-layout { grid-template-columns: 1fr; }
  .ticket-sidebar { position: static; }
}

@media (max-width: 760px) {
  .content { padding: 18px 14px; }
  .panel-card { padding: 20px 16px; border-radius: 18px; }
  .table-card { padding: 0; }
  .filters-card { padding: 18px 16px; }
  .filters-form,
  .tickets-filters-form,
  .services-filters-form,
  .services-filters-form.extended,
  .form-grid.three.equal { grid-template-columns: 1fr !important; }
  .filters-actions,
  .heading-actions,
  .action-stack { width: 100%; display: grid; grid-template-columns: 1fr; }
  .filters-actions .btn,
  .heading-actions .btn,
  .action-stack .btn,
  .sticky-actions .btn { width: 100%; }
  .sticky-actions { display: grid; grid-template-columns: 1fr; border-radius: 20px; }
  .page-heading { gap: 16px; }
  .topbar { gap: 10px; }
  .topbar form .btn { min-width: 0; padding: 0 12px; }
  .ticket-message { padding: 16px; }
  .dashboard-stats-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .content { padding: 16px 10px; }
  .panel-card { padding: 18px 14px; }
  .table-card { padding: 0; }
  h1 { font-size: clamp(30px, 10vw, 38px); }
  .stat-card strong { font-size: 34px; }
  .responsive-table tr { padding: 12px; }
  .responsive-table td { grid-template-columns: 1fr; gap: 4px; }
}

/* ==================== CRM v0.5 - To-do i kalendarz ==================== */
.tasks-filters-form {
  grid-template-columns: minmax(180px, 1fr) 170px 180px 170px 160px 190px auto;
}
.calendar-filters-form {
  grid-template-columns: 190px 190px minmax(220px, 1fr) auto;
}
.badge-task-open { background: #eef6ff; color: var(--primary); }
.badge-task-in_progress { background: #f3e8ff; color: #7c3aed; }
.badge-task-waiting { background: #fff7ed; color: #c2410c; }
.badge-task-done { background: #ecfdf5; color: #047857; }
.badge-task-cancelled { background: #f1f5f9; color: #475569; }
.text-danger { color: var(--danger) !important; }
.is-overdue-row { background: #fffafa; }
.center-actions { justify-content: center; }
.compact-actions { gap: 8px; }
.compact-actions form { margin: 0; }
.task-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}
.task-sidebar { position: sticky; top: 96px; }
.compact-mini-list article { padding: 12px; }
.calendar-card { overflow: hidden; }
.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.calendar-toolbar h2 {
  margin: 0;
  font-size: clamp(24px, 4vw, 38px);
}
.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}
.calendar-weekdays {
  margin-bottom: 10px;
}
.calendar-weekdays span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
  text-align: center;
}
.calendar-day {
  min-width: 0;
  min-height: 150px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  padding: 12px;
}
.calendar-day-empty { background: #f8fafc; border-style: dashed; }
.calendar-day.is-today { border-color: var(--primary-2); box-shadow: 0 0 0 4px rgba(22,134,223,.08); }
.calendar-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.calendar-day-head strong { font-size: 18px; }
.calendar-day-head span { color: var(--muted); font-size: 11px; font-weight: 900; text-transform: uppercase; }
.calendar-empty { margin: 0; font-size: 12px; }
.calendar-task-list { display: grid; gap: 7px; }
.calendar-task {
  display: block;
  border: 1px solid #dbeafe;
  background: #f8fbff;
  border-radius: 12px;
  padding: 9px;
  min-width: 0;
}
.calendar-task strong,
.calendar-task span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calendar-task strong { font-size: 12px; }
.calendar-task span { color: var(--muted); font-size: 11px; font-weight: 800; margin-top: 2px; }
.calendar-task.priority-urgent { border-color: #fecaca; background: #fef2f2; }
.calendar-task.priority-high { border-color: #fed7aa; background: #fff7ed; }
.calendar-task.priority-low { border-color: #e2e8f0; background: #f8fafc; }

@media (max-width: 1320px) {
  .tasks-filters-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tasks-filters-form .filters-actions { grid-column: 1 / -1; }
}

@media (max-width: 1080px) {
  .task-layout { grid-template-columns: 1fr; }
  .task-sidebar { position: static; }
  .calendar-filters-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calendar-filters-form .filters-actions { grid-column: 1 / -1; }
  .calendar-weekdays { display: none; }
  .calendar-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calendar-day-empty { display: none; }
}

@media (max-width: 760px) {
  .tasks-filters-form,
  .calendar-filters-form { grid-template-columns: 1fr !important; }
  .calendar-toolbar { display: grid; grid-template-columns: 1fr; text-align: center; }
  .calendar-toolbar .btn { width: 100%; }
  .calendar-grid { grid-template-columns: 1fr; }
  .calendar-day { min-height: auto; }
  .calendar-task strong,
  .calendar-task span { white-space: normal; }
  .center-actions { display: grid; grid-template-columns: 1fr; }
  .compact-actions { display: grid; grid-template-columns: 1fr; width: 100%; }
  .compact-actions .btn { width: 100%; }
}

/* ==================== CRM v0.6 - Wyceny i faktury ==================== */
.offers-filters-form {
  grid-template-columns: minmax(180px, 1fr) 220px 180px 190px auto;
}
.offer-items {
  display: grid;
  gap: 14px;
}
.offer-item-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(180px, 1fr) 90px 130px 90px;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fbfdff;
}
.badge-offer-draft { background: #f1f5f9; color: #475569; }
.badge-offer-sent { background: #eef6ff; color: var(--primary); }
.badge-offer-waiting_for_payment { background: #fff7ed; color: #c2410c; }
.badge-offer-paid { background: #ecfdf5; color: #047857; }
.badge-offer-cancelled { background: #f1f5f9; color: #475569; }
.badge-offer-expired { background: #fef2f2; color: #b91c1c; }
.details-list-dark div { border-bottom-color: rgba(255,255,255,.12); }
.details-list-dark dt { color: #94a3b8; }
.details-list-dark dd { color: #fff; }
.disabled-action { opacity: .68; pointer-events: none; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

@media (max-width: 1180px) {
  .offers-filters-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .offers-filters-form .filters-actions { grid-column: 1 / -1; }
  .offer-item-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .offers-filters-form,
  .offer-item-row { grid-template-columns: 1fr; }
  .offer-item-row { padding: 12px; border-radius: 16px; }
}

/* ==================== CRM v0.6.1 - Oferta/Proforma -> usługa po opłaceniu ==================== */
.wrap-actions { flex-wrap: wrap; }
.summary-grid.three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.summary-grid.three > div { padding: 18px; border: 1px solid var(--border); border-radius: 18px; background: #fff; }
.summary-grid .eyebrow { display: block; margin-bottom: 6px; }
.detail-columns.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.offer-totals-grid { margin-top: 18px; }
.sticky-actions--wrap { flex-wrap: wrap; }

@media (max-width: 900px) {
  .summary-grid.three,
  .detail-columns.two { grid-template-columns: 1fr; }
}

/* v0.6.1 – oferty/proformy, RWD formularzy i podsumowań */
.offer-summary-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.offer-summary-preview > div {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px;
}
.offer-summary-preview span {
  display: block;
  color: #64748b;
  font-size: 13px;
  margin-bottom: 4px;
}
.offer-summary-preview strong {
  display: block;
  font-size: clamp(18px, 2vw, 24px);
  letter-spacing: -0.03em;
}
.disabled-action { opacity: .72; cursor: default; pointer-events: none; }
.table-actions { white-space: nowrap; }
@media (max-width: 760px) {
  .offer-summary-preview { grid-template-columns: 1fr; }
  .heading-actions { width: 100%; }
  .heading-actions .btn,
  .heading-actions form,
  .heading-actions form .btn { width: 100%; }
}
.offer-items{display:grid;gap:18px;margin:18px 0}.offer-item-card{border:1px solid var(--line,#e2e8f0);border-radius:18px;background:#fff;padding:18px}.offer-line-summary{margin-top:10px;font-weight:800;color:#0b1020}.offer-total-box{padding:18px;border-radius:18px;background:#0b1020;color:#fff;font-weight:900;margin:18px 0}.doc-actions{display:flex;gap:10px;flex-wrap:wrap}.pdf-preview-card{background:#fff;border:1px solid #e2e8f0;border-radius:24px;padding:28px;box-shadow:0 16px 40px rgba(11,16,32,.06)}.offer-meta-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;margin:18px 0}@media(max-width:900px){.offer-meta-grid{grid-template-columns:1fr}.doc-actions .btn{width:100%}.offer-item-card{padding:14px}}

/* v0.6.2 – zakres zadań od-do */
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.task-range-grid label small { display: block; margin-top: 6px; color: var(--muted); line-height: 1.35; }
.calendar-task span { line-height: 1.35; }
@media (max-width: 1180px) { .form-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 680px) { .form-grid.four { grid-template-columns: 1fr !important; } }


/* ==================== CRM v0.6.7 – priorytety obsługi ticketów ==================== */
.badge-priority-normal { background: #eef6ff; color: #1179bf; }
.badge-priority-high { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.ticket-row-priority-high { background: linear-gradient(90deg, rgba(254, 242, 242, .95), #fff 36%); }
.ticket-row-priority-high td:first-child { border-left: 4px solid #ef4444; }
.info-box.compact {
  display: grid;
  gap: 4px;
  align-content: center;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #f8fafc;
  color: #334155;
}
.info-box.compact span { color: #64748b; font-size: 13px; line-height: 1.4; }
@media (max-width: 760px) {
  .ticket-row-priority-high { background: #fff; }
  .ticket-row-priority-high td:first-child { border-left: 0; }
}


/* CRM v0.7 – płatności Tpay */
.doc-actions form {
  display: inline-flex;
  margin: 0;
}
.alert-info {
  background: #eef6ff;
  color: #0f4f83;
  border: 1px solid #bfdbfe;
}
@media (max-width: 760px) {
  .doc-actions form,
  .doc-actions form .btn {
    width: 100%;
  }
}


/* CRM v0.7.1 – lżejsza typografia i karta klienta */
body {
  font-family: "Nunito Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 400;
}

h1 {
  font-weight: 800;
  letter-spacing: -0.045em;
}

h2,
h3,
label,
.btn,
.sidebar-nav a,
.topbar strong {
  font-weight: 700;
}

.sidebar-logo {
  font-weight: 800;
}

.client-services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 14px;
}

.client-service-card {
  display: grid;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: linear-gradient(180deg, #fff 0%, #fbfdff 100%);
  padding: 18px;
  box-shadow: 0 14px 34px rgba(11, 16, 32, .055);
  min-width: 0;
}

.client-service-card__top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.client-service-card__top strong {
  display: block;
  font-size: 17px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.client-service-card__top span:not(.badge) {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.client-service-card__meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.client-service-card__meta div {
  border: 1px solid #edf2f7;
  border-radius: 16px;
  background: #f8fafc;
  padding: 11px 12px;
  min-width: 0;
}

.client-service-card__meta span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 2px;
}

.client-service-card__meta strong {
  display: block;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.client-service-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pagination-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.pagination-nav a,
.pagination-nav span {
  min-width: 38px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--text);
}

.pagination-nav a.active {
  background: var(--dark);
  color: #fff;
  border-color: var(--dark);
}

.settings-card small {
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 700px) {
  .client-service-card__top {
    display: grid;
  }

  .client-service-card__meta {
    grid-template-columns: 1fr;
  }

  .client-service-card__actions .btn {
    width: 100%;
  }
}


/* CRM v0.7.2 – porządkowanie odstępów i stabilizacja układu */
.topbar {
  position: static;
  top: auto;
  z-index: auto;
  background: #f8fafc;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.content > * {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

.content > .alert {
  margin-bottom: 0;
}

.page-heading,
.page-head,
.section-mini-heading,
.heading-actions,
.card-grid,
.client-detail-grid,
.detail-columns,
.detail-sections,
.panel-card,
.pdf-preview-card,
.timeline-list,
.notes-list,
.mini-list,
.responsive-table,
.client-services-grid {
  min-width: 0;
  max-width: 100%;
}

.page-heading,
.page-head {
  align-items: flex-start;
}

.client-detail-grid,
.card-grid,
.detail-columns,
.detail-sections {
  align-items: start;
  gap: 20px;
}

.card-grid.two,
.detail-columns.two,
.client-detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel-card,
.pdf-preview-card,
.client-service-card,
.note-card {
  overflow: visible;
}

.details-list,
.timeline-list,
.notes-list,
.mini-list {
  overflow-wrap: anywhere;
  word-break: normal;
}

.details-list div,
.details-list dt,
.details-list dd,
.timeline-list article,
.timeline-list article *,
.note-card,
.note-card *,
.mini-list article,
.mini-list article *,
.client-service-card,
.client-service-card * {
  min-width: 0;
  max-width: 100%;
}

.timeline-list article {
  padding-left: 18px;
}

.timeline-list p,
.note-card p,
.panel-card p {
  overflow-wrap: anywhere;
}

.status-timeline-list article strong {
  display: block;
  line-height: 1.35;
}

.status-timeline-list article span,
.timeline-list article span {
  line-height: 1.45;
}

.status-timeline-list article p {
  line-height: 1.6;
  max-width: 100%;
}

.service-actions-card .action-stack.horizontal {
  align-items: flex-start;
}

.client-service-card {
  height: auto;
}

.client-service-card__top {
  align-items: flex-start;
}

.client-service-card__top .badge {
  flex: 0 0 auto;
}

.client-service-card__actions {
  margin-top: 2px;
}

.responsive-table {
  max-width: 100%;
}

.responsive-table table {
  width: 100%;
}

@media (max-width: 980px) {
  .card-grid.two,
  .detail-columns.two,
  .client-detail-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 760px) {
  .content {
    gap: 16px;
  }

  .page-heading,
  .page-head {
    gap: 14px;
  }

  .panel-card,
  .pdf-preview-card {
    border-radius: 18px;
  }

  .heading-actions,
  .service-actions-card .action-stack.horizontal,
  .client-service-card__actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .heading-actions .btn,
  .service-actions-card .action-stack.horizontal .btn,
  .client-service-card__actions .btn {
    width: 100%;
  }
}


/* CRM v0.7.3 – filtry klienta i dashboard tylko aktywne */
.client-filter-bar {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(180px, 260px) auto;
  align-items: end;
  gap: 14px;
}

.client-filter-bar label {
  min-width: 0;
}

.client-filter-bar .filters-actions {
  justify-content: flex-start;
}

@media (max-width: 900px) {
  .client-filter-bar {
    grid-template-columns: 1fr;
  }

  .client-filter-bar .filters-actions,
  .client-filter-bar .filters-actions .btn {
    width: 100%;
  }
}


/* CRM v0.7.4 – strefa RODO / trwałe usuwanie */
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  filter: brightness(.95);
  transform: translateY(-1px);
}

.danger-zone-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid rgba(239, 68, 68, .25);
  border-radius: 18px;
  background: #fff7f7;
}

.danger-zone-form label {
  color: #991b1b;
}

.danger-zone-form input {
  border-color: rgba(239, 68, 68, .35);
}

.danger-zone-form .btn {
  justify-self: start;
}

@media (max-width: 760px) {
  .danger-zone-form .btn {
    width: 100%;
  }
}


/* CRM v0.7.5 – ustawienia company i PDF wyceny */
.settings-layout {
  display: grid;
  gap: 20px;
}

.settings-layout .panel-card {
  display: grid;
  gap: 16px;
}

.settings-layout .section-mini-heading {
  margin-bottom: 0;
}

.settings-layout small {
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 760px) {
  .settings-layout .sticky-actions {
    position: static;
  }
}


/* CRM v0.7.6 – wyceny zewnętrzne i publiczny link płatności */
.manual-recipient-box {
  margin: 22px 0;
  padding: 18px;
  border: 1px dashed #bfdbfe;
  border-radius: 20px;
  background: #f8fbff;
}

.public-offer-card {
  display: grid;
  gap: 22px;
}

.public-offer-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.public-offer-head h1 {
  font-size: clamp(28px, 5vw, 42px);
}

.public-offer-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.public-offer-meta div {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  background: #f8fafc;
}

.public-offer-meta span,
.public-offer-meta small {
  display: block;
  color: var(--muted);
}

.public-offer-meta strong {
  display: block;
  overflow-wrap: anywhere;
}

.public-offer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.public-offer-actions form {
  margin: 0;
}

@media (max-width: 720px) {
  .public-offer-head,
  .public-offer-actions {
    display: grid;
  }

  .public-offer-meta {
    grid-template-columns: 1fr;
  }

  .public-offer-actions .btn,
  .public-offer-actions form {
    width: 100%;
  }
}


/* CRM v0.7.7 – kod dostępu do wyceny zewnętrznej i kosmetyka PDF/public */
.access-code-form {
  display: grid;
  gap: 16px;
}

.access-code-form input {
  font-size: 22px;
  letter-spacing: .18em;
  text-align: center;
  font-weight: 800;
}

.public-link-box {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid #bfdbfe;
  border-radius: 18px;
  background: #f8fbff;
  overflow-wrap: anywhere;
}

.public-link-box h3 {
  margin: 0;
}

.public-link-box form {
  margin: 0;
}

.access-code-admin {
  display: grid;
  gap: 5px;
}

.access-code-copy {
  display: inline-flex;
  width: fit-content;
  padding: 7px 12px;
  border-radius: 12px;
  background: #0b1020;
  color: #fff;
  font-size: 18px;
  letter-spacing: .16em;
  font-weight: 900;
}

.manual-recipient-box {
  border-style: solid;
}

.guest-card {
  max-width: 980px;
}

@media (max-width: 760px) {
  .public-link-box .btn,
  .public-link-box form {
    width: 100%;
  }
}


/* CRM v0.7.9 – poprawa układu publicznej wyceny */
.guest-shell-wide {
  width: min(100%, 1040px);
}

.guest-card-wide {
  padding: 42px;
}

.public-offer-card {
  gap: 26px;
}

.public-offer-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.public-offer-title-block {
  display: grid;
  gap: 8px;
}

.public-offer-title-block h1 {
  margin: 0;
  font-size: clamp(38px, 6vw, 56px);
  line-height: .96;
  letter-spacing: -.055em;
  overflow-wrap: anywhere;
}

.public-offer-title-block p {
  margin: 0;
  font-size: 16px;
}

.public-offer-meta {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.public-offer-meta div {
  min-width: 0;
  padding: 18px;
}

.public-offer-meta strong {
  margin-top: 6px;
  font-size: 18px;
  line-height: 1.25;
}

.public-offer-table-wrap {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #fff;
}

.public-offer-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.public-offer-table thead th {
  padding: 18px 20px;
  text-align: left;
  font-size: 13px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.public-offer-table tbody td {
  padding: 22px 20px;
  vertical-align: top;
  border-bottom: 1px solid #eef2f7;
  font-size: 15px;
}

.public-offer-table tbody tr:last-child td {
  border-bottom: 0;
}

.public-offer-table tbody td small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.public-offer-table tbody td:first-child {
  width: 34%;
}

.public-offer-table tbody td:not(:first-child) {
  width: 16.5%;
}

.public-offer-total {
  margin-top: -2px;
}

.public-offer-actions {
  gap: 12px;
}

.public-offer-actions .btn,
.public-offer-actions form {
  min-width: 200px;
}

@media (max-width: 980px) {
  .guest-shell-wide {
    width: min(100%, 920px);
  }

  .public-offer-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .guest-card-wide {
    padding: 28px 20px;
  }

  .public-offer-topline,
  .public-offer-actions {
    display: grid;
  }

  .public-offer-topline .badge {
    width: fit-content;
  }

  .public-offer-meta {
    grid-template-columns: 1fr;
  }

  .public-offer-table {
    min-width: 100%;
  }

  .public-offer-table tbody td,
  .public-offer-table thead th {
    padding-left: 16px;
    padding-right: 16px;
  }

  .public-offer-actions .btn,
  .public-offer-actions form {
    width: 100%;
    min-width: 0;
  }
}


/* CRM v0.8 – multi-brand */
.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eef6ff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.sidebar-logo {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.public-brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
