* { box-sizing: border-box; margin: 0; padding: 0; }

label.required::after { content: ' *'; color: #c5221f; font-weight: 700; }
input.invalid, select.invalid { border-color: #c5221f !important; background: #fff5f5; }

body {
  font-family: sans-serif;
  background: #f4f4f4;
  min-height: 100vh;
}

/* ШАПКА */
header {
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 1.1rem;
  font-weight: 600;
  color: #222;
  text-decoration: none;
  flex-shrink: 0;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  padding-left: 24px;
}

.nav-link {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.88rem;
  color: #555;
  text-decoration: none;
  transition: all 0.15s;
}

.nav-link:hover { background: #f4f4f4; color: #222; }
.nav-link.active { background: #e8f0fe; color: #1a73e8; font-weight: 500; }

.nav-dropdown { position: relative; }
.nav-dropdown > .nav-link { cursor: pointer; user-select: none; }
.nav-dropdown-menu {
  display: none;
  position: absolute; top: calc(100% + 4px); left: 0;
  background: #fff; border: 1px solid #e8e8e8; border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  min-width: 180px; padding: 4px 0; z-index: 100;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: block; padding: 8px 14px;
  font-size: 0.88rem; color: #333; text-decoration: none;
}
.nav-dropdown-menu a:hover { background: #f4f4f4; }
.nav-dropdown-menu a.active { color: #1a73e8; font-weight: 500; }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Переключатель языка */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  background: #f4f4f4;
  border-radius: 8px;
  padding: 3px;
}

.lang-btn {
  background: none;
  border: none;
  border-radius: 5px;
  padding: 3px 9px;
  font-size: 0.78rem;
  font-weight: 500;
  color: #888;
  cursor: pointer;
  transition: all 0.15s;
}

.lang-btn.active { background: #fff; color: #222; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* Пользователь */
#user-info { display: none; align-items: center; gap: 8px; }
#user-info img { width: 32px; height: 32px; border-radius: 50%; }
.uname { font-size: 0.85rem; color: #333; }
.uemail { font-size: 0.7rem; color: #999; }

/* Кнопки */
.btn {
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-outline { background: none; border: 1px solid #ddd; color: #555; }
.btn-outline:hover { background: #f4f4f4; }
.btn-primary { background: #1a73e8; border: none; color: #fff; }
.btn-primary:hover { background: #1557b0; }
.btn-danger { background: none; border: 1px solid #f44; color: #c33; }
.btn-danger:hover { background: #fff0f0; }

/* ГОСТЬ */
#guest-view {
  text-align: center;
  padding: 100px 24px;
}

#guest-view h2 { font-size: 1.4rem; color: #333; margin-bottom: 8px; }
#guest-view p { color: #999; margin-bottom: 32px; }
#guest-signin { display: flex; justify-content: center; }

/* LAYOUT */
#app-view { display: none; }

.layout {
  display: flex;
  height: calc(100vh - 56px);
}

/* САЙДБАР */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e8e8e8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-add-root {
  background: none;
  border: none;
  color: #1a73e8;
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  display: none;
}

.tree { flex: 1; overflow-y: auto; padding: 8px 0; }

/* Папки */
.folder-item { user-select: none; }

.folder-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 6px;
  margin: 1px 6px;
  transition: background 0.1s;
}

.folder-row:hover { background: #f4f4f4; }
.folder-row.active { background: #e8f0fe; }
.folder-row.active .folder-name { color: #1a73e8; font-weight: 500; }

.folder-toggle {
  font-size: 0.6rem;
  color: #bbb;
  width: 12px;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.folder-toggle.open { transform: rotate(90deg); }
.folder-toggle.invisible { visibility: hidden; }
.folder-icon { font-size: 0.95rem; flex-shrink: 0; }
.folder-name { font-size: 0.88rem; color: #333; flex: 1; }

.folder-actions { display: none; gap: 2px; }
.folder-row:hover .folder-actions { display: flex; }

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  color: #bbb;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.1s;
}

.icon-btn:hover { color: #555; background: #e8e8e8; }
.icon-btn.del:hover { color: #c33; background: #fff0f0; }

.folder-children { padding-left: 16px; }

/* ОСНОВНАЯ ОБЛАСТЬ */
.main-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.main-empty {
  text-align: center;
  padding: 80px 24px;
  color: #bbb;
}

/* Загрузка */
.upload-zone {
  border: 2px dashed #ddd;
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  margin-bottom: 24px;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafafa;
}

.upload-zone:hover,
.upload-zone.dragover { border-color: #1a73e8; background: #f0f4ff; }
.upload-zone input { display: none; }
.upload-icon { font-size: 2rem; margin-bottom: 6px; }
.upload-zone p { font-size: 0.88rem; color: #999; margin-top: 6px; }

.progress-bar {
  display: none;
  background: #f0f0f0;
  border-radius: 4px;
  height: 6px;
  margin-bottom: 16px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #1a73e8;
  border-radius: 4px;
  transition: width 0.3s;
  width: 0%;
}

/* Файлы */
.files-list { display: flex; flex-direction: column; gap: 8px; }

.file-item {
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: box-shadow 0.15s;
}

.file-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

.file-icon { font-size: 1.6rem; flex-shrink: 0; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 0.9rem; color: #222; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 0.75rem; color: #999; margin-top: 2px; }
.file-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Модалка */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  width: 360px;
  max-width: 90vw;
}

.modal h3 { font-size: 1rem; margin-bottom: 16px; color: #222; }

.modal input {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 0.9rem;
  margin-bottom: 16px;
  outline: none;
}

.modal input:focus { border-color: #1a73e8; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Уведомление */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #333;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.85rem;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s;
  z-index: 300;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #1e8e3e; }
.toast.error { background: #c5221f; }

/* Folder content header */
.folder-content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.folder-content-header h2 { font-size: 1.1rem; color: #222; }
