:root {
  --bg: #F6F7F5;
  --surface: #FFFFFF;
  --border: #E3E5E1;
  --text: #1C201E;
  --text-secondary: #6B726C;
  --text-muted: #9AA09A;
  --accent: #2F6F5E;
  --accent-dark: #234F43;
  --accent-tint: #E7F1EE;
  --danger: #C0392B;
  --danger-tint: #FBEAE8;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(28, 32, 30, 0.06), 0 4px 16px rgba(28, 32, 30, 0.06);
  color-scheme: light;
}

/* Modo oscuro: se activa con data-theme="dark" en <html> (ver app.js).
   Por defecto sigue la preferencia del sistema si el usuario no ha
   elegido nada explícitamente todavía. */
:root[data-theme="dark"] {
  --bg: #16181A;
  --surface: #1F2225;
  --border: #33373B;
  --text: #EDEFEE;
  --text-secondary: #A7ACAE;
  --text-muted: #74797C;
  --accent: #47A088;
  --accent-dark: #6FC2AB;
  --accent-tint: #1E3831;
  --danger: #E0605A;
  --danger-tint: #3A2224;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #16181A;
    --surface: #1F2225;
    --border: #33373B;
    --text: #EDEFEE;
    --text-secondary: #A7ACAE;
    --text-muted: #74797C;
    --accent: #47A088;
    --accent-dark: #6FC2AB;
    --accent-tint: #1E3831;
    --danger: #E0605A;
    --danger-tint: #3A2224;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

/* El atributo HTML "hidden" debe ganar siempre, aunque otra regla de esta
   hoja le ponga display:flex/block a ese mismo elemento (login-screen,
   app, modal-overlay, etc.). Sin esto, los modales y pantallas "ocultas"
   por JS siguen mostrándose igual. */
[hidden] { display: none !important; }

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

button, input, select {
  font-family: inherit;
  font-size: 14px;
}

/* ---------- Botones ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text); }
.btn-full { width: 100%; }

/* ---------- Marca ---------- */
.brand-mark {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, #4B9C86 100%);
  position: relative;
}
.brand-mark.small { width: 22px; height: 22px; border-radius: 6px; }
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 3px;
  background: rgba(255,255,255,0.85);
}
.brand-mark.has-logo { background: none; }
.brand-mark.has-logo::after { content: none; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; display: block; }

/* ================= LOGIN ================= */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.login-brand h1 { font-size: 18px; font-weight: 500; margin: 0; }
.login-sub { color: var(--text-secondary); margin: 0 0 24px; font-size: 13px; }

.login-form { display: flex; flex-direction: column; gap: 14px; }
.field-row { display: flex; flex-direction: column; gap: 6px; }
.field-row.two-col { flex-direction: row; gap: 10px; align-items: flex-end; }
.field-row.two-col > div { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.field-narrow { max-width: 90px; }

label { font-size: 12.5px; color: var(--text-secondary); font-weight: 500; }
input[type="text"], input[type="password"], input[type="number"], input[type="email"],
input[type="search"], input[type="url"], textarea, select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  outline: none;
  background: var(--surface);
  color: var(--text);
}
input::placeholder { color: var(--text-muted); opacity: 1; }
select option { background: var(--surface); color: var(--text); }
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.login-error {
  background: var(--danger-tint);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  margin: 0;
}

/* ================= APP SHELL ================= */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.app-body { flex: 1; display: flex; min-height: 0; }
.content-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---------- Barra lateral (escritorio) / barra inferior fija (móvil) ---------- */
.side-nav {
  width: 208px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 500;
}
.side-item:hover { background: var(--bg); color: var(--text); }
.side-item.active { background: var(--accent-tint); color: var(--accent-dark); }
.side-icon { font-size: 15px; }

@media (max-width: 640px) {
  .app-body { flex-direction: column; }

  /* La barra de secciones (Inicio/Archivos/Compartido/Papelera) se
     convierte en una barra de pestañas FIJA ABAJO, igual que la de
     Google Drive — mucho más natural en móvil que una fila horizontal
     deslizable arriba. "Configuración" (antes "Administración") vive
     en el menú del avatar, no aquí, para no saturar la barra. */
  .side-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 60;
    width: auto;
    flex-direction: row;
    justify-content: space-around;
    align-items: stretch;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
    gap: 0;
  }
  .side-item {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    flex: 1;
    padding: 6px 2px;
    border-radius: var(--radius-sm);
    font-size: 10.5px;
    text-align: center;
  }
  .side-icon { font-size: 19px; }
  .side-item.active { background: transparent; }

  .quota-bar { display: none; } /* no cabe de forma legible en una barra de pestañas */
}

