:root {
    color-scheme: dark;
    --bg: #0e1117;
    --panel: #161a23;
    --panel-2: #1d2230;
    --border: #2a3142;
    --text: #e7eaf0;
    --muted: #8f97ab;
    --accent: #4f8cff;
    --accent-strong: #3b76e6;
    --accent-soft: rgba(79, 140, 255, .14);
    --danger: #f0616d;
    --danger-soft: rgba(240, 97, 109, .13);
    --ok: #3ecf8e;
    --radius: 10px;
    --shadow: 0 18px 50px rgba(0, 0, 0, .45);
}

@media (prefers-color-scheme: light) {
    :root {
        color-scheme: light;
        --bg: #f3f5f9;
        --panel: #ffffff;
        --panel-2: #eef1f6;
        --border: #dde2ec;
        --text: #1a2030;
        --muted: #667085;
        --accent: #2f6bea;
        --accent-strong: #2558c9;
        --accent-soft: rgba(47, 107, 234, .1);
        --danger: #d43c4a;
        --danger-soft: rgba(212, 60, 74, .09);
        --ok: #15955f;
        --shadow: 0 18px 50px rgba(20, 30, 60, .16);
    }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; line-height: 1.25; }
h2 { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
h3 { font-size: 18px; }

[hidden] { display: none !important; }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-weight: 400; }

.logo { width: 28px; height: 28px; flex: none; }
.logo rect { fill: var(--accent); }
.logo path { stroke: #fff; stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------ formularios */

label { display: block; font-size: 13px; font-weight: 600; margin-top: 14px; }

input, textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    font: inherit;
    font-weight: 400;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 76px; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--muted); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    font: inherit;
    font-weight: 600;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--muted); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.block { width: 100%; margin-top: 20px; padding: 11px 16px; }

.alert {
    margin-top: 14px;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--danger);
    background: var(--danger-soft);
    border: 1px solid var(--danger);
    border-radius: 8px;
}

/* ------------------------------------------------------------ login / instalación */

body.auth { display: grid; place-items: center; padding: 20px; }

.card {
    width: 100%;
    max-width: 400px;
    padding: 30px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}
.card h1 { margin-bottom: 6px; }
.card-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font-size: 17px; font-weight: 700; }
.problems { padding-left: 20px; margin: 14px 0; }
.problems li { margin-bottom: 8px; }

/* ------------------------------------------------------------ panel */

body.app { display: flex; flex-direction: column; overflow: hidden; }

.topbar {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 56px;
    padding: 0 18px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.who { color: var(--muted); font-size: 13px; margin-right: 4px; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px minmax(0, 1fr); }

.sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 16px 12px 0;
    background: var(--panel);
    border-right: 1px solid var(--border);
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.search { margin: 12px 0 8px; }

.client-list { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 0 0 12px; }
.client-list .empty { padding: 14px 8px; color: var(--muted); font-size: 14px; }

.client-item {
    display: block;
    width: 100%;
    padding: 9px 10px;
    margin-bottom: 2px;
    text-align: left;
    font: inherit;
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
}
.client-item:hover { background: var(--panel-2); }
.client-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.client-item.active { background: var(--accent-soft); border-color: var(--accent); }
.client-item .name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-item .meta { display: block; font-size: 12.5px; color: var(--muted); }

.main { min-height: 0; overflow-y: auto; padding: 24px 28px 60px; }
.main > section { max-width: 980px; margin: 0 auto; }

.placeholder { padding: 70px 20px; text-align: center; color: var(--muted); }
.placeholder strong { display: block; margin-bottom: 6px; font-size: 18px; color: var(--text); }

.client-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.client-head h1 { overflow-wrap: anywhere; }
.client-head .desc { margin-top: 4px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.client-head .actions { display: flex; gap: 8px; flex: none; }

/* zona de subida */
.dropzone {
    display: block;
    margin: 0 0 22px;
    padding: 30px 20px;
    text-align: center;
    font-weight: 400;
    font-size: 15px;
    color: var(--muted);
    background: var(--panel);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone strong { display: block; margin-bottom: 4px; font-size: 16px; color: var(--text); }
.dropzone u { color: var(--accent); text-decoration: none; font-weight: 600; }
.dropzone small { display: block; margin-top: 8px; font-size: 13px; }

/* subidas en curso */
.main > .uploads { margin-bottom: 22px; }
.uploads-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.up { padding: 12px 14px; margin-bottom: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.up-top { display: flex; align-items: center; gap: 10px; }
.up-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-name strong { font-weight: 600; }
.up-name span { color: var(--muted); font-size: 13px; }
.bar { height: 6px; margin: 9px 0 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s linear; }
.up.done .bar-fill { background: var(--ok); }
.up.error .bar-fill { background: var(--danger); }
.up-status { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.up.error .up-status { color: var(--danger); }
.up.done .up-status a { color: var(--ok); }

/* lista de archivos */
.files-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.files { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.file { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 4px 18px; padding: 13px 16px; }
.file + .file { border-top: 1px solid var(--border); }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-link {
    display: inline-block;
    max-width: 100%;
    font: 13px/1.4 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    color: var(--accent);
    text-decoration: none;
    overflow-wrap: anywhere;
}
.file-link:hover { text-decoration: underline; }
.file-meta { font-size: 13px; color: var(--muted); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.file-actions { display: flex; gap: 6px; }
.files .placeholder { padding: 36px 20px; }

/* diálogos */
dialog {
    width: calc(100% - 32px);
    max-width: 420px;
    padding: 24px;
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(5, 8, 14, .6); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 99px;
    box-shadow: var(--shadow);
    z-index: 50;
}
.toast.bad { border-color: var(--danger); color: var(--danger); }

/* ------------------------------------------------------------ móvil */

@media (max-width: 820px) {
    body.app { overflow: auto; }
    .layout { display: block; }
    .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
    .client-list { max-height: 210px; }
    .main { overflow: visible; padding: 18px 14px 50px; }
    .who, #btn-password { display: none; }
    .client-head { flex-direction: column; }
    .file { grid-template-columns: minmax(0, 1fr); }
    .file-meta { text-align: left; }
}
