:root {
  --bg: #eef4ff;
  --panel: #ffffff;
  --sidebar: #ffffff;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #e7f0ff;
  --primary-softer: #f3f8ff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e3eaf5;
  --border-strong: #cdd9ee;
  --danger: #dc2626;
  --ok: #16a34a;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 14px rgba(37,99,235,.06);
  --radius: 12px;
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- LOGIN ---------- */
.login-wrap {
  height: 100%; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #dbe8ff 0%, var(--bg) 60%);
}
.login-card {
  width: 360px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 18px; padding: 32px; box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .sub { color: var(--muted); margin-bottom: 24px; font-size: 13px; }
.login-card label { display:block; font-size:12px; font-weight:600; color:var(--muted); margin:14px 0 5px; text-transform:uppercase; letter-spacing:.04em;}
.login-card input { width: 100%; padding: 11px 12px; border:1px solid var(--border-strong); border-radius:10px; }
.login-err { color: var(--danger); font-size: 13px; margin-top: 12px; }

/* ---------- LAYOUT ---------- */
.layout { display: grid; grid-template-columns: 252px 1fr; height: 100%; }
.sidebar {
  background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto;
}
.brand { padding: 20px 18px 14px; display:flex; align-items:center; gap:10px; }
.brand .logo { width:34px;height:34px;border-radius:9px;background:linear-gradient(135deg,var(--primary),#60a5fa);
  display:flex;align-items:center;justify-content:center;color:#fff;font-weight:800;font-size:17px; box-shadow:0 4px 10px rgba(37,99,235,.3);}
.brand .name { font-weight:800; font-size:15px; line-height:1.1; }
.brand .name small { display:block; font-weight:600; color:var(--muted); font-size:11px; }
.nav { padding: 6px 10px; flex: 1; }
.nav-label { font-size:10.5px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.07em; padding: 14px 10px 6px; }
.nav-item {
  display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:9px;
  color:var(--text); cursor:pointer; font-weight:600; font-size:13.5px; margin-bottom:2px; border:1px solid transparent;
}
.nav-item:hover { background: var(--primary-softer); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-dark); border-color:#d4e3ff; }
.nav-item .ico { width:18px; text-align:center; opacity:.9; }
.nav-item .badge {
  margin-left:auto; background:var(--primary); color:#fff; font-size:11px; font-weight:700;
  min-width:20px; height:20px; padding:0 6px; border-radius:10px; display:flex; align-items:center; justify-content:center;
}
.nav-item.active .badge { background: var(--primary-dark); }
.nav-item .nav-badges { margin-left:auto; display:flex; gap:6px; align-items:center; }
.nav-item .nav-badges .badge { margin-left:0; }
.nav-item .badge.orange { background:#f59e0b; }
.nav-item.active .badge.orange { background:#d97706; }
.nav-divider { height:1px; background:var(--border); margin:8px 10px; }
.sidebar-foot { border-top:1px solid var(--border); padding:12px 14px; display:flex; align-items:center; gap:10px; }
.avatar { width:32px;height:32px;border-radius:50%;background:var(--primary-soft);color:var(--primary-dark);
  display:flex;align-items:center;justify-content:center;font-weight:800; }
.sidebar-foot .u-name { font-weight:700; font-size:13px; }
.sidebar-foot .u-role { font-size:11px; color:var(--muted); }
.logout-btn { margin-left:auto; background:none;border:1px solid var(--border-strong);border-radius:8px;padding:6px 9px;color:var(--muted);}
.logout-btn:hover { color:var(--danger); border-color:#f3c0c0; }

/* ---------- MAIN ---------- */
.main { display:flex; flex-direction:column; overflow:hidden; }
.topbar { display:flex; align-items:center; gap:12px; padding:16px 22px; border-bottom:1px solid var(--border); background:var(--panel); }
.topbar h2 { margin:0; font-size:19px; font-weight:800; }
.topbar .count-pill { background:var(--primary-soft); color:var(--primary-dark); font-weight:700; font-size:12px; padding:3px 9px; border-radius:8px; }
.spacer { flex:1; }
.search { position:relative; }
.search input { width:230px; padding:9px 12px 9px 32px; border:1px solid var(--border-strong); border-radius:10px; background:var(--panel);}
.search .si { position:absolute; left:10px; top:50%; transform:translateY(-50%); opacity:.5; }
.flt { padding:9px 10px; border:1px solid var(--border-strong); border-radius:10px; background:var(--panel); color:var(--text); }
.btn { padding:9px 15px; border-radius:10px; border:1px solid var(--border-strong); background:var(--panel); font-weight:700; color:var(--text); }
.btn:hover { border-color:var(--primary); color:var(--primary); }
.btn-primary { background:var(--primary); color:#fff; border-color:var(--primary); box-shadow:0 4px 12px rgba(37,99,235,.25);}
.btn-primary:hover { background:var(--primary-dark); color:#fff; }
.btn-ghost { background:none; border:none; color:var(--muted); padding:7px; }
.btn-sm { padding:6px 10px; font-size:12.5px; }

.content { flex:1; overflow:auto; padding:22px; }
.card { background:var(--panel); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); overflow:hidden; }

/* ---------- TABLE ---------- */
table.grid { width:100%; border-collapse:collapse; }
table.grid th { text-align:left; font-size:11.5px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted);
  font-weight:700; padding:11px 14px; border-bottom:1px solid var(--border); background:var(--primary-softer); white-space:nowrap; position:sticky; top:0; }
table.grid td { padding:11px 14px; border-bottom:1px solid var(--border); vertical-align:top; }
table.grid tr:hover td { background:var(--primary-softer); }
table.grid tr { cursor:pointer; }
table.grid.compact th { padding:6px 12px; }
table.grid.compact td { padding:5px 12px; vertical-align:middle; }
table.grid th.col-note, table.grid td.col-note { background:#fff6e6; }
table.grid th.th-filter { white-space:nowrap; }
.funnel { background:none; border:none; cursor:pointer; padding:0; margin-left:6px; color:var(--muted); vertical-align:middle; line-height:0; }
.funnel:hover { color:var(--text); }
.funnel.active { color:#f59e0b; }
.filter-pop { position:absolute; top:100%; left:0; margin-top:4px; background:#fff; border:1px solid var(--border); border-radius:10px; box-shadow:0 12px 32px rgba(15,23,42,.20); min-width:180px; max-height:280px; overflow:auto; z-index:30; padding:4px; text-transform:none; letter-spacing:normal; }
.fp-item { padding:7px 10px; border-radius:7px; cursor:pointer; font-size:13px; font-weight:500; color:var(--text); }
.fp-item:hover { background:var(--primary-softer); }
.fp-item.sel { background:var(--primary-softer); font-weight:700; }
table.grid td.col-note { max-width:200px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.bulk-area { width:100%; min-height:150px; font-family:ui-monospace,Menlo,Consolas,monospace; font-size:13px; line-height:1.5; }
.bulk-prev { max-height:46vh; overflow:auto; border:1px solid var(--border); border-radius:10px; }
.bulk-prev table { width:100%; border-collapse:collapse; }
.bulk-prev th { position:sticky; top:0; background:var(--primary-softer); font-size:11px; text-transform:uppercase; letter-spacing:.03em; color:var(--muted); font-weight:700; text-align:left; padding:7px 10px; }
.bulk-prev td { padding:4px 10px; border-top:1px solid var(--border); vertical-align:middle; font-size:13px; }
.bulk-prev input { width:100%; padding:5px 8px; border:1px solid var(--border-strong); border-radius:7px; }
.bulk-prev .bad { color:var(--danger); }
.bulk-prev a { color:var(--primary); text-decoration:none; }
.td-opis { max-width:340px; color:var(--text); }
.td-mut { color:var(--muted); }
.chip { display:inline-flex; align-items:center; gap:6px; padding:3px 10px; border-radius:20px; font-size:12px; font-weight:700; white-space:nowrap; }
.chip .dot { width:7px; height:7px; border-radius:50%; }
.row-actions { display:flex; gap:6px; opacity:0; }
table.grid tr:hover .row-actions { opacity:1; }
.empty { text-align:center; padding:60px 20px; color:var(--muted); }
.empty .big { font-size:34px; margin-bottom:8px; }
.link { color:var(--primary); text-decoration:none; font-weight:600; }
.link:hover { text-decoration:underline; }

/* ---------- MODAL ---------- */
.overlay { position:fixed; inset:0; background:rgba(15,23,42,.45); display:flex; align-items:flex-start; justify-content:center; z-index:50; padding:28px 16px; overflow:auto;}
.modal { background:var(--panel); border-radius:16px; width:760px; max-width:100%; max-height:calc(100vh - 56px); display:flex; flex-direction:column; box-shadow:0 20px 60px rgba(15,23,42,.3); }
.modal.wide { width:1080px; }
.modal.full { width:1180px; max-width:96vw; height:88vh; max-height:88vh; }
.tk-2col { display:flex; flex:1; min-height:0; }
.modal.full .tk-left { flex:1; min-width:0; overflow:auto; }
.modal.full .tk-right { width:380px; flex:none; border-left:1px solid var(--border); background:#fbfcfd; display:flex; flex-direction:column; min-height:0; }
.disc-flag { margin-left:12px; font-size:12px; font-weight:700; color:#b45309; background:#fff6e6; border:1px solid #f6d98a; border-radius:999px; padding:3px 10px; }
.disc { display:flex; flex-direction:column; height:100%; min-height:0; }
.disc-head { padding:12px 16px; border-bottom:1px solid var(--border); flex:none; }
.disc-state { font-size:11px; font-weight:700; border-radius:999px; padding:2px 8px; margin-left:4px; }
.disc-state.open { background:#dcfce7; color:#15803d; }
.disc-state.closed { background:#e2e8f0; color:#475569; }
.disc-empty { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; padding:24px; }
.disc-empty .big { font-size:40px; margin-bottom:8px; }
.disc-empty p { margin:0 0 14px; color:var(--muted); }
.disc-msgs { flex:1; overflow:auto; padding:14px 16px; display:flex; flex-direction:column; gap:10px; }
.msg { max-width:88%; align-self:flex-start; background:#fff; border:1px solid var(--border); border-radius:12px; padding:8px 11px; }
.msg.mine { align-self:flex-end; background:var(--primary-softer); border-color:#cfe1f7; }
.msg .meta { font-size:11px; color:var(--muted); margin-bottom:3px; }
.msg .txt { font-size:13.5px; white-space:pre-wrap; word-break:break-word; }
.disc-input { flex:none; border-top:1px solid var(--border); padding:10px 12px; display:flex; gap:8px; align-items:flex-end; }
.disc-input textarea { flex:1; min-height:42px; max-height:120px; resize:vertical; padding:8px 10px; border:1px solid var(--border-strong); border-radius:10px; font:inherit; }
.disc-input.closed { justify-content:center; color:var(--muted); }
@media (max-width:900px){ .modal.full { height:92vh; max-height:92vh; } .tk-2col { flex-direction:column; } .modal.full .tk-right { width:auto; border-left:none; border-top:1px solid var(--border); min-height:320px; } }
.modal-head { display:flex; align-items:center; padding:18px 24px; border-bottom:1px solid var(--border); flex:none; }
.modal-head h3 { margin:0; font-size:18px; font-weight:800; }
.modal-body { padding:22px 24px; overflow-y:auto; flex:1 1 auto; }
.modal-foot { padding:16px 24px; border-top:1px solid var(--border); display:flex; gap:10px; justify-content:flex-end; flex:none; background:var(--panel); border-radius:0 0 16px 16px; }
.grid2 { display:grid; grid-template-columns:1fr 1fr; gap:14px 18px; }
.grid3 { display:grid; grid-template-columns:1fr 1fr 1fr; gap:14px 18px; }
.field { display:flex; flex-direction:column; gap:5px; }
.field.full { grid-column:1 / -1; }
.field label { font-size:11.5px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.03em; }
.field input, .field select, .field textarea { padding:9px 11px; border:1px solid var(--border-strong); border-radius:9px; background:var(--panel); width:100%; }
.field textarea { resize:vertical; min-height:74px; }
.field input:focus, .field select:focus, .field textarea:focus { outline:none; border-color:var(--primary); box-shadow:0 0 0 3px var(--primary-soft); }

/* ---------- DASHBOARD ---------- */
.stats { display:grid; grid-template-columns:repeat(auto-fill,minmax(170px,1fr)); gap:14px; margin-bottom:20px; }
.stat { background:var(--panel); border:1px solid var(--border); border-radius:var(--radius); padding:16px 18px; box-shadow:var(--shadow); }
.stat .k { font-size:12px; color:var(--muted); font-weight:600; }
.stat .v { font-size:28px; font-weight:800; margin-top:4px; }
.stat .v.warn { color:#d97706; }
.stat .v.ok { color:var(--ok); }
.bar-row { display:flex; align-items:center; gap:12px; padding:9px 0; }
.bar-row .lbl { width:120px; font-weight:600; font-size:13px; }
.bar-track { flex:1; height:10px; background:var(--primary-softer); border-radius:6px; overflow:hidden; }
.bar-fill { height:100%; background:linear-gradient(90deg,var(--primary),#60a5fa); }
.bar-row .num { width:46px; text-align:right; color:var(--muted); font-weight:700; font-size:13px; }

/* ---------- SETTINGS ---------- */
.tabs { display:flex; gap:6px; margin-bottom:18px; flex-wrap:wrap; }
.tab { padding:9px 15px; border-radius:10px; border:1px solid var(--border); background:var(--panel); font-weight:700; color:var(--muted); }
.ticket-tabs { margin-bottom:14px; }
.tab-count { display:inline-block; min-width:20px; text-align:center; padding:1px 7px; margin-left:6px; border-radius:999px; background:var(--border); color:var(--muted); font-size:12px; }
.tab.active .tab-count { background:rgba(255,255,255,.28); color:#fff; }
.ok-tag { display:inline-flex; align-items:center; gap:4px; padding:2px 9px; border-radius:999px; background:#e7f6ec; color:#16a34a; font-weight:700; font-size:12.5px; }
.check-row { display:inline-flex; align-items:center; gap:9px; cursor:pointer; font-weight:600; }
.check-row input { width:18px; height:18px; cursor:pointer; }
.tab.active { background:var(--primary); color:#fff; border-color:var(--primary); }
.list-row { display:flex; align-items:center; gap:12px; padding:12px 16px; border-bottom:1px solid var(--border); }
.list-row:last-child { border-bottom:none; }
.toast { position:fixed; bottom:22px; left:50%; transform:translateX(-50%); background:#0f172a; color:#fff; padding:11px 18px; border-radius:10px; font-weight:600; box-shadow:0 8px 24px rgba(0,0,0,.25); z-index:100; }
.color-dot { width:14px;height:14px;border-radius:4px;display:inline-block; }
.muted-note { color:var(--muted); font-size:12.5px; margin-top:10px; }
.og-card { padding:18px 20px; }
.og-card .check-row { display:flex; }
.og-card .check-row > span { min-width:0; overflow-wrap:anywhere; }
.og-card .muted-note { overflow-wrap:anywhere; }

/* ---------- KOMUNIKACJA / ZDJĘCIA / WSKAŹNIKI ---------- */
.id-wrap { display:inline-flex; align-items:center; }
.comm-dot { width:9px; height:9px; border-radius:50%; display:inline-block; margin-right:8px; box-shadow:0 0 0 3px rgba(2,6,23,.04); flex:none; }
.mini-badges { display:inline-flex; gap:7px; margin-left:9px; color:var(--muted); font-size:11px; font-weight:700; }
.mini-badges span { display:inline-flex; align-items:center; gap:2px; }
.btn-icon { background:var(--panel); border:1px solid var(--border-strong); border-radius:8px; padding:5px 9px; color:var(--muted); font-size:14px; line-height:1; }
.btn-icon:hover { color:var(--primary); border-color:var(--primary); }
.btn-icon.reply:hover { color:#16a34a; border-color:#16a34a; background:#f3fbf5; }

.field.hl-odp textarea { border-color:#8ccfa3; background:#f4fbf6; }
.field.hl-odp textarea:focus { border-color:#16a34a; box-shadow:0 0 0 3px #d7f3df; }
.field.hl-odp label { color:#16a34a; }
.field.hl-uwagi textarea { border-color:#f0c889; background:#fffaf1; }
.field.hl-uwagi textarea:focus { border-color:#f59e0b; box-shadow:0 0 0 3px #fdecc8; }
.field.hl-uwagi label { color:#d97706; }

.thread-wrap { border:1px solid #d4e3ff; border-radius:12px; background:var(--primary-softer); padding:13px 14px; margin-bottom:18px; }
.thread-title { font-weight:800; font-size:13px; margin-bottom:9px; display:flex; align-items:center; gap:8px; }
.thread { display:flex; flex-direction:column; gap:8px; max-height:240px; overflow:auto; }
.thread-empty { color:var(--muted); font-size:13px; padding:4px 2px; }
.msg { background:#fff; border:1px solid var(--border); border-radius:10px; padding:8px 11px; }
.msg .meta { font-size:11px; color:var(--muted); margin-bottom:3px; font-weight:700; }
.msg .body { white-space:pre-wrap; line-height:1.4; }
.reply-box { display:flex; gap:8px; margin-top:11px; align-items:flex-end; }
.reply-box textarea { flex:1; min-height:44px; padding:9px 11px; border:1px solid var(--border-strong); border-radius:9px; resize:vertical; font-family:inherit; font-size:14px; }
.reply-box textarea:focus { outline:none; border-color:var(--primary); box-shadow:0 0 0 3px var(--primary-soft); }

.section-label { font-size:11.5px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.03em; margin:6px 0 9px; }
.photos { display:flex; flex-wrap:wrap; gap:10px; }
.thumb { position:relative; width:86px; height:86px; border-radius:10px; overflow:hidden; border:1px solid var(--border-strong); background:#f1f5f9; }
.thumb img { width:100%; height:100%; object-fit:cover; display:block; }
.thumb .del { position:absolute; top:3px; right:3px; background:rgba(15,23,42,.72); color:#fff; border:none; border-radius:6px; width:20px; height:20px; cursor:pointer; font-size:11px; line-height:1; }
.thumb-add { width:86px; height:86px; border:2px dashed var(--border-strong); border-radius:10px; display:flex; flex-direction:column; align-items:center; justify-content:center; color:var(--muted); cursor:pointer; font-size:12px; gap:2px; }
.thumb-add:hover { border-color:var(--primary); color:var(--primary); background:var(--primary-softer); }
.thumb-add .plus { font-size:22px; line-height:1; }
.drive-box { margin-top:14px; }
.pdf-box { margin-top:14px; }
.pdf-row { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.pdf-name { font-weight:600; font-size:13.5px; }
/* Kompaktowa karta zgłoszenia — żeby zmieściło się bez przewijania */
.tk-modal .modal-body { padding:14px 20px; }
.tk-modal .grid2, .tk-modal .grid3 { gap:9px 14px; }
.tk-modal .field { gap:3px; }
.tk-modal .field label { font-size:11px; }
.tk-modal .field input, .tk-modal .field select, .tk-modal .field textarea { padding:6px 10px; }
.tk-modal .field textarea { min-height:46px; }
.tk-modal .section-label { margin-bottom:5px; }
.tk-modal .drive-box, .tk-modal .pdf-box { margin-top:10px; }
.tk-modal .photos .thumb, .tk-modal .thumb-add { width:64px; height:64px; }
.tk-modal .grid2[style] { margin-top:10px !important; }
.field-link { display:inline-flex; align-items:center; gap:6px; margin-top:7px; font-size:13px; font-weight:600; color:#16a34a; text-decoration:none; }
.field-link:hover { text-decoration:underline; }
.mini-badges a { text-decoration:none; color:inherit; }
.mini-badges a:hover { color:var(--primary); }
