/* ==========================================================================
   CloudStore — design tokens, base layer and animated backdrop
   ========================================================================== */

:root {
  --bg: #05070f;
  --bg-deep: #03040a;
  --panel: rgba(16, 23, 44, 0.68);
  --panel-solid: #0d1428;
  --panel-soft: rgba(23, 32, 58, 0.55);
  --stroke: rgba(140, 168, 255, 0.16);
  --stroke-strong: rgba(150, 180, 255, 0.34);
  --text: #eef2ff;
  --text-dim: #a9b6d6;
  --muted: #7d8bb0;

  --accent: #5b8cff;
  --accent-2: #22d3ee;
  --accent-3: #a855f7;
  --success: #34d399;
  --danger: #fb7185;
  --warning: #fbbf24;

  --grad-brand: linear-gradient(135deg, #5b8cff 0%, #22d3ee 52%, #a855f7 100%);
  --grad-accent: linear-gradient(135deg, #5b8cff 0%, #7c5cff 100%);

  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --shadow-lg: 0 40px 90px -50px rgba(2, 6, 23, 0.95);
  --shadow-glow: 0 18px 45px -22px rgba(91, 140, 255, 0.85);

  --font: "Inter", "SF Pro Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, "Cascadia Code", Consolas, monospace;

  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: radial-gradient(120% 90% at 20% -10%, #101a3a 0%, var(--bg) 46%, var(--bg-deep) 100%);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

p {
  margin: 0;
}

a {
  color: var(--accent-2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

svg {
  display: block;
}

::selection {
  background: rgba(91, 140, 255, 0.35);
  color: #fff;
}

:focus-visible {
  outline: 2px solid rgba(91, 140, 255, 0.9);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ------------------------------------------------------------------ backdrop */

.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.aurora::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(120, 150, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 150, 255, 0.05) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(85% 65% at 50% 0%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(85% 65% at 50% 0%, #000 0%, transparent 78%);
}

.blob {
  position: absolute;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  will-change: transform;
}

.blob-a {
  top: -22vmax;
  left: -10vmax;
  background: radial-gradient(circle at 30% 30%, rgba(91, 140, 255, 0.9), transparent 62%);
  animation: drift-a 28s ease-in-out infinite alternate;
}

.blob-b {
  top: 12vmax;
  right: -18vmax;
  background: radial-gradient(circle at 60% 40%, rgba(34, 211, 238, 0.75), transparent 64%);
  animation: drift-b 34s ease-in-out infinite alternate;
}

.blob-c {
  bottom: -26vmax;
  left: 24vmax;
  background: radial-gradient(circle at 50% 50%, rgba(168, 85, 247, 0.7), transparent 66%);
  animation: drift-c 30s ease-in-out infinite alternate;
}

@keyframes drift-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(6vmax, 4vmax, 0) scale(1.08); }
}

@keyframes drift-b {
  from { transform: translate3d(0, 0, 0) scale(1.05); }
  to { transform: translate3d(-5vmax, 6vmax, 0) scale(1); }
}

@keyframes drift-c {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-7vmax, -4vmax, 0) scale(1.1); }
}

.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Shared components
   ========================================================================== */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand:hover { text-decoration: none; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--grad-brand);
  box-shadow: var(--shadow-glow);
  color: #04101f;
}

.brand-mark svg { width: 24px; height: 24px; }

.brand small {
  display: block;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: var(--shadow-lg);
}

.btn {
  --btn-bg: rgba(255, 255, 255, 0.06);
  --btn-fg: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 20px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-md);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.btn svg { width: 18px; height: 18px; }

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--stroke-strong);
  background: rgba(255, 255, 255, 0.1);
}

.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  --btn-fg: #04101f;
  background: var(--grad-accent);
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #6d99ff 0%, #8f6dff 100%);
  border-color: transparent;
  box-shadow: 0 22px 50px -20px rgba(91, 140, 255, 0.95);
}

.btn-ghost { background: transparent; }
.btn-block { width: 100%; }

