/* Tema. Aceleași nume de variabile ca în terminal, ca regulile kanban aduse de acolo
   să funcționeze nemodificate — și ca ochiul să nu simtă că a schimbat aplicația. */
:root {
  --hdt-bg: #0f1115;
  --hdt-panel: #151922;
  --hdt-control: #1c2230;
  --hdt-hover: #232a3a;
  --hdt-drop: #1a2540;
  --hdt-line: #262d3d;
  --hdt-line-strong: #38415a;
  --hdt-ink: #e6e9f0;
  --hdt-muted: #8b93a7;
  --hdt-primary: #4f7cff;
  --hdt-active-ink: #ffffff;
  --hdt-accent: #6ea8ff;
  --hdt-input-bg: #11151d;
}

@media (prefers-color-scheme: light) {
  :root {
    --hdt-bg: #ffffff; --hdt-panel: #f7f8fa; --hdt-control: #eef0f4; --hdt-hover: #e4e7ee;
    --hdt-drop: #e3ebff; --hdt-line: #dfe3ea; --hdt-line-strong: #c2c8d4;
    --hdt-ink: #171a21; --hdt-muted: #666e80; --hdt-input-bg: #ffffff;
  }
}

/* Atributul `hidden` trebuie sa invinga orice regula de display din foaia asta.
   Fara el, .login-wrap (display:grid) si .topbar (display:flex) raman vizibile cand sunt
   marcate hidden, iar ecranul de login acopera aplicatia dupa autentificare. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }
body {
  margin: 0; height: 100dvh; display: flex; flex-direction: column;
  background: var(--hdt-bg); color: var(--hdt-ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--hdt-line); flex: none;
}
.brand { font-weight: 700; letter-spacing: .01em; }
.topbar-spacer { flex: 1; }
.vault-state { font-size: 11.5px; color: var(--hdt-muted); }
.vault-state.unlocked { color: var(--hdt-accent); }

main { flex: 1; min-height: 0; padding: 12px 14px; overflow: hidden; }

/* Login. Deliberat minimal: doi utilizatori, fără înregistrare, clienții nu intră. */
.login-wrap { display: grid; place-items: center; height: 100dvh; padding: 20px; }
.login-card {
  width: min(360px, 100%); display: flex; flex-direction: column; gap: 10px;
  padding: 22px; border: 1px solid var(--hdt-line); border-radius: 14px; background: var(--hdt-panel);
}
.login-card h1 { margin: 0 0 4px; font-size: 17px; }
.login-card p { margin: 0 0 6px; color: var(--hdt-muted); font-size: 12.5px; }
.login-card input {
  min-height: 42px; padding: 0 12px; border-radius: 9px;
  border: 1px solid var(--hdt-line); background: var(--hdt-input-bg); color: var(--hdt-ink); font-size: 15px;
}
.login-card button {
  min-height: 42px; border: 0; border-radius: 9px;
  background: var(--hdt-primary); color: var(--hdt-active-ink); font-weight: 700; font-size: 14px; cursor: pointer;
}
.err { color: #ff8a8a; font-size: 12.5px; min-height: 17px; }

#toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  padding: 9px 15px; border-radius: 999px; font-size: 13px;
  background: var(--hdt-control); border: 1px solid var(--hdt-line);
  opacity: 0; pointer-events: none; transition: opacity .18s ease; z-index: 50;
}
#toast.show { opacity: 1; }
#toast.warn { border-color: #7a4a4a; }

