:root {
  color-scheme: light dark;
  --bg: #f3f6fc;
  --bg-glow: #e6edff;
  --surface: #ffffff;
  --surface-soft: #f7f9fd;
  --text: #172033;
  --muted: #5a6980;
  --border: #d9e2f0;
  --border-strong: #c3d0e4;
  --accent: #2557d6;
  --accent-hover: #1b46b4;
  --accent-soft: #e8eeff;
  --accent-text: #ffffff;
  --danger: #a61b1b;
  --danger-bg: #fdf0ef;
  --danger-border: #f3c6c3;
  --success: #087443;
  --shadow-sm: 0 1px 2px rgba(23, 32, 51, 0.06);
  --shadow-md: 0 12px 32px rgba(23, 32, 51, 0.09);
  --radius: 14px;
  --radius-sm: 9px;
  --focus: 0 0 0 3px rgba(37, 87, 214, 0.35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1320;
    --bg-glow: #15213a;
    --surface: #151d2c;
    --surface-soft: #1a2436;
    --text: #e8eefb;
    --muted: #a7b4c9;
    --border: #2a3750;
    --border-strong: #3a4b6a;
    --accent: #7fa2ff;
    --accent-hover: #a3bcff;
    --accent-soft: #1e2c4a;
    --accent-text: #0b1220;
    --danger: #ff9d97;
    --danger-bg: #32191a;
    --danger-border: #5b2a2b;
    --success: #63d4a3;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 16px 40px rgba(0, 0, 0, 0.4);
    --focus: 0 0 0 3px rgba(127, 162, 255, 0.45);
  }
}

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

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
p {
  margin: 0;
}

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

a {
  color: var(--accent);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: 6px;
}

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

/* ---------- Marca ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  flex: 0 0 auto;
  border-radius: 12px;
  background: linear-gradient(145deg, #3f74ff, #1f45b3);
  color: #fff;
  font-size: 1.15rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.brand__name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand__sub {
  color: var(--muted);
  font-size: 0.8rem;
}

.brand--login .brand__mark {
  width: 3rem;
  height: 3rem;
  font-size: 1.35rem;
}

.brand--login .brand__name {
  font-size: 1.5rem;
}

/* ---------- Login ---------- */

.login-page {
  background:
    radial-gradient(900px 520px at 15% -10%, var(--bg-glow), transparent 70%),
    radial-gradient(700px 500px at 100% 110%, var(--bg-glow), transparent 65%),
    var(--bg);
}

.login-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-card {
  width: min(100%, 26.5rem);
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.login-intro {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.login-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.25rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field label {
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--text);
}

.field input {
  width: 100%;
  min-height: 46px;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  transition: border-color 120ms ease, background-color 120ms ease;
}

.field input:hover {
  border-color: var(--muted);
}

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

.login-foot {
  margin-top: 1.25rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

/* ---------- Botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-weight: 650;
  font-size: 0.9rem;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, transform 80ms ease;
}

.btn:hover {
  background: var(--surface-soft);
  border-color: var(--muted);
}

.btn:active {
  transform: translateY(1px);
}

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

.btn--primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: var(--shadow-sm);
}

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

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

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

.btn--small {
  min-height: 34px;
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
}

.btn--block {
  width: 100%;
  min-height: 46px;
}

/* ---------- Layout principal ---------- */

.app-page {
  background:
    radial-gradient(1000px 420px at 50% -220px, var(--bg-glow), transparent 70%),
    var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(100% - 2rem, 68rem);
  min-height: 4.25rem;
  margin: 0 auto;
}

.session {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.session__user {
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  font-size: 0.82rem;
  font-weight: 650;
}

.session form {
  margin: 0;
}

.container {
  width: min(100% - 2rem, 68rem);
  margin: 0 auto;
  padding: 1.5rem 0 2.5rem;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.toolbar__buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.toolbar__limit {
  color: var(--muted);
  font-size: 0.8rem;
}

.breadcrumb {
  margin-bottom: 0.85rem;
  min-height: 1.9rem;
}

.breadcrumb ol {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumb li {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  min-width: 0;
}

.breadcrumb button,
.breadcrumb span {
  max-width: 18rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.25rem 0.45rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.breadcrumb button {
  cursor: pointer;
}

.breadcrumb button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.breadcrumb span[aria-current="page"] {
  color: var(--text);
}

.breadcrumb .sep {
  color: var(--border-strong);
  font-weight: 400;
  user-select: none;
}

/* ---------- Zona de arrastre y tabla ---------- */

.dropzone {
  position: relative;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 140ms ease, background-color 140ms ease;
}

.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone__hint {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

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

.table-wrap {
  overflow-x: auto;
  border-radius: 0 0 var(--radius) var(--radius);
}

.files {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.files th {
  padding: 0.65rem 1.1rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.files td {
  padding: 0.55rem 1.1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.files tbody tr:last-child td {
  border-bottom: 0;
}

.files tbody tr:hover {
  background: var(--surface-soft);
}

.files__size {
  width: 9rem;
  text-align: right !important;
  white-space: nowrap;
}

.files__date {
  width: 13rem;
  white-space: nowrap;
}

.files td.files__size,
.files td.files__date {
  color: var(--muted);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

.files td.files__size {
  text-align: right;
}

.files__loading td,
.files td.empty-cell {
  padding: 2rem 1.1rem;
  color: var(--muted);
  text-align: center;
}

.entry {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  max-width: 100%;
  padding: 0.25rem 0.35rem;
  margin-left: -0.35rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.entry:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.entry__icon {
  width: 1.35rem;
  flex: 0 0 auto;
  text-align: center;
  font-size: 1rem;
}

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

.entry--dir .entry__icon {
  filter: saturate(0.4);
}

.empty {
  padding: 2rem 1.1rem;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
}

/* ---------- Subidas ---------- */

.uploads {
  margin-top: 1.5rem;
  padding: 1rem 1.1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.uploads__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.uploads__head h2 {
  font-size: 0.95rem;
  font-weight: 700;
}

.upload-list {
  display: grid;
  gap: 0.8rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.upload {
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.upload__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.4rem;
}

.upload__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
  font-weight: 650;
}

.upload__pct {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.bar > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #6f93ff);
  transition: width 220ms ease;
}

.upload[data-state="done"] .bar > span {
  background: var(--success);
}

.upload[data-state="error"] .bar > span {
  background: var(--danger);
}

.upload__state {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.upload[data-state="error"] .upload__state {
  color: var(--danger);
}

.upload[data-state="done"] .upload__state {
  color: var(--success);
}

/* ---------- Mensajes ---------- */

.alert {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.alert--inline {
  margin: 1rem 0 0;
}

.status {
  min-height: 1.4rem;
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.foot {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .topbar__inner,
  .container {
    width: min(100% - 1.25rem, 68rem);
  }

  .brand__sub {
    display: none;
  }

  .session__user {
    max-width: 8rem;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .files thead {
    display: none;
  }

  .files,
  .files tbody,
  .files tr,
  .files td {
    display: block;
    width: 100%;
  }

  .files tr {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
  }

  .files tr:last-child {
    border-bottom: 0;
  }

  .files td {
    padding: 0.12rem 0;
    border: 0;
  }

  .files td.files__size,
  .files td.files__date {
    width: auto;
    text-align: left;
  }

  .files td.files__size::before {
    content: "Tamaño: ";
    color: var(--muted);
    font-weight: 600;
  }

  .files td.files__date::before {
    content: "Modificado: ";
    color: var(--muted);
    font-weight: 600;
  }

  .entry {
    white-space: normal;
  }

  .entry__name {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .files__loading td {
    text-align: center;
  }
}

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