:root {
  /* Paleta de marca SIEM Business (siem.business) */
  --color-signal-orange: #5E17E9; /* violeta principal de marca */
  --color-sienna-bronze: #DB6144; /* coral, acento secundario */
  --color-siem-navy: #373266;     /* azul marino oscuro de marca */
  --color-siem-gold: #CBB93A;     /* dorado, tercer acento */
  --color-siem-teal: #5396A3;     /* teal del isotipo "ST" */
  --color-siem-blue: #0097B2;     /* azul vivo de marca, para acentos de UI */
  --color-siem-tint: #DCE7F6;     /* azul-gris claro de marca, para fondos sutiles */
  --color-carbon: #202020;
  --color-graphite: #4d4d4d;
  --color-slate: #828282;
  --color-fog: #F2F2F2;
  --color-mist: #F1F1F1;
  --color-chalk: #e8e8e8;
  --color-paper: #ffffff;

  --font-polysans: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-inter: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --radius-tags: 20px;
  --radius-cards: 8px;
  --radius-inputs: 8px;
  --radius-buttons: 20px;

  --bg-gradient: linear-gradient(180deg, var(--color-siem-tint) 0%, var(--color-mist) 320px);
  --panel-bg: var(--color-paper);
  --border-color: var(--color-chalk);

  --cyber-green: #10b981;
  --cyber-green-glow: rgba(16, 185, 129, 0.15);

  --cyber-blue: var(--color-siem-blue);
  --cyber-blue-glow: rgba(0, 151, 178, 0.15);

  --cyber-orange: var(--color-signal-orange);
  --cyber-orange-glow: rgba(94, 23, 233, 0.2);

  --cyber-purple: var(--color-siem-gold);

  --text-main: var(--color-carbon);
  --text-muted: var(--color-graphite);

  --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: var(--font-inter);
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.5;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1.5rem;
    background: var(--color-paper);
    border: 1px solid var(--color-chalk);
    border-radius: 200px;
    max-width: 1200px;
    width: calc(100% - 2rem);
    margin: 1.5rem auto 0 auto;
    box-shadow: 0 1px 3px rgba(32, 32, 32, 0.04), 0 4px 12px rgba(32, 32, 32, 0.03), 0 0 0 1px rgba(0, 151, 178, 0.06);
    z-index: 10;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--color-paper);
    border: 1px solid var(--color-chalk);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 5px;
}

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

.logo-divider {
    width: 1px;
    height: 28px;
    background: var(--color-chalk);
    margin: 0 12px;
}

.logo-section h1 {
    font-family: var(--font-polysans);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--color-siem-navy);
}

.logo-section h1 span {
    color: var(--color-signal-orange);
}

.logo-section .subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: -2px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.live-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--cyber-green);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--cyber-green);
    animation: pulse 1.6s infinite alternate;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.6; }
    100% { transform: scale(1.15); opacity: 1; box-shadow: 0 0 12px var(--cyber-green); }
}

.dashboard-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 320px;
    grid-template-rows: auto auto;
    align-items: start;
    gap: 1.5rem;
    padding: 1.5rem 2rem;
    max-width: 2200px;
    margin: 0 auto;
    width: 100%;
}

.dashboard-grid .viewport-panel { grid-column: 1; grid-row: 1; }
.dashboard-grid .bottom-panel { grid-column: 1; grid-row: 2; }
.dashboard-grid .right-panel { grid-column: 2; grid-row: 1 / 3; }

.panel {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-cards);
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(32, 32, 32, 0.04), 0 4px 12px rgba(32, 32, 32, 0.03);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: relative;
    overflow: hidden;
}

.panel::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-siem-blue), var(--color-signal-orange));
}

.right-panel::before {
    background: linear-gradient(90deg, var(--color-signal-orange), var(--color-siem-gold));
}

