/* ********************************************************************************************
 * @Name:        site.css
 * @Description: Dark theme Truevice — paleta azul/teal para empresa tech de Internet+WiFi
 * @Author:      pixel
 * @Date:        2026/05/25
 ******************************************************************************************** */

/* ===================== VARIABLES ===================== */
:root {
    --blue:    #1A6BFF;
    --blue2:   #1255CC;
    --blue3:   #4D90FF;
    --teal:    #00D4C8;
    --teal2:   #00A89D;
    --white:   #FFFFFF;
    --dark:    #07090F;
    --bg:      #0A0E1A;
    --sf:      #0F1526;
    --card:    #141929;
    --dim:     #1E2640;
    --border:  rgba(26,107,255,.18);
    --border2: rgba(0,212,200,.25);
    --green:   #22C55E;
    --yellow:  #F59E0B;
    --red:     #EF4444;
    --text:    #E8F0FF;
    --muted:   #7A8CB0;
    --mono:    'JetBrains Mono', monospace;
    --sans:    'Inter', system-ui, sans-serif;
    --sidebar-w: 240px;
    --sidebar-collapsed-w: 68px;
}

/* ===================== RESET ===================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

img,
svg,
canvas {
    max-width: 100%;
}

html {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    background: var(--bg);
    background-image:
        radial-gradient(ellipse at 15% 0%, rgba(26,107,255,.15) 0%, transparent 55%),
        radial-gradient(ellipse at 85% 100%, rgba(0,212,200,.08) 0%, transparent 50%);
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
    min-height: 100vh;
    line-height: 1.5;
    max-width: 100%;
    overflow-x: hidden;
}

/* ===================== LAYOUT ===================== */
.tv-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
}

/* ===================== SIDEBAR ===================== */
.tv-sidebar {
    width: var(--sidebar-w);
    background: var(--sf);
    border-right: 1.5px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transition: width .22s ease, transform .25s ease;
    overflow: hidden;
}

.tv-sidebar-backdrop { display: none; }

.tv-sidebar-logo {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 68px;
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex: 1 1 auto;
    min-width: 0;
}

.sidebar-brand-text {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand-text span:first-child { color: var(--blue3); }
.sidebar-brand-text span:last-child  { color: var(--teal); }

.sidebar-brand-compact {
    display: none;
    font-size: 16px;
    font-weight: 800;
    color: var(--blue3);
    width: 36px;
    text-align: center;
}

.tv-sidebar-collapse-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    flex-shrink: 0;
    transition: color .2s;
}
.tv-sidebar-collapse-btn:hover { color: var(--blue3); }
.collapse-open { display: none; }
.collapse-close { display: block; }

.tv-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tv-nav-section {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 12px 8px 4px;
    white-space: nowrap;
    overflow: hidden;
}

.tv-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background .15s, color .15s;
    white-space: nowrap;
    overflow: hidden;
}
.tv-nav a:hover { background: var(--dim); color: var(--text); }
.tv-nav a.active { background: rgba(26,107,255,.18); color: var(--blue3); }

.nav-icon { flex-shrink: 0; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; }
.nav-icon svg { width: 18px; height: 18px; }
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tv-sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
}

.tv-pwa-install-btn {
    width: 100%;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(26,107,255,.12);
    color: var(--blue3);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    font-family: var(--sans);
}
.tv-pwa-install-btn:hover {
    border-color: var(--border2);
    background: rgba(0,212,200,.12);
    color: var(--teal);
}
.tv-pwa-install-btn svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

/* Sidebar colapsado */
body.sidebar-collapsed .tv-sidebar { width: var(--sidebar-collapsed-w); }
body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .tv-nav-section,
body.sidebar-collapsed .tv-sidebar-footer > span { display: none; }
body.sidebar-collapsed .tv-pwa-install-btn span { display: none; }
body.sidebar-collapsed .tv-pwa-install-btn {
    width: 36px;
    padding: 0;
}
body.sidebar-collapsed .sidebar-brand-compact { display: block; }
body.sidebar-collapsed .collapse-close { display: none; }
body.sidebar-collapsed .collapse-open  { display: block; }
body.sidebar-collapsed .tv-sidebar-footer { justify-content: center; }
body.sidebar-collapsed .tv-sidebar-footer { justify-content: center; font-size: 10px; }

