* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0d1117;
    color: #e6edf3;
    min-height: 100vh;
}

.app-layout {
    display: grid;
    grid-template-areas:
        "header header"
        "sidebar main";
    grid-template-columns: 220px 1fr;
    grid-template-rows: 56px 1fr;
    min-height: 100vh;
}

.top-header {
    grid-area: header;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    z-index: 200;
}

.header-left {
    flex: 0 0 200px;
}

.logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: #58a6ff;
    letter-spacing: -0.5px;
}

.header-center {
    flex: 1;
}

.header-right {
    flex: 0 0 auto;
}

.header-status {
    font-size: 0.85rem;
    color: #3fb950;
}

.context-switcher {
    position: relative;
    display: inline-block;
}

.context-btn {
    background: #1c2333;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 8px 16px;
    color: #e6edf3;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.context-btn:hover {
    border-color: #58a6ff;
    background: #21262d;
}

.context-icon {
    font-size: 1.1rem;
}

.context-name {
    font-weight: 600;
}

.context-arrow {
    color: #8b949e;
    font-size: 0.8rem;
    margin-left: 4px;
}

.context-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: #1c2333;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 6px;
    min-width: 300px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    display: none;
    z-index: 300;
}

.context-menu.open {
    display: block;
}

.context-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.context-option:hover {
    background: #21262d;
}

.context-option.active {
    background: #161b22;
    border: 1px solid #58a6ff;
}

.ctx-icon {
    font-size: 1.4rem;
}

.ctx-label {
    font-weight: 600;
    color: #e6edf3;
    font-size: 0.9rem;
}

.ctx-desc {
    font-size: 0.78rem;
    color: #8b949e;
    margin-top: 2px;
}

.sidebar {
    grid-area: sidebar;
    background: #161b22;
    border-right: 1px solid #30363d;
    position: fixed;
    top: 56px;
    left: 0;
    width: 220px;
    height: calc(100vh - 56px);
    overflow-y: auto;
    z-index: 100;
}

.nav-links {
    list-style: none;
    padding: 8px 0;
}

.nav-section-label {
    padding: 16px 20px 6px;
    font-size: 0.68rem;
    font-weight: 700;
    color: #6e7681;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-link {
    display: block;
    padding: 10px 20px;
    color: #8b949e;
    text-decoration: none;
    transition: all 0.15s;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: #1c2333;
    color: #e6edf3;
}

.nav-link.active {
    background: #1c2333;
    color: #58a6ff;
    border-left-color: #58a6ff;
}

.main-content {
    grid-area: main;
    padding: 32px;
    margin-top: 56px;
    margin-left: 220px;
    min-width: 0;
    overflow-y: auto;
}

h1 {
    font-size: 1.7rem;
    margin-bottom: 24px;
    color: #e6edf3;
    font-weight: 600;
}

h3 {
    font-size: 1.05rem;
    margin-bottom: 16px;
    color: #e6edf3;
    font-weight: 600;
}

.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 24px;
    text-align: center;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: #58a6ff;
}

.metric-label {
    font-size: 0.8rem;
    color: #8b949e;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.chart-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 24px;
}

.chart-card.full-width {
    grid-column: 1 / -1;
}

.chart-card canvas {
    max-height: 300px;
}

.card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 24px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #21262d;
    font-size: 0.88rem;
}

.data-table th {
    background: #161b22;
    color: #8b949e;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.5px;
}

.data-table td {
    color: #e6edf3;
}

.data-table tbody tr:nth-child(even) td {
    background: #0d1117;
}

.data-table tbody tr:hover td {
    background: #1c2333;
}

.data-table td.text-cell {
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.input-field {
    padding: 10px 14px;
    border: 1px solid #30363d;
    border-radius: 8px;
    background: #0d1117;
    color: #e6edf3;
    font-size: 0.88rem;
    min-width: 160px;
    flex: 1;
}

.input-field:focus {
    outline: none;
    border-color: #58a6ff;
    box-shadow: 0 0 0 3px rgba(88,166,255,0.15);
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.15s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #58a6ff;
    color: #0d1117;
    font-weight: 600;
}

.btn-primary:hover {
    background: #79c0ff;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.78rem;
    background: #21262d;
    color: #8b949e;
    border: 1px solid #30363d;
}

.btn-sm:hover {
    background: #30363d;
    color: #e6edf3;
}

.btn-danger {
    background: #f85149;
    color: white;
    padding: 6px 12px;
    font-size: 0.78rem;
}

.btn-danger:hover {
    background: #da3633;
}

.search-form {
    margin-bottom: 16px;
}

.search-info {
    margin-bottom: 12px;
    color: #8b949e;
    font-size: 0.88rem;
}

.export-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6e7681;
    font-size: 0.92rem;
}

