/* ===================================================================
   Telemetria EMIND — Modern Responsive Design
   =================================================================== */

:root {
    --bg: #f1f5f9;
    --panel: rgba(255,255,255,0.95);
    --panel-solid: #ffffff;
    --text: #0f172a;
    --text-secondary: #475569;
    --muted: #64748b;
    --brand: #0d9488;
    --brand-light: #14b8a6;
    --brand-dark: #134e4a;
    --accent: #f59e0b;
    --danger: #ef4444;
    --success: #22c55e;
    --line: rgba(15,23,42,0.08);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 4px 16px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
    --shadow-hover: 0 20px 50px rgba(0,0,0,0.10);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --transition: 0.2s ease;
    --sidebar-w: 272px;
    --header-h: 60px;
    --font: 'Inter', system-ui, -apple-system, sans-serif;
}

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

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(15,23,42,0.14); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(15,23,42,0.24); }
::selection { background: rgba(20,184,166,0.2); color: var(--brand-dark); }

html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    line-height: 1.55;
}

a { color: inherit; text-decoration: none; transition: color var(--transition); }
img { max-width: 100%; height: auto; }

/* ===================================================================
   LAYOUT
   =================================================================== */
.layout {
    min-height: 100vh;
}

/* ===================================================================
   MOBILE HEADER (hidden on desktop)
   =================================================================== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    height: var(--header-h);
    padding: 0 16px;
    background: rgba(15,23,42,0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.mobile-header__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #f1f5f9;
}

.mobile-header__brand .brand-title {
    font-weight: 700;
    font-size: 1rem;
}

.mobile-header__logout {
    color: rgba(255,255,255,0.6);
    padding: 8px;
    border-radius: 8px;
    transition: all var(--transition);
}

.mobile-header__logout:hover { color: #fff; background: rgba(255,255,255,0.08); }

/* Hamburger */
.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 8px;
    border: none;
    border-radius: 10px;
    background: rgba(255,255,255,0.06);
    cursor: pointer;
    transition: background var(--transition);
}

.hamburger:hover { background: rgba(255,255,255,0.12); }

.hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    border-radius: 2px;
    background: #e2e8f0;
    transition: all 0.25s ease;
}

body.sidebar-open .hamburger span:nth-child(1) { transform: rotate(45deg) translate(5px,5px); }
body.sidebar-open .hamburger span:nth-child(2) { opacity: 0; }
body.sidebar-open .hamburger span:nth-child(3) { transform: rotate(-45deg) translate(5px,-5px); }

/* Sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.visible { display: block; opacity: 1; }

/* Sidebar close button (mobile only) */
.sidebar-close {
    display: none;
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    padding: 0;
}

.sidebar-close:hover { background: rgba(255,255,255,0.15); color: #fff; transform: none; box-shadow: none; }

/* ===================================================================
   SIDEBAR
   =================================================================== */
.sidebar {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 24px 16px;
    background: linear-gradient(180deg, #0f172a 0%, #0e1c2e 60%, #132337 100%);
    color: #e2e8f0;
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    z-index: 200;
    overflow-y: auto;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

.sidebar__top { display: flex; flex-direction: column; }

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    padding: 0 4px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 0.95rem;
    background: #0c1a2e;
    color: #082f49;
    box-shadow: 0 6px 20px rgba(20,184,166,0.3);
    flex-shrink: 0;
    transition: transform var(--transition);
    overflow: hidden;
    padding: 4px;
}

.brand-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-mark--sm {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    font-size: 0.75rem;
}

.brand:hover .brand-mark { transform: scale(1.05) rotate(-2deg); }

.brand-title { font-size: 0.95rem; font-weight: 700; }
.brand-subtitle { font-size: 0.78rem; color: rgba(226,232,240,0.45); margin-top: 1px; }

/* Nav links */
.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-link, .nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.92rem;
    color: rgba(226,232,240,0.65);
    transition: all var(--transition);
    position: relative;
}

.nav-link:hover, .nav a:hover {
    color: #e2e8f0;
    background: rgba(255,255,255,0.06);
}

.nav-link.active, .nav a.active {
    color: #ffffff;
    background: rgba(20,184,166,0.15);
}

.nav-link.active::before, .nav a.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    border-radius: 0 4px 4px 0;
    background: linear-gradient(180deg, #14b8a6, #f59e0b);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.55;
    transition: opacity var(--transition);
}

.nav-link.active .nav-icon, .nav a.active .nav-icon,
.nav-link:hover .nav-icon, .nav a:hover .nav-icon { opacity: 1; }

/* User box */
.user-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    border-radius: 14px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.05);
    flex-wrap: wrap;
}

