/* ===========================================================================
   PAM Manager — Hooks Platforms theme (light + dark, purple gradient)
   =========================================================================== */
:root, [data-theme="dark"] {
  --bg: #0b0710;
  --bg-grad: radial-gradient(1200px 600px at 15% -10%, #2a1650 0%, transparent 55%),
             radial-gradient(1000px 500px at 100% 0%, #3b1d63 0%, transparent 50%),
             #0b0710;
  --panel: #15101f;
  --panel2: #1e1730;
  --border: #2c2340;
  --text: #ece8f5;
  --muted: #9b93b4;
  --accent: #a855f7;
  --accent2: #7c3aed;
  --grad: linear-gradient(135deg, #7c3aed 0%, #a855f7 55%, #c084fc 100%);
  --grad-soft: linear-gradient(135deg, rgba(124,58,237,.18), rgba(168,85,247,.10));
  --green:#34d399; --red:#f87171; --amber:#fbbf24; --purple:#c084fc;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-bg: linear-gradient(180deg, #1a1030 0%, #130c22 100%);
}
/* Dim — a softer dark: muted slate/indigo background, not near-black. Easier on
   the eyes while keeping the purple brand accents. */
[data-theme="dim"] {
  --bg: #191527;
  --bg-grad: radial-gradient(1200px 600px at 15% -10%, #322459 0%, transparent 55%),
             radial-gradient(1000px 500px at 100% 0%, #3c2a66 0%, transparent 50%),
             #191527;
  --panel: #241f36;
  --panel2: #2e2844;
  --border: #3b3455;
  --text: #ece8f5;
  --muted: #aaa1c6;
  --accent: #b06bff;
  --accent2: #8b52ef;
  --grad: linear-gradient(135deg, #7c3aed 0%, #a855f7 55%, #c084fc 100%);
  --grad-soft: linear-gradient(135deg, rgba(124,58,237,.16), rgba(168,85,247,.10));
  --green:#34d399; --red:#f87171; --amber:#fbbf24; --purple:#c084fc;
  --shadow: 0 10px 30px rgba(0,0,0,.32);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-bg: linear-gradient(180deg, #261e42 0%, #1e1836 100%);
}
[data-theme="light"] {
  --bg: #f5f3fb;
  --bg-grad: radial-gradient(1200px 600px at 15% -10%, #e9ddff 0%, transparent 55%),
             radial-gradient(1000px 500px at 100% 0%, #f0e6ff 0%, transparent 50%),
             #f5f3fb;
  --panel: #ffffff;
  --panel2: #f4f0fc;
  --border: #e4ddf3;
  --text: #1e152e;
  --muted: #6b6383;
  --accent: #7c3aed;
  --accent2: #6d28d9;
  --grad: linear-gradient(135deg, #7c3aed 0%, #a855f7 55%, #c084fc 100%);
  --grad-soft: linear-gradient(135deg, rgba(124,58,237,.10), rgba(168,85,247,.06));
  --green:#059669; --red:#dc2626; --amber:#d97706; --purple:#7c3aed;
  --shadow: 0 10px 30px rgba(80,50,140,.12);
  --sidebar-bg: linear-gradient(180deg, #efe7ff 0%, #f6f2ff 100%);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-grad); background-attachment: fixed; color: var(--text);
  font-size: 14px; transition: background .3s, color .3s;
}
a { color: var(--accent); text-decoration: none; }

button {
  font: inherit; cursor: pointer; border: 1px solid var(--border);
  background: var(--panel2); color: var(--text); padding: 8px 15px;
  border-radius: 9px; transition: .15s; font-weight: 500;
}
button:hover { border-color: var(--accent); transform: translateY(-1px); }
button.primary {
  background: var(--grad); border: none; color: #fff;
  box-shadow: 0 4px 14px rgba(124,58,237,.35);
}
button.primary:hover { filter: brightness(1.08); box-shadow: 0 6px 18px rgba(124,58,237,.5); }
button.danger { background: transparent; border-color: var(--red); color: var(--red); }
button.danger:hover { background: rgba(248,113,113,.14); }
button.small { padding: 4px 10px; font-size: 12px; }

input, select, textarea {
  font: inherit; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
[data-theme="light"] input, [data-theme="light"] select, [data-theme="light"] textarea { background: #fff; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(168,85,247,.18);
}
label { display:block; font-size:12px; color: var(--muted); margin: 10px 0 4px; font-weight: 500; }

/* layout */
:root { --rail: 68px; --nav-open: 236px; }
#app { display: flex; height: 100vh; }

/* Collapsed icon rail by default; expands on hover (overlay, no reflow) or when
   pinned (pushes content). Vertical "Hooks Platforms" strip shows when collapsed. */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  width: var(--rail); background: var(--sidebar-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px; overflow: hidden;
  transition: width .18s ease, box-shadow .18s ease;
}
.sidebar:hover { width: var(--nav-open); box-shadow: 8px 0 30px rgba(0,0,0,.18); }
body.nav-pinned .sidebar { width: var(--nav-open); box-shadow: none; }

.content { flex: 1; display: flex; flex-direction: column; min-width: 0;
  margin-left: var(--rail); transition: margin-left .18s ease; }
body.nav-pinned .content { margin-left: var(--nav-open); }

.brand-wrap { padding: 4px 8px 14px; white-space: nowrap; }
.brand {
  font-weight: 800; font-size: 24px; letter-spacing: 1px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent; line-height: 1;
}
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: 2.5px; text-transform: uppercase;
  margin-top: 4px; opacity: 0; transition: opacity .12s; }
.sidebar:hover .brand-sub, body.nav-pinned .brand-sub { opacity: 1; }

.nav-pin {
  position: absolute; top: 18px; right: 10px; width: 26px; height: 26px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel2); color: var(--muted);
  cursor: pointer; display: none; align-items: center; justify-content: center; font-weight: 700;
  z-index: 2;
}
.sidebar:hover .nav-pin, body.nav-pinned .nav-pin { display: flex; }
body.nav-pinned .nav-pin .pin-ico { display: inline-block; transform: rotate(180deg); }

.nav { display: flex; flex-direction: column; }
.nav a {
  display: flex; align-items:center; gap:12px; padding: 10px 11px; border-radius: 10px;
  color: var(--muted); margin-bottom: 3px; cursor: pointer; font-weight: 500; transition: background .15s, color .15s;
  white-space: nowrap; overflow: hidden;
}
.nav a:hover { background: var(--grad-soft); color: var(--text); }
.nav a.active { background: var(--grad); color: #fff; box-shadow: 0 4px 12px rgba(124,58,237,.35); }
.nav-ico { flex: 0 0 24px; display: flex; align-items: center; justify-content: center; }
.ico { width: 18px; height: 18px; display: block; }
button .ico, .bc-btn .ico { vertical-align: -3px; margin-right: 5px; }
.bc-btn .ico { margin-right: 0; }
.nav-label { opacity: 0; transition: opacity .12s; }
.sidebar:hover .nav-label, body.nav-pinned .nav-label { opacity: 1; }
.nav a .badge { margin-left:auto; background: var(--amber); color:#000; border-radius: 20px;
  padding: 0 7px; font-size: 11px; font-weight:700; }

/* vertical brand strip, bottom-to-top, only while collapsed */
.vstrip {
  margin: 16px auto; writing-mode: vertical-rl; transform: rotate(180deg);
  text-transform: uppercase; letter-spacing: 4px; font-size: 11px; font-weight: 600;
  color: var(--muted); opacity: .65; user-select: none; white-space: nowrap;
}
.sidebar:hover .vstrip, body.nav-pinned .vstrip { display: none; }

.sidebar .whoami { margin-top:auto; font-size:12px; color: var(--muted); padding: 12px 4px 2px;
  border-top:1px solid var(--border); display: flex; flex-direction: column; }
.who-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--grad); color:#fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
  margin: 4px 2px 6px; flex: 0 0 auto;
}
.who-details { opacity: 0; transition: opacity .12s; white-space: nowrap; line-height: 1.5; }
.sidebar:hover .who-details, body.nav-pinned .who-details { opacity: 1; }
.logout-link { display: flex; align-items: center; gap: 12px; padding: 8px 9px; margin-top: 8px;
  border-radius: 10px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.logout-link:hover { background: var(--grad-soft); color: var(--text); }
.theme-toggle {
  display:flex; align-items:center; gap:8px; justify-content:center;
  margin-top: 8px; background: var(--panel2); border:1px solid var(--border);
}

.main { flex: 1; overflow: auto; padding: 26px 30px; }
.app-footer { flex: 0 0 auto; text-align: center; font-size: 11.5px; color: var(--muted);
  padding: 9px 12px; border-top: 1px solid var(--border); background: var(--sidebar-bg); letter-spacing: .3px; }
.topbar { display:flex; align-items:center; justify-content: space-between; margin-bottom: 22px; }
.topbar h1 { font-size: 22px; margin: 0; font-weight: 700; }

/* cards / tables */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fill, minmax(165px,1fr)); }
.stat { position: relative; background: var(--panel); border:1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); overflow: hidden; }
.stat::before { content:""; position:absolute; inset:0 auto 0 0; width:4px; background: var(--grad); }
.stat .n { font-size: 30px; font-weight: 800; background: var(--grad);
  -webkit-background-clip:text; background-clip:text; -webkit-text-fill-color:transparent; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing:.5px; margin-top:2px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing:.4px; }
tr:hover td { background: var(--grad-soft); }
.badge-pill { display:inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight:600; }
.b-green { background: rgba(52,211,153,.16); color: var(--green); }
.b-red { background: rgba(248,113,113,.16); color: var(--red); }
.b-amber { background: rgba(251,191,36,.16); color: var(--amber); }
.b-blue { background: rgba(168,85,247,.16); color: var(--accent); }
.b-gray { background: rgba(155,147,180,.18); color: var(--muted); }
.b-purple { background: rgba(192,132,252,.18); color: var(--purple); }
.muted { color: var(--muted); }
.row { display:flex; gap:10px; align-items:center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10,5,20,.66); backdrop-filter: blur(3px);
  display:flex; align-items:center; justify-content:center; z-index: 50; }
.modal { background: var(--panel); border:1px solid var(--border); border-radius: 16px;
  padding: 24px; width: 500px; max-width: 92vw; max-height: 88vh; overflow:auto; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 6px; font-size: 18px; }

/* login */
.login-wrap { display:flex; align-items:center; justify-content:center; height:100vh; }
.login { width: 380px; }
.login .brand-wrap { text-align:center; margin-bottom: 8px; }
.login .brand-sub { opacity: 1; }
.login .brand { font-size: 40px; }
.login .card { padding: 30px; }
.login-footer { text-align:center; margin-top: 18px; font-size: 11.5px; color: var(--muted); letter-spacing:.3px; }
.error { color: var(--red); font-size:13px; margin-top: 8px; min-height: 16px; }
.hint { font-size:12px; color: var(--muted); margin-top: 6px; }

/* terminal */
#terminal-host { height: calc(100vh - 168px); background:#000; border-radius: 12px; padding: 10px;
  border: 1px solid var(--border); box-shadow: var(--shadow); }
.term-bar { display:flex; gap:10px; align-items:center; margin-bottom: 12px; flex-wrap: wrap; }
.term-bar select { width:auto; padding: 5px 9px; }

/* Isolated-session "browser window" — full-viewport overlay, own-browser feel */
.browser-shell {
  position: fixed; inset: 0; z-index: 1000; background: #0b0d12;
  display: flex; flex-direction: column;
}
.browser-chrome {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
  height: 42px; padding: 0 14px; background: #1c2230; border-bottom: 1px solid #2a3242;
  color: #cdd3df;
}
.bc-dots { display: flex; gap: 7px; flex: 0 0 auto; }
.bc-dots span { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.bc-dots span:nth-child(1){ background:#ff5f57; } .bc-dots span:nth-child(2){ background:#febc2e; }
.bc-dots span:nth-child(3){ background:#28c840; }
.bc-tab {
  max-width: 46%; padding: 6px 16px; background: #0b0d12; border: 1px solid #2a3242;
  border-bottom: none; border-radius: 9px 9px 0 0; font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: -1px;
}
.bc-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.bc-actions .muted { color: #8b93a7; font-size: 12px; }
.bc-btn {
  width: 32px; height: 30px; border-radius: 8px; border: 1px solid #2a3242; background: #0b0d12;
  color: #cdd3df; cursor: pointer; font-size: 15px; line-height: 1; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.bc-btn:hover { background: #242c3c; }
.bc-btn.bc-danger:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
.browser-viewport {
  flex: 1; min-height: 0; background: #000; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
/* Single pointer: the server no longer bakes its own cursor into the stream
   (x11vnc -nocursor), so the viewer's own local pointer is the only one — keep
   it visible over the streamed canvas. */
.browser-viewport, .browser-viewport canvas, .browser-viewport * { cursor: default !important; }
.browser-shell:fullscreen { background: #000; }
.browser-shell:fullscreen .browser-viewport { background: #000; }
kbd { background: var(--panel2); border:1px solid var(--border); border-radius:5px; padding: 1px 6px; font-family: var(--mono); font-size:12px; }
code { font-family: var(--mono); background: var(--panel2); padding: 1px 6px; border-radius: 6px; }
.tag { display:inline-block; background: var(--grad-soft); border:1px solid var(--border);
  border-radius: 7px; padding: 1px 8px; font-size:11px; margin: 1px 2px; }
.daychip { display:inline-flex; align-items:center; gap:4px; background: var(--grad-soft);
  border:1px solid var(--border); border-radius: 8px; padding: 3px 10px; font-size:13px;
  cursor:pointer; user-select:none; margin:0; }

/* Catalog: resources you don't have access to yet are visible but dimmed
   (inactive); available/active access stays clear and bright. */
.cat-tile { transition: opacity .15s, filter .15s, transform .12s, box-shadow .15s; }
.cat-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.dim { opacity: .58; filter: saturate(.65); }
.dim:hover { opacity: 1; filter: none; }
tr.dim td { opacity: .62; }
tr.dim:hover td { opacity: 1; }

/* ---- My URLs: personal bookmarks (folders + tags) ------------------------ */
.bm-folder { margin-bottom: 18px; }
.bm-folder-h { display:flex; align-items:center; gap:8px; font-weight:600; font-size:14px;
  margin:0 0 10px; color: var(--text); }
.bm-folder-h .ico { width:16px; height:16px; opacity:.8; }
.bm-grid { display:grid; gap:12px; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); }
.bm-card { background: var(--panel); border:1px solid var(--border); border-radius: var(--radius);
  padding:14px; box-shadow: var(--shadow); display:flex; flex-direction:column; gap:6px; }
.bm-top { display:flex; align-items:center; gap:8px; }
.bm-name { font-size:14px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.bm-fav { cursor:pointer; color: var(--muted); font-size:16px; line-height:1; user-select:none; }
.bm-fav.on { color: var(--amber); }
.bm-url { font-size:12px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.bm-tags { display:flex; flex-wrap:wrap; gap:5px; }
.tag-chip { font-size:11px; padding:2px 8px; border-radius:999px; background: var(--grad-soft);
  border:1px solid var(--border); color: var(--text); }
.bm-login { font-size:12px; display:flex; align-items:center; gap:5px; }
.bm-login .ico { width:13px; height:13px; }
.bm-actions { display:flex; gap:6px; margin-top:6px; }

/* ---- Back button (in-page navigation history) --------------------------- */
.backbtn {
  display:inline-flex; align-items:center; gap:6px; padding:6px 12px; font-size:13px;
  background: var(--panel2); border:1px solid var(--border); color: var(--text); border-radius:9px;
}
.backbtn:hover { border-color: var(--accent); background: var(--grad-soft); }
.backbtn .ico { width:16px; height:16px; }
.topbar h1 { margin:0; }

/* ---- Access PIN prompt (OTP-style) -------------------------------------- */
.pin-overlay {
  position: fixed; inset: 0; z-index: 3000; display: flex; align-items: center; justify-content: center;
  background: rgba(6,3,12,.66); backdrop-filter: blur(4px);
}
.pin-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 28px 30px; box-shadow: var(--shadow); width: min(92vw, 420px); text-align: center;
}
.pin-boxes { display: flex; gap: 12px; justify-content: center; margin: 8px 0 14px; }
.pin-box {
  width: 56px; height: 66px; text-align: center; font-size: 30px; font-weight: 700;
  padding: 0; border: 2px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--text);
  caret-color: var(--accent);
}
.pin-box:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(168,85,247,.20); outline: none; }
@media (max-width: 480px) { .pin-box { width: 44px; height: 54px; font-size: 24px; } .pin-boxes { gap: 8px; } }

/* ---- Top-right header: live clock + theme toggle + logout ---------------- */
.topheader {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 10px 22px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 55%, transparent);
  backdrop-filter: blur(6px);
}
/* Single-line clock on the RIGHT of the header, next to the controls. */
.clock {
  display: flex; flex-direction: row; align-items: baseline; gap: 8px; margin-right: 6px;
}
.clock-day { font-size: 13px; color: var(--muted); font-weight: 600; }
.clock-sep { color: var(--muted); opacity: .55; }
.clock-time { font-size: 15px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.hdr-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; font-size: 13px;
  background: var(--panel2); border: 1px solid var(--border); color: var(--text); border-radius: 10px;
}
.hdr-btn:hover { border-color: var(--accent); background: var(--grad-soft); }
.hdr-btn .ico { width: 16px; height: 16px; }
#theme-toggle { font-size: 17px; padding: 6px 11px; line-height: 1; }
.hdr-logout { color: var(--muted); }
.hdr-logout:hover { color: var(--text); }

/* Version pinned at the bottom of the left menu — always visible, even when
   the rail is collapsed to icons. */
.app-version {
  text-align: center; font-size: 11px; letter-spacing: 1px; font-weight: 600;
  color: var(--muted); opacity: .7; padding: 8px 4px 2px; white-space: nowrap;
}
