:root {
  --bg: #0f1419;
  --panel: #1a222d;
  --panel-2: #222d3a;
  --border: #2d3a4a;
  --text: #e6edf3;
  --muted: #8b99a8;
  --accent: #4f9cf9;
  --accent-2: #3b82f6;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); margin-top: 8px; min-height: 18px; font-size: 13px; }

button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
}
button:hover { background: #2b3847; }
button.primary, button[type="submit"] { background: var(--accent-2); border-color: var(--accent-2); }
button.primary:hover { background: var(--accent); }
button.ghost { background: transparent; }
button.danger { background: transparent; border-color: var(--red); color: var(--red); }
button.danger:hover { background: rgba(248,81,73,.12); }
button.sm { padding: 4px 10px; font-size: 12px; }

input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 11px;
  border-radius: 6px;
  font-size: 14px;
  margin-top: 4px;
  font-family: inherit;
}
textarea { min-height: 80px; resize: vertical; }
label { display: block; margin-top: 12px; font-size: 13px; color: var(--muted); }

/* LOGIN */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--panel);
  padding: 36px;
  border-radius: 12px;
  border: 1px solid var(--border);
  width: 340px;
}
.login-card h1 { font-size: 24px; margin-bottom: 6px; }
.login-card p { margin-bottom: 20px; }
.login-card input { margin-bottom: 12px; margin-top: 0; }
.login-card button { width: 100%; }

