/* =========================================================
   Базовые сбросы и переменные
   ========================================================= */
* { box-sizing: border-box; }

:root{
  --bg:#f5f7fb;
  --panel:#ffffff;
  --border:#e5e9f2;
  --text:#1f2937;
  --muted:#6b7280;
  --brand:#3b82f6;
  --brand-2:#6366f1;
  --danger:#ef4444;
  --ok:#10b981;
  --radius:12px;
}

html,body{
  margin:0;
  padding:0;
  background:var(--bg);
  color:var(--text);
  font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
}

/* Каркас страницы: header + main + footer на всю высоту */
body{
  min-height:100vh;
  display:flex;
  flex-direction:column;
}

a{ color:var(--brand); text-decoration:none; }
a:hover{ text-decoration:underline; }

h1,h2,h3{ margin:0 0 16px; }
h1{ font-size:22px; }
h2{ font-size:18px; }
h3{ font-size:16px; }

/* =========================================================
   Шапка и подвал
   ========================================================= */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 24px;
  background:var(--panel);
  border-bottom:1px solid var(--border);
  position:sticky;
  top:0;
  z-index:10;
}
.brand{
  font-weight:700;
  color:var(--text);
  font-size:18px;
  display:flex;
  gap:8px;
  align-items:center;
}
.brand i{ color:var(--brand); }

.topnav{
  display:flex;
  gap:16px;
  align-items:center;
  flex-wrap:wrap;
}
.topnav a,
.topnav .user{
  color:var(--text);
  font-size:14px;
  display:inline-flex;
  gap:6px;
  align-items:center;
}
.topnav .user{ color:var(--muted); }

.footer{
  text-align:center;
  color:var(--muted);
  padding:20px;
  font-size:13px;
}

/* =========================================================
   Контейнер
   ========================================================= */
.container{
  width:100%;
  max-width:1400px;
  margin:0 auto;
  padding:24px;
  flex:1 1 auto;
  display:flex;
  flex-direction:column;
  min-height:0;
}

/* =========================================================
   Карточки
   ========================================================= */
.card{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:20px;
  box-shadow:0 1px 2px rgba(16,24,40,.04);
}

/* =========================================================
   Кнопки
   ========================================================= */
