/* VARQEN console — Jellyfin-inspired dark dashboard. Tokens from the spec §18.2. */
:root {
  --canvas: #0C1017;
  --sidebar: #11151F;
  --surface: #171D28;
  --surface-2: #1C2330;
  --surface-hover: #202936;
  --divider: #2B3544;
  --text: #F2F5FB;
  --text-dim: #ADB8CA;
  --text-faint: #6B7688;
  --teal: #17D9C2;
  --teal-dim: #0f9d8d;
  --violet: #8F80FF;
  --warning: #F6B85A;
  --danger: #F56B75;
  --danger-dim: #b84048;
  --online: #3ad29f;
  --radius: 12px;
  --radius-sm: 8px;
  --gap: 16px;
  --sidebar-w: 248px;
  --font: 'Segoe UI', Inter, system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', 'Cascadia Code', Consolas, 'SF Mono', monospace;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--text);
  font-family: var(--font); font-size: 14.5px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal); text-decoration: none; }
button { font-family: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a3444; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- boot splash ---------- */
.app-loading { display: grid; place-items: center; height: 100vh; }
.boot { text-align: center; animation: fade .5s ease; }
.boot-mark {
  width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 18px;
  background: linear-gradient(135deg, var(--teal), var(--violet));
  color: #04231f; font-weight: 800; font-size: 44px; display: grid; place-items: center;
}
.boot-text { letter-spacing: .4em; color: var(--text-dim); font-weight: 600; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- auth screens ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 70% -10%, rgba(143,128,255,.12), transparent),
              radial-gradient(900px 500px at 10% 110%, rgba(23,217,194,.10), transparent), var(--canvas); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--divider);
  border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); animation: rise .4s ease; }
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.auth-logo .mark { width: 42px; height: 42px; border-radius: 11px; background: linear-gradient(135deg,var(--teal),var(--violet));
  color: #04231f; font-weight: 800; font-size: 24px; display: grid; place-items: center; }
.auth-logo .name { font-size: 22px; font-weight: 700; letter-spacing: .08em; }
.auth-sub { color: var(--text-dim); margin: 4px 0 22px; font-size: 13.5px; }

/* ---------- forms ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--divider); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--teal); }
input::placeholder { color: var(--text-faint); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--divider);
  border-radius: var(--radius-sm); padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--teal); color: #04231f; border-color: transparent; }
.btn.primary:hover { background: #2fe6d0; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger-dim); }
.btn.danger:hover { background: rgba(245,107,117,.12); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.icon { padding: 8px; width: 36px; height: 36px; }
.form-error { color: var(--danger); font-size: 13px; margin: 6px 0 12px; min-height: 18px; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--divider); display: flex; flex-direction: column;
  overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 20px 14px; }
.brand .mark { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg,var(--teal),var(--violet));
  color: #04231f; font-weight: 800; font-size: 20px; display: grid; place-items: center; }
.brand .name { font-weight: 700; letter-spacing: .1em; font-size: 17px; }
.nav-group { padding: 6px 12px; }
.nav-group h4 { color: var(--text-faint); font-size: 10.5px; letter-spacing: .14em; margin: 14px 10px 6px; font-weight: 700; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-dim); cursor: pointer; font-weight: 500; font-size: 14px; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: linear-gradient(90deg, rgba(23,217,194,.16), rgba(23,217,194,.02)); color: var(--teal); }
.nav-item.active .ico { color: var(--teal); }
.nav-item .ico { width: 20px; display: inline-flex; justify-content: center; }
.nav-item .count { margin-left: auto; background: var(--surface-2); border-radius: 10px; padding: 1px 8px; font-size: 11.5px; color: var(--text-dim); }
.sidebar-foot { margin-top: auto; padding: 14px 20px; border-top: 1px solid var(--divider); font-size: 11px; color: var(--text-faint); letter-spacing: .05em; }

.main { overflow-y: auto; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 14px 28px; background: rgba(12,16,23,.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--divider); }
.topbar .page-title { font-size: 19px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.topbar .search { max-width: 280px; }
.user-chip { display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 5px 9px; border-radius: 20px; }
.user-chip:hover { background: var(--surface-hover); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg,var(--violet),var(--teal));
  color: #04231f; font-weight: 700; display: grid; place-items: center; font-size: 13px; }
.content { padding: 24px 28px 48px; animation: rise .25s ease; }
.menu-toggle { display: none; }

/* ---------- cards & layout ---------- */
.row { display: flex; gap: var(--gap); flex-wrap: wrap; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius); padding: 18px; }
.section-title { font-size: 13px; letter-spacing: .12em; color: var(--text-faint); font-weight: 700; margin: 26px 0 12px; }
.grid-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--gap); }
.metric { background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius); padding: 18px 20px; }
.metric .label { color: var(--text-faint); font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; }
.metric .value { font-size: 34px; font-weight: 700; margin-top: 6px; }
.metric .value.accent { color: var(--teal); }
.metric .hint { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; }

.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--gap); }
.device-card { background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius); padding: 16px;
  cursor: pointer; transition: border-color .15s, transform .08s, box-shadow .15s; }
