/* ── System ticketowy — tokeny ─────────────────────────────────────── */
:root {
  --ink: #16233B;
  --ink-2: #0F1A2E;
  --ink-3: #223350;
  --paper: #F6F4EF;
  --card: #FFFFFF;
  --line: #E6E2D8;
  --gold: #B8913D;
  --gold-2: #9A7830;
  --gold-soft: #F5EDDC;
  --text: #1F2937;
  --muted: #757A85;
  --danger: #DC2626;
  --s-new: #2563EB; --s-progress: #D97706; --s-waiting: #7C3AED; --s-closed: #059669;
  --p-low: #6B7280; --p-medium: #2563EB; --p-high: #EA580C; --p-critical: #DC2626;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(22,35,59,.05), 0 4px 14px rgba(22,35,59,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--paper); color: var(--text); font-size: 14.5px; line-height: 1.5; }
a { color: var(--gold-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ── Logowanie ─────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background:
  linear-gradient(160deg, var(--ink) 0%, var(--ink-2) 60%, #0B1424 100%); padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 16px;
  padding: 40px 36px 32px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.login-brand .mark { width: 40px; height: 40px; border-radius: 9px; background: var(--ink);
  display: grid; place-items: center; flex-shrink: 0; }
.login-brand h1 { font-size: 19px; margin: 0; letter-spacing: -.01em; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 26px; }

/* ── Formularze ────────────────────────────────────────────────────── */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14.5px; font-family: inherit; background: #FCFBF8; color: var(--text); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold); outline: none;
  box-shadow: 0 0 0 3px rgba(184,145,61,.15); background: #fff; }
.field textarea { resize: vertical; min-height: 110px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 16px;
  border-radius: 8px; border: 1px solid transparent; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .12s, border-color .12s; white-space: nowrap; }
.btn-primary { background: var(--gold); color: #fff; }
.btn-primary:hover { background: var(--gold-2); }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--text); }
.btn-secondary:hover { border-color: var(--gold); }
.btn-danger { background: #fff; border-color: #F3C7C7; color: var(--danger); }
.btn-danger:hover { background: #FEF2F2; }
.btn-ghost { background: transparent; color: var(--muted); border: none; padding: 6px 8px; }
.btn-ghost:hover { color: var(--text); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

.error-box { background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B; border-radius: 8px;
  padding: 9px 12px; font-size: 13.5px; margin-bottom: 14px; }
.info-box { background: var(--gold-soft); border: 1px solid #E7D9B7; color: #6B5320; border-radius: 8px;
  padding: 9px 12px; font-size: 13.5px; margin-bottom: 14px; }
.info-box code { background: #fff; padding: 2px 7px; border-radius: 5px; font-size: 13px; user-select: all; }

/* ── Layout aplikacji ──────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #C7CEDB; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; color: #fff; }
.side-brand .mark { width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,.08);
  display: grid; place-items: center; flex-shrink: 0; }
.side-brand strong { font-size: 15px; letter-spacing: -.01em; }
.side-brand span { display: block; font-size: 11px; color: #8B96AA; letter-spacing: .05em; text-transform: uppercase; }
.side-nav { padding: 6px 10px; flex: 1; overflow-y: auto; }
.side-nav .group { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: #6B7890;
  padding: 16px 10px 6px; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: #C7CEDB; font-size: 14px; font-weight: 500; position: relative; }
.side-nav a:hover { background: var(--ink-3); text-decoration: none; color: #fff; }
.side-nav a.active { background: var(--ink-3); color: #fff; }
.side-nav a.active::before { content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px;
  width: 3px; border-radius: 3px; background: var(--gold); }
.side-nav svg { flex-shrink: 0; opacity: .85; }
.side-user { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08); display: flex;
  align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--gold); color: #fff;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700; flex-shrink: 0; }
.side-user .who { flex: 1; min-width: 0; }
.side-user .who b { display: block; color: #fff; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who span { font-size: 11.5px; color: #8B96AA; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 14px 26px; background: rgba(246,244,239,.92);
  backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--line); }
.topbar h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; flex: 1; }
.hamburger { display: none; }
.content { padding: 22px 26px 60px; max-width: 1240px; width: 100%; }

/* dzwonek */
.bell { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; }
.bell .dot { position: absolute; top: 6px; right: 7px; min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; }
.notif-panel { position: absolute; right: 26px; top: 58px; width: 340px; max-width: calc(100vw - 40px);
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  z-index: 50; overflow: hidden; }
.notif-panel header { display: flex; justify-content: space-between; align-items: center;
  padding: 11px 14px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 13.5px; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item { padding: 10px 14px; border-bottom: 1px solid #F1EEE6; cursor: pointer; }
.notif-item:hover { background: #FBFAF6; }
.notif-item.unread { background: var(--gold-soft); }
.notif-item b { display: block; font-size: 13.5px; }
.notif-item p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.notif-item time { font-size: 11px; color: #A8A29E; }
.notif-empty { padding: 26px; text-align: center; color: var(--muted); font-size: 13px; }

/* ── Karty, tabele, odznaki ────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-bottom: 18px; flex-wrap: wrap; }
.page-head h3 { margin: 0; font-size: 16px; }

.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 11px 14px; border-bottom: 1px solid #F1EEE6; vertical-align: middle; }
table.list tr.row-link { cursor: pointer; }
table.list tr.row-link:hover td { background: #FBFAF6; }
.t-title { font-weight: 600; color: var(--text); }
.t-num { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.NEW { color: var(--s-new); background: #EFF4FE; }
.badge.IN_PROGRESS { color: var(--s-progress); background: #FEF6E9; }
.badge.WAITING { color: var(--s-waiting); background: #F4EFFE; }
.badge.CLOSED { color: var(--s-closed); background: #E9F7F1; }
.prio { font-size: 12px; font-weight: 700; letter-spacing: .03em; }
.prio.LOW { color: var(--p-low); } .prio.MEDIUM { color: var(--p-medium); }
.prio.HIGH { color: var(--p-high); } .prio.CRITICAL { color: var(--p-critical); }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px;
  font-weight: 600; color: #fff; margin-right: 4px; }
.cat-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.cat-chip i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

.sla-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 6px;
  font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sla-ok { background: #E9F7F1; color: #047857; }
.sla-warn { background: #FEF6E9; color: #B45309; }
.sla-over { background: #FEF2F2; color: #B91C1C; }

/* filtry */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filters select, .filters input[type=search] { padding: 8px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; font-size: 13.5px; font-family: inherit; color: var(--text); }
.filters input[type=search] { min-width: 220px; flex: 1; max-width: 340px; }

/* paginacja */
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px;
  color: var(--muted); font-size: 13px; }
.pager .btns { display: flex; gap: 6px; }

/* ── Dashboard ─────────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { padding: 16px 18px; }
.kpi .label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.kpi .value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums;
  color: var(--ink); margin-top: 2px; }
.kpi .value small { font-size: 14px; font-weight: 600; color: var(--muted); }
.kpi.alert .value { color: var(--danger); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.chart-title { font-size: 13px; font-weight: 700; margin: 0 0 14px; }
.bars .bar-row { display: grid; grid-template-columns: 120px 1fr 36px; gap: 10px; align-items: center;
  margin-bottom: 9px; font-size: 13px; }
.bars .bar-row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.bars .track { height: 9px; background: #F1EEE6; border-radius: 5px; overflow: hidden; }
.bars .fill { height: 100%; border-radius: 5px; }
.bars .num { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.spark { display: flex; align-items: flex-end; gap: 4px; height: 110px; padding-top: 8px; }
.spark .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.spark .stick { width: 100%; max-width: 26px; background: var(--ink); border-radius: 4px 4px 0 0; min-height: 3px; }
.spark .d { font-size: 9.5px; color: #A8A29E; }

/* ── Szczegóły ticketu ─────────────────────────────────────────────── */
.ticket-grid { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }
.timeline-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid #F1EEE6; }
.timeline-item:last-child { border-bottom: none; }
.timeline-item .body { flex: 1; min-width: 0; }
.timeline-item .meta { font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
.timeline-item .meta b { color: var(--text); }
.timeline-item .text { white-space: pre-wrap; word-wrap: break-word; }
.hist-entry { font-size: 12.5px; color: var(--muted); padding: 5px 0 5px 42px; }
.side-block { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.side-block:last-child { border-bottom: none; }
.side-block .lbl { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 6px; }
.side-block select { width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; font-family: inherit; font-size: 13.5px; }
.attach-item { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 5px 0; }
.attach-item span.size { color: var(--muted); font-size: 12px; }
.tag-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pick .tg { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; cursor: pointer;
  border: 1.5px solid var(--line); background: #fff; color: var(--muted); }
.tag-pick .tg.on { color: #fff; border-color: transparent; }
.comment-box { margin-top: 14px; }
.comment-box textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  min-height: 84px; font-family: inherit; font-size: 14px; resize: vertical; }
.comment-box .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ── Modal ─────────────────────────────────────────────────────────── */
.modal-back { position: fixed; inset: 0; background: rgba(15,26,46,.55); z-index: 100;
  display: grid; place-items: center; padding: 20px; }
.modal { width: 100%; max-width: 480px; background: #fff; border-radius: 14px; padding: 22px 24px;
  box-shadow: 0 30px 80px rgba(0,0,0,.35); max-height: 90vh; overflow-y: auto; }
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ── Toasty ────────────────────────────────────────────────────────── */
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex;
  flex-direction: column; gap: 8px; max-width: 340px; }
.toast { background: var(--ink); color: #fff; border-radius: 10px; padding: 11px 14px; font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(0,0,0,.3); border-left: 3px solid var(--gold); animation: slide .18s ease-out; }
.toast b { display: block; }
.toast.err { border-left-color: var(--danger); }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.muted { color: var(--muted); }
.mb0 { margin-bottom: 0; }

/* ── Mobile ────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 90;
    transform: translateX(-100%); transition: transform .18s ease; height: 100dvh; }
  .sidebar.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.4); }
  .side-scrim { position: fixed; inset: 0; background: rgba(15,26,46,.45); z-index: 80; }
  .hamburger { display: grid; place-items: center; width: 36px; height: 36px; background: #fff;
    border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 14px 70px; }
  .ticket-grid { grid-template-columns: 1fr; }
  .notif-panel { right: 12px; }
  table.list .hide-m { display: none; }
}
