.hidden { display: none !important; }

:root {
  --bg-deep: #0f172a;
  --bg-card: rgba(255, 255, 255, 0.08);
  --bg-card-solid: #1e293b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.15);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --success: #22c55e;
  --error: #ef4444;
  --info: #38bdf8;
  --radius: 16px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  overflow: hidden;
}

body {
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  position: fixed;
  inset: 0;
  width: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-deep);
}

.app-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 0%, rgba(59, 130, 246, 0.25), transparent),
    radial-gradient(ellipse 60% 50% at 90% 80%, rgba(99, 102, 241, 0.2), transparent),
    linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
  z-index: -1;
}

.app-shell {
  height: 100dvh;
  max-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding:
    max(0.75rem, env(safe-area-inset-top))
    1.25rem
    max(0.75rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-home .home-grid {
  flex: 1;
  min-height: 0;
  align-content: center;
}

.page-home .app-footer {
  margin-top: auto;
  flex-shrink: 0;
  padding: 0.75rem 0 0;
}

.page-auth {
  justify-content: center;
  overflow: hidden;
}

.page-auth .auth-card {
  margin: 0 auto;
  max-height: 100%;
  overflow: hidden;
}

/* Auth */
.auth-card {
  margin: auto;
  width: 100%;
  padding: 2rem 1.5rem;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand { text-align: center; margin-bottom: 2rem; }
.brand.compact { margin-bottom: 1.5rem; }
.brand-icon {
  width: 64px; height: 64px;
  margin: 0 auto 1rem;
  color: var(--accent);
}
.brand-logo {
  display: block;
  width: 128px;
  height: 128px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
.brand h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
.subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.35rem; }

.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field span { font-size: 0.85rem; color: var(--text-muted); }
.field input {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
.field input:focus { border-color: var(--accent); }

.auth-remember {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

/* Кастомные чекбоксы (логин, файлы) */
.cb-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}

.cb-wrap input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.cb-box {
  width: 22px;
  height: 22px;
  border: 2px solid #64748b;
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  pointer-events: none;
}

.cb-wrap:hover .cb-box {
  border-color: #93c5fd;
}

.cb-wrap input:checked + .cb-box {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.cb-wrap input:checked + .cb-box::after {
  content: "";
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
  margin-top: -2px;
}

.cb-wrap input:indeterminate + .cb-box {
  background: #3b82f6;
  border-color: #3b82f6;
}

.cb-wrap input:indeterminate + .cb-box::after {
  content: "";
  width: 10px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
}

.password-rules {
  margin-top: 1.25rem; padding-left: 1.25rem;
  font-size: 0.8rem; color: var(--text-muted);
  line-height: 1.7;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  border: none;
  font-size: 0.95rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: transform 0.15s, background 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-block { width: 100%; padding: 0.95rem; font-size: 1rem; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.btn-ghost:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.3); }
.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.85rem; }

/* Flash */
.flash-stack {
  position: fixed; top: 1rem; left: 50%; transform: translateX(-50%);
  z-index: 100; width: min(90%, 400px);
  display: flex; flex-direction: column; gap: 0.5rem;
}
.flash {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  backdrop-filter: blur(12px);
  animation: slideIn 0.3s ease;
}
.flash-success { background: rgba(34, 197, 94, 0.2); border: 1px solid rgba(34, 197, 94, 0.4); }
.flash-error { background: rgba(239, 68, 68, 0.2); border: 1px solid rgba(239, 68, 68, 0.4); }
.flash-info { background: rgba(56, 189, 248, 0.2); border: 1px solid rgba(56, 189, 248, 0.4); }
.flash.fade-out { opacity: 0; transition: opacity 0.4s; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Welcome */
.welcome-screen {
  flex: 1; display: flex; align-items: center; justify-content: center;
  text-align: center;
}
.welcome-content h1 { font-size: 1.5rem; font-weight: 500; color: var(--text-muted); }
.welcome-name {
  font-size: 2rem; font-weight: 700; margin-top: 0.5rem;
  background: linear-gradient(135deg, #fff, #93c5fd);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.welcome-icon {
  width: 80px; height: 80px; margin: 0 auto 1.5rem;
  color: var(--success);
}
.pulse { animation: pulse 1.5s ease infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.85; }
}

/* Home */
.top-bar {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 1rem; padding-top: 0.25rem;
  flex-shrink: 0;
}
.top-bar h1 { font-size: 1.15rem; flex: 1; }
.greeting { font-size: 0.85rem; color: var(--text-muted); }
.top-bar > div h1 { font-size: 1.35rem; }
.home-user h1 { margin: 0; }
.user-job-title {
  margin-top: 0.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #93c5fd;
}
.spacer { width: 60px; }
.back-btn { flex-shrink: 0; }

.home-grid {
  display: grid;
  gap: 1rem;
}

.tile {
  display: block;
  padding: 1.5rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.tile:hover {
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}
.tile-icon { width: 48px; height: 48px; color: var(--accent); margin-bottom: 0.75rem; }
.tile h2 { font-size: 1.2rem; margin-bottom: 0.25rem; }
.tile p { font-size: 0.85rem; color: var(--text-muted); }
.tile-personal { background: linear-gradient(135deg, rgba(59,130,246,0.12), rgba(30,41,59,0.8)); }
.tile-shared { background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(30,41,59,0.8)); }

.app-footer {
  display: flex; justify-content: space-between;
  font-size: 0.75rem; color: var(--text-muted);
  flex-shrink: 0;
}
.footer-brand {
  display: inline-flex; align-items: center; gap: 0.4rem;
}
.footer-brand img { border-radius: 50%; }

/* Files */
.breadcrumbs {
  display: flex; flex-wrap: wrap; gap: 0.25rem;
  font-size: 0.85rem; margin-bottom: 1rem;
  color: var(--text-muted);
}
.breadcrumbs a { color: var(--accent); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.sep { opacity: 0.5; }

.upload-bar { margin-bottom: 1rem; }
.upload-label input[type="file"] { display: none; }

.readonly-banner {
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}
.error-banner {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.file-list {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  overflow: hidden;
}

.file-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.9rem 1rem;
  text-decoration: none; color: var(--text);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.15s;
}
.file-row:last-child { border-bottom: none; }
.file-row:hover { background: rgba(255, 255, 255, 0.05); }
.file-icon { font-size: 1.25rem; flex-shrink: 0; }
.file-icon.folder { filter: hue-rotate(180deg); }
.file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: 0.8rem; color: var(--text-muted); flex-shrink: 0; }
.file-up { color: var(--text-muted); }

.empty-state {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
}

@media (min-width: 600px) {
  .home-grid { grid-template-columns: 1fr 1fr; }
}

/* PWA установка */
.pwa-install-banner {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: min(92vw, 400px);
  padding: 0.75rem 1rem;
  background: #1e293b;
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  animation: slideUp 0.35s ease;
}

.pwa-install-banner img { border-radius: 10px; }

.pwa-install-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.8rem;
}

.pwa-install-text strong { font-size: 0.9rem; }
.pwa-install-text span { color: var(--text-muted); }

.pwa-install-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.35rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.25rem;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