.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.icon-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary);
}
.icon-btn:hover { background: var(--bg); }
.search-box {
  flex: 1;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-radius: 24px;
  padding: 6px 14px;
}
.search-box .search-icon { font-size: 14px; opacity: 0.6; flex-shrink: 0; }
.search-box input { flex: 1; border: none; background: transparent; outline: none; color: var(--text); }
.avatar-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

/* ---------- Menú desplegable (cuenta / configuración) ---------- */
.app-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 20, 0.35);
  z-index: 90;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
}
.app-menu {
  margin: 64px 14px 0 0;
  width: 260px;
  max-width: calc(100vw - 28px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.app-menu-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 14px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.app-menu-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}
.app-menu-name { font-weight: 500; font-size: 14px; }
.app-menu-username { font-size: 12px; color: var(--text-muted); }
.app-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  text-align: left;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
  font-size: 13.5px;
}
.app-menu-item:hover { background: var(--bg); }

/* ---------- Pestañas de espacio de trabajo: Mi unidad / Grupos ---------- */
.workspace-tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.workspace-item {
  border: none;
  background: transparent;
  padding: 12px 6px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.workspace-item.active { color: var(--accent-dark); border-bottom-color: var(--accent); }

/* ---------- Fila de orden + vista (estilo Drive: "Nombre ↑") ---------- */
.list-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
}
.sort-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 2px;
}

/* ---------- Botón flotante de acciones (estilo Drive) ---------- */
.fab-btn {
  position: fixed;
  right: 20px;
  bottom: 84px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  box-shadow: var(--shadow);
  cursor: pointer;
  z-index: 55;
}
.fab-btn:hover { background: var(--accent-dark); }
.fab-menu { margin: 0; position: fixed; right: 20px; bottom: 148px; left: auto; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.breadcrumbs { display: flex; align-items: center; gap: 4px; font-size: 13.5px; flex-wrap: wrap; }
.breadcrumbs .crumb { color: var(--text-secondary); cursor: pointer; padding: 4px 6px; border-radius: 4px; }
.breadcrumbs .crumb:hover { background: var(--accent-tint); color: var(--accent-dark); }
.breadcrumbs .crumb.current { color: var(--text); font-weight: 500; cursor: default; }
.breadcrumbs .crumb.current:hover { background: none; }
.breadcrumbs .sep { color: var(--text-muted); }

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

.selection-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-tint);
  border-radius: var(--radius-sm);
  padding: 4px 6px 4px 12px;
  font-size: 13px;
  color: var(--accent-dark);
  font-weight: 500;
}
.danger-text { color: var(--danger); }

.trash-toolbar { display: flex; align-items: center; gap: 10px; position: relative; }
.trash-title { font-size: 15px; font-weight: 500; margin-right: 4px; }
.trash-more-btn { width: 36px; height: 36px; display: none; } /* solo móvil; en escritorio va junto a Papelera */
.view-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.view-btn { background: var(--surface); border: none; padding: 8px 10px; cursor: pointer; color: var(--text-secondary); }
.view-btn.active { background: var(--accent-tint); color: var(--accent-dark); }

.drop-zone {
  margin: 0 20px 14px;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--accent-tint);
  color: var(--accent-dark);
  text-align: center;
  padding: 40px;
  font-weight: 500;
}

.file-area { flex: 1; padding: 0 20px 40px; }

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

/* ---------- Vista cuadrícula ---------- */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}
.file-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 10px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  text-align: center;
  position: relative;
}
.file-item:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.file-item.selected { border-color: var(--accent); background: var(--accent-tint); }
.file-icon { font-size: 34px; line-height: 1; }

.select-check {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  opacity: 0.55;
  transition: opacity 0.1s ease;
}
.file-item:hover .select-check,
.file-item.selected .select-check { opacity: 1; }
.file-item.selected .select-check { background: var(--accent); border-color: var(--accent); }
.file-item.selected .select-check::after {
  content: "✓";
  color: #fff;
  font-size: 12px;
  display: block;
  text-align: center;
  line-height: 16px;
}

/* Botón "más acciones" (⋮): siempre visible, no depende de hover ni de
   pulsación larga — es la forma principal de llegar al menú en móvil. */