/* ===================== MAIN AREA ===================== */
.tv-main {
    flex: 0 0 auto;
    width: calc(100% - var(--sidebar-w));
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    transition: margin-left .22s ease;
}
body.sidebar-collapsed .tv-main {
    width: calc(100% - var(--sidebar-collapsed-w));
    margin-left: var(--sidebar-collapsed-w);
}

/* ===================== TOPBAR ===================== */
.tv-topbar {
    height: 56px;
    background: var(--sf);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    min-width: 0;
    max-width: 100%;
}

.tv-mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
}
.tv-mobile-menu-btn .menu-close { display: none; }

.tv-topbar-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tv-topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex-shrink: 1;
}

.tv-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--teal);
    box-shadow: 0 0 6px var(--teal);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .4; }
}

.tv-user-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    background: var(--dim);
    padding: 4px 10px;
    border-radius: 20px;
    min-width: 0;
    max-width: min(260px, 42vw);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tv-alert-menu {
    position: relative;
    flex-shrink: 0;
}
.tv-alert-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--dim);
    color: var(--muted);
    cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
}
.tv-alert-btn:hover,
.tv-alert-menu:focus-within .tv-alert-btn {
    color: var(--text);
    border-color: var(--border2);
    background: rgba(255,255,255,.06);
}
.tv-alert-btn svg {
    width: 17px;
    height: 17px;
}
.tv-alert-btn span {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--red);
    color: white;
    border: 2px solid var(--sf);
    font-size: 10px;
    font-weight: 800;
    line-height: 14px;
    text-align: center;
}
.tv-alert-popover {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(360px, calc(100vw - 24px));
    max-height: 420px;
    overflow: auto;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--sf);
    box-shadow: 0 18px 48px rgba(0,0,0,.45);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity .15s, transform .15s, visibility .15s;
    z-index: 180;
}
.tv-alert-menu:hover .tv-alert-popover,
.tv-alert-menu:focus-within .tv-alert-popover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.tv-alert-popover-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 4px 8px;
    color: var(--text);
    font-size: 12px;
}
.tv-alert-popover-head span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: rgba(239,68,68,.14);
    color: var(--red);
    font-size: 11px;
    font-weight: 800;
}
.tv-alert-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px 4px;
    border-top: 1px solid rgba(255,255,255,.06);
    color: inherit;
    text-decoration: none;
    border-radius: 8px;
}
a.tv-alert-item:hover {
    background: rgba(255,255,255,.04);
}
.tv-alert-item strong {
    display: block;
    color: var(--text);
    font-size: 12px;
    margin-bottom: 2px;
}
.tv-alert-item p {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.tv-alert-item > span {
    align-self: start;
    border-radius: 999px;
    padding: 2px 7px;
    background: rgba(255,255,255,.06);
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}
.tv-alert-item > span.danger {
    background: rgba(239,68,68,.14);
    color: var(--red);
}
.tv-alert-empty {
    padding: 14px 4px 6px;
    color: var(--muted);
    font-size: 12px;
}

.tv-btn-logout {
    background: rgba(239,68,68,.12);
    color: var(--red);
    border: 1px solid rgba(239,68,68,.3);
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.tv-btn-logout:hover { background: rgba(239,68,68,.25); }

/* ===================== CONTENT ===================== */
.tv-content {
    flex: 1;
    padding: 24px;
    max-width: 1400px;
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

/* ===================== CARDS ===================== */
.tv-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    min-width: 0;
    max-width: 100%;
}

.tv-module-card {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: transform .15s, border-color .15s, background .15s;
}
.tv-module-card:hover {
    color: inherit;
    transform: translateY(-2px);
    border-color: var(--border2);
    background: rgba(255,255,255,.035);
}

.tv-card-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin-bottom: 12px;
}

.tv-icon-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--dim);
    color: var(--muted);
    cursor: pointer;
}
.tv-icon-btn:hover { color: var(--text); border-color: var(--border2); }
.tv-icon-btn svg { width: 16px; height: 16px; }

