:root {
  --accent: #1a6fc4;
  --accent-dark: #135698;
  --border: #d5dbe3;
  --bg: #f4f6f9;
  --text: #24303d;
  --muted: #6b7785;
  --select: #dbeafb;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font: 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
button { font: inherit; color: inherit; padding: 5px 12px; border: 1px solid var(--border); border-radius: 3px; background: #fff; cursor: pointer; }
button:hover:not(:disabled) { background: #eef2f7; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent-dark); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--accent-dark); }
button.link { border: 0; background: none; color: inherit; text-decoration: underline; padding: 2px 4px; }
input { font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: 3px; width: 100%; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.error { color: #b3261e; margin: 0; }

.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, #1a6fc4, #0e3f70); }
.login-card { width: 340px; max-width: 100%; display: flex; flex-direction: column; gap: 12px; padding: 28px; background: #fff; border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.login-card h1 { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
.login-card label { display: flex; flex-direction: column; gap: 4px; }
.login-card p { margin: 0; }

.app { height: 100%; display: flex; flex-direction: column; }
.titlebar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--accent); color: #fff; }
.brand { font-size: 15px; font-weight: 600; }
.badge { padding: 1px 8px; border-radius: 9px; background: rgba(255,255,255,.22); font-size: 11px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--border); }
.pathbar { display: flex; align-items: center; gap: 6px; padding: 6px 12px; background: #fff; border-bottom: 1px solid var(--border); }
.pathbar > button { padding: 2px 8px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; min-width: 0; }
.crumbs button { border: 0; background: none; padding: 2px 5px; color: var(--accent-dark); }
.crumbs button:last-child { color: var(--text); font-weight: 600; }
.crumbs span { color: var(--muted); }

.body { flex: 1; min-height: 0; display: flex; }
.tree { width: 240px; flex: none; overflow: auto; padding: 8px 4px; background: #eef1f5; border-right: 1px solid var(--border); }
.tree-node { display: flex; align-items: center; padding: 3px 4px; border-radius: 3px; cursor: pointer; white-space: nowrap; }
.tree-node:hover { background: #e0e6ee; }
.tree-node.current { background: var(--select); font-weight: 600; }
.twist { width: 16px; flex: none; text-align: center; color: var(--muted); font-size: 10px; }
.tree-children { padding-left: 14px; }

.listing { flex: 1; min-width: 0; overflow: auto; background: #fff; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { position: sticky; top: 0; z-index: 1; padding: 6px 10px; text-align: left; font-weight: 600; background: #f7f9fb; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; }
th.sorted-asc::after { content: " \25B2"; font-size: 9px; }
th.sorted-desc::after { content: " \25BC"; font-size: 9px; }
td { padding: 5px 10px; border-bottom: 1px solid #eef1f5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tbody tr { cursor: default; }
tbody tr:hover { background: #f4f7fb; }
tbody tr.selected { background: var(--select); }
.col-size { width: 90px; } .col-type { width: 130px; } .col-mtime { width: 170px; }
.icon { display: inline-block; width: 16px; height: 13px; margin-right: 7px; vertical-align: -2px; border-radius: 2px; flex: none; }
.icon.folder { background: #e8b84a; border: 1px solid #c79528; }
.icon.file { width: 12px; height: 15px; margin-left: 2px; margin-right: 9px; background: #fff; border: 1px solid #8fa0b3; }
.empty { padding: 30px; text-align: center; }

.menu-wrap { position: relative; }
.menu { position: absolute; z-index: 20; top: 100%; left: 0; min-width: 150px; margin-top: 2px; padding: 4px 0; background: #fff; border: 1px solid var(--border); border-radius: 3px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.menu.context { position: fixed; top: auto; margin: 0; }
.menu button { display: block; width: 100%; border: 0; border-radius: 0; background: none; text-align: left; padding: 6px 14px; }
.menu button:hover:not(:disabled) { background: var(--select); }

.uploads { position: fixed; right: 16px; bottom: 16px; z-index: 15; width: 400px; max-width: calc(100vw - 32px); background: #fff; border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 6px 22px rgba(0,0,0,.22); }
.uploads > header { display: flex; align-items: center; padding: 7px 10px; background: #f7f9fb; border-bottom: 1px solid var(--border); }
.upload-rows { max-height: 260px; overflow: auto; }
.upload-row { padding: 6px 10px; border-bottom: 1px solid #eef1f5; }
.upload-line { display: flex; align-items: center; gap: 8px; }
.upload-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-status { color: var(--muted); font-size: 12px; }
.upload-status.failed { color: #b3261e; }
.upload-row button { padding: 0 6px; font-size: 12px; }
.bar { height: 4px; margin-top: 4px; background: #e5eaf0; border-radius: 2px; overflow: hidden; }
.bar > div { width: 0; height: 100%; background: var(--accent); }

.toast { position: fixed; left: 50%; bottom: 20px; z-index: 30; transform: translateX(-50%); padding: 8px 14px; color: #fff; background: #2a3644; border-radius: 3px; }
dialog { width: 400px; max-width: calc(100vw - 32px); border: 1px solid var(--border); border-radius: 5px; padding: 18px; }
dialog::backdrop { background: rgba(10,20,30,.4); }
dialog h2 { margin: 0 0 8px; font-size: 15px; }
dialog p { margin: 0 0 10px; overflow-wrap: anywhere; }
.check { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.check input { width: auto; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 6px; margin-top: 12px; }

@media (max-width: 700px) {
  .tree { display: none; }
  .col-type { display: none; }
  td:nth-child(3) { display: none; }
  .col-mtime { width: 130px; }
}