.user-box__avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0d9488, #14b8a6);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-box__info {
    flex: 1;
    min-width: 0;
}

.user-box__info strong {
    display: block;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-box__info span,
.user-box span {
    display: block;
    font-size: 0.78rem;
    color: rgba(226,232,240,0.45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: rgba(147,197,253,0.8);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 6px 10px;
    border-radius: 8px;
    width: 100%;
    margin-top: 4px;
    transition: all var(--transition);
}

.logout:hover {
    color: #bfdbfe;
    background: rgba(255,255,255,0.06);
}

/* ===================================================================
   MAIN CONTENT
   =================================================================== */
.content {
    margin-left: var(--sidebar-w);
    padding: 28px 32px;
    min-height: 100vh;
    animation: fadeIn 0.35s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===================================================================
   COMMON ELEMENTS
   =================================================================== */
.eyebrow {
    display: inline-block;
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--brand);
    font-weight: 700;
}

/* Form elements */
.stack-form { display: grid; gap: 14px; }

.stack-form label,
.hero-actions label {
    display: grid;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
}

input, select, textarea, button { font: inherit; }

input, select, textarea {
    width: 100%;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--line);
    background: #fff;
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    font-size: 0.92rem;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--brand-light);
    box-shadow: 0 0 0 3px rgba(20,184,166,0.10);
}

input[type="color"] {
    padding: 6px;
    min-height: 48px;
    cursor: pointer;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--brand);
}

.checkbox-inline {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 10px;
}

button {
    border: 0;
    padding: 11px 20px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--brand), var(--brand-light));
    color: #fff;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all var(--transition);
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(13,148,136,0.25);
}

button:active { transform: translateY(0); }

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ghost-button {
    background: var(--text);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    padding: 10px 18px;
    text-decoration: none;
    white-space: nowrap;
}

.ghost-button:hover { box-shadow: 0 6px 20px rgba(15,23,42,0.2); }

/* Panels */
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}

.panel h2 { margin: 0 0 16px; font-size: 1.1rem; }

/* Tables */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
}

table { width: 100%; border-collapse: collapse; }

th, td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    font-size: 0.88rem;
}

th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 700;
    background: rgba(248,250,252,0.8);
    position: sticky;
    top: 0;
}

tbody tr { transition: background var(--transition); }
tbody tr:hover { background: rgba(13,148,136,0.03); }

.inline-form { display: inline-block; }
.inline-form button { padding: 6px 12px; font-size: 0.82rem; }

.compact-form { margin-top: 10px; }

/* Details */
details { margin-top: 8px; }
details summary {
    cursor: pointer;
    color: var(--brand);
    font-weight: 600;
    font-size: 0.88rem;
    padding: 6px 0;
    transition: color var(--transition);
}
details summary:hover { color: var(--brand-dark); }
details[open] summary { margin-bottom: 10px; }

/* Messages */
.message.error {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: rgba(239,68,68,0.06);
    color: #991b1b;
    border: 1px solid rgba(239,68,68,0.12);
    font-weight: 600;
    font-size: 0.88rem;
}

.hint { font-size: 0.82rem; color: var(--muted); line-height: 1.5; }

/* ===================================================================
   OVERVIEW HERO
   =================================================================== */
.telemetry-stage { display: grid; gap: 20px; }