.bottom-panel::before {
    background: linear-gradient(90deg, var(--color-sienna-bronze), var(--color-siem-gold));
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.panel-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.viewport-panel {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.cameras-grid {
    display: grid;
    /* column count is set inline by JS so cameras always arrange into 2 rows */
    gap: 0.85rem;
}

.camera-card {
    min-width: 0;
}

.overlay-toggles {
    display: flex;
    gap: 1rem;
}

.switch-container {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.switch-container input {
    display: none;
}

.switch-slider {
    position: relative;
    display: inline-block;
    width: 28px;
    height: 16px;
    background-color: #cfcfcf;
    border-radius: 15px;
    transition: var(--transition);
}

.switch-slider::before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: var(--transition);
}

.switch-container input:checked + .switch-slider {
    background-color: var(--cyber-orange);
}

.switch-container input:checked + .switch-slider::before {
    transform: translateX(12px);
}

.video-container {
    width: 100%;
    height: 100%;
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #000;
    border-radius: 6px;
    border: 1px solid var(--color-chalk);
}

.video-container.zoomable {
    cursor: zoom-in;
    transition: var(--transition), border-color 0.2s ease;
}

.video-container.zoomable:hover {
    border-color: var(--color-siem-blue);
    box-shadow: 0 0 0 3px rgba(0, 151, 178, 0.12);
}

.video-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.camera-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}

.camera-card-name {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--color-carbon);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.camera-card-footer {
    font-size: 0.65rem;
    color: var(--color-slate);
    font-family: 'JetBrains Mono', monospace;
}

.switch-label {
    font-size: 0.68rem;
}

.channel-status-tag {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-tags);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.tag-live { background: rgba(16, 185, 129, 0.12); color: var(--cyber-green); }

.live-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--cyber-green);
    box-shadow: 0 0 5px var(--cyber-green);
    animation: pulse 1.6s infinite alternate;
}
.tag-off { background: rgba(130, 130, 130, 0.12); color: var(--color-slate); }

.playback-controls {
    display: flex;
    gap: 0.75rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-buttons);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--color-siem-navy);
    color: var(--color-paper);
    border-color: var(--color-siem-navy);
}

.btn-primary:hover {
    background: var(--color-signal-orange);
    border-color: var(--color-signal-orange);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(94, 23, 233, 0.25);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--color-siem-navy);
    color: var(--color-siem-navy);
}

.btn-secondary:hover {
    background: var(--color-siem-tint);
    border-color: var(--color-signal-orange);
    color: var(--color-signal-orange);
    transform: translateY(-1px);
}

.right-panel {
    /* placeholder for future themed variants */
}

.bottom-panel .panel-header {
    gap: 1rem;
}

.panel-header-icon {
    width: 15px;
    height: 15px;
    display: block;
}

.panel-header-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    flex-shrink: 0;
}

.panel-header-badge.badge-blue { background: rgba(0, 151, 178, 0.12); color: var(--color-siem-blue); }
.panel-header-badge.badge-orange { background: rgba(94, 23, 233, 0.12); color: var(--color-signal-orange); }
.panel-header-badge.badge-coral { background: rgba(219, 97, 68, 0.12); color: var(--color-sienna-bronze); }

.stats-cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.6rem;
}

.stat-card {
    background: var(--color-paper);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-cards);
    padding: 0.6rem 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--color-siem-blue);
    box-shadow: 0 2px 8px rgba(0, 151, 178, 0.1);
}

.stat-card > div:last-child {
    display: flex;
    flex-direction: column-reverse;
    gap: 2px;
}

.stat-icon-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.bg-soft-green { background: rgba(0, 151, 178, 0.1); color: var(--color-siem-blue); }
.bg-soft-blue { background: rgba(94, 23, 233, 0.1); color: var(--color-signal-orange); }
.bg-soft-purple { background: rgba(203, 185, 58, 0.15); color: var(--color-siem-gold); }

.stat-card .value {
    font-size: 1.35rem;
    font-weight: 400;
    font-family: var(--font-polysans);
    color: var(--color-carbon);
    letter-spacing: -0.02em;
}

.stat-card .label {
    font-size: 0.78rem;
    color: var(--color-slate);
    font-family: var(--font-inter);
    font-weight: 500;
}

.tabs-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tabs-header {
    display: flex;
    background: var(--color-siem-tint);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-cards);
    padding: 0.25rem;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--color-slate);
    padding: 0.5rem 0.35rem;
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: var(--transition);
    font-family: inherit;
}

.tab-btn.active {
    background: var(--color-paper);
    color: var(--color-siem-navy);
    box-shadow: 0 1px 3px rgba(32, 32, 32, 0.05);
}

.tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 250px;
}

.tab-content.hidden {
    display: none !important;
}

.list-container {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.people-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    max-height: 620px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.empty-state {
    position: relative;
    text-align: center;
    color: var(--color-slate);
    font-size: 0.85rem;
    padding: 2.9rem 1rem 1.25rem;
    border: 1px dashed var(--color-slate);
    border-radius: var(--radius-cards);
    background: var(--color-fog);
}

.empty-state::before {
    content: "";
    position: absolute;
    top: 0.9rem;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    background: url('/static/images/siem-icon.png') no-repeat center / contain;
    opacity: 0.35;
}

.person-card {
    background: var(--color-fog);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.7rem 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.person-card:hover {
    background: var(--color-chalk);
    border-color: var(--color-signal-orange);
}

.person-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.person-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cyber-green);
    box-shadow: 0 0 6px var(--cyber-green);
}

