:root {
  --bg: #f4f6f8; --surface: #fff; --surface-2: #f8fafb; --border: #dfe3e8; --text: #1c2833; --muted: #5f6b76;
  --primary: #2f6f9f; --primary-h: #255a82; --primary-soft: #e4eef6; --danger: #b3261e; --danger-soft: #fbe9e7;
  --ok: #2e7d32; --warn: #a86400; --warn-soft: #fff4e0; --radius: 8px; --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif; font-size: 15px; color: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14181c; --surface: #1c2227; --surface-2: #222a30; --border: #313b44; --text: #e4e8ec; --muted: #9aa6b1;
    --primary: #5fa3d6; --primary-h: #7bb6e2; --primary-soft: #1f3445; --danger: #ef8a80; --danger-soft: #3a2220;
    --ok: #7ccf82; --warn: #f0b45a; --warn-soft: #3a2e1a; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); padding: 7px 13px;
  border-radius: 6px; cursor: pointer; white-space: nowrap; line-height: 1.2; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-h); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.icon { padding: 5px 8px; border-color: transparent; background: transparent; }
.btn.icon:hover { background: var(--surface-2); border-color: var(--border); }
.btn:disabled { opacity: .5; cursor: default; }
.muted { color: var(--muted); }
.error { color: var(--danger); background: var(--danger-soft); padding: 8px 10px; border-radius: 6px; }
.hidden { display: none !important; }
.svg-ic { width: 18px; height: 18px; flex: none; vertical-align: middle; }

/* layout */
.app { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: 56px 1fr; height: 100vh; }
header.top { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--primary); color: #fff; }
header.top .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; }
header.top .brand img { width: 30px; height: 30px; }
header.top .spacer { flex: 1; }
header.top .btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); color: #fff; }
header.top .btn:hover { background: rgba(255,255,255,.22); }
nav.side { background: var(--surface); border-right: 1px solid var(--border); padding: 12px 8px; overflow-y: auto; }
nav.side a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 6px; color: var(--text); }
nav.side a:hover { background: var(--surface-2); text-decoration: none; }
nav.side a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
nav.side .sep { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 16px 12px 6px; }
nav.side .quota { margin: 18px 12px 0; font-size: 12px; color: var(--muted); }
.bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 5px; }
.bar > span { display: block; height: 100%; background: var(--primary); }
.bar.warn > span { background: var(--warn); }
main { overflow: auto; padding: 18px 24px 80px; position: relative; }
h1 { font-size: 21px; margin: 0 0 14px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* file list */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.crumbs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; font-size: 16px; margin-bottom: 12px; }
.crumbs a { padding: 3px 7px; border-radius: 5px; color: var(--text); }
.crumbs a:hover { background: var(--surface-2); text-decoration: none; }
.crumbs a.drop-target { background: var(--primary-soft); outline: 2px dashed var(--primary); }
.crumbs .sl { color: var(--muted); }
table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
table.list th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); user-select: none; }
table.list th.sortable { cursor: pointer; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: var(--surface-2); }
table.list tr.sel { background: var(--primary-soft) !important; }
table.list tr.drop-target { outline: 2px dashed var(--primary); outline-offset: -2px; background: var(--primary-soft); }
td.cb, th.cb { width: 36px; }
td.name { display: flex; align-items: center; gap: 10px; min-width: 0; }
td.name a, td.name span.nm { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
td.num, th.num { text-align: right; white-space: nowrap; width: 110px; }
td.date { white-space: nowrap; width: 160px; color: var(--muted); }
td.act { width: 90px; text-align: right; white-space: nowrap; }
.ficon { width: 28px; height: 28px; flex: none; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); white-space: nowrap; }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.green { background: rgba(46,125,50,.12); color: var(--ok); }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }

.dropzone { position: absolute; inset: 0; background: rgba(47,111,159,.12); border: 3px dashed var(--primary); border-radius: 12px; z-index: 50;
  display: flex; align-items: center; justify-content: center; font-size: 20px; color: var(--primary); font-weight: 600; pointer-events: none; }

/* menus / dialogs */
.menu { position: fixed; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 5px; z-index: 200; min-width: 190px; }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 5px; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 300; padding: 16px; }
.dialog { background: var(--surface); border-radius: 10px; box-shadow: var(--shadow); width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 20px 22px; }
.dialog.wide { width: min(900px, 100%); }
.dialog h3 { margin: 0 0 14px; font-size: 18px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.dialog .form { display: grid; gap: 12px; }
.preview { max-width: 100%; max-height: 72vh; display: block; margin: 0 auto; }
pre.preview { white-space: pre-wrap; background: var(--surface-2); padding: 12px; border-radius: 6px; overflow: auto; max-height: 70vh; font-size: 13px; }
.share-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; display: grid; gap: 8px; }
.share-item .url { font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; background: var(--surface-2); padding: 5px 8px; border-radius: 5px; }
.picker { border: 1px solid var(--border); border-radius: 6px; max-height: 300px; overflow: auto; }
.picker div { padding: 7px 10px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.picker div:hover { background: var(--surface-2); }

/* uploads */
.uploads { position: fixed; right: 16px; bottom: 16px; width: 360px; max-height: 50vh; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); z-index: 150; display: flex; flex-direction: column; }
.uploads .hd { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 600; }
.uploads .bd { overflow: auto; padding: 6px 12px 10px; font-size: 13px; }
.uploads .it { padding: 6px 0; border-bottom: 1px solid var(--border); }
.uploads .it:last-child { border-bottom: 0; }
.uploads .it .n { display: flex; justify-content: space-between; gap: 8px; }
.uploads .it .n span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #263238; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 400; box-shadow: var(--shadow); max-width: 90vw; }
.toast.err { background: var(--danger); }

/* status */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .v { font-size: 22px; font-weight: 600; }
.stat .k { font-size: 12px; color: var(--muted); }
.warnbox { background: var(--warn-soft); color: var(--warn); border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
pre.code { background: var(--surface-2); padding: 10px 12px; border-radius: 6px; overflow: auto; font-size: 13px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; }
.kv div:nth-child(odd) { color: var(--muted); }
.setting { display: grid; grid-template-columns: 1fr 220px; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; }
.setting .d { font-size: 13px; color: var(--muted); margin-top: 3px; }
.setting .t { font-weight: 500; }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #2f6f9f, #1d4766); padding: 16px; }
.login-card { background: var(--surface); padding: 28px 30px; border-radius: 12px; width: min(380px, 100%); display: grid; gap: 14px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0; text-align: center; }
.login-card p { margin: 0; text-align: center; }
.login-logo { width: 64px; height: 64px; margin: 0 auto; display: block; }

/* mobile */
.menu-toggle { display: none; }
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  nav.side { position: fixed; top: 56px; bottom: 0; left: 0; width: 240px; z-index: 120; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  nav.side.open { transform: none; }
  .menu-toggle { display: inline-flex; }
  td.date, th.date { display: none; }
  main { padding: 14px 12px 80px; }
  .setting { grid-template-columns: 1fr; }
  .uploads { left: 8px; right: 8px; width: auto; }
}
