:root { --bg: #14161b; --panel: #1c1f26; --line: #2a2e38; --text: #e6e8ee; --muted: #8b93a5; --accent: #4f8cff; --err: #ff6b6b; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font: 14px system-ui, sans-serif; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
.error { color: var(--err); min-height: 1.2em; margin: 0; }

#login { height: 100%; display: grid; place-items: center; }
#login-form { display: grid; gap: 12px; width: min(340px, 90vw); }
#login-form h1 { margin: 0 0 8px; text-align: center; }

#app { height: 100%; display: grid; grid-template-columns: 260px 1fr; }
aside { background: var(--panel); border-right: 1px solid var(--line); overflow: auto; }
.side-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px; border-bottom: 1px solid var(--line); }
.side-head .seg { flex: 1 1 100%; }
#host-list { list-style: none; margin: 0; padding: 6px; }
#host-list .group { color: var(--muted); font-size: 12px; padding: 10px 8px 4px; text-transform: uppercase; }
#host-list li.host { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
#host-list li.host:hover { background: var(--bg); }
#host-list .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#host-list .label small { display: block; color: var(--muted); }
#host-list .tools button { padding: 2px 6px; font-size: 12px; }

main { display: flex; flex-direction: column; min-width: 0; }
#tabs { display: flex; gap: 2px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; border-right: 1px solid var(--line); white-space: nowrap; }
.tab.active { background: var(--bg); box-shadow: inset 0 -2px var(--accent); }
.tab button { padding: 0 6px; border: 0; background: transparent; }
#terminals { flex: 1; position: relative; min-height: 0; }
#terminals .hint { color: var(--muted); text-align: center; margin-top: 30vh; }
.term { position: absolute; inset: 6px; display: none; }
.term.active { display: block; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 20px; width: min(440px, 94vw); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog form { display: grid; gap: 10px; }
dialog h2 { margin: 0; }
dialog label { display: grid; gap: 4px; color: var(--muted); }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 700px) { #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; } aside { max-height: 32vh; } }

.seg { flex: 1; display: flex; gap: 2px; }
.seg button { flex: 1; padding: 6px 4px; font-size: 12px; }
.seg button.on { border-color: var(--accent); color: var(--accent); }
.list { list-style: none; margin: 0; padding: 6px; }
.list .group { color: var(--muted); font-size: 12px; padding: 10px 8px 4px; text-transform: uppercase; }
.list li.item { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.list li.item:hover { background: var(--bg); }
.list .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .label small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.list .tools { display: flex; gap: 2px; }
.list .tools button { padding: 2px 6px; font-size: 12px; }
.list .empty { color: var(--muted); padding: 12px 8px; }

.sftp { display: none; flex-direction: column; gap: 8px; overflow: hidden; }
.sftp.active { display: flex; }
.sftp .bar { display: flex; gap: 6px; }
.sftp .bar input { flex: 1; min-width: 0; }
.sftp .files { flex: 1; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.sftp table { width: 100%; border-collapse: collapse; }
.sftp th, .sftp td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.sftp th { position: sticky; top: 0; background: var(--panel); color: var(--muted); font-weight: 500; }
.sftp tr.dir td:first-child { cursor: pointer; color: var(--accent); }
.sftp td.name { width: 100%; }
.sftp .row-tools button, .sftp .row-tools a { padding: 2px 8px; font-size: 12px; margin-left: 4px; color: inherit; text-decoration: none; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.sftp .status { color: var(--muted); min-height: 1.2em; }
