:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #f1f3f9;
  --border: #e6e9f2;
  --border-strong: #d5dae6;
  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --faint: #98a2b3;
  --primary: #e3262b;
  --primary-600: #c31d22;
  --primary-50: #fff1f1;
  --primary-100: #ffdada;
  --danger: #e5484d;
  --danger-50: #fff1f1;
  --success: #12a150;
  --success-50: #ecfdf3;
  --warn: #dc8a06;
  --warn-50: #fff8eb;
  --radius: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 8px 28px rgba(16, 24, 40, 0.09);
  --shadow-lg: 0 24px 60px rgba(16, 24, 40, 0.22);
  --ring: 0 0 0 4px rgba(227, 38, 43, 0.16);
  --font: 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Segoe UI Variable Display', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  --sidebar-w: 256px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-family: var(--font-display); letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 12.5px; color: var(--muted); }
.nowrap { white-space: nowrap; }
.prewrap { white-space: pre-wrap; word-break: break-word; }
.spacer { flex: 1; }
[hidden] { display: none !important; }
::selection { background: var(--primary-100); }

.ico { width: 18px; height: 18px; flex: none; }
.ico-sm { width: 14px; height: 14px; flex: none; vertical-align: -2px; }

/* ── przyciski ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-2); box-shadow: var(--shadow-xs);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, .seg button:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(227, 38, 43, .3), inset 0 1px 0 rgba(255, 255, 255, .15); }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn-soft { background: var(--primary-50); border-color: transparent; color: var(--primary); box-shadow: none; }
.btn-soft:hover { background: var(--primary-100); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #0e8a44; }
.btn-danger { color: var(--danger); border-color: #fbd0d1; }
.btn-danger:hover { background: var(--danger-50); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn-xs { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 8px; }
.btn.block { width: 100%; justify-content: flex-start; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; font: inherit; text-align: left; }
.link-btn:hover { text-decoration: underline; }

/* segmentowy przełącznik */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: 11px; }
.seg button {
  height: 32px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; color: var(--muted);
  font: inherit; font-weight: 600; cursor: pointer; transition: background .15s, color .15s;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs), 0 0 0 1px var(--border); }