.item-menu-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.item-menu-btn:hover, .item-menu-btn:active { background: var(--bg); color: var(--text); }
.file-grid.list-view .item-menu-btn { position: static; order: 5; flex-shrink: 0; }
.file-name {
  font-size: 12.5px;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.file-meta { font-size: 11px; color: var(--text-muted); }

/* ---------- Vista lista ---------- */
.file-grid.list-view {
  grid-template-columns: 1fr;
  gap: 2px;
}
.file-grid.list-view .file-item {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  text-align: left;
}
.file-grid.list-view .file-icon { font-size: 20px; }
.file-grid.list-view .file-name { flex: 1; -webkit-line-clamp: 1; }
.file-grid.list-view .file-meta { flex-shrink: 0; }

/* ---------- Menú contextual ---------- */
.context-menu {
  position: fixed;
  z-index: 50;
  list-style: none;
  margin: 0;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  min-width: 160px;
}
.context-menu li { padding: 8px 10px; border-radius: 4px; cursor: pointer; font-size: 13.5px; }
.context-menu li:hover { background: var(--accent-tint); color: var(--accent-dark); }
.context-menu li.danger:hover { background: var(--danger-tint); color: var(--danger); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  z-index: 60;
}
.toast.error { background: var(--danger); color: #fff; }

/* ---------- Compartidos (lista) ---------- */
.shares-list { display: flex; flex-direction: column; gap: 8px; }
.share-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.share-row .share-name { flex: 1; font-weight: 500; }
.share-row .share-expiry { color: var(--text-muted); font-size: 12.5px; }

/* ---------- Modales ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 20, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 16px;
}
.modal-box {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-preview { max-width: 720px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 15px; }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.modal-preview .modal-body { padding: 0; max-height: 70vh; overflow: auto; display: block; }
.modal-preview img { display: block; max-width: 100%; margin: 0 auto; }
.modal-preview iframe { width: 100%; height: 70vh; border: none; }
.modal-preview pre {
  margin: 0;
  padding: 18px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, monospace;
  font-size: 13px;
}
.share-filename { font-weight: 500; word-break: break-word; margin: 0; }
.share-result { display: flex; gap: 8px; }
.share-result input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--bg);
}

/* ---------- Setup inicial ---------- */
.setup-card { max-width: 420px; }
.setup-section-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 10px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.setup-section-title:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.field-hint { font-size: 12px; color: var(--text-muted); margin: 2px 0 0; }

/* ---------- Panel de administración ---------- */
.admin-section { display: flex; flex-direction: column; gap: 16px; }
.admin-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.admin-tab {
  background: none;
  border: none;
  padding: 10px 4px;
  margin-right: 16px;
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.admin-tab.active { color: var(--accent-dark); border-bottom-color: var(--accent); }
.admin-tab-panel { display: flex; flex-direction: column; gap: 14px; max-width: 460px; }
/* Paneles que contienen tablas/listas de datos (Actividad, Usuarios,
   Grupos): en vez de quedarse en un recuadro angosto de
   460px aunque la pantalla de escritorio sea mucho más ancha, aprovechan
   el espacio disponible del panel (hasta un límite razonable de lectura),
   y en móvil ocupan el 100% igual que cualquier otro panel. */
.admin-tab-panel-wide { max-width: min(100%, 1100px); }

.admin-users-list { display: flex; flex-direction: column; gap: 8px; }
.admin-user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.admin-user-info { flex: 1; min-width: 0; }
.admin-user-name { font-weight: 500; }
.admin-user-meta { font-size: 12.5px; color: var(--text-muted); word-break: break-word; }
.role-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent-tint);
  color: var(--accent-dark);
}
.role-badge.admin { background: var(--danger-tint); color: var(--danger); }

.folder-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.folder-picker input { flex: 1; min-width: 120px; background: var(--bg); }

.picker-list {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 10px 0;
}
.picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.picker-row:last-child { border-bottom: none; }
.picker-row:hover { background: var(--accent-tint); }

/* ---------- Barra de cuota ---------- */
.quota-bar { padding: 4px 12px 2px; text-align: center; }

.quota-bar-track { height: 6px; border-radius: 4px; background: var(--border); overflow: hidden; }
.quota-bar-fill { height: 100%; background: #3FA34D; border-radius: 4px; transition: width 0.2s ease, background-color 0.2s ease; }
.quota-bar-fill.ok { background: #3FA34D; }
.quota-bar-fill.warn { background: #E5B800; }
.quota-bar-fill.orange { background: #F08A24; }
.quota-bar-fill.danger { background: #D93025; }
.quota-bar-track { height: 8px; }

/* Medidor con degradado verde → amarillo → rojo y marcador (menú de móvil) */
.quota-gauge { padding: 4px 18px 22px; }
.quota-gauge-track { position: relative; height: 10px; border-radius: 6px;
  background: linear-gradient(90deg, #3FA34D 0%, #E5B800 55%, #F08A24 80%, #D93025 100%); }
.quota-gauge-marker { position: absolute; top: 50%; width: 2px; height: 18px; background: var(--text); transform: translate(-50%, -50%); border-radius: 1px; }
.quota-gauge-marker b { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 600; color: var(--text); white-space: nowrap; }
.quota-bar-text { font-size: 11px; color: var(--text-muted); display: block; margin-top: 4px; }

/* ---------- Checkbox de formularios ---------- */
.checkbox-row label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); font-weight: 400; }
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; }

/* ---------- Miembros de grupo ---------- */
.group-members-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
}
.group-member-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 4px; }
.group-member-row:hover { background: var(--bg); }
.group-member-row input { width: 15px; height: 15px; }

/* ---------- Prueba SMTP ---------- */
.smtp-test-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; max-width: 460px; }
.smtp-test-row input { flex: 1; min-width: 180px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 10px; }

/* ---------- Modal mover/copiar ---------- */
.move-actions { display: flex; gap: 10px; margin-top: 4px; }
.move-actions .btn { flex: 1; }

/* ---------- Miniaturas reales de imagen ---------- */
.file-thumb {
  width: 100%;
  aspect-ratio: 1;
  max-width: 56px;
  max-height: 56px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
}
.file-grid.list-view .file-thumb { max-width: 28px; max-height: 28px; }

/* ---------- Barra de progreso de subida ---------- */
.upload-queue {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 300px;
  max-width: calc(100vw - 40px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  z-index: 70;
  max-height: 60vh;
  overflow-y: auto;
}
.upload-row { margin-bottom: 10px; }
.upload-row:last-child { margin-bottom: 0; }
.upload-row-top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 4px; gap: 8px; }
.upload-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.upload-row-pct { color: var(--text-muted); flex-shrink: 0; }
.upload-progress-track { height: 5px; border-radius: 3px; background: var(--border); overflow: hidden; }
.upload-progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.15s ease; }
.upload-progress-fill.error { background: var(--danger); }
.upload-row-error {
  margin-top: 4px;
  font-size: 12px;
  color: var(--danger);
  word-break: break-word;
}
.upload-queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.upload-queue-close { background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 13px; }
.upload-progress-fill.done { background: var(--accent); }

/* ---------- Auditoría ---------- */
.audit-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; max-width: 640px; }
.audit-filters input { flex: 1; min-width: 180px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; }
.audit-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.audit-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.audit-table th, .audit-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.audit-table th { background: var(--bg); color: var(--text-secondary); font-weight: 500; }
.audit-table td.audit-path { white-space: normal; word-break: break-word; }