.tv-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.tv-stat-val {
    font-size: clamp(18px, 1.9vw, 24px);
    font-weight: 800;
    color: var(--text);
    line-height: 1.05;
    white-space: nowrap;
    letter-spacing: -.01em;
}
.tv-stat-val.blue  { color: var(--blue3); }
.tv-stat-val.teal  { color: var(--teal); }
.tv-stat-val.green { color: var(--green); }
.tv-stat-val.red   { color: var(--red); }
.tv-stat-val.yellow{ color: var(--yellow); }

.tv-stat-label {
    font-size: 12px;
    color: var(--muted);
}

.tv-stage-card {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: transform .15s, border-color .15s, background .15s;
}
.tv-stage-card:hover,
.tv-stage-card:focus-visible {
    color: inherit;
    transform: translateY(-2px);
    border-color: var(--border2);
    background: rgba(255,255,255,.035);
    outline: none;
}
.tv-stage-card.active {
    border-color: var(--border2);
    background: rgba(26,107,255,.12);
}
.tv-stat-wide {
    grid-column: span 2;
}
.tv-stat-val-xl {
    font-size: clamp(22px, 2.4vw, 30px);
}

/* ===================== GRID STATS ===================== */
.tv-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.tv-finance-summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    max-width: 880px;
}
.tv-finance-summary-grid .tv-stat-val {
    font-size: clamp(18px, 1.9vw, 22px);
    white-space: nowrap;
}
.tv-finance-summary-grid .tv-stat-label {
    overflow-wrap: anywhere;
}
.tv-finance-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.tv-finance-filter-card {
    padding: 12px;
}
.tv-finance-filter-bar {
    grid-template-columns: minmax(110px, 130px) minmax(150px, 180px) minmax(140px, 170px) minmax(140px, 170px) minmax(220px, 1fr) auto;
    align-items: end;
}
.tv-finance-filter-bar .select2-container {
    width: 100% !important;
    min-width: 0;
}
.tv-finance-filter-bar .tv-filter-actions {
    align-self: end;
    flex-wrap: nowrap;
}
.tv-cost-filter-card {
    padding: 12px;
}
.tv-cost-filter-bar {
    grid-template-columns: minmax(150px, 170px) minmax(150px, 190px) minmax(220px, 1fr) auto;
    align-items: end;
}
.tv-cost-filter-bar .tv-filter-actions {
    align-self: end;
    flex-wrap: nowrap;
}
.tv-cost-filter-bar .tv-filter-period .select2-container,
.tv-cost-filter-bar .tv-period-select + .select2-container {
    width: 100% !important;
    min-width: 0;
}
.tv-finance-year-form {
    display: flex;
    align-items: center;
}
.tv-finance-year-form .tv-select {
    width: auto;
    min-width: 112px;
}
.tv-finance-form-card {
    max-width: 980px;
    padding: 16px 20px;
}
.tv-finance-form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 14px;
    row-gap: 4px;
}
.tv-finance-form-grid-head {
    grid-template-columns: 120px minmax(180px, 1fr) minmax(160px, 220px);
}
.tv-finance-form .tv-form-group {
    margin-bottom: 12px;
}
.tv-finance-form .tv-input,
.tv-finance-form .tv-select {
    padding: 8px 10px;
    min-height: 34px;
}
.tv-finance-form .tv-textarea {
    min-height: 66px;
}
.tv-finance-form-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 2px;
}
.tv-project-form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}
.tv-project-form-grid-head {
    grid-template-columns: 140px minmax(220px, 1fr) minmax(180px, 260px);
}
.tv-project-form-grid-state {
    grid-template-columns: minmax(160px, 240px) 1fr;
}
.tv-service-checks {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}
.tv-service-check {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--dim);
    color: var(--text);
    font-size: 13px;
}
.tv-service-check input {
    margin: 0;
}
.tv-form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.tv-filter-card {
    margin-bottom: 18px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    max-width: 100%;
    min-width: 0;
}
.tv-filter-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    align-items: end;
    width: 100%;
    min-width: 0;
}
.tv-filter-bar-inline {
    max-width: 100%;
}
.tv-filter-bar .tv-form-group {
    position: relative;
    margin: 0;
    min-width: 0;
}
.tv-filter-search {
    min-width: min(260px, 100%);
}
.tv-filter-search-icon {
    position: absolute;
    left: 10px;
    bottom: 10px;
    width: 14px;
    height: 14px;
    color: var(--muted);
    pointer-events: none;
}
.tv-input-with-icon {
    padding-left: 32px;
}
.tv-filter-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* ===================== SEMÁFOROS ===================== */
.tv-ok      { color: var(--green); }
.tv-revisar { color: var(--yellow); }
.tv-alerta  { color: var(--red); }

