/* UNO OS — estilos base (sin Node ni compilación) */
:root {
    --bg: #f4f5f8;
    --surface: #ffffff;
    --border: #e3e6ec;
    --text: #1b2130;
    --muted: #6b7385;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --danger: #dc2626;
    --success: #16a34a;
    --sidebar: #141827;
    --sidebar-text: #c9cede;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
.muted { color: var(--muted); margin: 2px 0 0; }
.small { font-size: 12px; }

/* ── Layout ─────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 230px; flex-shrink: 0;
    background: var(--sidebar); color: var(--sidebar-text);
    display: flex; flex-direction: column;
    padding: 18px 14px;
    position: sticky; top: 0; height: 100vh;
}
.main { flex: 1; padding: 24px 28px; min-width: 0; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: #fff; margin-bottom: 26px; }
.brand-mark {
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--primary); color: #fff;
    display: grid; place-items: center; font-weight: 800;
}
.brand-lg { font-size: 22px; color: var(--text); justify-content: center; margin-bottom: 4px; }
.brand-lg .brand-mark { width: 40px; height: 40px; font-size: 20px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(255,255,255,.1); color: #fff; font-weight: 600; }
.nav-ico { width: 18px; text-align: center; opacity: .8; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #2c3250; color: #fff; display: grid; place-items: center; font-weight: 700; }
.me-name { color: #fff; font-weight: 600; }
.me-area { font-size: 12px; }
.sidebar .btn-ghost { color: var(--sidebar-text); border-color: #2c3250; }
.sidebar .btn-ghost:hover { background: rgba(255,255,255,.06); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* ── Botones y formularios ──────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
    font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: #eef0f4; }
.btn-block { width: 100%; }

input[type=text], input[type=search], input[type=password], input[type=email],
input[type=datetime-local], select, textarea {
    width: 100%; font: inherit; color: var(--text);
    padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(79,70,229,.25); border-color: var(--primary); }
select:disabled { background: #f1f2f5; color: var(--muted); }
textarea { resize: vertical; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > span { font-weight: 600; font-size: 13px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; color: var(--muted); }
.error { color: var(--danger); }

.form { padding: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.alert-success { background: #e8f7ee; color: #166534; border: 1px solid #bfe8cf; }
.alert-error { background: #fdecec; color: #991b1b; border: 1px solid #f6c7c7; }

/* ── Tarjetas y dashboard ───────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.link { color: var(--primary); font-weight: 600; font-size: 13px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow);
}
a.stat:hover { border-color: var(--primary); }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-danger { border-color: #f6c7c7; background: #fff7f7; }
.stat-danger .stat-value { color: var(--danger); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }

.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 36px; align-items: center; gap: 10px; padding: 4px 0; }
.bar-row:hover .bar-label { color: var(--primary); }
.bar-track { height: 10px; background: #eef0f4; border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--primary); border-radius: 99px; min-width: 2px; }
.bar-num { text-align: right; font-weight: 700; }

.mini-case { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.mini-case:first-of-type { border-top: 0; }
.mini-title { margin-left: 6px; }
.mini-meta { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; }

/* ── Etiquetas ──────────────────────────────────── */
.code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; color: var(--muted); white-space: nowrap; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: #eef0f4; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill {
    --c: #64748b;
    display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap;
    color: var(--c);
    background: color-mix(in srgb, var(--c) 12%, white);
    border: 1px solid color-mix(in srgb, var(--c) 30%, white);
}
.due { font-size: 12px; white-space: nowrap; }
.due-late { color: var(--danger); font-weight: 700; }

/* ── Tabla de casos ─────────────────────────────── */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; padding: 12px; }
.filters select { width: auto; min-width: 150px; }
.filters .grow { flex: 1; min-width: 220px; }

.table-wrap { padding: 0; overflow-x: auto; }
.table-wrap.loading { opacity: .55; transition: opacity .15s; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfc; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: #fafbff; }
.table tbody tr:last-child td { border-bottom: 0; }
.cell-title { font-weight: 600; }

.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 14px; }

/* ── Login ──────────────────────────────────────── */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(135deg, #141827, #2a2f55); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 30px 28px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card .muted { text-align: center; margin-bottom: 20px; }

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 900px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px; }
    .brand { margin: 0 16px 0 0; }
    .nav { flex-direction: row; }
    .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
    .sidebar-foot .btn-block { width: auto; }
    .main { padding: 16px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2, .form-grid { grid-template-columns: 1fr; }
}

