/* ipxDash · sistema de diseño. Familia visual IPX+: azul marino, degradado azul a verde. */

:root {
    --navy: #0f2547;
    --navy-deep: #0a1a33;
    --navy-line: #1c3561;
    --blue: #1e88e5;
    --blue-strong: #1565c0;
    --teal: #14b8a6;
    --green: #22c55e;
    --gradient: linear-gradient(135deg, #1e88e5 0%, #14b8a6 60%, #22c55e 100%);

    --bg: #f3f6fb;
    --surface: #ffffff;
    --surface-2: #f8fafd;
    --text: #0f1b2d;
    --muted: #5a6b84;
    --border: #e1e8f1;
    --ring: rgba(30, 136, 229, 0.35);

    --success: #15803d;
    --success-bg: #e8f7ee;
    --warning: #b45309;
    --warning-bg: #fef4e6;
    --danger: #c62828;
    --danger-bg: #fdecec;
    --info: #1565c0;
    --info-bg: #e8f1fc;
    --neutral-bg: #eef2f7;

    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 2px rgba(15, 27, 45, 0.06), 0 4px 14px rgba(15, 27, 45, 0.05);
    --sidebar: 252px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1220;
        --surface: #121b2d;
        --surface-2: #0f1727;
        --text: #e3e9f2;
        --muted: #93a3ba;
        --border: #22304a;
        --ring: rgba(80, 160, 240, 0.45);
        --success: #4ade80;
        --success-bg: #12301f;
        --warning: #fbbf24;
        --warning-bg: #33260d;
        --danger: #f87171;
        --danger-bg: #3a1717;
        --info: #7cb8f5;
        --info-bg: #13294a;
        --neutral-bg: #1b2539;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
        color-scheme: dark;
    }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font: 15px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 12px; }
h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.08rem; font-weight: 650; }
p { margin: 0 0 12px; }
code { font: 0.9em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--neutral-bg); padding: 1px 6px; border-radius: 5px; overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 4px; }

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip-link:focus { left: 8px; }

/* ── Estructura ─────────────────────────────────────────────── */

.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    background: var(--navy); color: #c9d6ea;
    display: flex; flex-direction: column;
    border-right: 1px solid var(--navy-line);
}

.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; color: #fff; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-name { font-size: 1.25rem; font-weight: 750; letter-spacing: -0.02em; }
.brand-name span { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }

.nav { padding: 6px 12px 16px; flex: 1; }
.nav-section { margin: 16px 10px 6px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #7f93b4; }
.nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 8px 10px; margin: 1px 0; border-radius: var(--radius-sm);
    color: #c9d6ea; font-weight: 500; text-decoration: none;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav a[aria-current="page"] { background: rgba(30, 136, 229, 0.18); color: #fff; box-shadow: inset 3px 0 0 #3ba0f3; }

.sidebar-footer { padding: 14px 16px 18px; border-top: 1px solid var(--navy-line); font-size: 0.85rem; }
.sidebar-footer .who { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer .role { color: #7f93b4; margin-bottom: 10px; }
.sidebar-footer form { margin: 0; }
.sidebar-footer button {
    width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
    background: transparent; color: #c9d6ea; border: 1px solid var(--navy-line); margin: 0;
}
.sidebar-footer button:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar-footer button svg { width: 16px; height: 16px; }

.content { min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; gap: 12px;
    height: 60px; padding: 0 28px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 5;
}
.topbar .account { font-weight: 650; }
.topbar .account small { display: block; font-weight: 400; color: var(--muted); font-size: 0.78rem; }
.topbar .spacer { flex: 1; }
.menu-toggle { display: none; }
.nav-backdrop { display: none; position: fixed; inset: 0; z-index: 25; background: rgba(5, 12, 25, 0.55); cursor: pointer; }

main.page { padding: 28px; width: 100%; max-width: 1200px; }

.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.page-header h1 { margin: 0; }
.page-header p { margin: 4px 0 0; color: var(--muted); }
.page-header .actions { display: flex; flex-wrap: wrap; gap: 8px; }

section { margin-top: 28px; }
main > section:first-child { margin-top: 0; }

/* ── Tarjetas ───────────────────────────────────────────────── */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; }
.card + .card { margin-top: 16px; }
.card > h2:first-child { margin-bottom: 14px; }
.card-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }

.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 24px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; position: relative; overflow: hidden; color: inherit; text-decoration: none; display: block; }
a.kpi:hover { text-decoration: none; border-color: var(--blue); }
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--gradient); }
.kpi .label { color: var(--muted); font-size: 0.85rem; font-weight: 550; display: flex; align-items: center; gap: 8px; }
.kpi .label svg { width: 16px; height: 16px; }
.kpi .value { font-size: 1.9rem; font-weight: 750; letter-spacing: -0.02em; margin-top: 4px; }
.kpi .hint { color: var(--muted); font-size: 0.8rem; }
.kpi.danger::before { background: var(--danger); }
.kpi.danger .value { color: var(--danger); }

/* ── Formularios ────────────────────────────────────────────── */

form.narrow { max-width: 560px; }
label { display: block; margin-top: 14px; margin-bottom: 5px; font-weight: 600; font-size: 0.9rem; }
label.inline { display: flex; gap: 9px; align-items: center; font-weight: 500; }

input, select, textarea {
    width: 100%; font: inherit; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 9px 12px; transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--ring); }
input[type="checkbox"], input[type="radio"] { width: 17px; height: 17px; padding: 0; accent-color: var(--blue); flex: none; }
input[type="file"] { padding: 7px; background: var(--surface-2); }
textarea { resize: vertical; min-height: 96px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 18px 18px; margin: 18px 0 0; }
legend { font-weight: 650; padding: 0 6px; }

button, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    margin-top: 18px; padding: 9px 16px;
    font: inherit; font-weight: 600; line-height: 1.2;
    border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer;
    background: var(--blue); color: #fff; text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}
button:hover, .btn:hover { background: var(--blue-strong); text-decoration: none; }
button svg, .btn svg { width: 16px; height: 16px; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); border-color: #c4d0e0; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #a61f1f; }
.btn-sm { padding: 5px 10px; font-size: 0.85rem; margin-top: 0; }
.actions .btn, .actions button { margin-top: 0; }

.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form input, .inline-form select { width: auto; flex: 1 1 170px; }
.inline-form button { margin: 0; }
.inline-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.inline-buttons form { margin: 0; }
.inline-buttons button { margin-top: 0; }

.filters { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 16px; box-shadow: var(--shadow); }

/* ── Avisos ─────────────────────────────────────────────────── */

.status, .warning, .notice {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 12px 14px; border-radius: var(--radius-sm); margin: 0 0 18px; border: 1px solid;
}
.status { background: var(--success-bg); border-color: color-mix(in srgb, var(--success) 35%, transparent); color: var(--success); }
.warning { background: var(--warning-bg); border-color: color-mix(in srgb, var(--warning) 40%, transparent); color: var(--text); }
.notice { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 30%, transparent); color: var(--text); }
.warning p:last-child, .notice p:last-child { margin-bottom: 0; }
.error { color: var(--danger); font-size: 0.88rem; margin: 6px 0 0; }
.muted { color: var(--muted); }
.help { color: var(--muted); font-size: 0.82rem; margin: -6px 0 12px; }

/* ── Tablas ─────────────────────────────────────────────────── */

.table { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th { text-align: left; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td a { font-weight: 600; }
.nowrap { white-space: nowrap; }

nav[aria-label="Paginación"] { display: flex; gap: 14px; align-items: center; justify-content: flex-end; margin-top: 14px; color: var(--muted); }

/* ── Etiquetas de estado ────────────────────────────────────── */

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 650; white-space: nowrap; background: var(--neutral-bg); color: var(--muted); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }

/* ── Detalles ───────────────────────────────────────────────── */

dl { display: grid; grid-template-columns: minmax(130px, max-content) 1fr; gap: 10px 20px; margin: 0; }
dt { color: var(--muted); font-size: 0.88rem; }
dd { margin: 0; font-weight: 500; }

/* ── Tickets ────────────────────────────────────────────────── */

.ticket-message { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--blue); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 12px; }
.ticket-message p:first-child { color: var(--muted); font-size: 0.85rem; margin-bottom: 6px; }
.ticket-message.internal { border-left-color: var(--warning); background: var(--warning-bg); }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.ticket-layout { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }

/* ── Importación ────────────────────────────────────────────── */

.import-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-top: 12px; }
.import-item h2 { font-size: 1rem; margin: 0 0 4px; }
.import-item p { margin: 0 0 10px; }

svg.qr, .qr svg { background: #fff; padding: 10px; border-radius: var(--radius-sm); max-width: 100%; }

/* ── Acceso ─────────────────────────────────────────────────── */

body.guest {
    min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
    background:
        radial-gradient(1200px 600px at 110% -10%, rgba(34, 197, 94, 0.18), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(30, 136, 229, 0.22), transparent 60%),
        var(--navy-deep);
}
.auth { width: 100%; max-width: 410px; }
.auth .brand { display: flex; justify-content: center; align-items: center; gap: 10px; color: #fff; margin-bottom: 22px; text-decoration: none; }
.auth .brand .brand-name { font-size: 1.6rem; }
.auth .brand-mark { width: 42px; height: 42px; }
.auth .card { padding: 28px 28px 24px; }
.auth h1 { font-size: 1.3rem; text-align: center; margin-bottom: 18px; }
.auth button[type="submit"] { width: 100%; }
.auth .footnote { text-align: center; margin: 16px 0 0; font-size: 0.9rem; }
.auth-tagline { color: #9fb2cf; text-align: center; margin-top: 18px; font-size: 0.82rem; }

/* ── Plataforma ─────────────────────────────────────────────── */

body.platform .sidebar { background: #1d1606; border-right-color: #3a2c0c; }
body.platform .nav a[aria-current="page"] { background: rgba(217, 119, 6, 0.2); box-shadow: inset 3px 0 0 #f59e0b; }
body.platform .platform-flag { display: inline-block; margin: 0 20px 6px; padding: 2px 8px; border-radius: 999px; background: #f59e0b; color: #1d1606; font-size: 0.72rem; font-weight: 750; letter-spacing: 0.05em; text-transform: uppercase; }

/* ── Celular ────────────────────────────────────────────────── */

@media (max-width: 960px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; inset: 0 auto 0 0; width: min(84vw, 290px); z-index: 30; transform: translateX(-100%); transition: transform 0.2s ease; }
    #nav-toggle:checked ~ .app .sidebar { transform: none; }
    #nav-toggle:checked ~ .nav-backdrop { display: block; }
    .menu-toggle { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: var(--radius-sm); border: 1px solid var(--border); cursor: pointer; color: var(--text); }
    .menu-toggle svg { width: 20px; height: 20px; }
    .topbar { padding: 0 16px; }
    main.page { padding: 20px 16px; }
    .ticket-layout { grid-template-columns: 1fr; }
    .card { padding: 16px; }
}

@media (max-width: 560px) {
    dl { grid-template-columns: 1fr; gap: 2px; }
    dd { margin-bottom: 8px; }
    h1 { font-size: 1.35rem; }
    .kpi .value { font-size: 1.6rem; }
}

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