:root {
  --accent: #2563eb;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: color-mix(in srgb, var(--accent) 8%, transparent);
  --ok: #15803d;
  --err: #b91c1c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --card: #171a21; --text: #e7e9ee; --muted: #9aa1ad; --line: #2a2f3a;
    --ok: #4ade80; --err: #f87171; --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.35rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 14px; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--soft); padding: 1px 6px; border-radius: 6px; word-break: break-all; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.center-text { text-align: center; padding: 28px 16px; margin: 0; }

/* ── barra superior ── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 60px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--text); }
.brand svg { width: 26px; height: 26px; color: var(--accent); fill: var(--soft); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: var(--muted); padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.nav a:hover { color: var(--text); background: var(--bg); }
.nav a.on { color: var(--accent); background: var(--soft); }
.logout { display: flex; align-items: center; gap: 12px; margin: 0; }
.who { color: var(--muted); font-size: 14px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

/* ── botones y formularios ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid transparent; font: inherit; font-weight: 550; cursor: pointer;
  white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--card); border-color: var(--line); color: var(--text); }
.btn.ghost:hover { border-color: var(--muted); }
.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--err) 40%, transparent); color: var(--err); }
.btn.danger:hover { background: color-mix(in srgb, var(--err) 8%, transparent); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.form { display: grid; gap: 16px; }
.form label { display: grid; gap: 6px; font-size: 14px; font-weight: 550; }
.form small { font-weight: 400; color: var(--muted); }
input:not([type=checkbox]):not([type=file]), select {
  width: 100%; height: 42px; padding: 0 12px; font: inherit; font-weight: 400;
  color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--soft); }
input:disabled { background: var(--bg); color: var(--muted); }
.form label.check { display: flex; align-items: center; gap: 10px; align-self: end; height: 42px; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.prefix { display: flex; align-items: stretch; }
.prefix span {
  display: flex; align-items: center; padding: 0 10px; font: 13px ui-monospace, Menlo, monospace; color: var(--muted);
  background: var(--bg); border: 1px solid var(--line); border-right: 0; border-radius: 10px 0 0 10px;
}
.prefix span:empty { display: none; }
.prefix span:not(:empty) + input { border-radius: 0 10px 10px 0; }
.row-end { display: flex; justify-content: flex-end; gap: 10px; }

/* ── tarjetas ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden; }
.card.pad { padding: 24px; }
.card.narrow { max-width: 520px; }
.pad-h { padding: 20px 20px 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions form { margin: 0; }

.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); }
.auth-card.wide { max-width: 620px; }
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head svg { width: 44px; height: 44px; color: var(--accent); fill: var(--soft); margin-bottom: 8px; }
.auth-head p { color: var(--muted); margin: 6px 0 0; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.alert.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, transparent); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert.err { color: var(--err); background: color-mix(in srgb, var(--err) 8%, transparent); border-color: color-mix(in srgb, var(--err) 25%, transparent); }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

.facts { display: grid; grid-template-columns: 110px 1fr; gap: 8px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 550; }

/* ── migas ── */
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 1.15rem; font-weight: 600; min-width: 0; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { color: var(--line); }
.crumbs .here { color: var(--text); }
.crumbs a:only-child { color: var(--text); }

/* ── zona de subida ── */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 26px 16px; margin-bottom: 20px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line); border-radius: var(--radius); color: var(--muted);
  transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--accent); background: var(--soft); }
.dropzone svg { width: 30px; height: 30px; color: var(--accent); }
.dropzone strong { color: var(--text); }
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 18%, rgba(0, 0, 0, .35)); backdrop-filter: blur(2px);
  pointer-events: none;
}
.overlay > div { background: var(--card); padding: 22px 32px; border-radius: 14px; font-size: 1.1rem; border: 2px dashed var(--accent); }
.overlay[hidden] { display: none; }

/* ── cola de subidas ── */
.queue { display: grid; gap: 10px; margin-bottom: 20px; }
.qitem { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.qhead { display: flex; justify-content: space-between; gap: 12px; font-weight: 550; }
.qname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { color: var(--muted); font-weight: 500; font-size: 14px; white-space: nowrap; }
.qmeta { color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
.bar { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .2s; }
.qitem.ok .bar i { background: var(--ok); }
.qitem.ok .status { color: var(--ok); }
.qitem.err .bar i { background: var(--err); }
.qitem.err .status { color: var(--err); white-space: normal; text-align: right; }

/* ── tablas ── */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 12px 20px; border-bottom: 1px solid var(--line); }
td { padding: 12px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
.date { white-space: nowrap; width: 1%; color: var(--muted); }
th.date { color: var(--muted); }
.files tbody tr:hover { background: var(--soft); }
.files .name { display: flex; align-items: center; gap: 12px; color: var(--text); font-weight: 500; min-width: 0; }
.files .name .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .name:hover .label { color: var(--accent); }
.ic { width: 22px; height: 22px; }
.ic.dir { color: var(--accent); fill: var(--soft); }
.ic.file { color: var(--muted); }
.files td.num { color: var(--muted); }
.users tr.off td { opacity: .55; }
.log td { font-size: 14px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--soft); color: var(--accent); font-size: 12px; font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 8px; }
.dot.on { background: var(--ok); }

.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }

/* ── diálogo y avisos ── */
.dialog { border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: min(420px, calc(100vw - 32px)); background: var(--card); color: var(--text); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.dialog::backdrop { background: rgba(0, 0, 0, .4); }
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 40px)); }
.toast { padding: 12px 16px; border-radius: 10px; background: var(--text); color: var(--card); font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); transition: opacity .4s, transform .4s; }
.toast.error { background: var(--err); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ── móvil ── */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px 16px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .who { display: none; }
  .logout { margin-left: auto; }
  .wrap { padding: 20px 16px 48px; }
  .grid2 { grid-template-columns: 1fr; }
  th, td { padding: 10px 12px; }
  .files .date, .log .date, .users .date, .users td:nth-child(3), .users th:nth-child(3) { display: none; }
  .actions { width: 100%; }
  .actions .btn, .actions form { flex: 1; }
  .actions form .btn { width: 100%; }
  .danger-zone { flex-direction: column; align-items: stretch; }
  .auth-card { padding: 24px; }
}