.overview-hero {
    padding: 26px 28px;
    border-radius: var(--radius-xl);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

.overview-hero h1 {
    margin: 6px 0 8px;
    font-size: clamp(1.5rem, 3vw, 2rem);
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.telemetry-stage__copy {
    color: var(--muted);
    margin: 0;
    max-width: 600px;
    font-size: 0.92rem;
}

/* ===================================================================
   CHANNEL CARDS
   =================================================================== */
.channel-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.channel-overview-card {
    display: flex;
    flex-direction: column;
    padding: 20px;
    border-radius: var(--radius-lg);
    background: var(--panel);
    border: 1.5px solid var(--line);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    animation: cardEnter 0.35s ease-out both;
}

.channel-overview-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(13,148,136,0.2);
}

.channel-overview-card:nth-child(1) { animation-delay: 0s; }
.channel-overview-card:nth-child(2) { animation-delay: 0.04s; }
.channel-overview-card:nth-child(3) { animation-delay: 0.04s; }
.channel-overview-card:nth-child(4) { animation-delay: 0.08s; }
.channel-overview-card:nth-child(5) { animation-delay: 0.08s; }
.channel-overview-card:nth-child(6) { animation-delay: 0.12s; }
.channel-overview-card:nth-child(7) { animation-delay: 0.12s; }
.channel-overview-card:nth-child(8) { animation-delay: 0.16s; }

@keyframes cardEnter {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.channel-overview-card__head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.channel-overview-card__head h2 { margin: 0 0 2px; font-size: 1.05rem; line-height: 1.2; }
.channel-overview-card__head p { margin: 0; color: var(--muted); font-size: 0.82rem; }

.channel-overview-card__dot {
    width: 14px; height: 14px;
    border-radius: 999px;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
}

.channel-overview-card__metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--bg);
}

.channel-overview-card__metrics > div { min-width: 0; overflow: hidden; }

.channel-overview-card__metrics span {
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.channel-overview-card__metrics strong {
    display: block;
    margin-top: 4px;
    font-size: 1.05rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-overview-card__footer {
    color: var(--brand);
    font-weight: 700;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    padding-top: 4px;
    transition: gap var(--transition);
}

.channel-overview-card:hover .channel-overview-card__footer { gap: 10px; }

.channel-overview-card__footer::after {
    content: '\2192';
    transition: transform var(--transition);
}

.channel-overview-card:hover .channel-overview-card__footer::after { transform: translateX(3px); }

/* Admin variant */
.channel-admin-card--unknown {
    border-color: rgba(245,158,11,0.2);
    background: linear-gradient(135deg, #fffbeb 0%, var(--panel) 30%);
}

.channel-admin-card__badges {
    display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px;
}

.admin-badge {
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(15,23,42,0.05);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.78rem;
}

.admin-badge--ok { background: rgba(20,184,166,0.1); color: var(--brand-dark); }
.admin-badge--warn { background: rgba(245,158,11,0.12); color: #9a3412; }

/* Summary strip */
.channel-summary-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.summary-chip {
    padding: 18px 20px;
    border-radius: var(--radius-md);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition);
}

.summary-chip:hover { transform: translateY(-2px); }

.summary-chip span {
    display: block;
    margin-bottom: 6px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--muted);
}

.summary-chip strong { font-size: 1.8rem; color: var(--text); line-height: 1; }

/* ===================================================================
   CHANNEL DETAIL
   =================================================================== */
.detail-topbar { margin-bottom: 4px; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--muted);
    background: var(--panel);
    border: 1px solid var(--line);
    transition: all var(--transition);
}

.back-link:hover { color: var(--brand); border-color: rgba(13,148,136,0.2); gap: 12px; }
.back-link svg { transition: transform var(--transition); }
.back-link:hover svg { transform: translateX(-3px); }

.telemetry-stage__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    padding: 26px 28px;
    border-radius: var(--radius-xl);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

.telemetry-toolbar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }

.range-switch {
    display: flex; gap: 2px; padding: 4px;
    border-radius: var(--radius-md);
    background: var(--bg);
    border: 1px solid var(--line);
}

.range-pill {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.82rem;
    transition: all var(--transition);
    white-space: nowrap;
}