.btn{
  display:inline-flex;
  gap:8px;
  align-items:center;
  justify-content:center;
  padding:10px 16px;
  border-radius:10px;
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  cursor:pointer;
  font-size:14px;
  transition:.15s;
  line-height:1;
  text-decoration:none;
}
.btn:hover{ border-color:#cbd5e1; text-decoration:none; }
.btn-primary{ background:var(--brand); color:#fff; border-color:var(--brand); }
.btn-primary:hover{ background:#2563eb; border-color:#2563eb; }
.btn-danger{ background:var(--danger); color:#fff; border-color:var(--danger); }
.btn-danger:hover{ background:#dc2626; border-color:#dc2626; }
.btn-sm{ padding:6px 10px; font-size:13px; }
.btn-lg{ padding:12px 22px; font-size:15px; border-radius:12px; }

/* =========================================================
   Формы
   ========================================================= */
input[type=text],
input[type=password],
input[type=file],
select{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#fff;
  font-size:14px;
  outline:none;
  color:var(--text);
  font-family:inherit;
}
input:focus,
select:focus{ border-color:var(--brand); }

label{
  display:block;
  font-size:13px;
  color:var(--muted);
  margin:12px 0 6px;
}

/* =========================================================
   Уведомления
   ========================================================= */
.alert{
  padding:10px 14px;
  border-radius:10px;
  margin-bottom:14px;
  font-size:14px;
}
.alert-error{ background:#fee2e2; color:#991b1b; }
.alert-ok{ background:#dcfce7; color:#166534; }

/* =========================================================
   Авторизация
   ========================================================= */
.auth-wrap{ max-width:380px; margin:60px auto; width:100%; }
.auth-wrap h1{ text-align:center; }

/* =========================================================
   Главная страница
   ========================================================= */
.hero{
  flex:1 1 auto;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:40px 16px;
}
.hero-card{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:16px;
  padding:48px 40px;
  max-width:440px;
  width:100%;
  text-align:center;
  box-shadow:0 4px 16px rgba(16,24,40,.05);
}
.hero-icon{
  width:72px;
  height:72px;
  border-radius:50%;
  background:#eff6ff;
  color:var(--brand);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:32px;
  margin-bottom:20px;
}
.hero-card h1{ font-size:24px; margin:0 0 10px; }
.hero-sub{
  color:var(--muted);
  font-size:15px;
  line-height:1.5;
  margin:0 0 26px;
}

/* =========================================================
   Публичная сетка файлов (если используется)
   ========================================================= */
.grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(240px, 1fr));
  gap:16px;
}
.file-card{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:16px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.file-card .name{ font-weight:600; word-break:break-word; }
.file-card .meta{
  color:var(--muted);
  font-size:12px;
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}
.file-card .actions{ display:flex; gap:8px; margin-top:auto; }

/* =========================================================
   Dashboard — 25% слева, 75% справа, на всю высоту
   ========================================================= */
.dash{
  flex:1 1 auto;
  display:grid;
  grid-template-columns: 1fr 3fr;   /* 25% / 75% */
  gap:20px;
  min-height:0;
}

@media (max-width: 860px){
  .dash{
    grid-template-columns: 1fr;     /* мобильные — друг под другом, равная ширина */
  }
}

.dash > .card{
  display:flex;
  flex-direction:column;
  min-height:0;
  height:100%;
}

.dash > .card [data-tree]{
  flex:1 1 auto;
  overflow:auto;
  min-height:0;
}

.dash > .card [data-file-list]{
  flex:1 1 auto;
  overflow:auto;
  min-height:0;
  margin-top:16px;
}

/* =========================================================
   Дерево каталогов
   ========================================================= */
.tree{
  list-style:none;
  padding:0;
  margin:0;
  font-size:14px;
  user-select:none;
}
.tree ul{
  list-style:none;
  padding-left:16px;
  margin:2px 0;
  border-left:1px dashed #e5e9f2;
  margin-left:6px;
}
.tree li{ list-style:none; }

.tree .node{
  display:flex;
  align-items:center;
  gap:8px;
  padding:6px 8px;
  border-radius:8px;
  cursor:pointer;
  color:var(--text);
  transition:background .12s, color .12s;
  min-width:0;
}
.tree .node:hover{ background:#eef2ff; }
.tree .node.active{
  background:#e0e7ff;
  color:#1e3a8a;
  font-weight:600;
}
.tree .node.active .icon{ color:#4f46e5; }

.tree .node .name{
  flex:1 1 auto;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.tree .node .actions{
  display:none;
  gap:6px;
  flex:0 0 auto;
}
.tree .node:hover .actions{ display:inline-flex; }
.tree .node .actions a{
  color:var(--muted);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:22px;
  height:22px;
  border-radius:6px;
  transition:background .12s, color .12s;
}
.tree .node .actions a:hover{
  background:#fff;
  color:var(--brand);
  text-decoration:none;
}
.tree .node .actions a[data-act="delete"]:hover{
  color:var(--danger);
}
.tree .icon{
  width:16px;
  text-align:center;
  color:#f59e0b;
  flex:0 0 auto;
}
.tree .icon.file{ color:#64748b; }

/* Корневой узел — отдельный вид */
[data-tree] > .node{
  font-weight:600;
  padding:8px;
  border-bottom:1px solid var(--border);
  border-radius:0;
  margin-bottom:6px;
}
[data-tree] > .node:hover{ background:#eef2ff; }

/* =========================================================
   Dropzone и прогресс
   ========================================================= */
.dropzone{
  border:2px dashed #c7d2fe;
  background:#f8faff;
  border-radius:var(--radius);
  padding:40px 20px;
  text-align:center;
  color:var(--muted);
  transition:.15s;
  cursor:pointer;
}
.dropzone.drag{
  background:#eef2ff;
  border-color:var(--brand);
  color:var(--brand);
}
.dropzone .dz-icon{
  font-size:34px;
  color:var(--brand);
  margin-bottom:10px;
  display:block;
}
.progress{
  margin-top:12px;
  height:6px;
  background:#e5e7eb;
  border-radius:99px;
  overflow:hidden;
  display:none;
}
.progress > span{
  display:block;
  height:100%;
  width:0;
  background:var(--brand);
  transition:width .15s;
}

/* =========================================================
   Тулбар, хлебные крошки
   ========================================================= */
.toolbar{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  margin-bottom:12px;
}
.breadcrumbs{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  color:var(--muted);
  font-size:13px;
  margin-bottom:8px;
}
.breadcrumbs a{ color:var(--muted); }
.breadcrumbs span.sep{ opacity:.6; }

/* =========================================================
   Модалка
   ========================================================= */
.modal-bg{
  position:fixed;
  inset:0;
  background:rgba(15,23,42,.45);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:100;
}
.modal-bg.open{ display:flex; }
.modal{
  background:#fff;
  border-radius:var(--radius);
  max-width:420px;
  width:92%;
  padding:20px;
}
.modal h3{ margin-top:0; }
.modal .row{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  margin-top:16px;
}

/* =========================================================
   Таблицы (админка + список файлов)
   ========================================================= */
table.tbl{
  width:100%;
  border-collapse:collapse;
  font-size:14px;
}
.tbl th,
.tbl td{
  padding:10px;
  border-bottom:1px solid var(--border);
  text-align:left;
  vertical-align:middle;
}
.tbl th{
  color:var(--muted);
  font-weight:600;
  font-size:13px;
}
.tbl tr:last-child td{ border-bottom:0; }

/* Короткие ссылки */
.shortlink{
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size:13px;
  color:var(--brand);
  white-space:nowrap;
}
.shortlink:hover{ text-decoration:underline; }