:root {
    --bg: #f4f5f7;
    --panel: #ffffff;
    --ink: #1c2430;
    --ink-soft: #5b6472;
    --line: #e2e5ea;
    --brand: #2b5cff;
    --brand-dark: #1c3fc2;
    --amber: #f2994a;
    --green: #1f9d55;
    --red: #d94f4f;
    --radius: 10px;
    font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }

/* ---------- LOGIN / INSTALL ---------- */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(160deg, #1c2430 0%, #2b5cff 140%);
}
.auth-box {
    background: var(--panel);
    padding: 40px;
    border-radius: var(--radius);
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.auth-box h1 { margin-top: 0; font-size: 22px; }
.auth-box .subtitle { color: var(--ink-soft); margin-top: -8px; font-size: 14px; }
.auth-box code { background: #eef0f4; padding: 2px 6px; border-radius: 4px; }

/* ---------- TOPBAR ---------- */
.topbar {
    background: var(--ink);
    color: #fff;
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 14px 20px;
}
.logo { color: #fff; font-weight: 700; font-size: 18px; }
.topbar nav { display: flex; gap: 18px; flex: 1; }
.topbar nav a { color: #cfd6e4; font-size: 14px; }
.topbar nav a:hover { color: #fff; }
.user-info { display: flex; align-items: center; gap: 14px; font-size: 14px; color: #cfd6e4; }
.user-info small { opacity: 0.7; }
.btn-logout {
    background: rgba(255,255,255,0.1);
    padding: 6px 14px;
    border-radius: 6px;
    color: #fff !important;
}
.btn-logout:hover { background: rgba(255,255,255,0.2); }
.avatar-icono {
    font-size: 18px;
    background: rgba(255,255,255,0.12);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.btn-icono {
    font-size: 16px;
    background: rgba(255,255,255,0.1);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    text-decoration: none;
}
.btn-icono:hover { background: rgba(255,255,255,0.2); }

.container { max-width: 1100px; margin: 0 auto; padding: 30px 20px 60px; }

/* ---------- GENERAL ---------- */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.page-head h1 { margin: 0; font-size: 24px; }

.btn {
    display: inline-block;
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 600;
}
.btn:hover { background: var(--brand-dark); }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-secondary { background: var(--ink-soft); }
.btn-danger { background: var(--red); margin-top: 10px; }

.error { background: #fdecec; color: var(--red); padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.exito { background: #e8f7ee; color: var(--green); padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.empty-msg { color: var(--ink-soft); font-style: italic; }

/* ---------- STATS ---------- */
.stats { display: flex; gap: 14px; margin-bottom: 26px; flex-wrap: wrap; }
.stat-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    min-width: 100px;
}
.stat-num { font-size: 26px; font-weight: 700; }
.stat-card span:last-child { color: var(--ink-soft); font-size: 13px; }

/* ---------- TICKET GRID ---------- */
.ticket-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.ticket-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    display: block;
    color: var(--ink);
    transition: box-shadow .15s, transform .15s;
}
.ticket-card:hover { box-shadow: 0 8px 20px rgba(0,0,0,0.08); transform: translateY(-2px); }
.ticket-card h3 { margin: 10px 0 6px; font-size: 16px; }
.ticket-card-top { display: flex; justify-content: space-between; align-items: center; }
.ticket-meta { margin: 2px 0; font-size: 13px; color: var(--ink-soft); }

/* ---------- BADGES ---------- */
.badge { font-size: 12px; padding: 3px 10px; border-radius: 100px; font-weight: 600; }
.badge-pendiente { background: #fdf0da; color: #a3690f; }
.badge-progreso { background: #dbe6ff; color: var(--brand-dark); }
.badge-completado { background: #dcf3e4; color: var(--green); }

.prio { font-size: 12px; font-weight: 600; }
.prio-baja { color: var(--green); }
.prio-media { color: var(--amber); }
.prio-alta { color: var(--red); }

/* ---------- TICKET DETAIL ---------- */
.ticket-detail { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; margin-bottom: 30px; }
.ticket-info, .ticket-actions {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
}
.info-list { list-style: none; padding: 0; margin-top: 16px; }
.info-list li { padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.info-list li:first-child { border-top: none; }

.edit-details { margin-top: 20px; border-top: 1px dashed var(--line); padding-top: 14px; }
.edit-details summary { cursor: pointer; font-weight: 600; color: var(--brand); margin-bottom: 10px; }

/* ---------- FORMS ---------- */
.card-form {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    max-width: 480px;
    display: flex;
    flex-direction: column;
}
.ticket-actions .card-form { max-width: none; padding: 0; border: none; }
.auth-box form { display: flex; flex-direction: column; }
label { font-size: 13px; font-weight: 600; margin: 12px 0 4px; color: var(--ink-soft); }
input, textarea, select {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 16px;
    font-family: inherit;
    width: 100%;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 400;
    color: var(--ink);
    margin: 14px 0 4px;
}
.checkbox-label input[type="checkbox"] { width: auto; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
form .btn { margin-top: 18px; align-self: flex-start; }

/* ---------- TIMELINE ---------- */
.timeline { display: flex; flex-direction: column; gap: 12px; }
.timeline-item {
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 3px solid var(--brand);
    border-radius: 8px;
    padding: 14px 16px;
}
.timeline-head { display: flex; justify-content: space-between; margin-bottom: 6px; }
.timeline-date { color: var(--ink-soft); font-size: 12px; }

/* ---------- USUARIOS TABLE ---------- */
.tabla-usuarios { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tabla-usuarios th, .tabla-usuarios td { text-align: left; padding: 12px 14px; border-top: 1px solid var(--line); font-size: 14px; }
.tabla-usuarios thead { background: #f7f8fa; }
.acciones-cell { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form { display: flex; gap: 8px; align-items: center; margin: 0; }
.inline-form input { width: auto; }
details summary { cursor: pointer; font-size: 13px; color: var(--brand); }

/* ---------- FOTOS ---------- */
.foto-adjunta {
    max-width: 100%;
    max-height: 260px;
    border-radius: 8px;
    margin: 12px 0;
    border: 1px solid var(--line);
    display: block;
    cursor: zoom-in;
}

/* ---------- ANUNCIOS ---------- */
.anuncios-lista { display: flex; flex-direction: column; gap: 14px; }
.anuncio-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.anuncio-fijado {
    border-left: 4px solid var(--amber);
    background: #fffaf3;
}
.anuncio-card h3 { margin: 8px 0 4px; font-size: 17px; }
.anuncio-acciones { display: flex; gap: 10px; margin-top: 12px; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 720px) {
    .container { padding: 20px 14px 50px; }
    .topbar-inner { flex-wrap: wrap; padding: 12px 14px; gap: 10px; }
    .topbar nav { gap: 14px; order: 3; width: 100%; }
    .topbar nav a { padding: 6px 0; font-size: 14px; }
    .user-info { margin-left: auto; }

    .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
    .page-head > div { width: 100%; flex-direction: column !important; }
    .page-head .btn, .page-head .btn-secondary { width: 100%; text-align: center; }

    .ticket-detail { grid-template-columns: 1fr; }
    .stats { justify-content: space-between; gap: 8px; }
    .stat-card { flex: 1 1 40%; min-width: 0; padding: 12px 14px; }
    .stat-num { font-size: 22px; }

    .ticket-grid { grid-template-columns: 1fr; }
    .card-form { max-width: 100%; }
    form .btn { width: 100%; text-align: center; }

    .auth-box { padding: 28px 22px; margin: 16px; }

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