.tv-badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    gap: 4px;
}
.tv-badge-ok      { background: rgba(34,197,94,.15);  color: var(--green); }
.tv-badge-revisar { background: rgba(245,158,11,.15); color: var(--yellow); }
.tv-badge-alerta  { background: rgba(239,68,68,.15);  color: var(--red); }
.tv-badge-blue    { background: rgba(26,107,255,.18); color: var(--blue3); }
.tv-badge-teal    { background: rgba(0,212,200,.15);  color: var(--teal); }
.tv-badge-muted   { background: var(--dim); color: var(--muted); }

.tv-pay-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--dim);
}
.tv-pay-summary-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--teal);
    line-height: 1.1;
}
.tv-pay-summary-value span {
    font-size: 13px;
    color: var(--muted);
    font-weight: 700;
}
.tv-pay-summary-right {
    display: grid;
    justify-items: end;
    gap: 8px;
    min-width: 180px;
}
.tv-pay-bar {
    width: 180px;
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,.08);
}
.tv-pay-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--teal);
}

/* ===================== TABLA ===================== */
.tv-table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.tv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.tv-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}
table.tv-table td {
    padding: 11px 12px;
    border-bottom: 1px solid rgba(255,255,255,.04);
    vertical-align: middle;
}
table.tv-table tbody tr:hover { background: rgba(255,255,255,.025); }
table.tv-table tbody tr:last-child td { border-bottom: none; }

/* ===================== TIMELINE DE ETAPAS ===================== */
.tv-timeline {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 12px 0;
    overflow-x: auto;
}

.tv-tl-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex: 1;
    min-width: 90px;
    cursor: pointer;
    border-radius: 8px;
    padding-bottom: 4px;
    outline: none;
}
.tv-tl-step:hover .tv-tl-label,
.tv-tl-step:focus-visible .tv-tl-label { color: var(--text); }
.tv-tl-step:focus-visible { box-shadow: 0 0 0 3px rgba(26,107,255,.18); }

/* Línea conectora */
.tv-tl-step::before {
    content: '';
    position: absolute;
    top: 12px;
    left: calc(-50% + 12px);
    right: calc(50% + 12px);
    height: 2px;
    background: var(--dim);
    transition: background .3s;
}
.tv-tl-step:first-child::before { display: none; }
.tv-tl-step.done::before,
.tv-tl-step.active::before { background: var(--blue); }

/* Círculo */
.tv-tl-dot {
    width: 24px; height: 24px;
    border-radius: 50%;
    border: 2px solid var(--dim);
    background: var(--card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: var(--muted);
    position: relative;
    z-index: 1;
    transition: all .3s;
}
.tv-tl-step.done .tv-tl-dot {
    background: var(--blue);
    border-color: var(--blue);
    color: white;
}
.tv-tl-step.active .tv-tl-dot {
    background: var(--blue3);
    border-color: var(--blue3);
    color: white;
    box-shadow: 0 0 0 4px rgba(26,107,255,.25);
    animation: tl-pulse 2s infinite;
}
.tv-tl-step.finalizado .tv-tl-dot {
    background: var(--teal);
    border-color: var(--teal);
    color: white;
}

@keyframes tl-pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(26,107,255,.25); }
    50%       { box-shadow: 0 0 0 8px rgba(26,107,255,.10); }
}

