:root {
  --bg: #0f1418; --panel: #161d23; --panel2: #1c252d; --line: #26323c; --text: #e3e9ee; --muted: #8b9aa7;
  --accent: #2fb37a; --accent-d: #1f8a5b; --danger: #e05d5d; --warn: #e2a33d; --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
.muted { color: var(--muted); }
.center { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.hidden { display: none !important; }
button, .btn, select, input, textarea {
  font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 12px;
}
button, .btn { cursor: pointer; white-space: nowrap; }
button:hover, .btn:hover { border-color: var(--accent); }
button.primary { background: var(--accent-d); border-color: var(--accent-d); color: #fff; }
button.primary:hover { background: var(--accent); }
button.danger { border-color: #5a2a2a; color: #ffb4b4; }
button.danger:hover { background: #5a2a2a; }
button.small { padding: 3px 8px; font-size: 12px; }
input, textarea, select { width: 100%; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-d); outline-offset: 0; }
label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.code { background: #0b0f12; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; word-break: break-all; font-family: ui-monospace, Consolas, monospace; font-size: 12px; user-select: all; }

/* login */
.login { width: 360px; max-width: calc(100vw - 32px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.login h1 { margin: 0 0 4px; font-size: 22px; display: flex; gap: 10px; align-items: center; }
.login h1 img { width: 28px; }
.login button { width: 100%; margin-top: 18px; }
.err { color: #ffb4b4; margin-top: 10px; min-height: 1em; }
.qr { background: #fff; padding: 8px; border-radius: 8px; display: block; margin: 12px auto; width: 200px; }

/* shell */
.shell { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: 52px 1fr; height: 100vh; }
.topbar { grid-column: 1 / 3; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 16px; display: flex; gap: 8px; align-items: center; }
.brand img { width: 24px; }
.spacer { flex: 1; }
.side { background: var(--panel); border-right: 1px solid var(--line); overflow: auto; padding: 12px 8px; }
.side h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 8px 6px; display: flex; justify-content: space-between; align-items: center; }
.navitem { display: flex; justify-content: space-between; padding: 7px 10px; border-radius: 6px; cursor: pointer; color: var(--text); }
.navitem:hover { background: var(--panel2); }
.navitem.active { background: #1d3a2d; color: #bff0d8; }
.navitem .count { color: var(--muted); font-size: 12px; }
.content { overflow: auto; padding: 20px 24px; }
.content-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.content-head h2 { margin: 0; font-size: 20px; }
.content-head input { width: 240px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; max-width: 760px; }
.card h3 { margin-top: 0; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--panel2); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #1a232a; }
td .sub { color: var(--muted); font-size: 12px; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { margin-left: 4px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #55606a; }
.dot.on { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.empty { padding: 40px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: #bff0d8; border-color: var(--accent-d); }
.pill.bad { color: #ffb4b4; border-color: #5a2a2a; }
.pill.warn { color: #ffd99a; border-color: #6b4f1d; }

/* modal + toasts */
.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: 560px; max-width: 100%; max-height: 90vh; overflow: auto; padding: 20px; }
.modal h2 { margin: 0 0 12px; font-size: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal p { line-height: 1.45; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row > button { flex: 0; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 6px; max-width: 380px; box-shadow: 0 4px 16px rgba(0,0,0,.4); }
.toast.error { border-left-color: var(--danger); }

/* viewer */
body.viewer { display: flex; flex-direction: column; overflow: hidden; }
#toolbar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
#toolbar button, #toolbar select { padding: 4px 9px; font-size: 13px; width: auto; }
.brand-sm { font-weight: 700; color: var(--accent); margin-right: 6px; }
.v-title { font-weight: 600; }
#main { flex: 1; display: flex; min-height: 0; }
#stage { flex: 1; position: relative; overflow: auto; background: #050708; display: flex; align-items: center; justify-content: center; outline: none; }
#stage.actual { align-items: flex-start; justify-content: flex-start; }
#screen { display: block; image-rendering: auto; cursor: default; outline: none; background: #000; }
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5,7,8,.75); font-size: 16px; color: var(--muted); pointer-events: none; }
.dropzone { position: absolute; inset: 12px; border: 3px dashed var(--accent); border-radius: 14px; background: rgba(31,138,91,.15); display: flex; align-items: center; justify-content: center; font-size: 20px; pointer-events: none; }
#files { width: 380px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
#files.drag { outline: 3px dashed var(--accent); outline-offset: -6px; }
.files-head { display: flex; gap: 4px; padding: 8px; flex-wrap: wrap; }
.files-head button, .files-head .btn { padding: 4px 9px; font-size: 13px; }
.path { margin: 0 8px 6px; width: calc(100% - 16px); font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.flist { flex: 1; overflow: auto; border-top: 1px solid var(--line); }
.fitem { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid #1d262d; cursor: default; }
.fitem:hover { background: var(--panel2); }
.fitem .ic { width: 18px; text-align: center; }
.fitem .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fitem.dir .nm { cursor: pointer; color: #cfe8ff; }
.fitem .sz { color: var(--muted); font-size: 12px; }
.files-foot { padding: 8px; font-size: 12px; border-top: 1px solid var(--line); }
#transfers { position: fixed; left: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 40; }
.xfer { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 300px; font-size: 12px; }
.xfer .bar { height: 4px; background: var(--line); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.xfer .bar > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.xfer.err .bar > div { background: var(--danger); }
textarea { min-height: 140px; font-family: ui-monospace, Consolas, monospace; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
  .topbar { grid-column: 1; flex-wrap: wrap; padding: 8px 16px; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); max-height: 40vh; }
  .content { padding: 16px; }
  table { display: block; overflow-x: auto; }
}
.btn-primary { display: inline-block; background: var(--accent-d); border-color: var(--accent-d); color: #fff; text-decoration: none; }
.btn-primary:hover { background: var(--accent); }
.files-head label.btn { display: inline-block; margin: 0; text-transform: none; letter-spacing: 0; color: var(--text); font-size: 13px; }
