:root {
    --tp-navy: #0b1f3a;
    --tp-navy-2: #123056;
    --tp-blue: #1a5fd1;
    --tp-blue-soft: #e8f0fc;
    --tp-bg: #eef2f6;
    --tp-card: #ffffff;
    --tp-text: #12233d;
    --tp-muted: #5b6b82;
    --tp-line: #d9e2ee;
    --tp-ok: #0f7b4a;
    --tp-warn: #9a6700;
    --tp-danger: #b42318;
    --tp-radius: 14px;
    --tp-shadow: 0 10px 28px rgba(11, 31, 58, 0.08);
    --tp-sidebar: 272px;
    --tp-focus: 0 0 0 3px rgba(26, 95, 209, 0.35);
}

html[data-theme="oscuro"] {
    --tp-navy: #081526;
    --tp-navy-2: #142844;
    --tp-blue: #6ea8ff;
    --tp-blue-soft: #163152;
    --tp-bg: #0e1724;
    --tp-card: #152033;
    --tp-text: #e8eef7;
    --tp-muted: #9aabc2;
    --tp-line: #24344c;
    --tp-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body.tp-body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background: var(--tp-bg);
    color: var(--tp-text);
}

a { color: var(--tp-blue); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: none;
    box-shadow: var(--tp-focus);
}