/* ── formularze ── */
input[type=text], input[type=password], input[type=email], input[type=search], input[type=date], input[type=time], input[type=tel], input:not([type]), select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s;
}
select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
input[type=color] { width: 52px; height: 40px; padding: 3px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
input[readonly] { background: var(--surface-2); color: var(--text-2); }
input::placeholder, textarea::placeholder { color: var(--faint); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > legend { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field small { color: var(--muted); font-size: 12px; }
fieldset.field { border: 0; padding: 0; margin: 0; }
fieldset.field > legend { padding: 0; margin-bottom: 8px; }
.req { color: var(--danger); }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 16px; }
.grid-form .full, .grid-form .field:not(.half) { grid-column: 1 / -1; }
.grid-form .field.half { grid-column: span 1; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 14px; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 500; color: var(--text); }
.check input { width: 17px; height: 17px; accent-color: var(--primary); margin: 0; }
.form-error { margin-top: 16px; padding: 11px 14px; border-radius: var(--radius-sm); background: var(--danger-50); color: #c42b30; border: 1px solid #fbd0d1; font-weight: 550; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.privacy-note { margin-top: 18px; font-size: 12.5px; line-height: 1.55; color: var(--muted); }

/* ── karty, układ ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card.flush > .card-head { padding: 16px 20px 0; margin-bottom: 12px; }
.card-head h2 { display: flex; align-items: center; gap: 9px; }
.card-head h2 .ico { color: var(--muted); }
.cols-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { word-break: break-word; }
.page-head p { margin: 5px 0 0; font-size: 14.5px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; color: var(--muted); font-weight: 600; font-size: 13px; }
.back:hover { color: var(--text); text-decoration: none; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty::before { content: ''; display: block; width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 12px; background: var(--surface-3) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2398a2b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 22px no-repeat; }
.loading { padding: 48px; text-align: center; color: var(--muted); }
.error-box { color: #c42b30; background: var(--danger-50); border-color: #fbd0d1; }
.link { font-weight: 600; font-size: 13px; }

/* ── odznaki ── */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2);
}
.badge.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-new { background: #fff0f0; color: #d93036; }
.st-in_progress { background: #eef2ff; color: #3451e0; }
.st-waiting { background: #fff6e5; color: #b86e00; }
.st-closed { background: #f2f4f7; color: #667085; }
.pr-low { background: #f2f4f7; color: #667085; }
.pr-normal { background: #f2f4f7; color: #344054; }
.pr-high { background: #fff1e6; color: #c4520a; }
.pr-urgent { background: #e5484d; color: #fff; }
.is-todo { background: #fff6e5; color: #b86e00; }
.is-ordered, .is-sent { background: #eef2ff; color: #3451e0; }
.is-delivered, .is-accepted, .is-invoiced { background: var(--success-50); color: #0c7a3d; }
.is-cancelled, .is-rejected { background: #f2f4f7; color: #667085; }
.count { display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--primary-50); color: var(--primary); font-weight: 700; font-size: 12px; }
.avatar {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; flex: none; vertical-align: middle;
  background: var(--c, #667085); color: #fff; font-size: 10.5px; font-weight: 700; box-shadow: 0 0 0 2px var(--surface);
}
.avatars { display: inline-flex; }
.avatars .avatar + .avatar, .ev-users .avatar + .avatar { margin-left: -7px; }
.person { display: inline-flex; align-items: center; gap: 8px; font-weight: 550; }

/* ── tabele ── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 11px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover td { background: #fafbff; }
.table .num { text-align: right; }
.click-rows tbody tr[data-href] { cursor: pointer; }
.row-new td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
tr.inactive td { opacity: .55; }
.table select.inline { height: 32px; width: auto; min-width: 150px; font-size: 13px; padding: 0 30px 0 10px; box-shadow: none; }
.table .actions-cell { white-space: nowrap; text-align: right; }
.table .title-cell { min-width: 240px; }
.table .title-cell .sub { display: block; font-size: 12.5px; color: var(--muted); white-space: pre-wrap; margin-top: 2px; }
.ticket-title { font-weight: 600; color: var(--text); }

/* ── filtry ── */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px; }
.filters select, .filters input[type=search] { width: auto; min-width: 170px; flex: 0 1 auto; box-shadow: none; }
.filters input[type=search] { flex: 1 1 220px; padding-left: 36px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2398a2b3' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") 11px center / 17px no-repeat; }

/* ── statystyki ── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  position: relative; display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text);
  transition: box-shadow .18s, transform .18s, border-color .18s;
}
.stat:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary-100); }
.stat-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--tone-bg, var(--primary-50)); color: var(--tone, var(--primary)); }
.stat-n { font-family: var(--font-display); font-size: 30px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-l { color: var(--muted); font-weight: 550; font-size: 13px; }
.stat.hot { border-color: #ffd5d6; background: linear-gradient(180deg, #fff6f6, #fff 60%); }
.stat.hot .stat-n { color: var(--danger); }

/* ── lista zadań ── */
.ev-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ev { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--c) 7%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 18%, var(--surface)); }
.ev::before { content: ''; align-self: stretch; width: 4px; border-radius: 4px; background: var(--c); flex: none; }
.ev-main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; background: none; border: 0; padding: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.ev-time { font-size: 12px; font-weight: 650; color: var(--muted); }
.ev-title { font-weight: 600; word-break: break-word; }
.ev-client { font-size: 12.5px; color: var(--muted); }
.ev-done { width: 18px; height: 18px; accent-color: var(--success); flex: none; cursor: pointer; }
.ev.done { opacity: .6; }
.ev.done .ev-title { text-decoration: line-through; }
.ev-users { display: inline-flex; }

/* ── modal ── */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 7vh 16px 16px; background: rgba(16, 24, 40, .45); backdrop-filter: blur(3px); overflow-y: auto; animation: fade .15s ease-out; }
.modal { width: 100%; max-width: 560px; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); animation: pop .18s cubic-bezier(.2, .9, .3, 1.2); }
.modal-wide { max-width: 780px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 6px; }
.modal-head h3 { font-size: 18px; }
.modal-body { padding: 14px 24px 22px; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 20px 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ── powiadomienia ── */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: #101828; color: #fff; font-weight: 550; box-shadow: var(--shadow-lg); transition: opacity .3s, transform .3s; max-width: 380px; }
.toast::before { content: '✓'; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--success); font-size: 12px; flex: none; }
.toast-err::before { content: '!'; background: var(--danger); }
.toast.hide { opacity: 0; transform: translateY(6px); }

/* ════════════ PANEL PRACOWNIKA ════════════ */
body.app { display: flex; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; width: var(--sidebar-w); flex: none; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 11px; padding: 22px 22px 18px; }
.brand img { width: 36px; height: 36px; border-radius: 10px; box-shadow: 0 4px 12px rgba(227, 38, 43, .3); }
.brand-name { font-family: var(--font-display); font-size: 17px; font-weight: 750; letter-spacing: -.02em; color: var(--text); }
.brand-sub { font-size: 11px; color: var(--faint); font-weight: 650; text-transform: uppercase; letter-spacing: .1em; }
#nav { flex: 1; overflow-y: auto; padding: 4px 12px; display: flex; flex-direction: column; gap: 2px; }
#nav .nav-label { padding: 16px 12px 6px; font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; }
#nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--text-2); font-weight: 550; text-decoration: none; transition: background .12s, color .12s; }
#nav a .ico { color: var(--faint); transition: color .12s; }
#nav a:hover { background: var(--surface-3); color: var(--text); }
#nav a:hover .ico { color: var(--text-2); }
#nav a.active { background: var(--primary-50); color: var(--primary); font-weight: 650; }
#nav a.active .ico { color: var(--primary); }
#nav a .nav-ext { margin-left: auto; opacity: .6; }
.nav-badge { margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
.nav-badge.soft { background: var(--surface-3); color: var(--text-2); }
#nav a.active .nav-badge.soft { background: var(--primary-100); color: var(--primary); }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }
.userbox { display: flex; align-items: center; gap: 11px; padding: 8px; border-radius: 12px; }
.userbox .avatar { width: 36px; height: 36px; font-size: 12.5px; }
.userbox-name { font-weight: 650; line-height: 1.25; }
.userbox-links { display: flex; gap: 12px; font-size: 12.5px; }
.userbox-links a, .userbox-links button { color: var(--muted); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.userbox-links a:hover, .userbox-links button:hover { color: var(--primary); text-decoration: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.view { padding: 30px 36px 48px; max-width: 1560px; width: 100%; }

/* helpdesk */
.hd-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; align-items: start; }
.client-filter { padding: 10px; position: sticky; top: 16px; }
.client-filter h3 { padding: 8px 10px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.client-filter button { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; border: 0; border-radius: 9px; background: none; text-align: left; font: inherit; font-weight: 550; color: var(--text-2); cursor: pointer; }
.client-filter button:hover { background: var(--surface-3); }
.client-filter button.active { background: var(--primary-50); color: var(--primary); font-weight: 650; }
.client-filter button span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.take-btn { white-space: nowrap; }

/* zgłoszenie */
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.ticket-side .field { margin-bottom: 14px; }
.ticket-side .btn.block { margin-bottom: 8px; }
.ticket-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.requester { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--border); display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--text-2); }
.assignee-card { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 14px; }
.assignee-card .avatar { width: 40px; height: 40px; font-size: 13px; }
.assignee-card.none { background: var(--warn-50); border-color: #fde3b0; }
.assignee-card .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.assignee-card .nm { font-weight: 650; }
.take-banner { display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 18px; border-radius: var(--radius); background: linear-gradient(90deg, #fff8eb, #fff); border: 1px solid #fde3b0; flex-wrap: wrap; }
.take-banner .spacer { min-width: 10px; }
.timeline { position: relative; display: flex; flex-direction: column; gap: 12px; margin: 14px 0 18px; }
.comment { padding: 12px 14px; border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--border); }
.comment-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.comment-head strong { color: var(--text); }
.comment.internal { background: #fffcf2; border-color: #f7e6bb; }
.comment.client { background: #f3f6ff; border-color: #d6e0ff; }
.comment.system { display: flex; gap: 8px; align-items: baseline; background: none; border: 0; padding: 0 4px; font-size: 12.5px; color: var(--muted); }
.comment.system::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); flex: none; transform: translateY(-1px); }
.comment-form { display: flex; flex-direction: column; gap: 10px; }
.comment-form .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.related { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.related li { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 13px; }

/* pozycje (zamówienia/oferty/faktury) */
.group-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.group-head h2 { font-size: 15px; }
.group-head .ico { color: var(--muted); }
.item-actions { display: inline-flex; gap: 4px; align-items: center; }
.tick { position: relative; display: inline-grid; place-items: center; width: 26px; height: 26px; cursor: pointer; }
.tick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.tick span { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); display: grid; place-items: center; transition: all .15s; }
.tick:hover span { border-color: var(--success); background: var(--success-50); }
.tick input:checked + span { background: var(--success); border-color: var(--success); }
.tick input:checked + span::after { content: ''; width: 10px; height: 6px; border-left: 2.5px solid #fff; border-bottom: 2.5px solid #fff; transform: rotate(-45deg) translate(1px, -1px); }
.tick input:focus-visible + span { box-shadow: var(--ring); }
tr.done-row .ticket-title { text-decoration: line-through; color: var(--muted); }
tr.done-row td { background: #fcfdfc; }
.done-info { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12px; color: #0c7a3d; font-weight: 600; }
.done-info .avatar { width: 18px; height: 18px; font-size: 8px; box-shadow: none; }
.progress { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.progress-bar { width: 90px; height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress-bar i { display: block; height: 100%; background: var(--success); border-radius: 6px; }

/* klient */
.linkbox { display: flex; flex-direction: column; gap: 20px; }
.copy-row { display: flex; gap: 6px; margin-top: 8px; }
.copy-row input { flex: 1; min-width: 0; font-size: 13px; }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 10px 12px; margin: 0; }
.dl dt { color: var(--muted); font-weight: 550; }
.dl dd { margin: 0; word-break: break-word; }

/* ── kalendarz: pasek ── */
.cal-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; }
.cal-toolbar h2 { font-size: 19px; font-weight: 700; min-width: 220px; }
.cal-toolbar .nav-btns { display: inline-flex; gap: 4px; align-items: center; }
.cal-toolbar .nav-btns .icon-btn { border: 1px solid var(--border-strong); width: 36px; height: 36px; background: var(--surface); }
.cal-toolbar select { width: auto; min-width: 210px; box-shadow: none; }
.cal-toolbar .right { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: -6px 0 14px; padding: 0 4px; }
.legend button { display: inline-flex; align-items: center; gap: 7px; border: 0; background: none; padding: 3px 6px; border-radius: 7px; font: inherit; font-size: 12.5px; color: var(--text-2); cursor: pointer; font-weight: 550; }
.legend button:hover { background: var(--surface-3); }
.legend button.active { background: var(--primary-50); color: var(--primary); }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }

/* ── kalendarz: siatka godzin (dzień / tydzień) ── */
.tg-wrap { overflow-x: auto; }
.tg { --hour: 60px; --cols: 7; min-width: calc(64px + var(--cols) * var(--minw, 128px)); }
.tg-row { display: grid; grid-template-columns: 64px repeat(var(--cols), minmax(0, 1fr)); }
.tg-head { position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--border); }
.tg-dayhead { padding: 12px 8px 10px; text-align: center; border-left: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.tg-dayhead:hover { background: var(--surface-2); }
.tg-dayhead .dn { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tg-dayhead .dd { display: inline-grid; place-items: center; min-width: 36px; height: 36px; margin-top: 3px; padding: 0 6px; border-radius: 12px; font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--text); }
.tg-dayhead.today .dn { color: var(--primary); }
.tg-dayhead.today .dd { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(227, 38, 43, .35); }
.tg-dayhead.weekend .dd { color: var(--faint); }
.tg-dayhead .cnt { display: block; font-size: 11.5px; color: var(--faint); margin-top: 2px; font-weight: 550; }
.tg-allday { border-bottom: 1px solid var(--border); background: var(--surface-2); }
.tg-allday .tg-label { display: flex; align-items: center; justify-content: flex-end; padding: 6px 8px; font-size: 11px; color: var(--faint); font-weight: 650; text-align: right; line-height: 1.2; }
.tg-allday .tg-cell { border-left: 1px solid var(--border); padding: 5px; display: flex; flex-direction: column; gap: 4px; min-height: 38px; cursor: pointer; }
.tg-body { position: relative; }
.tg-hours { position: relative; }
.tg-hour { height: var(--hour); position: relative; }
.tg-hour span { position: absolute; top: -8px; right: 10px; font-size: 11.5px; color: var(--faint); font-weight: 600; font-variant-numeric: tabular-nums; }
.tg-hour:first-child span { display: none; }
.tg-col {
  position: relative; border-left: 1px solid var(--border); cursor: copy;
  background-image: linear-gradient(to bottom, var(--border) 1px, transparent 1px), linear-gradient(to bottom, transparent calc(var(--hour) / 2), #f1f3f8 calc(var(--hour) / 2), #f1f3f8 calc(var(--hour) / 2 + 1px), transparent calc(var(--hour) / 2 + 1px));
  background-size: 100% var(--hour);
}
.tg-col.today { background-color: #f7f9ff; }
.tg-col.weekend { background-color: #fbfbfd; }
.tg-ev {
  position: absolute; z-index: 1; overflow: hidden; padding: 5px 8px; border-radius: 9px; text-align: left; cursor: pointer;
  border: 0; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 13%, var(--surface)); color: var(--text);
  font: inherit; font-size: 12.5px; line-height: 1.3; box-shadow: 0 0 0 1.5px var(--surface);
  transition: box-shadow .12s, transform .12s;
}
.tg-ev:hover { z-index: 2; box-shadow: 0 0 0 1.5px var(--surface), var(--shadow-md); transform: translateY(-1px); }
.tg-ev .t { display: block; font-size: 11.5px; font-weight: 700; color: color-mix(in srgb, var(--c) 70%, black); }
.tg-ev .n { display: block; font-weight: 650; word-break: break-word; }
.tg-ev .c { display: block; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-ev .avatars { margin-top: 4px; }
.tg-ev .avatar { width: 20px; height: 20px; font-size: 8.5px; box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--c) 13%, var(--surface)); }
.tg-ev.short .c, .tg-ev.short .avatars { display: none; }
.tg-ev.short .t { display: inline; margin-right: 4px; }
.tg-ev.short .n { display: inline; }
.tg-ev.done { opacity: .55; }
.tg-ev.done .n { text-decoration: line-through; }
.tg-ev.done::after { content: '✓'; position: absolute; top: 4px; right: 6px; font-weight: 800; color: var(--success); }
.tg-day .tg-ev { font-size: 13.5px; padding: 8px 12px; }
.tg-day .tg-ev .desc { display: block; color: var(--text-2); font-size: 12.5px; margin-top: 3px; white-space: pre-wrap; }
.tg-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 2; pointer-events: none; }
.tg-now::before { content: ''; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

/* chip (miesiąc, cały dzień) */
.chip {
  display: block; width: 100%; padding: 3px 7px; border: 0; border-radius: 7px; text-align: left; cursor: pointer;
  background: color-mix(in srgb, var(--c) 14%, var(--surface)); box-shadow: inset 3px 0 0 var(--c);
  font: 550 12px/1.4 var(--font); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip:hover { background: color-mix(in srgb, var(--c) 24%, var(--surface)); }
.chip .t { font-weight: 700; color: color-mix(in srgb, var(--c) 70%, black); }
.chip.done { opacity: .55; text-decoration: line-through; }

/* ── kalendarz: miesiąc ── */
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow { padding: 10px 12px; font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); }
.cal-cell { min-height: 124px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; cursor: pointer; min-width: 0; transition: background .12s; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:hover { background: #fafbff; }
.cal-cell.other { background: var(--surface-2); }
.cal-cell.other .cal-date { color: #c2c8d4; }
.cal-cell.selected { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-date { font-size: 13px; font-weight: 650; color: var(--text-2); width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; }
.cal-cell.today .cal-date { background: var(--primary); color: #fff; }
.cal-more { font-size: 12px; color: var(--muted); font-weight: 600; padding-left: 4px; }
.day-panel h2 { text-transform: capitalize; }
.users-checks { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.users-checks .check { padding: 7px 10px; border: 1px solid var(--border); border-radius: 10px; }
.users-checks .check:has(input:checked) { border-color: var(--primary); background: var(--primary-50); }
.users-checks .avatar { width: 22px; height: 22px; font-size: 9.5px; box-shadow: none; }

/* ════════════ STRONY KLIENTA I LOGOWANIE ════════════ */
body.plain { min-height: 100vh; background: radial-gradient(1200px 600px at 10% -10%, #c9d6ff 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #d7ccff 0%, transparent 55%), #eef1f8; }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 410px; background: rgba(255, 255, 255, .9); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, .8); border-radius: 22px; box-shadow: var(--shadow-lg); padding: 34px 30px; }
.auth-card .brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth-card .brand-row img { width: 46px; height: 46px; border-radius: 13px; box-shadow: 0 6px 16px rgba(227, 38, 43, .35); }
.auth-card h1 { font-size: 21px; }
.auth-card form { display: flex; flex-direction: column; gap: 16px; }
.auth-card .btn { height: 44px; }
.auth-foot { text-align: center; margin-top: 18px; color: var(--muted); font-size: 12.5px; }

body.client-page { background: var(--bg); }
.client-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.client-header-inner { max-width: 1100px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.client-header img { width: 34px; height: 34px; border-radius: 10px; }
.client-header .brand-name { font-size: 16px; }
.client-header .who { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13.5px; flex-wrap: wrap; }
.client-header .who button { background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-2); border-radius: 9px; padding: 6px 12px; cursor: pointer; font: inherit; font-weight: 600; }
.client-header .who button:hover { background: var(--surface-2); }
.client-hero { background: linear-gradient(120deg, #b3161b 0%, #e3262b 55%, #ff5a3c 100%); color: #fff; }
.client-hero-inner { max-width: 1100px; margin: 0 auto; padding: 34px 20px 34px; }
.client-hero h1 { font-size: 30px; }
.client-hero p { margin: 8px 0 0; color: rgba(255, 255, 255, .85); font-size: 15px; }
.client-main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 50px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: -54px 0 24px; }
.tile { display: flex; flex-direction: column; gap: 8px; padding: 22px; text-align: left; cursor: pointer; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); font: inherit; color: var(--text); transition: transform .18s, box-shadow .18s, border-color .18s; }
.tile:hover { transform: translateY(-3px); box-shadow: 0 16px 36px rgba(16, 24, 40, .12); border-color: var(--primary-100); }
.tile-ico { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); margin-bottom: 4px; }
.tile-ico .ico { width: 22px; height: 22px; }
.tile strong { font-size: 16px; }
.tile span { color: var(--muted); font-size: 13px; }
.form-card { max-width: 780px; margin: -44px auto 0; }
.type-switch { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.type-switch button { flex: 1 1 200px; display: flex; align-items: center; gap: 10px; padding: 13px 15px; cursor: pointer; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); font: inherit; font-weight: 600; color: var(--text-2); transition: all .15s; }
.type-switch button.active { border-color: var(--primary); background: var(--primary-50); color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.section-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 24px 0 12px; }
.success { text-align: center; padding: 34px 10px; }
.success .big { width: 68px; height: 68px; border-radius: 50%; background: var(--success-50); color: var(--success); display: grid; place-items: center; margin: 0 auto 16px; font-size: 32px; }

/* ════════════ RESPONSYWNOŚĆ ════════════ */
@media (max-width: 1200px) { .cal-layout { grid-template-columns: 1fr; } }
@media (max-width: 1050px) {
  .ticket-layout, .hd-layout, .cols-2 { grid-template-columns: minmax(0, 1fr); }
  .client-filter { position: static; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 90; left: 0; top: 0; transform: translateX(-100%); transition: transform .22s; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(16, 24, 40, .4); z-index: 80; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: rgba(255, 255, 255, .9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 70; }
  .topbar img { width: 28px; height: 28px; border-radius: 8px; }
  .view { padding: 20px 16px 40px; }
  h1 { font-size: 22px; }
  .cal-cell { min-height: 76px; padding: 4px; }
  .cal-grid .chip { font-size: 0; height: 7px; padding: 0; box-shadow: none; background: var(--c); }
  .grid-form { grid-template-columns: 1fr; }
  .grid-form .field.half { grid-column: 1 / -1; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
  .filters select, .filters input[type=search] { flex: 1 1 100%; min-width: 0; }
  .cal-toolbar .right { margin-left: 0; width: 100%; }
  .cal-toolbar select { flex: 1; min-width: 0; }
  .cal-toolbar h2 { min-width: 0; font-size: 17px; }
  .tg { --minw: 112px; }
  .tiles { margin-top: -40px; }
}