.btn-danger {
  --btn-fg: #ffe4e8;
  border-color: rgba(251, 113, 133, 0.45);
  background: rgba(251, 113, 133, 0.14);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(251, 113, 133, 0.22);
  border-color: rgba(251, 113, 133, 0.7);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.icon-btn svg { width: 17px; height: 17px; }

.icon-btn:hover {
  color: var(--text);
  border-color: var(--stroke-strong);
  background: rgba(255, 255, 255, 0.09);
  transform: translateY(-1px);
}

.icon-btn.danger:hover {
  color: #fecdd3;
  border-color: rgba(251, 113, 133, 0.6);
  background: rgba(251, 113, 133, 0.16);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.input,
.field input {
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  background: rgba(6, 11, 24, 0.72);
  color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.input::placeholder,
.field input::placeholder { color: #5f6c8d; }

.input:focus,
.field input:focus {
  outline: none;
  border-color: rgba(91, 140, 255, 0.75);
  box-shadow: 0 0 0 4px rgba(91, 140, 255, 0.16);
  background: rgba(8, 14, 30, 0.9);
}

.password-wrap { position: relative; }
.password-wrap input { padding-right: 52px; }

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease;
}

.password-toggle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.password-toggle svg { width: 18px; height: 18px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.badge-pdf { color: #ffb3bd; background: rgba(251, 113, 133, 0.14); border-color: rgba(251, 113, 133, 0.34); }
.badge-docx { color: #a9c4ff; background: rgba(91, 140, 255, 0.16); border-color: rgba(91, 140, 255, 0.36); }
.badge-xlsx { color: #9df3c9; background: rgba(52, 211, 153, 0.14); border-color: rgba(52, 211, 153, 0.34); }
.badge-txt { color: #c8d3ee; background: rgba(148, 174, 255, 0.12); border-color: rgba(148, 174, 255, 0.3); }
.badge-html { color: #ffdca8; background: rgba(251, 191, 36, 0.14); border-color: rgba(251, 191, 36, 0.34); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.82rem;
  color: var(--text-dim);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.grad {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent-2);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Login page
   ========================================================================== */

.auth-shell {
  position: relative;
  z-index: 1;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  align-items: center;
  gap: clamp(24px, 5vw, 80px);
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: clamp(28px, 5vw, 64px) clamp(20px, 5vw, 56px);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  gap: 26px;
  max-width: 560px;
}

.auth-brand h1 {
  font-size: clamp(2.3rem, 4.4vw, 3.7rem);
  letter-spacing: -0.035em;
}

.auth-brand .lead {
  font-size: clamp(1rem, 1.15vw, 1.1rem);
  color: var(--text-dim);
  max-width: 46ch;
}

.feature-list {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.feature-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.95rem;
  color: var(--text-dim);
}

.feature-list .tick {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  border-radius: 9px;
  background: rgba(52, 211, 153, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.35);
  color: #6ee7b7;
}

.feature-list .tick svg { width: 14px; height: 14px; }

.type-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.auth-card {
  position: relative;
  padding: clamp(26px, 3vw, 42px);
  border-radius: var(--radius-xl);
  background: linear-gradient(160deg, rgba(24, 34, 64, 0.92), rgba(9, 14, 30, 0.94));
  border: 1px solid var(--stroke);
  box-shadow: 0 50px 120px -60px rgba(3, 8, 24, 1), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(26px);
  -webkit-backdrop-filter: blur(26px);
  overflow: hidden;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: -1px -1px auto;
  height: 2px;
  background: var(--grad-brand);
  opacity: 0.85;
}

.auth-card h2 {
  margin-top: 6px;
  font-size: clamp(1.5rem, 2.2vw, 1.9rem);
}

.auth-card .subtitle {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.login-form {
  display: grid;
  gap: 18px;
  margin-top: 26px;
}

.form-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(251, 113, 133, 0.45);
  background: rgba(251, 113, 133, 0.12);
  color: #ffd4da;
  font-size: 0.9rem;
  animation: shake 0.32s ease;
}

.form-alert svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 2px; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.auth-hint {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed var(--stroke);
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.6;
}

.auth-hint code {
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  color: #cfe0ff;
}

.auth-footer {
  position: relative;
  z-index: 1;
  padding: 18px clamp(20px, 5vw, 56px) 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
  width: min(1320px, 100%);
  margin: 0 auto;
}

/* ==========================================================================
   Application shell
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 12px clamp(16px, 4vw, 40px);
  background: rgba(5, 8, 18, 0.74);
  border-bottom: 1px solid rgba(140, 168, 255, 0.12);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(1240px, 100%);
  margin: 0 auto;
}

.topbar .spacer { flex: 1; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 5px 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.85rem;
  color: var(--text-dim);
  max-width: 260px;
}

.user-chip .username {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--grad-accent);
  color: #04101f;
  font-weight: 800;
  font-size: 0.85rem;
  text-transform: uppercase;
}

.workspace {
  flex: 1;
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 3vw, 38px) clamp(16px, 4vw, 40px) 64px;
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 2.2vw, 26px);
}

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.hero h1 {
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  letter-spacing: -0.03em;
}

.hero p {
  margin-top: 8px;
  max-width: 60ch;
  color: var(--text-dim);
  font-size: 0.97rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.stat {
  position: relative;
  padding: 15px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  background: linear-gradient(150deg, rgba(28, 38, 70, 0.72), rgba(11, 17, 34, 0.66));
  overflow: hidden;
}

.stat::after {
  content: "";
  position: absolute;
  right: -34px;
  top: -34px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(91, 140, 255, 0.35), transparent 70%);
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.stat small {
  display: block;
  margin-top: 2px;
  font-size: 0.76rem;
  color: var(--muted);
}

/* ------------------------------------------------------------------ upload */

.upload-card {
  padding: clamp(12px, 1.6vw, 18px);
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: clamp(24px, 3.6vw, 40px) 20px;
  text-align: center;
  border-radius: var(--radius-lg);
  border: 1.5px dashed rgba(140, 168, 255, 0.32);
  background: radial-gradient(130% 120% at 50% 0%, rgba(91, 140, 255, 0.12), transparent 62%);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: rgba(34, 211, 238, 0.75);
  background: radial-gradient(130% 120% at 50% 0%, rgba(34, 211, 238, 0.16), transparent 62%);
}

.dropzone.is-dragover { transform: scale(1.004); }

.dropzone-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  border: 1px solid rgba(91, 140, 255, 0.4);
  background: rgba(91, 140, 255, 0.16);
  color: #c3d6ff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.dropzone-icon svg { width: 24px; height: 24px; }

.dropzone h2 {
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.dropzone p {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.dropzone .browse { color: var(--accent-2); font-weight: 650; text-decoration: underline; text-underline-offset: 3px; }
.dropzone .hint { font-size: 0.78rem; color: var(--muted); }

.upload-progress {
  display: none;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
}

.upload-progress.is-visible { display: block; }

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.84rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}

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

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--grad-brand);
  transition: width 0.18s ease;
}

/* ------------------------------------------------------------------ library */

.library { padding: clamp(14px, 1.8vw, 20px); }

.library-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.library-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.library-title h2 {
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.library-title .count {
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.07);
  font-size: 0.76rem;
  color: var(--text-dim);
}

.search-wrap {
  position: relative;
  flex: 1 1 220px;
  max-width: 320px;
  min-width: 180px;
}

.search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  background: rgba(6, 11, 24, 0.7);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search-wrap input:focus {
  outline: none;
  border-color: rgba(91, 140, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.15);
}

.table-scroll { margin-top: 14px; overflow-x: auto; }

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

.file-table thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--stroke);
  white-space: nowrap;
}

.file-table tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(140, 168, 255, 0.08);
  vertical-align: middle;
}

.file-table tbody tr { transition: background 0.16s ease; }
.file-table tbody tr:hover { background: rgba(91, 140, 255, 0.07); }
.file-table tbody tr:last-child td { border-bottom: none; }

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

.file-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.05);
}

.file-icon svg { width: 18px; height: 18px; }
.file-icon.type-pdf { color: #ff9aa8; border-color: rgba(251, 113, 133, 0.36); background: rgba(251, 113, 133, 0.12); }
.file-icon.type-docx { color: #9db9ff; border-color: rgba(91, 140, 255, 0.38); background: rgba(91, 140, 255, 0.13); }
.file-icon.type-xlsx { color: #86efac; border-color: rgba(52, 211, 153, 0.36); background: rgba(52, 211, 153, 0.12); }
.file-icon.type-txt { color: #c8d3ee; }
.file-icon.type-html { color: #fcd34d; border-color: rgba(251, 191, 36, 0.36); background: rgba(251, 191, 36, 0.12); }

.file-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.file-title {
  font-weight: 600;
  font-size: 0.93rem;
  max-width: 44ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

.cell-muted {
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
}

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

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-state svg {
  width: 38px;
  height: 38px;
  color: rgba(148, 174, 255, 0.45);
  margin-bottom: 4px;
}

.empty-state strong {
  color: var(--text-dim);
  font-weight: 600;
}

/* ==========================================================================
   Preview modal
   ========================================================================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 36px);
  background: rgba(3, 6, 16, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: fade-in 0.18s ease;
}

.modal[hidden] { display: none; }

.modal-card {
  display: flex;
  flex-direction: column;
  width: min(1080px, 100%);
  max-height: min(88vh, 900px);
  border-radius: var(--radius-xl);
  border: 1px solid var(--stroke-strong);
  background: linear-gradient(165deg, rgba(20, 29, 56, 0.98), rgba(7, 11, 24, 0.99));
  box-shadow: 0 60px 140px -60px rgba(0, 0, 0, 1);
  overflow: hidden;
  animation: pop-in 0.2s ease;
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 14px 20px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.02);
}

.modal-head .file-icon { width: 40px; height: 40px; }

.modal-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.modal-title strong {
  font-size: 0.98rem;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-title span {
  font-size: 0.76rem;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-body {
  position: relative;
  flex: 1;
  min-height: 220px;
  overflow: auto;
  background: rgba(4, 8, 18, 0.75);
  padding: clamp(12px, 2vw, 22px);
}

.modal-body.is-framed { padding: 0; }

.preview-frame {
  width: 100%;
  height: min(72vh, 760px);
  border: 0;
  background: #fff;
  display: block;
}

.preview-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 60px 20px;
  color: var(--text-dim);
  font-size: 0.92rem;
}

.preview-text {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.65;
  color: #d7e2ff;
  white-space: pre-wrap;
  word-break: break-word;
}

.preview-doc {
  font-size: 0.92rem;
  line-height: 1.7;
  color: #dde5ff;
}

.preview-doc h1, .preview-doc h2, .preview-doc h3, .preview-doc h4 {
  margin: 1.1em 0 0.5em;
  color: #f2f6ff;
}

.preview-doc h1 { font-size: 1.5rem; }
.preview-doc h2 { font-size: 1.28rem; }
.preview-doc h3 { font-size: 1.1rem; }
.preview-doc p { margin: 0 0 0.85em; }
.preview-doc .doc-list-item { padding-left: 8px; }
.preview-doc .doc-note { color: var(--muted); font-style: italic; }

.doc-sheet { margin-bottom: 26px; }
.doc-sheet-title {
  margin: 0 0 10px;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-2);
}

.doc-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-md);
}

.doc-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.84rem;
}

.doc-table th,
.doc-table td {
  padding: 7px 11px;
  border-bottom: 1px solid rgba(140, 168, 255, 0.12);
  border-right: 1px solid rgba(140, 168, 255, 0.08);
  text-align: left;
  vertical-align: top;
  max-width: 340px;
}

.doc-table th {
  background: rgba(91, 140, 255, 0.14);
  font-weight: 650;
  color: #e7eeff;
  white-space: nowrap;
}

.doc-table tr:last-child td { border-bottom: none; }

.preview-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 56px 24px;
  text-align: center;
  color: var(--text-dim);
}

.preview-fallback strong { color: var(--text); }

.modal-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px 12px 20px;
  border-top: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.78rem;
  color: var(--muted);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@keyframes pop-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   Confirmation dialog
   ========================================================================== */

.confirm-card {
  width: min(440px, 100%);
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--stroke-strong);
  background: linear-gradient(160deg, rgba(22, 31, 58, 0.99), rgba(8, 12, 26, 1));
  box-shadow: 0 40px 100px -50px rgba(0, 0, 0, 1);
  animation: pop-in 0.18s ease;
}

.confirm-card h3 {
  font-size: 1.08rem;
}

.confirm-card p {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 0.92rem;
  word-break: break-word;
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 22px;
}

/* ==========================================================================
   Toasts
   ========================================================================== */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke-strong);
  background: rgba(13, 20, 40, 0.96);
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.95);
  font-size: 0.88rem;
  color: var(--text-dim);
  animation: toast-in 0.24s ease;
  pointer-events: auto;
}

.toast svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 2px; }
.toast strong { display: block; color: var(--text); font-weight: 650; font-size: 0.9rem; }
.toast-success { border-color: rgba(52, 211, 153, 0.45); }
.toast-success svg { color: var(--success); }
.toast-error { border-color: rgba(251, 113, 133, 0.5); }
.toast-error svg { color: var(--danger); }
.toast-info svg { color: var(--accent-2); }
.toast.is-leaving { animation: toast-out 0.2s ease forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px) scale(0.97); }
}

/* ==========================================================================
   Responsive adjustments
   ========================================================================== */

@media (max-width: 1024px) {
  .auth-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 34px;
    padding-top: 34px;
  }

  .auth-brand { max-width: 640px; }
  .auth-card { width: 100%; max-width: 520px; }
}

@media (max-width: 900px) {
  .topbar { padding: 10px 16px; }
  .topbar .brand small { display: none; }
  .topbar .brand span.brand-text { font-size: 1rem; }
  .user-chip { max-width: 190px; padding-left: 12px; }

  .file-table thead { display: none; }

  .file-table,
  .file-table tbody,
  .file-table tr,
  .file-table td {
    display: block;
    width: 100%;
  }

  .file-table tbody tr {
    margin-bottom: 12px;
    padding: 12px 14px;
    border: 1px solid var(--stroke);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.035);
  }

  .file-table tbody tr:last-child { margin-bottom: 0; }

  .file-table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 5px 0;
    border-bottom: none;
  }

  .file-table tbody td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .file-table td.col-file::before,
  .file-table td.col-type,
  .file-table td.col-size { display: none; }

  .file-table td.col-file { display: block; padding-bottom: 10px; }
  .file-table td.col-date { font-size: 0.8rem; }

  .file-title { max-width: 100%; white-space: normal; word-break: break-word; }

  .row-actions { justify-content: flex-end; gap: 6px; }
  .row-actions .icon-btn { width: 40px; height: 40px; }

  .modal { padding: 0; place-items: stretch; }
  .modal-card {
    width: 100%;
    max-height: 100vh;
    height: 100%;
    border-radius: 0;
    border: none;
  }

  .modal-body { padding: 12px; }
  .modal-body.is-framed { padding: 0; }
  .preview-frame { height: calc(100vh - 132px); }
  .modal-foot { font-size: 0.74rem; }

  .toasts { right: 12px; left: 12px; bottom: 12px; width: auto; }
}

@media (max-width: 640px) {
  body { font-size: 15px; }

  .hero { flex-direction: column; align-items: flex-start; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 13px 14px; }
  .stat strong { font-size: 1.2rem; }

  .auth-shell { padding: 22px 16px 8px; }
  .auth-brand h1 { font-size: clamp(1.9rem, 8vw, 2.4rem); }
  .auth-card { padding: 22px; border-radius: var(--radius-lg); }
  .auth-footer { padding: 12px 16px 22px; flex-direction: column; align-items: flex-start; }

  .workspace { padding: 18px 14px 56px; }
  .library-head { align-items: stretch; }
  .search-wrap { max-width: none; }

  .modal-head { padding: 10px 10px 10px 14px; }
  .modal-head .file-icon { display: none; }
  .modal-actions .btn-label { display: none; }
  .modal-actions .btn { padding: 10px; }
}

@media (hover: none) {
  .btn:hover:not(:disabled),
  .icon-btn:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .blob { opacity: 0.35; }
}