.person-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-signal-orange), var(--color-siem-blue));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    font-family: var(--font-polysans);
    flex-shrink: 0;
}

.person-details h4 {
    font-size: 0.88rem;
    font-weight: 600;
}

.person-details .meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.person-actions {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.person-duration {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--cyber-blue);
    font-weight: 500;
}

.action-icon {
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    padding: 0.3rem;
    border-radius: 4px;
}

.action-icon:hover {
    color: var(--cyber-blue);
    background: rgba(0, 0, 0, 0.05);
}

.table-container {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-cards);
    max-height: 420px;
    background: var(--color-paper);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    text-align: left;
}

th, td {
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--color-siem-tint);
    font-weight: 600;
    color: var(--color-siem-navy);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--color-fog);
}

td .badge {
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-tags);
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-green { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.badge-gray { background: rgba(130, 130, 130, 0.1); color: var(--color-slate); }
.badge-accent { background: rgba(94, 23, 233, 0.1); color: var(--color-signal-orange); }

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-cyber-green { color: var(--cyber-green); }
.text-cyber-blue { color: var(--cyber-blue); }
.text-cyber-orange { color: var(--cyber-orange); }

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 8, 17, 0.5);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--color-paper);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-cards);
    width: 90%;
    max-width: 420px;
    box-shadow: 0 10px 40px rgba(32, 32, 32, 0.15);
    overflow: hidden;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    background: var(--color-siem-tint);
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--color-chalk);
}

.modal-header h3 {
    font-family: var(--font-polysans);
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--color-carbon);
}

.close-btn {
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--color-slate);
    transition: var(--transition);
}

.close-btn:hover {
    color: var(--color-signal-orange);
}

.modal-body {
    padding: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.form-group label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--color-slate);
}

.form-group input {
    background: var(--color-fog);
    border: 1px solid var(--color-chalk);
    border-radius: var(--radius-inputs);
    padding: 0.75rem 1rem;
    color: var(--color-carbon);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.form-group input:focus {
    border-color: var(--color-signal-orange);
    box-shadow: 0 0 8px var(--cyber-orange-glow);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.zoom-hint {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    opacity: 0;
    transition: var(--transition);
    pointer-events: none;
}

.zoomable:hover .zoom-hint {
    opacity: 1;
}

.zoom-modal-box {
    max-width: min(92vw, 1100px);
    width: 92vw;
}

.zoom-modal-body {
    padding: 0;
    background: #000;
}

.zoom-modal-body img {
    display: block;
    width: 100%;
    max-height: 78vh;
    object-fit: contain;
    background: #000;
}

.zoom-modal-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--color-fog);
}

.zoom-modal-metrics {
    display: flex;
    gap: 0.9rem;
    font-size: 0.78rem;
    color: var(--color-slate);
    font-family: 'JetBrains Mono', monospace;
}

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--color-siem-navy);
    border: 1px solid var(--cyber-blue);
    box-shadow: 0 10px 25px rgba(55, 50, 102, 0.3);
    color: var(--color-paper);
    padding: 0.85rem 1.5rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 200;
    transform: translateY(100px);
    opacity: 0;
    transition: var(--transition);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--color-mist);
}

::-webkit-scrollbar-thumb {
    background: var(--color-chalk);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-siem-blue);
}

footer {
    text-align: center;
    padding: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background: var(--color-paper);
    margin-top: auto;
}

.footer-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    background: var(--color-siem-navy);
    border-radius: var(--radius-inputs);
    padding: 0.5rem 1.1rem;
    margin-bottom: 0.6rem;
}

.footer-brand-label {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.footer-brand img {
    height: 18px;
    width: auto;
    display: block;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        padding: 1.5rem 1.5rem;
    }
    .dashboard-grid .viewport-panel,
    .dashboard-grid .bottom-panel,
    .dashboard-grid .right-panel {
        grid-column: 1;
        grid-row: auto;
    }
    .cameras-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1rem;
    }
    .header-controls {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }
    .playback-controls {
        flex-wrap: wrap;
    }
    .stats-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .stats-cards-grid {
        grid-template-columns: 1fr;
    }
    .tabs-header {
        flex-direction: column;
        gap: 0.25rem;
    }
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .overlay-toggles {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }
    .modal {
        width: 95%;
        margin: 10px;
    }
    .toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        text-align: center;
    }
}

@media (min-width: 1600px) {
    html { font-size: 17px; }
    .dashboard-grid { max-width: 2000px; }
}

@media (min-width: 2200px) {
    html { font-size: 20px; }
    .dashboard-grid { max-width: 2600px; }
}