.tp-skip {
    position: absolute;
    left: -999px;
    top: 8px;
}
.tp-skip:focus { left: 8px; background: #fff; padding: 8px 12px; z-index: 20; }

.tp-shell { display: flex; min-height: 100vh; }

.tp-sidebar {
    width: var(--tp-sidebar);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--tp-navy) 0%, var(--tp-navy-2) 100%);
    color: #dbe7f6;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.tp-brand {
    padding: 22px 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.tp-brand strong { display: block; color: #fff; font-size: 16px; letter-spacing: .02em; }
.tp-brand small { color: #8eabc9; }

.tp-nav { padding: 12px 12px 24px; overflow: auto; flex: 1; }
.tp-nav-group { margin: 14px 8px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8eabc9; }
.tp-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #dbe7f6;
    text-decoration: none;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
}
.tp-nav a:hover { background: rgba(255,255,255,.08); }
.tp-nav a[aria-current="page"] { background: var(--tp-blue); color: #fff; }
.tp-nav svg { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; }

.tp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.tp-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    background: var(--tp-card);
    border-bottom: 1px solid var(--tp-line);
    position: sticky;
    top: 0;
    z-index: 6;
}
.tp-topbar form.tp-search { flex: 1; max-width: 440px; }
.tp-search input {
    width: 100%;
    border: 1px solid var(--tp-line);
    border-radius: 10px;
    padding: 9px 12px;
    background: var(--tp-bg);
    color: var(--tp-text);
}
.tp-chip {
    font-size: 12px;
    background: var(--tp-blue-soft);
    color: var(--tp-navy-2);
    border-radius: 999px;
    padding: 6px 10px;
    white-space: nowrap;
}
.tp-top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.tp-btn, .tp-topbar button, .erp-form button, .tp-card button[type="submit"] {
    border: 0;
    border-radius: 10px;
    padding: 9px 14px;
    background: var(--tp-blue);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.tp-btn-ghost, .tp-iconbtn {
    background: transparent;
    color: var(--tp-text);
    border: 1px solid var(--tp-line);
}
.tp-btn-danger { background: var(--tp-danger); }
.tp-btn-ok { background: var(--tp-ok); }

.tp-menu { position: relative; }
.tp-menu summary { list-style: none; cursor: pointer; }
.tp-menu summary::-webkit-details-marker { display: none; }
.tp-menu-panel {
    position: absolute;
    right: 0;
    top: 110%;
    background: var(--tp-card);
    border: 1px solid var(--tp-line);
    border-radius: 12px;
    box-shadow: var(--tp-shadow);
    min-width: 220px;
    padding: 8px;
    z-index: 8;
}
.tp-menu-panel a, .tp-menu-panel button {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    color: var(--tp-text);
    border: 0;
    padding: 8px 10px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
}
.tp-menu-panel a:hover, .tp-menu-panel button:hover { background: var(--tp-blue-soft); }

.tp-page { padding: 22px 22px 48px; }
.tp-aviso {
    background: #fff6e5;
    color: #6a4b00;
    border: 1px solid #f0d59a;
    border-radius: 10px;
    padding: 10px 14px;
    margin: 0 0 16px;
}
html[data-theme="oscuro"] .tp-aviso { background: #3a2a10; color: #f3d48a; border-color: #6a5318; }
.tp-error { background: #fdecec; color: var(--tp-danger); border-radius: 10px; padding: 10px 14px; }

.tp-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 18px; }
.tp-head h1 { margin: 0 0 6px; font-size: 26px; }
.tp-head p { margin: 0; color: var(--tp-muted); max-width: 720px; }

.tp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tp-card {
    background: var(--tp-card);
    border: 1px solid var(--tp-line);
    border-radius: var(--tp-radius);
    box-shadow: var(--tp-shadow);
    padding: 16px 18px;
}
.tp-kpi span { display: block; color: var(--tp-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.tp-kpi strong { font-size: 26px; }
.tp-kpi em { font-style: normal; font-size: 11px; color: var(--tp-warn); }

.tp-table-wrap { overflow: auto; }
table.tp-table { width: 100%; border-collapse: collapse; }
.tp-table th, .tp-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--tp-line); font-size: 13px; vertical-align: top; }
.tp-table thead th { background: var(--tp-blue-soft); color: var(--tp-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.tp-table tbody tr:hover { background: rgba(26, 95, 209, .04); }

.tp-badge { border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 700; }
.tp-badge-ok { background: #e5f6ee; color: var(--tp-ok); }
.tp-badge-off { background: #f3f4f6; color: var(--tp-muted); }
.tp-badge-warn { background: #fff4d6; color: var(--tp-warn); }
.tp-badge-sim { background: #e8f0fc; color: var(--tp-blue); }

.erp-form { display: grid; gap: 10px; }
.erp-form fieldset { border: 1px solid var(--tp-line); border-radius: 12px; padding: 14px; }
.erp-form legend { font-weight: 700; padding: 0 6px; }
.erp-form label, .erp-form p { display: grid; gap: 4px; margin: 0; color: var(--tp-muted); font-size: 13px; }
.erp-form input, .erp-form select, .erp-form textarea {
    border: 1px solid var(--tp-line);
    border-radius: 8px;
    padding: 8px 10px;
    background: var(--tp-card);
    color: var(--tp-text);
}
.tp-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tp-empty { padding: 28px; text-align: center; color: var(--tp-muted); }
.tp-pager { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.tp-quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 20px; }
.tp-quick a { background: var(--tp-card); border: 1px solid var(--tp-line); color: var(--tp-text); padding: 10px 14px; border-radius: 12px; text-decoration: none; font-weight: 700; box-shadow: var(--tp-shadow); }
.tp-hamb { display: none; }
#tp-cargando, #tp-aviso-lento {
    position: sticky; top: 0; z-index: 8; margin: 0 0 12px;
    padding: 10px 14px; border-radius: 10px; font-weight: 700;
}
#tp-cargando { background: var(--tp-blue-soft); color: var(--tp-navy); }
#tp-aviso-lento { background: #fff4e5; color: var(--tp-warn); }

@media (max-width: 900px) {
    .tp-hamb { display: inline-flex; }
    .tp-sidebar {
        position: fixed;
        z-index: 12;
        transform: translateX(-105%);
        transition: transform .2s ease;
    }
    body.tp-nav-open .tp-sidebar { transform: none; }
    .tp-chip-hide { display: none; }
    .tp-page { padding: 14px; }
}
