:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1e222b; --line: #2a2f3a;
  --text: #e8eaef; --muted: #8b93a3; --accent: #5b8cff; --accent2: #3f6fe0;
  --ok: #3ccf8e; --warn: #f5b84a; --bad: #ff5d6c; --radius: 12px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}
@media (prefers-color-scheme: light) {
  :root { --bg:#f4f6fa; --panel:#fff; --panel2:#f0f2f7; --line:#dfe3ea; --text:#1b1f27; --muted:#6b7385; --shadow:0 10px 30px rgba(20,30,60,.12); }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }

/* --- кнопки и поля --- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel2); cursor: pointer; white-space: nowrap; transition: .15s; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.icon { padding: 6px 9px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=password], input[type=number], input[type=url], select {
  width: 100%; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel2); outline: none; }
input:focus, select:focus { border-color: var(--accent); }
label.field { display: block; margin: 10px 0; }
label.field span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* --- вход --- */
.auth { max-width: 380px; margin: 12vh auto; padding: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.auth h1 { margin: 0 0 4px; font-size: 22px; }
.auth .btn { width: 100%; justify-content: center; margin-top: 8px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin-top: 8px; }

/* --- каркас --- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.logo { font-weight: 700; font-size: 18px; padding: 4px 10px 16px; }
.logo b { color: var(--accent); }
.nav a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 9px; color: var(--text); }
.nav a:hover { background: var(--panel2); }
.nav a.active { background: var(--panel2); color: var(--accent); font-weight: 600; }
.quota { margin-top: auto; padding: 12px; background: var(--panel2); border-radius: 10px; font-size: 13px; }
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 6px 0; display: flex; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar > i.warn { background: var(--warn); } .bar > i.bad { background: var(--bad); } .bar > i.other { background: var(--muted); }
.main { padding: 22px 28px 120px; min-width: 0; }
.topbar { display: none; }
h2 { margin: 0 0 16px; font-size: 22px; }

/* --- файлы --- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .search { flex: 1; min-width: 160px; max-width: 320px; margin-left: auto; }
.crumbs { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; font-size: 15px; }
.crumbs a { padding: 3px 6px; border-radius: 6px; color: var(--text); }
.crumbs a:hover { background: var(--panel2); }
.crumbs .sep { color: var(--muted); }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item { display: grid; grid-template-columns: 34px 1fr 110px 150px 40px; gap: 10px; align-items: center; padding: 9px 14px; border-top: 1px solid var(--line); cursor: default; }
.item:first-child { border-top: 0; }
.item:hover { background: var(--panel2); }
.item .ic { font-size: 22px; text-align: center; }
.item .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.item .nm small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.item .sz, .item .dt { color: var(--muted); font-size: 13px; text-align: right; }
.item.head { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; cursor: default; }
.item.head:hover { background: none; }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); }
.dropzone { outline: 2px dashed var(--accent); outline-offset: -8px; }

/* --- меню --- */
.menu { position: fixed; z-index: 60; min-width: 210px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; }
.menu button { display: flex; width: 100%; gap: 10px; align-items: center; padding: 8px 12px; border: 0; background: none; border-radius: 7px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--panel2); }
.menu button.danger { color: var(--bad); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* --- модалки --- */
.overlay { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 12px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.copybox { display: flex; gap: 6px; margin-top: 8px; }
.copybox input { font-family: ui-monospace, monospace; font-size: 12px; }
.picker { border: 1px solid var(--line); border-radius: 10px; max-height: 300px; overflow: auto; margin-top: 8px; }
.picker div { padding: 8px 12px; cursor: pointer; border-top: 1px solid var(--line); }
.picker div:first-child { border-top: 0; }
.picker div:hover { background: var(--panel2); }

/* --- загрузки --- */
.uploads { position: fixed; right: 16px; bottom: 16px; z-index: 50; width: 360px; max-width: calc(100vw - 32px); max-height: 50vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.uploads .uh { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 600; position: sticky; top: 0; background: var(--panel); }
.up { padding: 10px 14px; border-top: 1px solid var(--line); font-size: 13px; }
.up:first-of-type { border-top: 0; }
.up .t { display: flex; gap: 8px; align-items: center; }
.up .t .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up .s { color: var(--muted); font-size: 12px; }

/* --- карточки и таблицы --- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card .v { font-size: 22px; font-weight: 700; margin-top: 4px; }
.card .l { color: var(--muted); font-size: 13px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; }
.panel h3 { margin: 0 0 12px; font-size: 16px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; padding: 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tablewrap { overflow-x: auto; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px; background: var(--panel2); border: 1px solid var(--line); }
.badge.ok { color: var(--ok); } .badge.bad { color: var(--bad); } .badge.warn { color: var(--warn); } .badge.acc { color: var(--accent); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 7px 14px; border-radius: 20px; border: 1px solid var(--line); color: var(--text); }
.tabs a.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.quota-edit { display: flex; gap: 6px; align-items: center; }
.quota-edit input { width: 90px; }

/* --- публичная страница --- */
.public { max-width: 760px; margin: 6vh auto; padding: 0 16px; }
.public .hero { text-align: center; padding: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; margin-bottom: 16px; }
.public .hero .ic { font-size: 54px; }
.public .hero h1 { font-size: 20px; word-break: break-word; margin: 8px 0; }

/* --- уведомления --- */
.toasts { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 90vw; }
.toast.bad { border-left-color: var(--bad); } .toast.ok { border-left-color: var(--ok); }

/* --- телефон --- */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 80; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: .2s; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
  .main { padding: 16px 12px 140px; }
  .item { grid-template-columns: 30px 1fr 40px; }
  .item .sz, .item .dt { display: none; }
  .item .nm small.mob { display: block; }
  .toolbar .search { max-width: none; margin-left: 0; width: 100%; }
}
.item .nm small.mob { display: none; }
@media (max-width: 820px) { .item .nm small.mob { display: block; } }
