/* Spot Sniper – ciemny motyw „lunety”: czerwony celownik, zielone trafienia, bursztynowe ostrzeżenia. */
:root {
  --bg: #070b10;
  --bg-2: #0c1219;
  --panel: #101820;
  --panel-2: #152029;
  --line: #22303d;
  --line-2: #2c3d4d;
  --text: #e6edf3;
  --muted: #8d9bab;
  --faint: #5c6b7b;
  --reticle: #ff3b30;
  --reticle-soft: rgba(255, 59, 48, .14);
  --hit: #2fd07a;
  --hit-soft: rgba(47, 208, 122, .13);
  --amber: #ffb020;
  --amber-soft: rgba(255, 176, 32, .13);
  --steel: #5aa7ff;
  --steel-soft: rgba(90, 167, 255, .13);
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 50% -10%, #122130 0%, transparent 60%),
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px) 0 0 / 44px 44px,
    var(--bg);
  min-height: 100vh;
}
a { color: var(--steel); }
a:hover { color: #8cc3ff; }
main { padding: 20px 28px 64px; max-width: 1560px; margin: 0 auto; }
h1 { font-size: 22px; margin: 6px 0 18px; letter-spacing: .3px; display: flex; align-items: center; gap: 10px; }
h2 { font-size: 16px; margin: 20px 0 10px; color: #cfd8e2; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono, .countdown { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.kicker { font-size: 11px; letter-spacing: 2.4px; text-transform: uppercase; color: var(--faint); font-weight: 700; }

/* --- Nagłówek ---------------------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  padding: 10px 28px; background: rgba(7, 11, 16, .92); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(6px);
}
.topbar.is-live { box-shadow: inset 0 -2px 0 var(--reticle); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand svg { width: 30px; height: 30px; }
.brand b { font-size: 15px; letter-spacing: 3.5px; }
.brand span { display: block; font-size: 10px; letter-spacing: 2px; color: var(--faint); margin-top: -3px; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px; }
.topbar nav a {
  color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px;
  font-size: 13px; letter-spacing: .6px; text-transform: uppercase; font-weight: 600;
}
.topbar nav a:hover { color: var(--text); background: var(--panel-2); }
.topbar nav a.active { color: var(--text); box-shadow: inset 0 -2px 0 var(--reticle); border-radius: 6px 6px 0 0; }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.who a { color: var(--muted); }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; font: inherit; }

/* --- Pasek stanu ------------------------------------------------------------------------- */
.statusbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px 28px; background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.statusbar .spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .4px; border: 1px solid var(--line-2); color: var(--muted);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip-dry { color: var(--steel); background: var(--steel-soft); border-color: rgba(90,167,255,.35); }
.chip-live { color: #fff; background: var(--reticle); border-color: var(--reticle); }
.chip-live::before { background: #fff; animation: blink 1.2s steps(2, start) infinite; }
.chip-ok { color: var(--hit); background: var(--hit-soft); border-color: rgba(47,208,122,.35); }
.chip-alarm { color: #fff; background: #b3261e; border-color: #b3261e; }
.chip-neutral { color: var(--muted); }
.ceasefire {
  display: flex; align-items: center; gap: 14px; justify-content: center; flex-wrap: wrap;
  padding: 9px 28px; font-weight: 800; letter-spacing: 1.5px; font-size: 13px; color: #fff;
  background: repeating-linear-gradient(135deg, #8e1510 0 18px, #5c0d09 18px 36px);
  border-bottom: 1px solid #ff3b30;
}

/* --- Przyciski i formularze -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 7px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
  cursor: pointer; text-decoration: none; font: 600 14px/1.2 inherit; font-family: inherit;
}
.btn:hover { border-color: #3d5266; background: #1b2833; color: var(--text); }
.btn svg { width: 16px; height: 16px; }
svg.ico { width: 16px; height: 16px; flex: none; }
h1 svg.ico { width: 24px; height: 24px; color: var(--reticle); }
.btn-fire { background: var(--reticle); border-color: var(--reticle); color: #fff; }
.btn-fire:hover { background: #ff5a50; border-color: #ff5a50; color: #fff; }
.btn-danger { background: #b3261e; border-color: #b3261e; color: #fff; }
.btn-danger:hover { background: #cf2e25; color: #fff; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn-kill {
  background: #b3261e; border: 1px solid #ff3b30; color: #fff; padding: 6px 14px; border-radius: 7px;
  cursor: pointer; font-weight: 800; letter-spacing: 1.2px; font-size: 12px; line-height: 1.15; text-align: left;
}
.btn-kill small { display: block; font-size: 9px; letter-spacing: 1.8px; opacity: .8; font-weight: 700; }
.btn-kill:hover { background: #d32f25; }
form.inline { display: inline; }
input, select, textarea {
  background: #0b1117; color: var(--text); border: 1px solid var(--line-2); border-radius: 7px;
  padding: 8px 10px; font: 15px/1.3 inherit; font-family: inherit;
}
input:focus, select:focus { outline: 2px solid rgba(255,59,48,.55); outline-offset: 1px; border-color: transparent; }
input[type=checkbox], input[type=radio] { accent-color: var(--reticle); width: 16px; height: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; }
.hint { font-weight: normal; font-size: 13px; color: var(--muted); }
.check { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 7px; font-weight: normal !important; margin-right: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px 12px; }
legend { font-size: 11px; color: var(--faint); letter-spacing: 1.6px; text-transform: uppercase; padding: 0 4px; }

/* --- Karty i komunikaty ------------------------------------------------------------------ */
fieldset .hint { display: block; margin-top: 6px; }
.dash > *, .card { min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.card h2:first-child { margin-top: 0; }
.narrow { max-width: 460px; }
.flash { padding: 11px 15px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.flash-ok { background: var(--hit-soft); color: #9ff0c4; border-color: rgba(47,208,122,.35); }
.flash-error { background: rgba(255,59,48,.12); color: #ffb3ad; border-color: rgba(255,59,48,.45); font-weight: 600; }
.flash-info { background: var(--steel-soft); color: #b7d8ff; border-color: rgba(90,167,255,.35); }
.flash-warn { background: var(--amber-soft); color: #ffd98a; border-color: rgba(255,176,32,.4); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; background: var(--panel); padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: -6px 0 16px; }

/* --- Tabele ------------------------------------------------------------------------------ */
table.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
table.grid th, table.grid td { padding: 9px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.grid th { background: var(--panel-2); font-size: 11px; color: var(--faint); font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; }
table.grid tbody tr:hover td { background: #131e28; }
table.grid tr:last-child td { border-bottom: 0; }
.targetable, .targetable * { cursor: crosshair; }
.targetable a, .targetable button, .targetable input, .targetable label { cursor: pointer; }
table.kv th { text-align: left; padding: 4px 18px 4px 0; color: var(--muted); font-weight: 600; }
table.kv td { padding: 4px 0; }
.row-error td { background: rgba(255,59,48,.06); }
.row-dry td { color: #b7d8ff; }
.error-text { color: #ff8a82; }
code { font-size: 12px; word-break: break-all; color: #aebbc8; font-family: var(--mono); }
pre.reason { white-space: pre-wrap; font: 13px/1.6 var(--mono); color: #cfd8e2; }
/* Małe „i” z wyjaśnieniem (np. dlaczego spotu nie da się pilnować) – klik rozwija, działa też na telefonie */
.why > summary { list-style: none; }
.why > summary, .why > summary * { cursor: pointer; }
.why > summary::-webkit-details-marker { display: none; }
.why-i { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; margin-left: 6px; border-radius: 50%; border: 1px solid rgba(90,167,255,.6); color: #9ccbff; font: 700 11px/1 var(--mono); vertical-align: middle; }
.why > summary:hover .why-i, .why[open] .why-i { background: var(--steel-soft); }
.why > div { margin-top: 8px; min-width: 260px; max-width: 340px; padding: 9px 11px; border: 1px solid rgba(90,167,255,.35); border-radius: 8px; background: var(--steel-soft); color: #cfe3ff; font-size: 13px; line-height: 1.45; }
.countdown { font-weight: 700; }
.countdown.soon { color: var(--reticle); }
.countdown.past { color: var(--faint); font-weight: normal; }

/* --- Statusy ----------------------------------------------------------------------------- */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #1b2631; color: var(--muted); border: 1px solid var(--line-2); white-space: nowrap; }
.pill-watched, .pill-safety_placed { background: var(--steel-soft); color: #9ccbff; border-color: rgba(90,167,255,.3); }
.pill-armed { background: var(--reticle-soft); color: #ff8a82; border-color: rgba(255,59,48,.45); }
.pill-final_sent, .pill-confirmed, .pill-skipped { background: var(--amber-soft); color: #ffd27a; border-color: rgba(255,176,32,.35); }
.pill-won { background: var(--hit-soft); color: #8ff0bb; border-color: rgba(47,208,122,.4); }
.pill-lost { background: #1b2631; color: #a9b6c3; }
.pill-failed, .pill-expired { background: rgba(255,59,48,.12); color: #ff9a93; border-color: rgba(255,59,48,.35); }
.pill-cancelled { background: #141c24; color: var(--faint); }
.hitmark { display: inline-flex; width: 18px; height: 18px; vertical-align: -4px; margin-right: 4px; }

/* --- Celownik (luneta) ------------------------------------------------------------------- */
.scope { position: relative; display: inline-grid; place-items: center; }
.scope svg { display: block; width: 100%; height: 100%; overflow: visible; }
.scope .ring-track { stroke: var(--line-2); }
.scope .ring { stroke: var(--steel); transition: stroke-dashoffset .25s linear, stroke .3s; }
.scope .cross { stroke: #d7e0e8; stroke-opacity: .55; }
.scope .ticks { stroke: #d7e0e8; stroke-opacity: .35; transform-origin: 50% 50%; }
.scope .dot { fill: var(--reticle); }
/* Odczyt „dalmierza” pod krzyżem – na ciemnym tle, żeby linie celownika nie zasłaniały cyfr. */
.scope .readout {
  position: absolute; left: 0; right: 0; top: 58%; display: flex; flex-direction: column;
  align-items: center; gap: 3px; pointer-events: none;
}
.scope .readout .countdown {
  font-size: clamp(18px, 2.4vw, 30px); color: var(--text); background: rgba(7, 11, 16, .9);
  padding: 1px 10px; border-radius: 6px; border: 1px solid var(--line);
}
.scope .readout .cap {
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); font-weight: 700;
  background: rgba(7, 11, 16, .85); padding: 0 6px; border-radius: 4px;
}
.scope.armed .readout .countdown { color: #fff; border-color: rgba(255,59,48,.6); box-shadow: 0 0 14px rgba(255,59,48,.35); }
.scope.lock .ring { stroke: var(--amber); }
.scope.armed .ring { stroke: var(--reticle); }
.scope.armed .ticks { animation: spin 40s linear infinite; }
.scope.armed .dot { animation: pulse 1s ease-in-out infinite; transform-origin: 50% 50%; transform-box: fill-box; }
.scope.fired .ring, .scope.done .ring { stroke: var(--faint); }
.scope.won .ring { stroke: var(--hit); }
.scope.won .dot { fill: var(--hit); }
.scope-hero { width: min(380px, 80vw); height: min(380px, 80vw); }
.scope-hero .readout .countdown { font-size: clamp(34px, 5vw, 52px); letter-spacing: 1px; }
.scope-mini { width: 118px; height: 118px; flex: none; }
.scope-mini .readout { top: 60%; }
.scope-mini .readout .countdown { font-size: 14px; padding: 0 6px; }
.scope-mini .readout .cap { font-size: 8.5px; letter-spacing: 1.4px; }

/* --- Pulpit ------------------------------------------------------------------------------ */
.dash { display: grid; grid-template-columns: minmax(320px, 440px) 1fr; gap: 18px; align-items: start; }
.hero { text-align: center; padding: 22px 18px; background:
  radial-gradient(circle at 50% 46%, rgba(255,59,48,.07), transparent 58%), var(--panel); }
.hero .target-name { font-size: 18px; font-weight: 800; margin-top: 12px; letter-spacing: .3px; }
.hero .target-lane { color: var(--muted); font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat b { display: block; font: 800 30px/1.1 var(--mono); margin-top: 4px; }
.stat.hit b { color: var(--hit); }
.stat.miss b { color: #a9b6c3; }
.stat.warn b { color: var(--reticle); }
.stat.info b { color: var(--steel); }
.stat.wide b { font-size: 24px; }
/* Raporty: wygrane tydzień po tygodniu (słupki bez bibliotek) */
.bars { display: flex; align-items: stretch; gap: 10px; height: 190px; padding-top: 6px; overflow-x: auto; }
.bars .bar { flex: 1 1 0; min-width: 64px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.bars .bar b { font: 700 13px var(--mono); margin-bottom: 4px; }
.bars .bar i { display: block; width: 100%; max-width: 46px; min-height: 2px; background: var(--hit); border-radius: 6px 6px 0 0; }
.bars .bar span { font-size: 11px; color: var(--faint); margin-top: 6px; white-space: nowrap; }
.bars .bar span.small { margin-top: 2px; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }

/* --- Karty celów (Na celowniku) ---------------------------------------------------------- */
.targets { display: grid; grid-template-columns: repeat(auto-fill, minmax(430px, 1fr)); gap: 14px; }
.target { display: flex; gap: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; position: relative; }
.target.armed { border-color: rgba(255,59,48,.55); box-shadow: 0 0 0 1px rgba(255,59,48,.2), 0 0 24px rgba(255,59,48,.12); }
.target .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.target .title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 800; }
.target .lane { color: var(--muted); font-size: 13px; }
.target dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 4px 0 0; font-size: 13px; }
.target dt { color: var(--faint); }
.target dd { margin: 0; font-weight: 600; }
.target .actions { margin-top: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-top: 6px; }

/* --- Ekran logowania (luneta) ------------------------------------------------------------ */
.scope-screen {
  min-height: 100vh; display: grid; place-items: center; position: relative; overflow: hidden;
  background: radial-gradient(circle at 50% 50%, #0f1a24 0, #0a1119 34%, #020305 62%);
}
.scope-screen .bg-reticle {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(1100px, 150vmin); height: min(1100px, 150vmin); opacity: .5; pointer-events: none;
}
.scope-screen .bg-reticle .scope { width: 100%; height: 100%; }
.scope-screen .bg-reticle .ring { stroke: rgba(255, 59, 48, .55); }
.scope-screen .bg-reticle .ticks { animation: spin 120s linear infinite; transform-origin: 50% 50%; }
.login-card {
  position: relative; z-index: 1; width: min(380px, 88vw); padding: 30px 28px; border-radius: 16px;
  background: rgba(10, 16, 23, .88); border: 1px solid var(--line-2); box-shadow: 0 30px 80px rgba(0,0,0,.6);
  text-align: left;
}
.login-card .brand-big { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 18px; text-align: center; }
.login-card .brand-big svg { width: 62px; height: 62px; }
.login-card .brand-big b { font-size: 20px; letter-spacing: 5px; }
.login-card .btn-fire { justify-content: center; padding: 10px; }

/* --- Instalacja aplikacji ---------------------------------------------------------------- */
#install-app[hidden] { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { transform: scale(1.8); opacity: .55; } }
@keyframes blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) {
  .scope.armed .ticks, .scope.armed .dot, .scope-screen .bg-reticle .ticks, .chip-live::before { animation: none; }
}
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash { grid-template-columns: minmax(0, 1fr) !important; }
  .scope-hero { width: min(330px, 72vw); height: min(330px, 72vw); }
  main { padding: 16px; }
  .topbar, .statusbar { padding-left: 16px; padding-right: 16px; }
  .targets { grid-template-columns: 1fr; }
}
