/* IosevkaTerm (self-host, subset) — żeby telefon też miał terminalowy font */
@font-face {
  font-family: 'IosevkaTerm';
  src: url('fonts/IosevkaTerm-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IosevkaTerm';
  src: url('fonts/IosevkaTerm-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}

/* ── Paleta colorblind-safe (czerwono-zielony daltonizm) ──
   Status NIGDY kolorem zielony↔czerwony. Oś: żółty/niebieski/biały + jasność,
   ZAWSZE wzmacniany glifem (✓ ⚠ ✗ ·) i SŁOWEM. */
:root {
  --bg:        #14161a;
  --bg-card:   #1b1e24;
  --bg-card2:  #21252c;
  --line:      #2c313a;
  --fg:        #e6e8ec;
  --fg-dim:    #9aa0aa;
  --fg-mute:   #6b7079;

  --ok:        #ffe873;   /* jasny żółty — sprawdzony „ok" */
  --alert:     #66b3ff;   /* niebieski — uwaga/alert */
  --fail:      #e7baff;   /* fiolet/róż — błąd (NIE czerwień) */
  --accent:    #ffe873;

  --r: 10px;
  --pad: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'IosevkaTerm', 'IosevkaTerm Nerd Font', 'Iosevka', ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;
  font-size: 15px; line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

/* ── Topbar ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: #11131722; backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; letter-spacing: .5px; }
.brand .host { color: var(--fg-mute); font-weight: 400; margin-left: 8px; font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  background: var(--bg-card); color: var(--fg); border: 1px solid var(--line);
  border-radius: 8px; width: 36px; height: 32px; font-size: 16px; cursor: pointer;
}
.icon-btn:active { background: var(--bg-card2); }

.conn { font-size: 13px; color: var(--fg-mute); border: 1px solid var(--line);
        border-radius: 8px; padding: 4px 8px; white-space: nowrap; }
.conn[data-state="on"]  { color: var(--ok);    border-color: #4a4a30; }
.conn[data-state="off"] { color: var(--fg-mute); }
.conn[data-state="err"] { color: var(--fail); border-color: #4a3a50; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); }
.tab {
  background: none; border: none; color: var(--fg-dim); font: inherit;
  padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent;
}
.tab.is-active { color: var(--fg); border-bottom-color: var(--accent); }
.badge { background: var(--alert); color: #06121f; border-radius: 10px;
         padding: 0 7px; font-size: 12px; font-weight: 700; margin-left: 4px; }

main { padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); max-width: 980px; margin: 0 auto; }
.tabpane { display: none; }
.tabpane.is-active { display: block; }

/* ── Job cards ── */
.jobs { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 620px) { .jobs { grid-template-columns: 1fr 1fr; } }

.card {
  background: var(--bg-card); border: 1px solid var(--line); border-left-width: 4px;
  border-radius: var(--r); padding: var(--pad); cursor: pointer;
}
.card:active { background: var(--bg-card2); }
.card[data-st="ok"]    { border-left-color: var(--ok); }
.card[data-st="alert"] { border-left-color: var(--alert); }
.card[data-st="error"] { border-left-color: var(--fail); }
.card[data-st="idle"]  { border-left-color: var(--fg-mute); }

.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-name { font-weight: 700; }
.card-sched { color: var(--fg-mute); font-size: 13px; }
.card-msg { color: var(--fg-dim); margin: 8px 0 10px; font-size: 14px;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-foot { display: flex; justify-content: space-between; align-items: center;
             color: var(--fg-mute); font-size: 12.5px; }

/* status pill — glif + SŁOWO (nie sam kolor) */
.pill { font-weight: 700; font-size: 13px; white-space: nowrap; }
.pill[data-st="ok"]    { color: var(--ok); }
.pill[data-st="alert"] { color: var(--alert); }
.pill[data-st="error"] { color: var(--fail); }
.pill[data-st="idle"]  { color: var(--fg-mute); }
.pill .run { animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ── Buttons ── */
.btn { background: var(--accent); color: #1a1500; border: none; border-radius: 8px;
       font: inherit; font-weight: 700; padding: 8px 12px; cursor: pointer; }
.btn:active { filter: brightness(.9); }
.btn-ghost { background: var(--bg-card2); color: var(--fg); border: 1px solid var(--line); }

/* ── Modal ── */
.modal { position: fixed; inset: 0; background: #0009; display: flex;
         align-items: flex-end; justify-content: center; z-index: 50; }
/* WAŻNE: .modal{display:flex} nadpisuje UA [hidden]{display:none}.
   Bez tego atrybut hidden nie chowa modala. */
.modal[hidden] { display: none; }
@media (min-width: 620px) { .modal { align-items: center; } }
.modal-card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 14px 14px 0 0; width: 100%; max-width: 920px;
  max-height: 88vh; display: flex; flex-direction: column; overflow: hidden;
}
@media (min-width: 620px) { .modal-card { border-radius: 14px; } }
.modal-narrow { max-width: 460px; padding-bottom: 16px; }
.modal-head { display: flex; align-items: center; justify-content: space-between;
              padding: 12px 14px; border-bottom: 1px solid var(--line); }
.modal-title { font-weight: 700; }
.modal-actions { display: flex; gap: 8px; align-items: center; }
.modal-meta { padding: 10px 14px; color: var(--fg-dim); font-size: 13px;
              border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px 16px; }
.modal-meta b { color: var(--fg); font-weight: 700; }

/* ── Log viewer (duży tekst, telefon-friendly) ── */
.logview {
  margin: 0; padding: 12px 14px; overflow: auto; flex: 1;
  font-size: 13px; line-height: 1.5; tab-size: 2;
  white-space: pre; word-break: normal;
  background: #0e1014; color: #d7dade;
}
.logview.wrap { white-space: pre-wrap; word-break: break-word; }
.logview .lbl { color: var(--fg-mute); }

/* ── Proposals / list ── */
.list { display: flex; flex-direction: column; gap: 10px; }
.prop { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--r); padding: var(--pad); }
.prop .cmd { background: #0e1014; border: 1px solid var(--line); border-radius: 6px;
             padding: 8px 10px; margin: 8px 0; overflow-x: auto; color: var(--ok); }
.prop-actions { display: flex; gap: 8px; }

.audit-ctl { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; color: var(--fg-dim); }
.audit-ctl input { width: 70px; background: var(--bg-card); color: var(--fg);
                   border: 1px solid var(--line); border-radius: 6px; padding: 6px; font: inherit; }

.hint { color: var(--fg-dim); font-size: 13px; margin: 8px 0; }
.hint code { color: var(--ok); }
#token-input { width: 100%; margin: 6px 0 12px; background: #0e1014; color: var(--fg);
               border: 1px solid var(--line); border-radius: 8px; padding: 10px; font: inherit; }

.empty { color: var(--fg-mute); text-align: center; padding: 40px 10px; }

/* ── Toast ── */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
         background: var(--bg-card2); color: var(--fg); border: 1px solid var(--line);
         border-radius: 10px; padding: 10px 16px; z-index: 100; max-width: 90vw; }
.toast[data-st="error"] { border-color: var(--fail); }
.toast[data-st="ok"] { border-color: var(--ok); }
