:root {
    --navy: #141427;
    --navy-light: #1e1e3a;
    --navy-card: #22223d;
    --orange: #e87c2a;
    --orange-hover: #f08a3a;
    --white: #ffffff;
    --gray: #9898b0;
    --gray-light: #c0c0d0;
}

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

body {
    background-color: var(--navy);
    color: var(--white);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    line-height: 1.6;
}

/* ─── Logo ─── */

.logo {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.logo-img {
    display: block;
    height: 30px;
    width: auto;
}

.logo-img-large {
    height: 56px;
}

/* ─── Navbar ─── */

.navbar {
    padding: 1rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-user-name {
    color: var(--gray-light);
    font-size: 0.875rem;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

/* ─── Main Content ─── */

.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* ─── Buttons ─── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.5;
    cursor: pointer;
    border: none;
    box-sizing: border-box;
    text-decoration: none;
    transition: all 0.15s ease;
}

.btn-google {
    background: var(--white);
    color: #333;
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
}

.btn-google:hover {
    background: #f0f0f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-microsoft {
    background: var(--white);
    color: #333;
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    margin-top: 0.75rem;
}

.btn-microsoft:hover {
    background: #f0f0f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-outline {
    background: transparent;
    color: var(--gray-light);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-outline:hover {
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--white);
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

.google-icon {
    flex-shrink: 0;
}

/* ─── Login Page ─── */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.tagline {
    color: var(--orange);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 2.5rem;
}

.error-message {
    background: rgba(220, 60, 60, 0.15);
    border: 1px solid rgba(220, 60, 60, 0.3);
    color: #ff8888;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* ─── Spinner ─── */

.spinner {
    justify-content: center;
    padding: 1rem;
}

.spinner-ring {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--orange);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ─── Splash / Dashboard ─── */

.splash-container {
    padding-top: 3rem;
}

.splash-hero {
    text-align: center;
    margin-bottom: 4rem;
}

.splash-title {
    font-size: 2.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
}

.splash-tagline {
    color: var(--orange);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.splash-subtitle {
    color: var(--gray);
    font-size: 1.1rem;
    max-width: 500px;
    margin: 0 auto;
}

/* ─── Cards ─── */

.splash-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--navy-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 2rem;
    transition: border-color 0.15s ease;
    color: inherit;
    text-decoration: none;
    display: block;
}

.card:hover {
    border-color: rgba(232, 124, 42, 0.3);
}

a.card:hover {
    border-color: var(--orange);
}

.card-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.card p {
    color: var(--gray);
    font-size: 0.9rem;
}

/* ─── Responsive ─── */

@media (max-width: 640px) {
    .splash-title {
        font-size: 2rem;
    }

    .login-card {
        padding: 0 1rem;
    }

    .navbar {
        padding: 1rem;
    }
}

/* ─── ARCADE page ─── */

.arcade-page {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.arcade-page h1 {
    font-size: 1.75rem;
    font-weight: 600;
}

.arcade-page .subtitle {
    color: var(--gray);
    font-size: 0.95rem;
}

.arcade-config {
    background: var(--navy-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.5rem 1.5rem;
    font-size: 0.9rem;
}

.arcade-config code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--orange);
}

.arcade-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.arcade-controls label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: var(--gray-light);
}

.arcade-controls input {
    background: var(--navy-light);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    max-width: 320px;
}

.arcade-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.arcade-buttons button {
    background: var(--orange);
    color: var(--white);
    border: none;
    border-radius: 6px;
    padding: 0.55rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
}

.arcade-buttons button:hover:not(:disabled) {
    background: var(--orange-hover);
}

.arcade-buttons button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.arcade-result {
    background: var(--navy-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    overflow: hidden;
}

.arcade-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.85rem;
    color: var(--gray-light);
}

.arcade-result pre {
    padding: 1rem 1.25rem;
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    color: var(--gray-light);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 480px;
    overflow-y: auto;
}

/* --- Monitoring page --- */

.monitoring-page {
    max-width: 1080px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.monitoring-page h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.monitoring-page .subtitle {
    color: var(--gray);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.monitoring-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    background-color: var(--navy-card);
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.monitoring-controls label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--gray-light);
}

.monitoring-controls select,
.monitoring-controls button {
    background: var(--navy-light);
    color: var(--white);
    border: 1px solid #2f2f52;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font: inherit;
    font-size: 0.9rem;
}

.monitoring-controls button {
    background: var(--orange);
    border-color: var(--orange);
    cursor: pointer;
}

.monitoring-controls button:hover {
    background: var(--orange-hover);
}

#loading-indicator {
    color: var(--gray);
    font-size: 0.85rem;
    align-self: center;
}

.monitoring-charts section {
    background-color: var(--navy-card);
    padding: 1rem 1.25rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.monitoring-charts h2 {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.monitoring-charts canvas {
    width: 100% !important;
    max-height: 280px;
}

/* --- Live channel monitor --- */

.live-page {
    max-width: 1080px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.live-page h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.live-page .subtitle {
    color: var(--gray);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.live-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    background-color: var(--navy-card);
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

/* hierarchical channel picker */

.picker-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    flex: 1;
}

.picker-row label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: var(--gray-light);
}

.picker-row select {
    background: var(--navy-light);
    color: var(--white);
    border: 1px solid #2f2f52;
    border-radius: 6px;
    padding: 0.45rem 0.6rem;
    font: inherit;
    font-size: 0.875rem;
    min-width: 110px;
}

.picker-search-label {
    flex: 1;
    min-width: 180px;
}

.picker-search-wrap {
    position: relative;
}

.picker-search-wrap input {
    width: 100%;
    background: var(--navy-light);
    color: var(--white);
    border: 1px solid #2f2f52;
    border-radius: 6px;
    padding: 0.45rem 0.6rem;
    font: inherit;
    font-size: 0.875rem;
}

.picker-search-wrap input:focus {
    outline: none;
    border-color: var(--orange);
}

.channel-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--navy-card);
    border: 1px solid #2f2f52;
    border-radius: 6px;
    list-style: none;
    margin: 0;
    padding: 0.25rem 0;
    max-height: 260px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.channel-suggestions li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
}

.channel-suggestions li:hover,
.channel-suggestions li:focus {
    background: rgba(255,255,255,0.06);
    outline: none;
}

.sug-name {
    font-size: 0.85rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--white);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sug-meta {
    font-size: 0.75rem;
    color: var(--gray);
    white-space: nowrap;
    flex-shrink: 0;
}

.stream-controls {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.stream-controls label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: var(--gray-light);
}

.stream-controls select {
    background: var(--navy-light);
    color: var(--white);
    border: 1px solid #2f2f52;
    border-radius: 6px;
    padding: 0.45rem 0.6rem;
    font: inherit;
    font-size: 0.875rem;
}

#live-status {
    color: var(--gray);
    font-size: 0.85rem;
    align-self: center;
}

#empty-hint {
    grid-column: 1 / -1;
}