.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    display: inline-block;
}

.badge-info {
    background: rgba(88,166,255,0.15);
    color: #58a6ff;
}

.badge-positive {
    background: rgba(63,185,80,0.15);
    color: #3fb950;
}

.badge-negative {
    background: rgba(248,81,73,0.15);
    color: #f85149;
}

.badge-neutral {
    background: rgba(139,148,158,0.15);
    color: #8b949e;
}

.recent-content {
    margin-top: 8px;
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 12px 20px;
    color: #e6edf3;
    z-index: 9999;
    animation: slideIn 0.3s ease;
}

.toast.success { border-left: 4px solid #3fb950; }
.toast.error { border-left: 4px solid #f85149; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.sencia-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.sencia-title {
    font-size: 1.7rem;
    color: #e6edf3;
    font-weight: 600;
}

.sencia-subtitle {
    font-size: 0.88rem;
    color: #8b949e;
    margin-top: 4px;
}

.traffic-light {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
}

.tl-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    opacity: 0.15;
}

.tl-circle.active {
    opacity: 1;
    box-shadow: 0 0 16px currentColor;
}

.tl-red { background: #f85149; color: #f85149; }
.tl-yellow { background: #d29922; color: #d29922; }
.tl-green { background: #3fb950; color: #3fb950; }
.tl-label { font-size: 0.82rem; color: #8b949e; margin-top: 8px; }

.sencia-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.entity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.entity-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 16px;
    transition: border-color 0.15s;
}

.entity-card:hover {
    border-color: #58a6ff;
}

.entity-card .entity-name {
    font-weight: 600;
    color: #e6edf3;
    font-size: 0.92rem;
}

.entity-card .entity-type {
    font-size: 0.72rem;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.entity-card .entity-count {
    font-size: 1.4rem;
    font-weight: 700;
    color: #58a6ff;
    margin-top: 8px;
}

.priority-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
}

.priority-p1 { background: #f85149; color: white; }
.priority-p2 { background: #d29922; color: white; }
.priority-p3 { background: #d29922; color: #0d1117; opacity: 0.8; }
.priority-p4 { background: #6e7681; color: white; }

.taxonomy-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 500;
}

.entity-tag {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.68rem;
    margin: 1px;
    background: rgba(88,166,255,0.1);
    color: #79c0ff;
    border: 1px solid rgba(88,166,255,0.2);
}

.hoyos-card {
    background: #161b22;
    border: 2px solid #58a6ff;
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 24px;
}

.hoyos-card h3 {
    color: #58a6ff;
}

.sencia-section {
    margin-bottom: 32px;
}

.sencia-section h3 {
    border-bottom: 1px solid #30363d;
    padding-bottom: 8px;
    margin-bottom: 16px;
}

.sencia-entity-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.entity-filter-btn {
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 0.78rem;
    font-weight: 500;
    background: #21262d;
    color: #8b949e;
    border: 1px solid #30363d;
    cursor: pointer;
    transition: all 0.15s;
}

.entity-filter-btn:hover {
    border-color: #58a6ff;
    color: #e6edf3;
}

.entity-filter-btn.active {
    background: rgba(88,166,255,0.15);
    color: #58a6ff;
    border-color: #58a6ff;
}

.sencia-quick-alerts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.sencia-feeds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.feed-category-card {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 16px;
}

.feed-category-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: #58a6ff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.feed-item {
    padding: 5px 0;
    font-size: 0.82rem;
    color: #e6edf3;
    border-bottom: 1px solid #161b22;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.feed-item .feed-priority {
    font-size: 0.68rem;
    color: #6e7681;
}

.feed-item .feed-added {
    color: #3fb950;
    font-size: 0.72rem;
}

.taxonomy-ref-card {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.taxonomy-ref-title {
    font-weight: 600;
    font-size: 0.92rem;
    margin-bottom: 6px;
}

.taxonomy-ref-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.taxonomy-kw {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    background: #21262d;
    color: #8b949e;
}

@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 60px 1fr;
    }
    .sidebar {
        width: 60px;
    }
    .nav-section-label, .nav-link {
        font-size: 0;
        padding: 10px;
    }
    .main-content {
        margin-left: 60px;
        padding: 16px;
    }
    .charts-row {
        grid-template-columns: 1fr;
    }
    .form-row {
        flex-direction: column;
    }
    .context-btn .context-name {
        display: none;
    }
}