/* En móvil una tabla de 5 columnas no cabe de forma legible ni haciendo
   scroll horizontal diminuto: se convierte en una lista de "tarjetas",
   una fila = un bloque, con cada celda mostrando su etiqueta (la misma
   que el encabezado de columna) delante del valor. */
@media (max-width: 640px) {
  .audit-table-wrap { border: none; }
  .audit-table thead { display: none; }
  .audit-table, .audit-table tbody, .audit-table tr, .audit-table td { display: block; width: 100%; }
  .audit-table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    padding: 4px 0;
    background: var(--surface);
  }
  .audit-table td {
    white-space: normal;
    word-break: break-word;
    padding: 6px 12px;
    border-bottom: none;
    display: flex;
    gap: 8px;
  }
  .audit-table td::before {
    content: attr(data-label);
    flex-shrink: 0;
    width: 70px;
    color: var(--text-muted);
    font-weight: 500;
  }
  .audit-table tr:has(td[colspan]) { background: none; border: none; }
  .audit-table tr:has(td[colspan]) td::before { content: none; }
}

/* ---------- Mantenimiento (backup, retención) ---------- */
.maintenance-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  max-width: 480px;
}
.maintenance-block h3 { margin: 0 0 6px; font-size: 14.5px; }
.maintenance-block .field-hint { margin: 0 0 12px; }

/* ---------- Selector de modo de instalación ---------- */
.mode-choice { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
.mode-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
}
.mode-option:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); color: var(--text); }
.mode-option input { margin-top: 3px; flex-shrink: 0; }
.mode-option strong { color: var(--text); }