/* TOPBAR */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 58px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 600; font-size: 16px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs button { background: transparent; border: none; color: var(--muted); border-radius: 0; border-bottom: 2px solid transparent; padding: 8px 12px; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--text); background: transparent; }
.user-box { display: flex; align-items: center; gap: 10px; }
.pack-alert { position: relative; width: 30px; height: 30px; border-radius: 50%; background: var(--red); color: #fff; border: none; font-weight: 800; font-size: 16px; padding: 0; display: flex; align-items: center; justify-content: center; animation: pack-pulse 1.4s ease-in-out infinite; }
.pack-alert:hover { background: #ff6b63; }
.pack-alert-count { position: absolute; top: -4px; right: -4px; background: #fff; color: var(--red); font-size: 10px; font-weight: 800; min-width: 16px; height: 16px; border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 0 3px; }
@keyframes pack-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(248,81,73,.6); } 50% { box-shadow: 0 0 0 7px rgba(248,81,73,0); } }

main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
.tab-panel h2 { margin-bottom: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

/* CARDS */
.cards { display: flex; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 20px 26px; min-width: 150px; }
.card .big { font-size: 34px; font-weight: 700; color: var(--accent); }

/* SERIES GRID */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.series-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.series-card img { width: 100%; height: 300px; object-fit: cover; background: #000; }
.series-card .body { padding: 12px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.series-card h4 { font-size: 15px; }
.series-card .meta { font-size: 12px; color: var(--muted); }
.series-card .rating { color: var(--yellow); font-weight: 600; }
.series-card .actions { display: flex; gap: 6px; margin-top: auto; }

/* TABLE-LIKE LIST */
.row-item { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.row-item .info { flex: 1; }
.row-item .info .title { font-weight: 600; }
.row-item .info .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.row-item .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; border: 1px solid var(--border); background: var(--panel-2); margin-right: 4px; }
.tag.ssh { color: #a5d6ff; } .tag.ftp, .tag.sftp { color: #7ee787; }
.status-ok { color: var(--green); } .status-error { color: var(--red); } .status-running { color: var(--yellow); }

/* TERMINAL */
.terminal, .mini-terminal {
  background: #0a0e13; border: 1px solid var(--border); border-radius: 8px;
  font-family: "SF Mono", "Consolas", "Menlo", monospace; font-size: 12.5px;
  padding: 12px; overflow-y: auto; line-height: 1.5;
}
.terminal { height: calc(100vh - 220px); min-height: 300px; }
.mini-terminal { height: 240px; }
.log-line { white-space: pre-wrap; word-break: break-word; }
.log-time { color: #586069; }
.log-src { color: #58a6ff; }
.lvl-INFO { color: #c9d1d9; }
.lvl-WARN { color: var(--yellow); }
.lvl-ERROR { color: var(--red); }
.lvl-DEBUG { color: var(--muted); }
.badge { font-size: 12px; padding: 3px 10px; border-radius: 20px; background: var(--panel-2); border: 1px solid var(--border); }
.badge.on { color: var(--green); border-color: var(--green); }
.badge.off { color: var(--red); border-color: var(--red); }

/* MODAL */
.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; width: 520px; max-width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
#modal-body { padding: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.search-result { display: flex; gap: 10px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; margin-top: 8px; cursor: pointer; align-items: center; }
.search-result:hover { background: var(--panel-2); }
.search-result img { width: 40px; height: 60px; object-fit: cover; border-radius: 4px; }

/* KALENDARZ ODCINKÓW */
.cal-item { display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; cursor: pointer; }
.cal-item:hover { background: var(--panel-2); }
.cal-item img, .cal-noimg { width: 46px; height: 68px; object-fit: cover; border-radius: 6px; background: #000; flex-shrink: 0; }
.cal-info { flex: 1; }
.cal-title { font-weight: 600; }
.cal-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.cal-date { text-align: right; white-space: nowrap; }
.cal-rel { color: var(--accent); font-weight: 600; font-size: 14px; }
.cal-abs { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* GDZIE OGLĄDAĆ */
.watch-area { margin-top: 14px; }
.watch-head, .cmd-head { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.watch-region { margin-bottom: 10px; }
.watch-region-label { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.watch-region-label a { color: var(--accent); text-decoration: none; font-weight: 400; }
.watch-list { display: flex; gap: 10px; flex-wrap: wrap; }
.watch-prov { width: 68px; text-align: center; display: block; color: inherit; text-decoration: none; cursor: pointer; border-radius: 10px; padding: 4px; transition: background .12s; }
a.watch-prov:hover { background: var(--panel-2); }
a.watch-prov:hover .watch-name { color: var(--accent); }
.watch-prov img, .watch-noimg { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; background: var(--panel-2); }
.watch-name { font-size: 11px; margin-top: 4px; line-height: 1.2; }
.watch-type { font-size: 10px; color: var(--muted); }
.watch-link { display: inline-block; margin-top: 8px; font-size: 12px; color: var(--accent); text-decoration: none; }

/* KOMENDY SSH */
.commands-area { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.cmd-list { display: flex; flex-direction: column; gap: 8px; }
.cmd-item { display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.cmd-info { flex: 1; min-width: 0; }
.cmd-name { font-size: 13px; margin-bottom: 4px; }
.cmd-code { display: block; font-size: 12px; color: #a5d6ff; white-space: pre-wrap; word-break: break-all; background: #0a0e13; padding: 6px 8px; border-radius: 6px; }
.cmd-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }

/* DETAIL MODAL */
.modal.wide { width: 820px; }
.detail-head { display: flex; gap: 18px; align-items: flex-start; }
.detail-poster { width: 160px; height: 240px; border-radius: 8px; flex-shrink: 0; background: #000; object-fit: cover; position: sticky; top: 0; }
.detail-meta { flex: 1; }
.detail-sub { color: var(--muted); font-size: 13px; }
.detail-rating { font-size: 20px; color: var(--yellow); margin: 8px 0; }
.detail-rating .muted { font-size: 13px; }
.detail-genres { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.detail-plot { margin-top: 10px; line-height: 1.5; font-size: 13.5px; }
.detail-grid { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.drow { display: flex; gap: 12px; padding: 5px 0; font-size: 13px; }
.drow .dk { width: 150px; color: var(--muted); flex-shrink: 0; }
.drow .dv { flex: 1; }
.drow .dv a { color: var(--accent); text-decoration: none; }
h4.sec { margin: 20px 0 8px; padding-top: 14px; border-top: 1px solid var(--border); }
.next-ep { background: rgba(79,156,249,.12); border: 1px solid var(--accent); border-radius: 8px; padding: 10px 14px; margin-top: 18px; font-size: 14px; }
.ep-list { display: flex; flex-direction: column; }
.season-block { margin-bottom: 10px; }
.season-title { font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin: 10px 0 4px; }
.ep { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.ep:hover { background: var(--panel-2); }
.ep.up { background: rgba(63,185,80,.08); border-left: 2px solid var(--green); }
.ep-num { width: 58px; color: var(--muted); flex-shrink: 0; font-family: monospace; }
.ep-title { flex: 1; }
.ep-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.ep.up .ep-date { color: var(--green); font-weight: 600; }
.ep-rate { color: var(--yellow); font-size: 12px; width: 50px; text-align: right; }

/* Plakietka PolishTracker z animowanym ptaszkiem */
.pt-badge { display: inline-flex; align-items: center; gap: 3px; color: var(--green); font-weight: 700; font-size: 10px; letter-spacing: .03em; border: 1px solid var(--green); border-radius: 6px; padding: 1px 5px; margin-right: 8px; background: rgba(63,185,80,.1); white-space: nowrap; }
.pt-check { width: 12px; height: 12px; fill: none; stroke: var(--green); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 26; stroke-dashoffset: 26; animation: pt-draw .5s ease forwards, pt-pulse 1.8s ease-in-out .5s infinite; }
@keyframes pt-draw { to { stroke-dashoffset: 0; } }
@keyframes pt-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .55; transform: scale(1.18); } }

/* TOAST */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--border); padding: 12px 20px; border-radius: 8px; z-index: 100; }
.toast.ok { border-color: var(--green); }
.toast.err { border-color: var(--red); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
