:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --border: #e3e7ee;
  --text: #1c2433;
  --muted: #7a8699;
  --accent: #2563eb;
  --accent-hover: #1d4fd7;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* ---------- логин ---------- */

.login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eef2f9 0%, #e2e9f5 100%);
  z-index: 100;
}

.login-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 36px 32px 32px;
  width: min(360px, calc(100vw - 40px));
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-logo { font-size: 42px; margin-bottom: 6px; }

.login-card h1 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: .5px;
}

.login-sub {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
}

#login-key {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  outline: none;
  transition: border-color .15s;
}

#login-key:focus { border-color: var(--accent); }

.login-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 20px;
  margin-top: 8px;
  text-align: center;
}

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

/* ---------- кнопки ---------- */

.btn {
  padding: 8px 16px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  transition: background .15s, border-color .15s;
}

.btn:hover { background: #f5f7fa; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.icon-btn {
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 15px;
  color: var(--muted);
  line-height: 1;
}

.icon-btn:hover { background: #eef1f6; color: var(--text); }

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

.icon-btn.lock.on { color: #b45309; }

.lock-badge { font-size: 12px; }

/* ---------- каркас ---------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 20px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 0 12px;
}

.brand { font-size: 18px; font-weight: 700; white-space: nowrap; }

.crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
  font-size: 14px;
}

.crumbs button {
  padding: 4px 8px;
  border-radius: 8px;
  color: var(--accent);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crumbs button:hover { background: #e9eefb; }

.crumbs button:last-child { color: var(--text); font-weight: 600; }

.crumbs .sep { color: var(--muted); }

.top-actions { margin-left: auto; display: flex; gap: 4px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 14px;
  flex-wrap: wrap;
}

.hint { color: var(--muted); font-size: 13px; }

/* ---------- список ---------- */

.list-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden auto;
  flex: 1;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 100px 150px 150px 84px;
  gap: 10px;
  align-items: center;
  padding: 9px 16px;
  border-top: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.row:first-child { border-top: none; }

.row:not(.head):hover { background: #f7f9fc; }

.row.head {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
  cursor: default;
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}

.name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.name .lbl {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.name.folder .lbl { font-weight: 600; }

.row > div:nth-child(2), .row > div:nth-child(3), .row > div:nth-child(4) {
  color: var(--muted);
  white-space: nowrap;
  font-size: 13px;
}

.expired, .soon { color: #d97706; }

.row-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity .12s;
}

.row:hover .row-actions { opacity: 1; }

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
}

/* ---------- загрузки ---------- */

.uploads {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 340px;
  max-height: 45vh;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(16, 24, 40, .18);
  padding: 10px;
  display: none;
  z-index: 50;
}

.uploads.active { display: block; }

.up-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 30px;
  gap: 8px;
  align-items: center;
  padding: 6px 4px;
}

.up-name {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.up-bar {
  height: 6px;
  background: #edf0f5;
  border-radius: 4px;
  overflow: hidden;
}

.up-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 4px;
  transition: width .15s;
}

.up-row.done .up-bar i { background: #16a34a; }
.up-row.fail .up-bar i { background: var(--danger); }

.up-pct {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}

/* ---------- dropzone ---------- */

.dropzone {
  position: fixed;
  inset: 0;
  background: rgba(37, 99, 235, .08);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 90;
  pointer-events: none;
}

.dropzone.on { display: flex; }

.dz-inner {
  border: 2px dashed var(--accent);
  border-radius: 16px;
  background: rgba(255, 255, 255, .9);
  padding: 36px 56px;
  font-size: 17px;
  font-weight: 600;
  color: var(--accent);
}

/* ---------- мобильная версия ---------- */

@media (max-width: 720px) {
  .row { grid-template-columns: minmax(0, 1fr) 80px 64px; }
  .row > div:nth-child(3), .row > div:nth-child(4) { display: none; }
  .uploads { left: 12px; right: 12px; width: auto; }
}
