:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-muted: #71717a;
  --text-faint: #a1a1aa;
  --accent: #18181b;
  --accent-hover: #000000;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --success: #15803d;
  --radius: 8px;
  --radius-sm: 6px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-feature-settings: 'tnum' 1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ---------- Экран входа ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.login-card .subtitle {
  margin: 0 0 28px;
  color: var(--text-muted);
  font-size: 14px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 7px;
  color: var(--text-muted);
}

.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
  margin-top: 4px;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn-danger {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-danger:hover {
  background: var(--surface-2);
  color: var(--text);
}

.alert {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.alert.error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #fecaca;
  display: block;
}

.form-foot {
  margin: 20px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.form-foot a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
  padding-bottom: 1px;
}

.form-foot a:hover {
  border-color: var(--accent);
}

/* ---------- Шапка портала ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar .brand .logo {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.topbar .user-area {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-muted);
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ---------- Зона загрузки ---------- */
.dropzone {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 32px 24px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}

.dropzone:hover {
  border-color: var(--text-faint);
}

.dropzone.dragover {
  border-color: var(--accent);
  background: var(--surface-2);
}

.dropzone .icon {
  display: none;
}

.dropzone .hint {
  color: var(--text-faint);
  font-size: 13px;
  margin-top: 6px;
}

.dropzone strong {
  color: var(--text);
  font-weight: 500;
}

/* ---------- Список загрузок (прогресс) ---------- */
.uploads {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upload-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
}

.upload-item .row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.progress {
  height: 3px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s;
}

.upload-item.done .progress > span {
  background: var(--success);
}

.upload-item.error {
  border-color: #fecaca;
}

.upload-item.error .progress > span {
  background: var(--danger);
}

/* ---------- Таблица файлов ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 36px 0 16px;
}

.toolbar h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.search {
  flex: 1;
  max-width: 260px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
}

.search:focus {
  outline: none;
  border-color: var(--accent);
}

.file-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--surface-2);
}

.file-name {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 400;
  word-break: break-all;
}

.file-ext {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

.actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.actions a.btn-icon,
.actions button.btn-icon {
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.actions a.btn-icon:hover {
  background: var(--surface-2);
  color: var(--text);
}

.actions button.btn-icon.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.empty {
  padding: 56px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
}

.empty .icon {
  display: none;
}

/* ---------- Тосты ---------- */
.toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}

.toast {
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  animation: slidein 0.2s ease;
  max-width: 320px;
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

@keyframes slidein {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

@media (max-width: 640px) {
  .col-hide-sm {
    display: none;
  }
  .container {
    padding: 20px 14px 50px;
  }
}