.watched-channels {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* channel chips (multi-series per card) */

.channel-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    flex: 1;
    min-width: 0;
}

.channel-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    padding: 0.2rem 0.4rem 0.2rem 0.35rem;
    font-size: 0.78rem;
    max-width: 100%;
}

.chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chip-name {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--gray-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
}

.chip-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--white);
    font-weight: 600;
    white-space: nowrap;
}

.chip-remove {
    background: none;
    border: none;
    color: var(--gray);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0 0.1rem;
    line-height: 1;
    flex-shrink: 0;
}

.chip-remove:hover { color: var(--white); }

.channel-card-add-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 5px;
    color: var(--gray);
    font-size: 0.78rem;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.channel-card-add-btn:hover {
    border-color: var(--orange);
    color: var(--orange);
}

/* inline card picker */

.card-picker {
    border-top: 1px solid rgba(255,255,255,0.06);
    padding-top: 0.75rem;
    margin-top: 0.25rem;
}

.channel-card {
    background: var(--navy-card);
    border: 1px solid #2f2f52;
    border-radius: 8px;
    padding: 1rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.channel-card-error {
    border-color: #f85149;
}

.channel-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.channel-card-chart-wrap {
    position: relative;
    height: 200px;
    margin-top: 0.5rem;
}

/* ─── Hardware Configs ─── */

.btn-primary {
    background: var(--orange);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--orange-hover);
}

.configs-page {
    max-width: 900px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--gray);
    margin: 0.5rem 0 1.5rem;
}

.configs-page code {
    background: var(--navy-card);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--gray-light);
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-ok {
    background: rgba(60, 180, 110, 0.15);
    border: 1px solid rgba(60, 180, 110, 0.4);
    color: #8fe0b0;
}

.alert-err {
    background: rgba(220, 80, 80, 0.15);
    border: 1px solid rgba(220, 80, 80, 0.4);
    color: #f0a0a0;
}

.upload-form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    background: var(--navy-card);
    padding: 1.25rem;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.upload-form input[type="file"] {
    color: var(--gray-light);
    font-family: inherit;
    font-size: 0.9rem;
}

.upload-hint {
    color: var(--gray);
    font-size: 0.8rem;
}

.config-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.config-table th,
.config-table td {
    text-align: left;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.config-table th {
    color: var(--gray);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.config-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.config-actions form {
    display: inline;
}

.config-empty {
    color: var(--gray);
    padding: 2rem 0;
    text-align: center;
}

/* ─── Config viewer ─── */

.back-link {
    color: var(--gray);
    text-decoration: none;
    font-size: 0.9rem;
}

.back-link:hover {
    color: var(--white);
}

.badge {
    display: inline-block;
    background: var(--navy-card);
    color: var(--gray-light);
    padding: 0.15rem 0.55rem;
    border-radius: 6px;
    font-size: 0.8rem;
    margin-right: 0.5rem;
}

.muted {
    color: var(--gray);
}

.meta-pair {
    color: var(--gray);
    font-size: 0.85rem;
    margin-right: 1.25rem;
}

.stat-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    background: var(--navy-card);
    padding: 1.25rem;
    border-radius: 12px;
    margin: 1rem 0 1.5rem;
}

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

.stat-num {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-label {
    color: var(--gray);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dir {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
}

.dir-input {
    background: rgba(60, 140, 220, 0.18);
    color: #8fc0f0;
}

.dir-output {
    background: rgba(232, 124, 42, 0.18);
    color: var(--orange-hover);
}
