:root {
  --green: #16a34a; --green-d: #15803d; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --bg: #f8fafc; --card: #ffffff; --red: #dc2626; --radius: 10px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green-d); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; font-size: .85em; }

/* przyciski i pola */
.btn { display: inline-flex; align-items: center; gap: .35em; padding: .5em .9em; border: 1px solid var(--line); background: var(--card);
  border-radius: 8px; cursor: pointer; text-decoration: none; color: var(--ink); font-size: .9rem; white-space: nowrap; }
.btn:hover { border-color: #cbd5e1; background: #f1f5f9; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--green-d); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: #f1f5f9; }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; justify-content: center; }
.btn.icon { padding: .35em .6em; }
input, select, textarea { width: 100%; padding: .5em .65em; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bbf7d0; border-color: var(--green); }
label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .55rem; }
label > input, label > select, label > textarea { margin-top: .25rem; color: var(--ink); font-size: .92rem; }
label.check { display: inline-flex; align-items: center; gap: .4em; margin: 0 .8em .3em 0; color: var(--ink); cursor: pointer; }
label.check input { width: auto; margin: 0; accent-color: var(--green); }
.row { display: flex; gap: .6rem; }
.row > * { flex: 1; min-width: 0; }
.row > .narrow { flex: 0 0 30%; }
.inline { display: inline; margin: 0; }

/* marka */
.brand { font-weight: 600; font-size: 1.05rem; display: flex; align-items: center; gap: .4em; white-space: nowrap; }
.brand b { color: var(--green); }
.brand-mark { display: inline-grid; place-items: center; width: 26px; height: 26px; background: var(--green); color: #fff; border-radius: 7px; font-size: .9rem; }
.brand-tag { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px; }

/* logowanie */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(circle at 20% 10%, #dcfce7 0, transparent 45%), radial-gradient(circle at 90% 90%, #e0f2fe 0, transparent 40%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--card); padding: 32px 28px; border-radius: 16px; box-shadow: 0 20px 50px -20px rgba(15, 23, 42, .25); border: 1px solid var(--line); }
.login-card h1 { margin: 1.4rem 0 .2rem; font-size: 1.5rem; }
.login-card .muted { margin: 0 0 1.4rem; }
.login-card .btn { margin-top: .6rem; padding: .75em; }
.alert { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; padding: .6em .8em; border-radius: 8px; font-size: .9rem; }

/* aplikacja */
body.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: .55rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.stats { display: flex; gap: 1.1rem; font-size: .85rem; color: var(--muted); flex: 1; flex-wrap: wrap; }
.stats b { color: var(--ink); }
.top-actions { display: flex; gap: .3rem; flex-wrap: wrap; }
.layout { flex: 1; display: flex; min-height: 0; position: relative; }
.sidebar { width: 360px; flex-shrink: 0; display: flex; flex-direction: column; background: var(--card); border-right: 1px solid var(--line); min-height: 0; }
.filters { padding: .8rem; border-bottom: 1px solid var(--line); display: grid; gap: .5rem; }
.filters select, .filters input { font-size: .85rem; padding: .42em .55em; }
.filters .row.small { align-items: center; flex-wrap: wrap; gap: 0; }
.filters .row.small > * { flex: 0 0 auto; }
.filters #colorBy { width: auto; margin-left: .5em; }
.list-head { display: flex; justify-content: space-between; align-items: baseline; padding: .55rem .9rem; font-size: .85rem; font-weight: 600; border-bottom: 1px solid var(--line); }
.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.list li { padding: .65rem .9rem; border-bottom: 1px solid #f1f5f9; cursor: pointer; }
.list li:hover { background: #f8fafc; }
.list li.active { background: #f0fdf4; box-shadow: inset 3px 0 0 var(--green); }
.list li.empty { cursor: default; color: var(--muted); font-size: .9rem; padding: 1.5rem .9rem; }
.li-top { display: flex; align-items: center; gap: .45em; font-size: .92rem; }
.li-top b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-sub { font-size: .8rem; color: var(--muted); margin: .15rem 0 .35rem 1.15em; }
.li-tags { display: flex; gap: .3rem; flex-wrap: wrap; margin-left: 1.15em; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.hot { margin-left: auto; }
.tag { --c: #94a3b8; font-size: .72rem; padding: 1px 7px; border-radius: 99px; color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, white); border: 1px solid color-mix(in srgb, var(--c) 35%, white); }

.map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }
.legend { position: absolute; left: 10px; bottom: 22px; z-index: 500; background: rgba(255, 255, 255, .95); border: 1px solid var(--line);
  border-radius: 8px; padding: .45rem .6rem; font-size: .75rem; display: flex; flex-wrap: wrap; gap: .2rem .8rem; max-width: 70%; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .35em; }

.detail { width: 400px; flex-shrink: 0; background: var(--card); border-left: 1px solid var(--line); overflow-y: auto; }
.detail-form { padding: 1rem 1rem 0; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.detail-head h2 { margin: 0; font-size: 1.15rem; line-height: 1.3; }
.detail .muted.small { margin: .3rem 0 .8rem; }
.box { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; margin-bottom: .8rem; }
.box h3 { margin: 0 0 .6rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.bdo-box { background: #fbfefc; border-color: #bbf7d0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; margin-bottom: .7rem; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { --c: #94a3b8; display: block; text-align: center; padding: .45em; border: 1px solid var(--line); border-radius: 8px; font-size: .82rem; color: var(--ink); cursor: pointer; }
.seg input:checked + span { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, white); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--green); }
.quick { display: flex; gap: .35rem; flex-wrap: wrap; }
.detail-actions { position: sticky; bottom: 0; background: var(--card); display: flex; justify-content: space-between; gap: .5rem; padding: .7rem 0 1rem; border-top: 1px solid var(--line); }
.detail-actions .primary { margin-left: auto; }

/* modale */
.modal { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 30px 70px -20px rgba(15, 23, 42, .4); }
.modal::backdrop { background: rgba(15, 23, 42, .45); }
.modal-card { padding: 1.4rem; max-height: 85vh; overflow-y: auto; }
.modal-card h2 { margin: 0 0 .4rem; font-size: 1.2rem; }
.modal-card h3 { margin: .2rem 0 .3rem; font-size: 1rem; }
.cats { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; margin: 0 0 .8rem; display: grid; grid-template-columns: 1fr 1fr; gap: .25rem; }
.cats legend { font-size: .8rem; color: var(--muted); padding: 0 .3rem; }
.cats .dot { margin-right: .1em; }
.modal-actions { display: flex; justify-content: flex-end; gap: .4rem; margin-top: 1rem; flex-wrap: wrap; }
.jobs .job { font-size: .88rem; padding: .45rem .6rem; border-radius: 8px; background: #f8fafc; margin-bottom: .35rem; border-left: 3px solid #94a3b8; }
.jobs .job.running, .jobs .job.queued { border-color: #f59e0b; }
.jobs .job.done { border-color: var(--green); }
.jobs .job.error { border-color: var(--red); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
.info { padding-left: 1.1rem; font-size: .9rem; line-height: 1.5; }
.info li { margin-bottom: .5rem; }
.clause { font-size: .82rem; background: #f8fafc; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 2000; padding: .65em 1.1em; border-radius: 10px;
  background: var(--ink); color: #fff; font-size: .9rem; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4); max-width: calc(100vw - 32px); }
.toast.err { background: var(--red); }

/* telefon */
@media (max-width: 900px) {
  body.app { height: auto; overflow: auto; }
  .topbar { gap: .5rem; }
  .stats { order: 3; flex-basis: 100%; gap: .8rem; }
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: 0; max-height: none; }
  .list { max-height: 45vh; }
  .map-wrap { height: 60vh; flex: none; }
  .detail { position: fixed; inset: 0; width: 100%; z-index: 1000; border: 0; }
  .legend { max-width: calc(100% - 20px); }
}