/* ---------- Personalización / logo ---------- */
.logo-preview-row { display: flex; align-items: center; gap: 14px; }
.logo-preview {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  overflow: hidden;
  flex-shrink: 0;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.logo-preview-actions { display: flex; flex-direction: column; gap: 6px; }

@media (max-width: 640px) {
  .toolbar { padding: 10px 14px; }
  /* El relleno inferior deja hueco para la barra de pestañas fija de abajo
     (estilo Google Drive) más el margen seguro del iPhone, para que no
     tape el final del contenido. */
  .file-area, .admin-section, .shares-list, #trashSection {
    padding: 0 14px calc(64px + env(safe-area-inset-bottom, 0px));
  }

  .topbar { padding: 0 8px; gap: 6px; }

  /* Objetivos táctiles más grandes (mínimo recomendado ~44px) */
  .item-menu-btn { width: 34px; height: 34px; font-size: 20px; }
  .select-check { width: 22px; height: 22px; opacity: 0.7; }
  .file-item.selected .select-check::after { line-height: 19px; }
  .context-menu li { padding: 12px 14px; font-size: 14.5px; }

  /* La barra de progreso de subida, igual que el FAB, deja hueco para la
     barra de pestañas fija de abajo en vez de quedar tapada por ella. */
  .upload-queue { bottom: calc(64px + env(safe-area-inset-bottom, 0px)); right: 10px; left: 10px; width: auto; max-width: none; }

  /* En pantallas muy estrechas, dos campos lado a lado (Servidor/Puerto,
     usuario/contraseña, etc.) se apilan para que cada uno tenga ancho
     legible en vez de quedar comprimidos a unos pocos caracteres. */
  .field-row.two-col { flex-direction: column; align-items: stretch; }
  .field-row.two-col > div { flex: none; }
  .field-row.two-col .field-narrow { max-width: none; }
}

/* ---------- Parte inferior del menú lateral: logo centrado + cuota ---------- */
.side-bottom {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 14px 6px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.side-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: center;
}
.side-brand .brand-mark { width: 52px; height: 52px; border-radius: 12px; flex-shrink: 0; }
.side-brand .brand-mark.has-logo img { object-fit: contain; }
.side-brand-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.3;
  max-width: 100%;
  overflow-wrap: anywhere; /* el nombre se parte en varias líneas, nunca se corta */
}
.side-bottom .quota-bar { width: 100%; }
.side-bottom .quota-bar-track { margin-bottom: 2px; }

/* ---------- ⋮ junto a "Papelera" en el menú lateral ---------- */
.side-item-wrap { position: relative; display: flex; align-items: center; }
.side-item-wrap .side-item { flex: 1; padding-right: 40px; }
.side-more-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.side-more-btn:hover { background: var(--bg); color: var(--text); }
.trash-more-menu { z-index: 95; }

/* ---------- Filtros de Compartido ---------- */
.shares-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 14px;
}
.shares-filters input[type="text"] { flex: 1; min-width: 180px; }
.shares-filters select { min-width: 150px; }
.shares-date-filter { display: flex; flex-direction: column; gap: 4px; }
.shares-filters input[type="datetime-local"] {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
}
.share-row { flex-wrap: wrap; }
.share-row .share-name { min-width: 120px; word-break: break-word; }

@media (max-width: 640px) {
  .side-bottom { display: none; } /* en móvil la barra lateral es la de pestañas inferior; la cuota va en el menú del avatar */
  .side-item-wrap { flex: 1; }
  .side-item-wrap .side-item { padding-right: 2px; }
  .side-more-btn { display: none; }
  .trash-more-btn { display: inline-block; }
  .shares-filters > * { flex: 1 1 100%; }
}

/* ---------- Logo grande y centrado en login / setup / 2FA / recuperar ---------- */
.login-brand { flex-direction: column; justify-content: center; text-align: center; gap: 12px; margin-bottom: 10px; }
.login-brand .brand-mark { width: 72px; height: 72px; border-radius: 16px; flex-shrink: 0; }
.login-brand .brand-mark::after { inset: 25%; border-radius: 6px; }
.login-brand .brand-mark.has-logo img { object-fit: contain; }
.login-brand h1 { font-size: 20px; line-height: 1.25; overflow-wrap: anywhere; }
.login-card .login-sub { text-align: center; }
@media (max-width: 640px) {
  .login-brand .brand-mark { width: 60px; height: 60px; border-radius: 14px; }
}