.tv-tl-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
    text-align: center;
    margin-top: 6px;
    white-space: nowrap;
}
.tv-tl-step.done .tv-tl-label,
.tv-tl-step.active .tv-tl-label { color: var(--blue3); }
.tv-tl-step.finalizado .tv-tl-label { color: var(--teal); }

/* Timeline miniatura (en lista de proyectos) */
.tv-tl-mini {
    display: flex;
    align-items: center;
    gap: 3px;
}
.tv-tl-mini-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--dim);
    flex-shrink: 0;
    transition: background .2s;
}
.tv-tl-mini-dot.done   { background: var(--blue); }
.tv-tl-mini-dot.active { background: var(--blue3); box-shadow: 0 0 4px var(--blue3); }
.tv-tl-mini-dot.finalizado{ background: var(--teal); }
.tv-tl-mini-line {
    flex: 1;
    height: 2px;
    background: var(--dim);
    min-width: 8px;
}
.tv-tl-mini-line.done { background: var(--blue); }

/* ===================== FORMULARIOS ===================== */
.tv-form-group { margin-bottom: 18px; }
.tv-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.tv-input,
.tv-select,
.tv-textarea {
    width: 100%;
    background: var(--dim);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-family: var(--sans);
    transition: border-color .2s;
    outline: none;
}
.tv-input:focus, .tv-select:focus, .tv-textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(26,107,255,.15);
}
.tv-textarea { resize: vertical; min-height: 80px; }
.tv-select option { background: var(--card); }

.tv-period-select + .select2-container {
    min-width: 160px;
}
.select2-container--default .select2-selection--single {
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--dim);
    color: var(--text);
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    padding: 4px 34px 4px 12px;
    color: var(--text);
    font-size: 13px;
    line-height: 28px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px;
    right: 6px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: var(--muted) transparent transparent transparent;
}
.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(26,107,255,.15);
}
.select2-dropdown.tv-select2-dropdown {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    color: var(--text);
}
.tv-select2-dropdown .select2-search--dropdown {
    padding: 8px;
}
.tv-select2-dropdown .select2-search__field {
    border: 1px solid var(--border) !important;
    border-radius: 6px;
    background: var(--dim);
    color: var(--text);
    outline: none;
}
.tv-select2-dropdown .select2-results__option {
    padding: 8px 10px;
    color: var(--text);
    font-size: 13px;
}
.select2-container--default .select2-results__option--selected,
.select2-container--default .select2-results__option[aria-selected=true] {
    background: rgba(0,212,200,.18);
    color: var(--teal);
}
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable,
.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: rgba(0,212,200,.24);
    color: var(--teal);
}
.tv-select2-dropdown .select2-results__option--highlighted[aria-selected] {
    background: rgba(26,107,255,.22);
    color: var(--text);
}
.tv-select2-dropdown .select2-results__option--highlighted.select2-results__option--selectable,
.tv-select2-dropdown .select2-results__option--highlighted[aria-selected=true] {
    background: rgba(0,212,200,.22);
    color: var(--teal);
}
.tv-select2-dropdown .select2-results__option[aria-selected=true] {
    background: rgba(0,212,200,.16);
    color: var(--teal);
}
.tv-select2-dropdown .select2-results__option--selected,
.tv-select2-dropdown .select2-results__option[aria-selected=true].select2-results__option--selected {
    background: rgba(0,212,200,.18);
    color: var(--teal);
}
.has-error .tv-input,
.has-error .tv-select { border-color: var(--red); }
.help-block { font-size: 11px; color: var(--red); margin-top: 4px; }

.tv-check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--dim);
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
}
.tv-check-row input { width: 18px; height: 18px; accent-color: var(--teal); }

.tv-modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.tv-modal.open { display: flex; }
.tv-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.62);
}
.tv-modal-dialog {
    position: relative;
    width: min(620px, 100%);
    max-height: calc(100vh - 40px);
    overflow: auto;
    background: var(--card);
    border: 1px solid var(--border2);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 24px 80px rgba(0,0,0,.35);
}
.tv-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
body.modal-open { overflow: hidden; }