/* ═══ Fase 2: paneles por área, módulos, ficha del caso ═══ */
.sidebar { overflow-y: auto; }
.nav-section { margin: 14px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7d849c; font-weight: 700; }
.nav a.sub { padding: 6px 10px 6px 22px; font-size: 13px; }
.crumbs { margin: 0 0 4px; font-size: 12px; color: var(--muted); }
.crumbs a { color: var(--primary); font-weight: 600; }
.link-plain:hover { color: var(--primary); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.mt { margin-top: 10px; }
.pre { white-space: pre-wrap; margin: 0 0 12px; }
.head-pills { display: flex; gap: 8px; flex-wrap: wrap; }

/* Tarjetas de módulos */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); transition: border-color .12s, transform .12s; }
.tile:hover { border-color: var(--primary); transform: translateY(-1px); }
.tile-ico { font-size: 22px; }
.tile-label { font-weight: 700; }
.tile-count { font-size: 12px; color: var(--muted); }

/* Casos con avance */
.status-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.case-row { display: block; padding: 10px 0; border-top: 1px solid var(--border); }
.case-row:first-of-type { border-top: 0; }
.case-row:hover .mini-title { color: var(--primary); }
.case-row-top { margin-bottom: 6px; }
.case-row-meta { margin-top: 4px; }

.progress { display: flex; align-items: flex-start; gap: 0; }
.progress-step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; min-width: 0; }
.progress-step::before { content: ""; position: absolute; top: 6px; left: -50%; width: 100%; height: 3px; background: #e3e6ec; z-index: 0; }
.progress-step:first-child::before { display: none; }
.progress-dot { width: 15px; height: 15px; border-radius: 50%; background: #fff; border: 3px solid #cfd4dd; position: relative; z-index: 1; }
.progress-label { font-size: 11px; color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.progress-step.done .progress-dot { background: var(--success); border-color: var(--success); }
.progress-step.done::before, .progress-step.current::before { background: var(--success); }
.progress-step.current .progress-dot { background: var(--primary); border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,70,229,.18); }
.progress-step.current .progress-label { color: var(--primary); font-weight: 700; }
.progress-cancelled { opacity: .55; align-items: center; }
.progress-card { margin-bottom: 16px; }
.progress-card .progress-dot { width: 20px; height: 20px; }
.progress-card .progress-step::before { top: 9px; }
.progress-card .progress-label { font-size: 13px; }

/* Ficha del caso */
.grid-wide { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.facts { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 0; }
.facts dt { color: var(--muted); font-weight: 600; font-size: 13px; }
.facts dd { margin: 0; }
.timeline { list-style: none; margin: 0 0 14px; padding: 0 0 0 16px; border-left: 2px solid var(--border); }
.tl-item { position: relative; padding: 0 0 14px 6px; }
.tl-item::before { content: ""; position: absolute; left: -23px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: #cfd4dd; border: 2px solid #fff; }
.tl-comment::before { background: var(--primary); }
.tl-comment .pre { background: #f6f7fb; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin: 4px 0 0; }
.tl-meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.comment-form textarea { margin-bottom: 8px; }

/* Tabla de módulos */
.actions-col { white-space: nowrap; text-align: right; width: 1%; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger-text { color: var(--danger); }

/* Ventana del formulario */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 18, 32, .45); display: flex; justify-content: center; align-items: flex-start; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 820px; box-shadow: 0 25px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 18px 20px 4px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: #fafbfc; border-radius: 0 0 14px 14px; }
.span-2 { grid-column: 1 / -1; }
.form-group-title { grid-column: 1 / -1; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--primary); border-bottom: 1px solid var(--border); padding-bottom: 4px; margin: 6px 0 12px; }
input.computed { background: #f1f5ff; font-weight: 700; color: var(--primary-dark); }
input[type=number], input[type=date], input[type=url] { width: 100%; font: inherit; color: var(--text); padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

@media (max-width: 900px) {
    .grid-wide { grid-template-columns: 1fr; }
    .progress-label { display: none; }
    .nav { flex-wrap: wrap; }
}

/* Buscador de alumnos (y otras relaciones grandes) */
.picker { position: relative; }
.picker-selected { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid #bfe8cf; background: #effaf3; border-radius: 8px; font-weight: 600; }
.picker-list { list-style: none; margin: 6px 0 0; padding: 4px; border: 1px solid var(--border); border-radius: 8px; background: #fff; max-height: 260px; overflow-y: auto; box-shadow: 0 8px 24px rgba(16,24,40,.08); }
.picker-list button { width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; font: inherit; display: flex; justify-content: space-between; gap: 12px; }
.picker-list button:hover { background: #f1f2ff; }
.picker-list .muted { margin: 0; font-size: 13px; }
.picker-empty { padding: 8px 10px; color: var(--muted); }
.handled { margin: -8px 0 12px; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--border); background: #f6f7fb; cursor: pointer; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.case-link { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }

/* Barra de sincronización con la plataforma en línea */
.sync-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: #f4f6ff; border: 1px solid #d9defc; border-radius: 8px; padding: 8px 12px; margin-bottom: 14px; font-size: 13px; }
.sync-items { display: flex; gap: 18px; flex-wrap: wrap; }
.sync-ok { color: var(--success); font-weight: 700; }