.range-pill:hover { color: var(--text); background: rgba(255,255,255,0.7); transform: none; box-shadow: none; }

.range-pill.active {
    background: var(--brand); color: #fff;
    box-shadow: 0 2px 8px rgba(13,148,136,0.2);
}

.range-pill.active:hover { background: var(--brand); color: #fff; }

.custom-range { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.custom-range--hidden { display: none; }

.focus-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 22px;
    border-radius: var(--radius-lg);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

.focus-strip__title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.focus-strip__title h2 { margin: 0 0 2px; font-size: 1.2rem; }

.channel-badge {
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.live-chip {
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(20,184,166,0.08);
    color: var(--brand-dark);
    font-weight: 600;
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.live-chip::before {
    content: '';
    width: 7px; height: 7px;
    border-radius: 999px;
    background: var(--brand-light);
    animation: livePulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes livePulse {
    0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(20,184,166,0.4); }
    50% { opacity: 0.5; box-shadow: 0 0 0 5px rgba(20,184,166,0); }
}

.telemetry-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.insight-card {
    padding: 20px;
    border-radius: var(--radius-lg);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
}

.insight-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.insight-card--hero {
    background: linear-gradient(135deg, #082f49, #0d9488);
    color: #f1f5f9; border: none;
}

.insight-card--hero:hover { box-shadow: 0 12px 36px rgba(13,148,136,0.2); }

.insight-card--hero .insight-card__label,
.insight-card--hero .insight-card__meta { color: rgba(241,245,249,0.7); }

.insight-card__label {
    display: block; margin-bottom: 8px;
    font-size: 0.72rem; letter-spacing: 0.10em;
    text-transform: uppercase; color: var(--muted); font-weight: 700;
}

.insight-card__value {
    display: block;
    font-size: clamp(1.5rem, 2.5vw, 2.2rem);
    font-weight: 800; line-height: 1; margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
}

.insight-card__meta { color: var(--muted); font-size: 0.82rem; }

.telemetry-layout {
    display: grid;
    grid-template-columns: 1.6fr 0.8fr;
    gap: 16px;
}

.telemetry-panel {
    padding: 22px;
    border-radius: var(--radius-xl);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

.telemetry-panel__head {
    display: flex; justify-content: space-between;
    align-items: flex-start; gap: 16px; margin-bottom: 18px;
}

.telemetry-panel__head h2 { margin: 0 0 4px; font-size: 1.05rem; }
.telemetry-panel__head p { margin: 0; color: var(--muted); font-size: 0.88rem; }

.telemetry-legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.telemetry-legend span { display: inline-flex; align-items: center; gap: 6px; }

.legend-swatch { width: 10px; height: 10px; border-radius: 999px; display: inline-block; }
.legend-swatch--level { background: #0d9488; }
.legend-swatch--flow { background: #f59e0b; }

.chart-shell {
    position: relative;
    min-height: 420px;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.telemetry-panel--side {
    background: linear-gradient(180deg, var(--panel) 0%, #f8fafc 100%);
}

.recent-table-wrap { overflow: auto; max-height: 480px; -webkit-overflow-scrolling: touch; }
.recent-table th { position: sticky; top: 0; background: rgba(248,250,252,0.98); }

/* ===================================================================
   CHANNEL EDIT
   =================================================================== */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    align-items: start;
}

.channel-detail-layout { gap: 18px; }

.channel-detail-summary { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.channel-detail-summary__dot { width: 16px; height: 16px; border-radius: 999px; flex-shrink: 0; margin-top: 4px; }

/* ===================================================================
   USERS PAGE
   =================================================================== */
.hero {
    padding: 26px 28px;
    border-radius: var(--radius-xl);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.hero h1 { margin: 6px 0 8px; font-size: clamp(1.4rem, 3vw, 1.9rem); letter-spacing: -0.02em; }

.checkbox-grid { display: grid; gap: 8px; }

fieldset { margin: 0; padding: 14px; border-radius: 14px; border: 1px solid var(--line); }
legend { padding: 0 8px; font-weight: 700; font-size: 0.88rem; }

/* ===================================================================
   PLACEHOLDER
   =================================================================== */
.analytics-placeholder {
    padding: 40px 28px;
    border-radius: var(--radius-xl);
    background: var(--panel);
    border: 2px dashed var(--line);
    text-align: center;
}

.analytics-placeholder h2 { margin: 8px 0 6px; font-size: 1.4rem; }
.analytics-placeholder p { margin: 0 auto; color: var(--muted); max-width: 460px; font-size: 0.92rem; }

.analytics-section--hidden { display: none; }
.analytics-section { animation: slideUp 0.35s ease-out; }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===================================================================
   LOGIN / AUTH
   =================================================================== */
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 20% 30%, rgba(13,148,136,0.1), transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(245,158,11,0.06), transparent 35%),
        linear-gradient(145deg, #0f172a 0%, #0e1c2e 40%, #132337 100%);
}

.auth-panel {
    width: min(1020px, 100%);
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: 0 32px 80px rgba(0,0,0,0.3);
    animation: authSlide 0.4s ease-out;
}

@keyframes authSlide {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-copy {
    padding: 40px 36px;
    background: linear-gradient(135deg, #082f49, #134e4a);
    color: #f1f5f9;
    display: flex; flex-direction: column; justify-content: center;
    border: none; box-shadow: none;
}

.auth-copy h1 {
    margin: 8px 0 12px;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    line-height: 1.15; letter-spacing: -0.02em;
}

.auth-copy p { color: rgba(255,255,255,0.6); line-height: 1.7; font-size: 0.92rem; }

.auth-card {
    padding: 40px 36px;
    display: grid; gap: 16px; align-content: center;
    background: #fff; border: none; box-shadow: none;
}

.auth-card h2 { margin: 0 0 2px; font-size: 1.4rem; }
.auth-card button { margin-top: 4px; padding: 13px; font-size: 0.95rem; }

/* ===================================================================
   RESPONSIVE — Tablet (<=1024)
   =================================================================== */
@media (max-width: 1024px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: flex; }
    .mobile-header { display: flex; }

    .content {
        margin-left: 0;
        padding: 24px 20px;
        padding-top: calc(var(--header-h) + 20px);
    }

    .telemetry-layout { grid-template-columns: 1fr; }
    .two-col { grid-template-columns: 1fr; }
    .telemetry-grid { grid-template-columns: repeat(2, 1fr); }

    .auth-panel { grid-template-columns: 1fr; }
    .auth-copy { padding: 32px 28px; }
    .auth-card { padding: 32px 28px; }

    .telemetry-stage__header { flex-direction: column; align-items: stretch; }
    .telemetry-toolbar { flex-direction: column; align-items: stretch; }

    .range-switch { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .focus-strip { flex-direction: column; align-items: flex-start; }
    .telemetry-panel__head { flex-direction: column; }
    .chart-shell { min-height: 320px; }
}

/* ===================================================================
   RESPONSIVE — Mobile (<=640)
   =================================================================== */
@media (max-width: 640px) {
    :root { --header-h: 56px; }

    .content { padding: 16px 14px; padding-top: calc(var(--header-h) + 14px); }

    .overview-hero { padding: 20px; }
    .overview-hero h1 { font-size: 1.3rem; }

    .channel-overview-grid { grid-template-columns: 1fr; }
    .channel-summary-strip { grid-template-columns: repeat(2, 1fr); }

    .telemetry-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .insight-card { padding: 16px; }
    .insight-card__value { font-size: 1.3rem; }

    .telemetry-stage__header { padding: 20px; }

    .channel-overview-card { padding: 16px; }
    .summary-chip { padding: 14px 16px; }
    .summary-chip strong { font-size: 1.4rem; }

    .telemetry-panel { padding: 16px; }
    .chart-shell { min-height: 260px; }

    .auth-panel { border-radius: var(--radius-lg); }
    .auth-copy { padding: 28px 22px; }
    .auth-card { padding: 28px 22px; }
    .auth-copy h1 { font-size: 1.3rem; }

    .panel { padding: 18px; }
    .hero { padding: 20px; }

    .back-link { padding: 8px 12px; font-size: 0.82rem; }

    .sidebar { width: 280px; padding: 20px 14px; }

    .overview-hero { flex-direction: column; align-items: stretch; }
    .overview-hero .ghost-button { align-self: flex-start; }
}

@media (max-width: 420px) {
    .telemetry-grid { grid-template-columns: 1fr; }
    .channel-summary-strip { grid-template-columns: 1fr 1fr; gap: 8px; }
    .range-pill { padding: 7px 10px; font-size: 0.78rem; }
}

/* ===================================================================
   FOCUS & ACCESSIBILITY
   =================================================================== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--brand-light);
    outline-offset: 2px;
}

@keyframes valueFlash {
    0% { opacity: 0.4; transform: translateY(3px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ===================================================================
   DGA INTEGRATION
   =================================================================== */
.dga-toggle {
    padding: 12px 16px;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    font-weight: 500;
}

.dga-status-panel {
    padding: 16px;
    background: var(--bg-page);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
}

.dga-status-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.dga-status-label {
    display: block;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.6;
    margin-bottom: 4px;
}

.dga-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
}

.dga-badge--active { background: rgba(34, 197, 94, 0.12); color: #16a34a; }
.dga-badge--inactive { background: rgba(148, 163, 184, 0.12); color: #64748b; }

/* ═══════════════════════════════════════════════════════════════════
   DGA DETAIL SECTION  (channel_detail.html)
   =================================================================== */
.dga-detail-section {
    margin-top: 32px;
    padding: 28px;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg, 12px);
}

.dga-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
}
.dga-detail-header h2 { margin: 4px 0 0; font-size: 1.2rem; }

.dga-detail-badges { display: flex; gap: 8px; flex-shrink: 0; }

.dga-detail-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}
.dga-detail-chip--ok      { background: rgba(34,197,94,0.12); color: #16a34a; }
.dga-detail-chip--error   { background: rgba(239,68,68,0.12); color: #dc2626; }
.dga-detail-chip--waiting { background: rgba(234,179,8,0.12); color: #a16207; }

/* KPI strip */
.dga-kpi-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.dga-kpi-card {
    position: relative;
    padding: 18px 16px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-page);
    overflow: hidden;
}
.dga-kpi-card__value {
    display: block;
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.1;
}
.dga-kpi-card__label {
    display: block;
    margin-top: 4px;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.6;
}
.dga-kpi-card__icon {
    position: absolute;
    top: 14px;
    right: 14px;
    opacity: 0.12;
}
.dga-kpi-card__hint {
    display: block;
    margin-top: 6px;
    font-size: 0.72rem;
    opacity: 0.55;
}

.dga-kpi-card--success .dga-kpi-card__value { color: #16a34a; }
.dga-kpi-card--pending .dga-kpi-card__value { color: #d97706; }
.dga-kpi-card--failed .dga-kpi-card__value  { color: #dc2626; }
.dga-kpi-card--rate .dga-kpi-card__value    { color: var(--text-primary); }

.dga-kpi-bar {
    margin-top: 8px;
    height: 6px;
    background: var(--border-subtle);
    border-radius: 3px;
    overflow: hidden;
}
.dga-kpi-bar__fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}
.dga-kpi-bar--ok     { background: #16a34a; }
.dga-kpi-bar--warn   { background: #d97706; }
.dga-kpi-bar--danger { background: #dc2626; }

/* Tabs */
.dga-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-page);
    border-radius: 8px;
    padding: 3px;
    margin-bottom: 0;
    border: 1px solid var(--border-subtle);
}

.dga-tab {
    flex: 1;
    padding: 10px 14px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.dga-tab:hover { background: rgba(0,0,0,0.03); }
.dga-tab.active {
    background: var(--bg-panel);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    font-weight: 600;
}

.dga-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
}
.dga-tab-count--ok     { background: #16a34a; }
.dga-tab-count--warn   { background: #d97706; }
.dga-tab-count--danger { background: #dc2626; }

/* Tab panels */
.dga-tab-panel {
    display: none;
    margin-top: 16px;
}
.dga-tab-panel.active { display: block; }

/* Log table */
.dga-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
}

.dga-log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.dga-log-table thead {
    background: var(--bg-page);
}
.dga-log-table th {
    padding: 10px 12px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}
.dga-log-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}
.dga-log-table tbody tr:last-child td { border-bottom: none; }
.dga-log-table tbody tr:hover { background: rgba(0,0,0,0.015); }

.dga-log-id {
    font-family: var(--font-mono, monospace);
    font-size: 0.75rem;
    opacity: 0.5;
}
.dga-log-center { text-align: center; }
.dga-log-reading {
    font-family: var(--font-mono, monospace);
    font-size: 0.78rem;
    white-space: nowrap;
}
.dga-log-error {
    font-size: 0.78rem;
    color: #dc2626;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Status pills */
.dga-status-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}
.dga-status-pill--pending { background: rgba(234,179,8,0.12); color: #a16207; }
.dga-status-pill--retry   { background: rgba(249,115,22,0.12); color: #c2410c; }
.dga-status-pill--ok      { background: rgba(34,197,94,0.12); color: #16a34a; }
.dga-status-pill--failed  { background: rgba(239,68,68,0.12); color: #dc2626; }

.dga-comprobante {
    font-family: var(--font-mono, monospace);
    font-size: 0.75rem;
    padding: 2px 6px;
    background: var(--bg-page);
    border-radius: 4px;
    border: 1px solid var(--border-subtle);
}

/* Empty state */
.dga-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
    gap: 12px;
}
.dga-empty-state p { margin: 0; font-size: 0.88rem; }
.dga-empty-state--good svg { color: #16a34a; opacity: 0.4 !important; }

/* Error banner */
.dga-last-error-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 16px;
    padding: 14px 16px;
    background: rgba(239,68,68,0.06);
    border: 1px solid rgba(239,68,68,0.18);
    border-radius: 8px;
    color: #dc2626;
    font-size: 0.85rem;
}
.dga-last-error-banner svg { flex-shrink: 0; margin-top: 1px; }
.dga-last-error-banner strong { margin-right: 4px; }

/* Footer */
.dga-detail-footer {
    display: flex;
    gap: 24px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}
.dga-detail-footer code {
    font-family: var(--font-mono, monospace);
    font-size: 0.75rem;
    padding: 1px 5px;
    background: var(--bg-page);
    border-radius: 3px;
}

.session-warning {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(8px);
    z-index: 1000;
}
.session-warning.visible {
    display: flex;
}
.session-warning__card {
    width: min(420px, 100%);
    padding: 28px;
    border-radius: 26px;
    background:
        radial-gradient(circle at top right, rgba(245, 158, 11, 0.16), transparent 34%),
        #ffffff;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.32);
    border: 1px solid rgba(255, 255, 255, 0.72);
    text-align: left;
    animation: sessionWarningIn 0.22s ease-out;
}
.session-warning__eyebrow {
    color: #b45309;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
    text-transform: uppercase;
}
.session-warning h2 {
    margin: 0 0 10px;
    color: #0f172a;
    font-size: 1.45rem;
}
.session-warning p {
    margin: 0;
    color: #475569;
    line-height: 1.55;
}
.session-warning p strong {
    color: #0f172a;
}
.session-warning__actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 24px;
    flex-wrap: wrap;
}
.session-warning__actions button {
    margin: 0;
}
.session-warning__actions a {
    color: #64748b;
    font-weight: 700;
    text-decoration: none;
}
.session-warning__actions a:hover {
    color: #0f172a;
}

@keyframes sessionWarningIn {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 768px) {
    .dga-kpi-strip { grid-template-columns: repeat(2, 1fr); }
    .dga-tabs { flex-direction: column; }
    .dga-detail-header { flex-direction: column; }
    .dga-detail-footer { flex-direction: column; gap: 6px; }
}

@media (max-width: 640px) {
    .dga-status-grid { grid-template-columns: 1fr 1fr; }
    #dgaFields > div { grid-template-columns: 1fr !important; }
}