.device-card:hover { border-color: #3a475c; transform: translateY(-2px); box-shadow: var(--shadow); }
.device-card .head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.os-badge { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; font-size: 20px; }
.device-card h3 { margin: 0; font-size: 15.5px; }
.device-card .host { color: var(--text-faint); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: var(--surface-2); border-radius: 20px;
  padding: 3px 10px; font-size: 11.5px; color: var(--text-dim); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.chip.online { color: var(--online); } .chip.online .dot { background: var(--online); box-shadow: 0 0 6px var(--online); }
.chip.offline .dot { background: var(--text-faint); }
.dot-live { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-live.on { background: var(--online); box-shadow: 0 0 7px var(--online); } .dot-live.off { background: var(--text-faint); }

.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.quick-actions .btn { flex: 1; min-width: 76px; }

.empty { text-align: center; color: var(--text-dim); padding: 60px 20px; border: 1px dashed var(--divider); border-radius: var(--radius); }
.empty .big { font-size: 40px; margin-bottom: 12px; }

/* ---------- tables ---------- */
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; color: var(--text-faint); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase;
  padding: 10px 12px; border-bottom: 1px solid var(--divider); position: sticky; top: 0; background: var(--surface); }
table.data td { padding: 10px 12px; border-bottom: 1px solid rgba(43,53,68,.5); font-size: 13.5px; }
table.data tr:hover td { background: var(--surface-hover); }
.pill { padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.pill.owner { background: rgba(143,128,255,.18); color: var(--violet); }
.pill.admin { background: rgba(23,217,194,.16); color: var(--teal); }
.pill.operator { background: rgba(246,184,90,.16); color: var(--warning); }
.pill.viewer { background: var(--surface-2); color: var(--text-dim); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--divider); margin-bottom: 20px; overflow-x: auto; }
.tab { padding: 11px 16px; color: var(--text-dim); cursor: pointer; border-bottom: 2px solid transparent; font-weight: 600; font-size: 14px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--teal); border-bottom-color: var(--teal); }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--surface-2); border: 1px solid var(--divider); border-left: 3px solid var(--teal);
  border-radius: var(--radius-sm); padding: 12px 16px; min-width: 240px; max-width: 360px; box-shadow: var(--shadow); animation: rise .2s ease; }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warning); }
.toast .t-title { font-weight: 600; margin-bottom: 2px; }
.toast .t-body { color: var(--text-dim); font-size: 13px; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(4,6,10,.65); z-index: 500; display: grid; place-items: center; padding: 20px; animation: fade .15s; }
.modal { background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius); width: 100%; max-width: 480px;
  box-shadow: var(--shadow); animation: rise .2s ease; max-height: 90vh; overflow-y: auto; }
.modal.wide { max-width: 680px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--divider); font-size: 17px; font-weight: 700; display:flex; justify-content:space-between; align-items:center; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--divider); display: flex; justify-content: flex-end; gap: 10px; }
.x-close { cursor: pointer; color: var(--text-dim); font-size: 22px; line-height: 1; }
.x-close:hover { color: var(--text); }

/* ---------- activity feed ---------- */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(43,53,68,.4); font-size: 13.5px; }
.feed-item:last-child { border-bottom: none; }
.feed-item .when { color: var(--text-faint); font-size: 12px; white-space: nowrap; }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); margin-top: 6px; flex: none; }

/* ---------- terminal & desktop viewers ---------- */
.viewer-wrap { position: fixed; inset: 0; background: #06080c; z-index: 400; display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--sidebar); border-bottom: 1px solid var(--divider); flex: none; }
.viewer-bar .title { font-weight: 600; }
.viewer-bar .spacer { flex: 1; }
.viewer-stage { flex: 1; overflow: hidden; display: grid; place-items: center; background: #06080c; position: relative; }
.viewer-stage canvas { max-width: 100%; max-height: 100%; background: #000; image-rendering: auto; }
.term-host { flex: 1; padding: 6px 8px; overflow: hidden; }
.viewer-status { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: rgba(12,16,23,.9);
  padding: 8px 16px; border-radius: 20px; border: 1px solid var(--divider); font-size: 13px; }
.badge-live { background: rgba(58,210,159,.16); color: var(--online); padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }

/* ---------- file manager ---------- */
.fm-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.crumb { color: var(--text-dim); cursor: pointer; } .crumb:hover { color: var(--teal); }
.fm-list { border: 1px solid var(--divider); border-radius: var(--radius); overflow: hidden; }
.fm-row { display: grid; grid-template-columns: 1fr 120px 180px 90px; gap: 10px; padding: 9px 14px; align-items: center;
  border-bottom: 1px solid rgba(43,53,68,.4); cursor: default; font-size: 13.5px; }
.fm-row:last-child { border-bottom: none; }
.fm-row:hover { background: var(--surface-hover); }
.fm-row .nm { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.fm-row .nm .i { font-size: 17px; }
.fm-row.dir .nm { cursor: pointer; color: var(--text); font-weight: 500; }
.fm-row .actions { display: flex; gap: 6px; opacity: 0; }
.fm-row:hover .actions { opacity: 1; }
.dropzone.drag { outline: 2px dashed var(--teal); outline-offset: -6px; }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv .k { color: var(--text-faint); }
.bar { height: 7px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg,var(--teal),var(--violet)); }
.spin { width: 30px; height: 30px; border: 3px solid var(--divider); border-top-color: var(--teal); border-radius: 50%; animation: rot .8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.center-load { display: grid; place-items: center; padding: 60px; }
.qr-box { background: #fff; padding: 14px; border-radius: var(--radius); display: inline-block; }
.code-big { font-family: var(--mono); font-size: 30px; letter-spacing: .3em; color: var(--teal); text-align: center; padding: 10px; }
.copy-field { display: flex; gap: 8px; }
.copy-field input { font-family: var(--mono); font-size: 12.5px; }
.inline-note { background: rgba(23,217,194,.08); border: 1px solid rgba(23,217,194,.25); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px; color: var(--text-dim); margin: 12px 0; }
.inline-note.warn { background: rgba(246,184,90,.08); border-color: rgba(246,184,90,.3); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 252px; z-index: 100; transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .menu-toggle { display: inline-flex; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 90; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 12px 16px; }
  .fm-row { grid-template-columns: 1fr 70px; } .fm-row .sz, .fm-row .md { display: none; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; } .kv .k { margin-top: 8px; }
}