.tv-pwa-login-install {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 120;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--border2);
    border-radius: 999px;
    background: rgba(15,21,38,.94);
    color: var(--teal);
    padding: 0 16px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
    box-shadow: 0 14px 40px rgba(0,0,0,.35);
}
.tv-pwa-login-install:hover {
    color: var(--text);
    background: rgba(26,107,255,.24);
}
.tv-pwa-login-install svg {
    width: 16px;
    height: 16px;
}
.tv-pwa-modal {
    max-width: 460px;
}
.tv-pwa-modal-title {
    color: var(--text);
    font-size: 18px;
    font-weight: 800;
}
.tv-pwa-modal-subtitle {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}
.tv-pwa-direct-btn {
    width: 100%;
    justify-content: center;
    margin-bottom: 14px;
}
.tv-pwa-ios-guide {
    display: grid;
    gap: 10px;
}
.tv-pwa-step {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255,255,255,.035);
}
.tv-pwa-step span {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(0,212,200,.14);
    color: var(--teal);
    font-size: 12px;
    font-weight: 900;
}
.tv-pwa-step p {
    color: var(--text);
    font-size: 13px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

/* ===================== BOTONES ===================== */
.tv-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all .15s;
    font-family: var(--sans);
}
.tv-btn svg { width: 15px; height: 15px; }

.tv-btn-primary  { background: var(--blue);  color: white; }
.tv-btn-primary:hover  { background: var(--blue2); color: white; }

.tv-btn-teal     { background: var(--teal);  color: var(--dark); }
.tv-btn-teal:hover     { background: var(--teal2); color: var(--dark); }

.tv-btn-ghost    { background: var(--dim);   color: var(--text); border: 1px solid var(--border); }
.tv-btn-ghost:hover    { background: rgba(255,255,255,.07); color: var(--text); }

.tv-btn-danger   { background: rgba(239,68,68,.15); color: var(--red); border: 1px solid rgba(239,68,68,.3); }
.tv-btn-danger:hover   { background: rgba(239,68,68,.25); color: var(--red); }

.tv-btn-sm { padding: 5px 10px; font-size: 11px; }

/* ===================== PAGE HEADER ===================== */
.tv-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
    min-width: 0;
    max-width: 100%;
}
.tv-page-header > * {
    min-width: 0;
}
.tv-page-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    overflow-wrap: anywhere;
}
.tv-page-title small {
    font-size: 13px;
    font-weight: 400;
    color: var(--muted);
    margin-left: 8px;
}

/* ===================== ALERTAS FLASH ===================== */
.tv-flash {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 20px;
}
.tv-flash-success { background: rgba(34,197,94,.12);  color: var(--green); border: 1px solid rgba(34,197,94,.3); }
.tv-flash-error   { background: rgba(239,68,68,.12);  color: var(--red);   border: 1px solid rgba(239,68,68,.3); }
.tv-flash-info    { background: rgba(26,107,255,.12); color: var(--blue3); border: 1px solid rgba(26,107,255,.3); }

/* ===================== KPI AREA HEADER ===================== */
.tv-area-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0 6px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--blue3);
}

/* ===================== LOGIN ===================== */
.tv-login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    background-image:
        radial-gradient(ellipse at 25% 0%, rgba(26,107,255,.18) 0%, transparent 55%),
        radial-gradient(ellipse at 75% 100%, rgba(0,212,200,.10) 0%, transparent 50%);
}

.tv-login-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 24px 64px rgba(0,0,0,.5);
}