/* Credențiale, în cardul extins. */
.pj-creds { border-top: 1px solid var(--hdt-line); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.pj-creds-head { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--hdt-muted); font-weight: 600; }
.pj-cred { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.pj-cred-label { font-weight: 600; }
.pj-cred-user { color: var(--hdt-muted); }
.pj-cred-secret { margin-left: auto; font-family: ui-monospace, monospace; font-size: 11.5px; color: var(--hdt-accent); }
/* ---- Projects kanban ------------------------------------------------------------
   Columns per stage. On a phone the board scrolls sideways one full column at a time
   (scroll-snap) rather than collapsing into a list, so the mental model is the same on
   both devices — the operator picked the board precisely because "where is the ball"
   is the question it answers at a glance. */
.pj-wrap { display: flex; flex-direction: column; gap: 10px; height: 100%; min-height: 0; }

.pj-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pj-toolbar-count { margin-left: auto; color: var(--hdt-muted); font-size: 12px; }

.pj-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 0 12px;
  border: 1px solid var(--hdt-line); border-radius: 8px;
  background: var(--hdt-control); color: var(--hdt-ink);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.pj-btn:hover { background: var(--hdt-hover); }
.pj-btn.primary { background: var(--hdt-primary); color: var(--hdt-active-ink); border-color: transparent; }
.pj-btn i { width: 14px; height: 14px; }

.pj-board {
  display: flex; gap: 10px; flex: 1; min-height: 0;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.pj-col {
  flex: 0 0 260px; display: flex; flex-direction: column; min-height: 0;
  scroll-snap-align: start;
  border: 1px solid var(--hdt-line); border-radius: 10px;
  background: var(--hdt-panel);
}
.pj-col.drop { border-color: var(--hdt-primary); background: var(--hdt-drop); }

.pj-col-head {
  display: flex; align-items: baseline; gap: 6px;
  padding: 9px 11px; border-bottom: 1px solid var(--hdt-line);
}
.pj-col-title { font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.pj-col-count {
  min-width: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--hdt-control); color: var(--hdt-muted);
  font-size: 11px; text-align: center;
}
.pj-col-hint { margin-left: auto; color: var(--hdt-muted); font-size: 10.5px; font-style: italic; }
.pj-col-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 7px; }
.pj-col-empty { margin: 4px 0 0; color: var(--hdt-muted); text-align: center; font-size: 12px; }

.pj-card {
  border: 1px solid var(--hdt-line); border-radius: 8px;
  background: var(--hdt-bg); padding: 8px 9px; cursor: pointer;
}
.pj-card:hover { border-color: var(--hdt-line-strong); }
.pj-card.expanded { border-color: var(--hdt-primary); cursor: default; }
.pj-card.is-dragging { opacity: .45; }

.pj-card-head { display: flex; align-items: baseline; gap: 8px; }
.pj-card-name { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.pj-card-when { margin-left: auto; flex: none; color: var(--hdt-muted); font-size: 11px; }
.pj-card-meta { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 5px; color: var(--hdt-muted); font-size: 11.5px; }
.pj-card-meta i { font-style: normal; opacity: .5; }

.pj-detail { margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--hdt-line); display: flex; flex-direction: column; gap: 7px; }
.pj-detail-row { display: flex; align-items: center; gap: 7px; font-size: 12px; flex-wrap: wrap; }
.pj-detail-row label { flex: 0 0 54px; color: var(--hdt-muted); font-size: 11px; }
.pj-detail-row code { font-size: 11px; color: var(--hdt-muted); overflow-wrap: anywhere; }
.pj-detail-note { color: var(--hdt-muted); font-size: 11px; }
.pj-links { display: flex; gap: 8px; }
.pj-links a { color: var(--hdt-accent); font-size: 12px; }

.pj-stage-select, .pj-task-add select, .pj-task-add input {
  border: 1px solid var(--hdt-line); border-radius: 6px;
  background: var(--hdt-input-bg); color: var(--hdt-ink);
  font-size: 12px; padding: 4px 6px; min-height: 30px;
}
.pj-task-add { display: flex; gap: 5px; }
.pj-task-add input { flex: 1; min-width: 0; }

.pj-task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.pj-task { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.pj-task label { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; cursor: pointer; }
.pj-task-text { overflow-wrap: anywhere; }
.pj-task.done .pj-task-text { text-decoration: line-through; color: var(--hdt-muted); }
.pj-task-who, .pj-task-due { flex: none; color: var(--hdt-muted); font-size: 10.5px; }
.pj-task-del { flex: none; border: 0; background: none; color: var(--hdt-muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 3px; }
.pj-tasks-empty, .pj-tasks-loading { color: var(--hdt-muted); font-size: 12px; }

/* Page dots for the sideways paging. Pointer devices get the whole board at once and
   do not need them. */
.pj-dots { display: none; justify-content: center; gap: 6px; padding: 2px 0 4px; }
.pj-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--hdt-line-strong); cursor: pointer; }
.pj-dot.active { background: var(--hdt-primary); width: 16px; }

.pj-loading { padding: 24px 12px; text-align: center; color: var(--hdt-muted); font-size: 13px; }

.pj-scan-note { margin: 0; color: var(--hdt-muted); font-size: 12px; line-height: 1.5; }
.pj-scan-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.pj-scan-row { display: flex; align-items: center; gap: 9px; padding: 6px 4px; border-bottom: 1px solid var(--hdt-line); flex-wrap: wrap; }
.pj-scan-row.tracked { opacity: .5; }
.pj-scan-row label { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.pj-scan-name { font-size: 12.5px; font-weight: 600; }
.pj-scan-meta { margin-left: auto; color: var(--hdt-muted); font-size: 11px; }

@media (max-width: 720px) {
  /* One column fills the viewport; the finger pages between stages. */
  .pj-col { flex-basis: 100%; }
  .pj-dots { display: flex; }
  .pj-scan-meta { margin-left: 0; flex-basis: 100%; }
}

/* Agent history inside an expanded project card. */
.pj-history { border-top: 1px solid var(--hdt-line); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.pj-history-head { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--hdt-muted); font-weight: 600; }
.pj-history-head .pj-btn.small { margin-left: auto; min-height: 26px; padding: 0 8px; font-size: 11px; }
.pj-ses-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.pj-ses { border-left: 2px solid var(--hdt-line-strong); padding-left: 8px; }
.pj-ses-top { display: flex; align-items: baseline; gap: 8px; }
.pj-ses-title { font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.pj-ses-when { margin-left: auto; flex: none; color: var(--hdt-muted); font-size: 10.5px; }
.pj-ses-req { color: var(--hdt-muted); font-size: 11px; margin-top: 2px; overflow-wrap: anywhere; }
.pj-ses-meta { color: var(--hdt-muted); font-size: 10.5px; margin-top: 2px; }
.pj-ses-foot { color: var(--hdt-muted); font-size: 10.5px; }

/* The conversation itself, opened from a session row. Only human turns — tool traffic is
   the bulk of a transcript and noise when you are trying to recall what was decided. */
.pj-ses { cursor: pointer; }
.pj-ses.open { border-left-color: var(--hdt-primary); }
.pj-ses-open { color: var(--hdt-accent); font-size: 10.5px; margin-left: 6px; }
.pj-msgs { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; cursor: default; }
.pj-msg { display: flex; gap: 7px; font-size: 11.5px; line-height: 1.45; }
.pj-msg-who { flex: 0 0 40px; color: var(--hdt-muted); font-size: 10px; text-transform: uppercase; padding-top: 1px; }
.pj-msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.pj-msg.assistant .pj-msg-text { color: var(--hdt-muted); }

/* ---- Restricted accounts ---------------------------------------------------
   A `restricted` user (role set in Users) is provisioned with exactly one thing:
   their own Claude terminal, running as an unprivileged unix account. Every panel
   below is already refused server-side by restrictedApiGate — hiding the entry
   points here just avoids offering buttons that could only ever fail. Treat this
   block as UX, never as the boundary; the boundary is in src/server.js. */
body.restricted-user [data-hub-mode],
body.restricted-user [data-flyout],
body.restricted-user [data-hud-toggle],
body.restricted-user [data-new-type],
body.restricted-user #moreBtn,
body.restricted-user #notesToggleBtn,
body.restricted-user .hub-drawer,
body.restricted-user .hub-resize-handle { display: none !important; }