.tv-login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.tv-login-logo .brand-name {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -1px;
}
.tv-login-logo .brand-name span:first-child { color: var(--blue3); }
.tv-login-logo .brand-name span:last-child  { color: var(--teal); }
.tv-login-logo small {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

/* ===================== FOOTER INSTITUCIONAL ===================== */
.tv-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--muted);
    background: var(--bg);
    flex-shrink: 0;
}
.tv-footer__right {
    display: flex;
    align-items: center;
    gap: 6px;
}
.tv-footer__logo {
    height: 16px;
    filter: brightness(0) invert(1);
    opacity: .6;
    vertical-align: middle;
    transition: opacity .2s;
}
.tv-footer__right a:hover .tv-footer__logo { opacity: 1; }
.tv-footer__right a {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

/* ===================== MOBILE QUICKNAV ===================== */
.tv-mobile-quicknav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--sf);
    border-top: 1px solid var(--border);
    z-index: 150;
    padding: 6px 0;
    justify-content: space-around;
    max-width: 100%;
    overflow: hidden;
}
.tv-mobile-quicknav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--muted);
    text-decoration: none;
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 6px;
    min-width: 0;
    max-width: 25%;
    overflow: hidden;
}
.tv-mobile-quicknav a.active { color: var(--blue3); }
.tv-mobile-quicknav .quick-icon { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
.tv-mobile-quicknav .quick-icon svg { width: 20px; height: 20px; }

/* ===================== TABS ===================== */
.tv-tabs {
    display: inline-flex;
    gap: 4px;
    padding: 3px;
    margin-bottom: 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
}
.tv-tab {
    min-height: 30px;
    padding: 0 12px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.tv-tab span {
    margin-left: 6px;
    color: inherit;
    opacity: .75;
}
.tv-tab.active {
    background: var(--card);
    color: var(--text);
    box-shadow: 0 0 0 1px rgba(255,255,255,.04);
}
.tv-tab-panel { display: none; }
.tv-tab-panel.active { display: block; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
    .tv-sidebar {
        transform: translateX(-100%);
    }
    .tv-sidebar.open { transform: translateX(0); }

    .tv-sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 199;
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s;
    }
    body.sidebar-open .tv-sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .tv-main { margin-left: 0; }
    .tv-main { width: 100%; }
    .tv-mobile-menu-btn { display: flex; }
    .tv-mobile-quicknav { display: flex; }
    .tv-content { padding: 16px 12px 80px; }
    .tv-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .tv-stage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .tv-stat-wide { grid-column: 1 / -1; }
    .tv-stat-val-xl { font-size: 24px; }
    .tv-alert-popover {
        right: -58px;
        width: min(340px, calc(100vw - 16px));
    }
    .tv-finance-actions {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
    }
    .tv-cost-filter-bar {
        grid-template-columns: 1fr;
        width: 100%;
    }
    .tv-finance-filter-bar {
        grid-template-columns: 1fr;
        width: 100%;
    }
    .tv-cost-filter-bar .tv-filter-actions {
        flex-wrap: wrap;
    }
    .tv-finance-filter-bar .tv-filter-actions {
        flex-wrap: wrap;
    }
    .tv-cost-filter-bar .select2-container {
        width: 100% !important;
    }
    .tv-finance-filter-bar .select2-container {
        width: 100% !important;
    }
    .tv-finance-year-form,
    .tv-finance-year-form .tv-select,
    .tv-finance-actions .tv-btn {
        width: 100%;
    }
    .tv-finance-form-card {
        max-width: 100%;
    }
    .tv-finance-form-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }
    .tv-finance-form-actions .tv-btn {
        width: 100%;
        justify-content: center;
    }
    .tv-project-form-grid,
    .tv-project-form-grid-head,
    .tv-project-form-grid-state,
    .tv-service-checks {
        grid-template-columns: 1fr;
    }
    .tv-form-actions .tv-btn {
        width: 100%;
        justify-content: center;
    }
    .tv-filter-card {
        padding: 12px;
    }
    .tv-filter-bar {
        grid-template-columns: 1fr;
    }
    .tv-filter-actions .tv-btn {
        width: 100%;
        justify-content: center;
    }
    .tv-pwa-login-install {
        right: 12px;
        bottom: 12px;
        min-height: 44px;
    }
    .tv-pwa-modal {
        max-width: 100%;
        padding: 16px;
    }
}

@media (min-width: 769px) and (max-width: 1100px) {
    .tv-stage-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}

/* ===================== UTILIDADES ===================== */
.text-muted   { color: var(--muted); }
.text-blue    { color: var(--blue3); }
.text-teal    { color: var(--teal); }
.text-green   { color: var(--green); }
.text-yellow  { color: var(--yellow); }
.text-red     { color: var(--red); }
.mono         { font-family: var(--mono); font-size: 12px; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
