/* ============================================================================
   TURRET CONTROL SYSTEM - TACTICAL CONSOLE THEME
   A military command console aesthetic for hardware control interfaces
   ============================================================================ */

/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@300;400;500;600;700&family=IBM+Plex+Sans:wght@300;400;500;600&display=swap');

/* ============================================================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================================================ */
:root {
    /* Core Background Colors */
    --tc-bg-deepest: #05080d;
    --tc-bg-deep: #0a0e14;
    --tc-bg-dark: #0d1117;
    --tc-bg-panel: #161b22;
    --tc-bg-elevated: #1c2128;
    --tc-bg-surface: #21262d;
    --tc-bg-hover: #292e36;

    /* Border Colors */
    --tc-border: #30363d;
    --tc-border-light: #3d444d;
    --tc-border-focus: var(--tc-accent-cyan);

    /* Text Colors */
    --tc-text-primary: #e6edf3;
    --tc-text-secondary: #8b949e;
    --tc-text-muted: #6e7681;
    --tc-text-disabled: #484f58;

    /* Accent Colors */
    --tc-accent-cyan: #00d4ff;
    --tc-accent-cyan-dim: rgba(0, 212, 255, 0.15);
    --tc-accent-cyan-glow: rgba(0, 212, 255, 0.4);

    --tc-accent-green: #4caf50;
    --tc-accent-green-dim: rgba(76, 175, 80, 0.15);
    --tc-accent-green-glow: rgba(76, 175, 80, 0.4);

    --tc-accent-orange: #f0883e;
    --tc-accent-orange-dim: rgba(240, 136, 62, 0.15);
    --tc-accent-orange-glow: rgba(240, 136, 62, 0.4);

    --tc-accent-red: #f85149;
    --tc-accent-red-dim: rgba(248, 81, 73, 0.15);
    --tc-accent-red-glow: rgba(248, 81, 73, 0.4);

    --tc-accent-purple: #a371f7;
    --tc-accent-purple-dim: rgba(163, 113, 247, 0.15);

    --tc-accent-blue: #58a6ff;
    --tc-accent-blue-dim: rgba(88, 166, 255, 0.15);

    /* Typography */
    --tc-font-display: 'Orbitron', 'Segoe UI', sans-serif;
    --tc-font-mono: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
    --tc-font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Spacing Scale */
    --tc-space-xs: 4px;
    --tc-space-sm: 8px;
    --tc-space-md: 16px;
    --tc-space-lg: 24px;
    --tc-space-xl: 32px;
    --tc-space-2xl: 48px;

    /* Border Radius */
    --tc-radius-sm: 4px;
    --tc-radius-md: 8px;
    --tc-radius-lg: 12px;
    --tc-radius-xl: 16px;

    /* Shadows */
    --tc-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --tc-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --tc-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --tc-shadow-glow-cyan: 0 0 20px var(--tc-accent-cyan-glow);
    --tc-shadow-glow-green: 0 0 20px var(--tc-accent-green-glow);
    --tc-shadow-glow-orange: 0 0 20px var(--tc-accent-orange-glow);
    --tc-shadow-glow-red: 0 0 20px var(--tc-accent-red-glow);

    /* Transitions */
    --tc-transition-fast: 0.1s ease;
    --tc-transition-base: 0.2s ease;
    --tc-transition-slow: 0.3s ease;

    /* Layout */
    --tc-sidebar-width: 260px;
    --tc-header-height: 56px;
}

/* ============================================================================
   GLOBAL RESET & BASE STYLES
   ============================================================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: var(--tc-bg-deepest);
    color: var(--tc-text-primary);
    font-family: var(--tc-font-body);
    line-height: 1.5;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--tc-bg-deep);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--tc-border-light);
}

/* Selection */
::selection {
    background: var(--tc-accent-cyan-dim);
    color: var(--tc-accent-cyan);
}

/* ============================================================================
   TYPOGRAPHY
   ============================================================================ */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--tc-font-display);
    font-weight: 600;
    letter-spacing: 0.05em;
    margin: 0 0 var(--tc-space-md) 0;
    color: var(--tc-text-primary);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p {
    margin: 0 0 var(--tc-space-md) 0;
    color: var(--tc-text-secondary);
}

a {
    color: var(--tc-accent-cyan);
    text-decoration: none;
    transition: color var(--tc-transition-fast);
}

a:hover {
    color: var(--tc-text-primary);
    text-decoration: underline;
}

code, pre, .mono {
    font-family: var(--tc-font-mono);
}

code {
    background: var(--tc-bg-surface);
    padding: 2px 6px;
    border-radius: var(--tc-radius-sm);
    font-size: 0.875em;
    color: var(--tc-accent-cyan);
}

/* ============================================================================
   LAYOUT - PAGE STRUCTURE
   ============================================================================ */
.page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--tc-sidebar-width);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--tc-bg-panel) 0%, var(--tc-bg-deep) 100%);
    border-right: 1px solid var(--tc-border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    margin-left: var(--tc-sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at top right, rgba(0, 212, 255, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at bottom left, rgba(76, 175, 80, 0.02) 0%, transparent 50%),
        var(--tc-bg-dark);
}

/* Grid Background Pattern */
main::before {
    content: '';
    position: fixed;
    top: 0;
    left: var(--tc-sidebar-width);
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(rgba(48, 54, 61, 0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(48, 54, 61, 0.3) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
}

.top-row {
    height: var(--tc-header-height);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--tc-space-lg);
    padding: 0 var(--tc-space-lg);
    background: var(--tc-bg-panel);
    border-bottom: 1px solid var(--tc-border);
    position: relative;
    z-index: 10;
}

.app-header {
    background: linear-gradient(180deg, var(--tc-bg-elevated) 0%, var(--tc-bg-panel) 100%) !important;
    border-bottom: 1px solid var(--tc-border) !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.top-row a {
    color: var(--tc-text-secondary);
    font-size: 0.875rem;
    transition: color var(--tc-transition-fast);
}

.top-row a:hover {
    color: var(--tc-accent-cyan);
    text-decoration: none;
}

article.content {
    flex: 1;
    padding: var(--tc-space-lg);
    position: relative;
    z-index: 1;
}

/* ============================================================================
   NAVIGATION
   ============================================================================ */
.top-row.ps-3.navbar {
    height: 70px;
    padding: 0 var(--tc-space-md);
    background: linear-gradient(180deg, var(--tc-bg-elevated) 0%, var(--tc-bg-panel) 100%);
    border-bottom: 1px solid var(--tc-border);
    display: flex;
    align-items: center;
}

.navbar-brand {
    font-family: var(--tc-font-display);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--tc-text-primary) !important;
    display: flex;
    align-items: center;
    gap: var(--tc-space-sm);
}

.navbar-brand::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--tc-accent-green);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--tc-accent-green-glow);
    animation: status-pulse 2s ease-in-out infinite;
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 10px var(--tc-accent-green-glow); }
    50% { opacity: 0.6; box-shadow: 0 0 5px var(--tc-accent-green-glow); }
}

.nav-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: var(--tc-space-md) 0;
}

.nav.flex-column {
    gap: var(--tc-space-xs);
}

.nav-item {
    padding: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--tc-space-sm);
    padding: var(--tc-space-sm) var(--tc-space-md);
    margin: 0 var(--tc-space-sm);
    color: var(--tc-text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--tc-radius-md);
    border: 1px solid transparent;
    transition: all var(--tc-transition-base);
    text-decoration: none !important;
}

.nav-link:hover {
    background: var(--tc-bg-hover);
    color: var(--tc-text-primary);
    border-color: var(--tc-border);
}

.nav-link.active {
    background: var(--tc-accent-cyan-dim);
    color: var(--tc-accent-cyan);
    border-color: var(--tc-accent-cyan);
    box-shadow: var(--tc-shadow-glow-cyan);
}

/* Nav Icons */
.nav-link span[class^="bi"] {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

/* Mobile Nav Toggle */
.navbar-toggler {
    display: none;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--tc-transition-slow);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    main {
        margin-left: 0;
    }

    main::before {
        left: 0;
    }

    .navbar-toggler {
        display: block;
    }
}

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn, button {
    font-family: var(--tc-font-body);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--tc-transition-base);
}

/* Primary Button - Cyan */
.btn-primary, .tc-btn-primary {
    background: linear-gradient(180deg, var(--tc-accent-cyan) 0%, #00a8cc 100%);
    border: 1px solid var(--tc-accent-cyan);
    color: var(--tc-bg-deepest);
    padding: var(--tc-space-sm) var(--tc-space-lg);
    border-radius: var(--tc-radius-md);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.875rem;
    box-shadow: var(--tc-shadow-sm), 0 0 10px var(--tc-accent-cyan-dim);
}

.btn-primary:hover, .tc-btn-primary:hover {
    background: linear-gradient(180deg, #33ddff 0%, var(--tc-accent-cyan) 100%);
    box-shadow: var(--tc-shadow-md), var(--tc-shadow-glow-cyan);
    transform: translateY(-1px);
}

.btn-primary:active, .tc-btn-primary:active {
    transform: translateY(0);
    box-shadow: var(--tc-shadow-sm);
}

/* Secondary Button */
.btn-secondary, .tc-btn-secondary {
    background: var(--tc-bg-surface);
    border: 1px solid var(--tc-border);
    color: var(--tc-text-primary);
    padding: var(--tc-space-sm) var(--tc-space-lg);
    border-radius: var(--tc-radius-md);
    font-weight: 500;
}

.btn-secondary:hover, .tc-btn-secondary:hover {
    background: var(--tc-bg-hover);
    border-color: var(--tc-border-light);
}

/* Success Button - Green */
.btn-success, .tc-btn-success {
    background: linear-gradient(180deg, var(--tc-accent-green) 0%, #3d8b40 100%);
    border: 1px solid var(--tc-accent-green);
    color: white;
    padding: var(--tc-space-sm) var(--tc-space-lg);
    border-radius: var(--tc-radius-md);
    font-weight: 600;
    box-shadow: var(--tc-shadow-sm), 0 0 10px var(--tc-accent-green-dim);
}

.btn-success:hover, .tc-btn-success:hover {
    box-shadow: var(--tc-shadow-md), var(--tc-shadow-glow-green);
    transform: translateY(-1px);
}

/* Danger Button - Red */
.btn-danger, .tc-btn-danger {
    background: linear-gradient(180deg, var(--tc-accent-red) 0%, #c73e38 100%);
    border: 1px solid var(--tc-accent-red);
    color: white;
    padding: var(--tc-space-sm) var(--tc-space-lg);
    border-radius: var(--tc-radius-md);
    font-weight: 600;
    box-shadow: var(--tc-shadow-sm), 0 0 10px var(--tc-accent-red-dim);
}

.btn-danger:hover, .tc-btn-danger:hover {
    box-shadow: var(--tc-shadow-md), var(--tc-shadow-glow-red);
    transform: translateY(-1px);
}

/* Warning Button - Orange */
.btn-warning, .tc-btn-warning {
    background: linear-gradient(180deg, var(--tc-accent-orange) 0%, #cc6d2e 100%);
    border: 1px solid var(--tc-accent-orange);
    color: var(--tc-bg-deepest);
    padding: var(--tc-space-sm) var(--tc-space-lg);
    border-radius: var(--tc-radius-md);
    font-weight: 600;
    box-shadow: var(--tc-shadow-sm), 0 0 10px var(--tc-accent-orange-dim);
}

.btn-warning:hover, .tc-btn-warning:hover {
    box-shadow: var(--tc-shadow-md), var(--tc-shadow-glow-orange);
    transform: translateY(-1px);
}

/* Ghost/Link Button */
.btn-link, .tc-btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--tc-text-secondary);
    padding: var(--tc-space-sm) var(--tc-space-md);
    border-radius: var(--tc-radius-md);
}

.btn-link:hover, .tc-btn-ghost:hover {
    background: var(--tc-bg-hover);
    color: var(--tc-text-primary);
    text-decoration: none;
}

/* Icon Button */
.tc-btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tc-bg-surface);
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius-md);
    color: var(--tc-text-secondary);
}

.tc-btn-icon:hover {
    background: var(--tc-bg-hover);
    color: var(--tc-text-primary);
    border-color: var(--tc-border-light);
}

/* ============================================================================
   FORM CONTROLS
   ============================================================================ */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select,
.form-control {
    width: 100%;
    padding: var(--tc-space-sm) var(--tc-space-md);
    background: var(--tc-bg-surface);
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius-md);
    color: var(--tc-text-primary);
    font-family: var(--tc-font-body);
    font-size: 0.875rem;
    transition: all var(--tc-transition-base);
}

input:focus,
textarea:focus,
select:focus,
.form-control:focus {
    outline: none;
    border-color: var(--tc-accent-cyan);
    box-shadow: 0 0 0 3px var(--tc-accent-cyan-dim);
}

input::placeholder,
textarea::placeholder {
    color: var(--tc-text-muted);
}

/* Checkbox and Radio */
input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--tc-accent-cyan);
    cursor: pointer;
}

/* Range Slider */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--tc-bg-surface);
    border-radius: 3px;
    border: none;
    padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--tc-accent-cyan);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 0 10px var(--tc-accent-cyan-dim);
    transition: all var(--tc-transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), var(--tc-shadow-glow-cyan);
}

input[type="range"]:focus {
    outline: none;
}

/* Select Dropdown */
select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* Label */
label, .form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--tc-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--tc-space-xs);
}

/* ============================================================================
   PANELS & CARDS
   ============================================================================ */
.tc-panel {
    background: var(--tc-bg-panel);
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius-lg);
    overflow: hidden;
}

.tc-panel-header {
    display: flex;
    align-items: center;
    gap: var(--tc-space-sm);
    padding: var(--tc-space-md) var(--tc-space-lg);
    background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 100%);
    border-bottom: 1px solid var(--tc-border);
}

.tc-panel-title {
    font-family: var(--tc-font-display);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--tc-text-secondary);
    margin: 0;
}

.tc-panel-icon {
    font-size: 1rem;
}

.tc-panel-body {
    padding: var(--tc-space-lg);
}

/* Card with Glow Effect */
.tc-card-glow {
    position: relative;
    background: var(--tc-bg-panel);
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius-lg);
    overflow: hidden;
    transition: all var(--tc-transition-base);
}

.tc-card-glow::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--tc-accent-cyan), transparent);
    opacity: 0;
    transition: opacity var(--tc-transition-base);
}

.tc-card-glow:hover {
    border-color: var(--tc-accent-cyan);
}

.tc-card-glow:hover::before {
    opacity: 1;
}

/* ============================================================================
   STATUS INDICATORS
   ============================================================================ */
.tc-status-light {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--tc-text-muted);
    flex-shrink: 0;
}

.tc-status-light.online,
.tc-status-light.success,
.tc-status-light.active {
    background: var(--tc-accent-green);
    box-shadow: 0 0 10px var(--tc-accent-green-glow);
    animation: status-pulse 2s ease-in-out infinite;
}

.tc-status-light.warning {
    background: var(--tc-accent-orange);
    box-shadow: 0 0 10px var(--tc-accent-orange-glow);
    animation: status-pulse 1.5s ease-in-out infinite;
}

.tc-status-light.error,
.tc-status-light.danger {
    background: var(--tc-accent-red);
    box-shadow: 0 0 10px var(--tc-accent-red-glow);
    animation: status-pulse 1s ease-in-out infinite;
}

.tc-status-light.offline,
.tc-status-light.inactive {
    background: var(--tc-text-muted);
    box-shadow: none;
    animation: none;
}

/* Status Badge */
.tc-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--tc-space-xs);
    padding: 2px 8px;
    font-family: var(--tc-font-mono);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 10px;
}

.tc-badge-cyan {
    background: var(--tc-accent-cyan-dim);
    color: var(--tc-accent-cyan);
    border: 1px solid rgba(0, 212, 255, 0.3);
}

.tc-badge-green {
    background: var(--tc-accent-green-dim);
    color: var(--tc-accent-green);
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.tc-badge-orange {
    background: var(--tc-accent-orange-dim);
    color: var(--tc-accent-orange);
    border: 1px solid rgba(240, 136, 62, 0.3);
}

.tc-badge-red {
    background: var(--tc-accent-red-dim);
    color: var(--tc-accent-red);
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.tc-badge-purple {
    background: var(--tc-accent-purple-dim);
    color: var(--tc-accent-purple);
    border: 1px solid rgba(163, 113, 247, 0.3);
}

/* ============================================================================
   DATA DISPLAY
   ============================================================================ */
.tc-data-label {
    font-family: var(--tc-font-mono);
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--tc-text-muted);
}

.tc-data-value {
    font-family: var(--tc-font-mono);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--tc-text-primary);
}

.tc-data-value.highlight {
    color: var(--tc-accent-cyan);
    text-shadow: 0 0 10px var(--tc-accent-cyan-dim);
}

.tc-data-value.success {
    color: var(--tc-accent-green);
    text-shadow: 0 0 10px var(--tc-accent-green-dim);
}

.tc-data-value.warning {
    color: var(--tc-accent-orange);
    text-shadow: 0 0 10px var(--tc-accent-orange-dim);
}

.tc-data-value.danger {
    color: var(--tc-accent-red);
    text-shadow: 0 0 10px var(--tc-accent-red-dim);
}

/* ============================================================================
   TOGGLE SWITCH
   ============================================================================ */
.tc-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.tc-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.tc-toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--tc-bg-surface);
    border: 1px solid var(--tc-border);
    border-radius: 24px;
    transition: all var(--tc-transition-base);
}

.tc-toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--tc-text-secondary);
    border-radius: 50%;
    transition: all var(--tc-transition-base);
}

.tc-toggle input:checked + .tc-toggle-slider {
    background: var(--tc-accent-cyan-dim);
    border-color: var(--tc-accent-cyan);
}

.tc-toggle input:checked + .tc-toggle-slider::before {
    transform: translateX(20px);
    background: var(--tc-accent-cyan);
    box-shadow: 0 0 10px var(--tc-accent-cyan-glow);
}

/* ============================================================================
   TABLES
   ============================================================================ */
.tc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.tc-table th {
    font-family: var(--tc-font-mono);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--tc-text-muted);
    text-align: left;
    padding: var(--tc-space-sm) var(--tc-space-md);
    border-bottom: 1px solid var(--tc-border);
}

.tc-table td {
    padding: var(--tc-space-md);
    border-bottom: 1px solid var(--tc-border);
    color: var(--tc-text-secondary);
}

.tc-table tr:hover td {
    background: var(--tc-bg-hover);
}

/* ============================================================================
   MODALS
   ============================================================================ */
.tc-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.tc-modal {
    background: var(--tc-bg-panel);
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius-xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--tc-shadow-lg);
}

.tc-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--tc-space-lg);
    border-bottom: 1px solid var(--tc-border);
}

.tc-modal-title {
    font-family: var(--tc-font-display);
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.tc-modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tc-bg-surface);
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius-md);
    color: var(--tc-text-secondary);
    cursor: pointer;
    transition: all var(--tc-transition-fast);
}

.tc-modal-close:hover {
    background: var(--tc-accent-red);
    border-color: var(--tc-accent-red);
    color: white;
}

.tc-modal-body {
    padding: var(--tc-space-lg);
    overflow-y: auto;
}

.tc-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--tc-space-sm);
    padding: var(--tc-space-lg);
    border-top: 1px solid var(--tc-border);
}

/* ============================================================================
   ALERTS & MESSAGES
   ============================================================================ */
.tc-alert {
    padding: var(--tc-space-md);
    border-radius: var(--tc-radius-md);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: var(--tc-space-sm);
}

.tc-alert-success {
    background: var(--tc-accent-green-dim);
    border: 1px solid rgba(76, 175, 80, 0.3);
    color: var(--tc-accent-green);
}

.tc-alert-warning {
    background: var(--tc-accent-orange-dim);
    border: 1px solid rgba(240, 136, 62, 0.3);
    color: var(--tc-accent-orange);
}

.tc-alert-error {
    background: var(--tc-accent-red-dim);
    border: 1px solid rgba(248, 81, 73, 0.3);
    color: var(--tc-accent-red);
}

.tc-alert-info {
    background: var(--tc-accent-cyan-dim);
    border: 1px solid rgba(0, 212, 255, 0.3);
    color: var(--tc-accent-cyan);
}

/* ============================================================================
   LOADING STATES
   ============================================================================ */
.tc-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--tc-border);
    border-top-color: var(--tc-accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.tc-skeleton {
    background: linear-gradient(90deg, var(--tc-bg-surface) 25%, var(--tc-bg-hover) 50%, var(--tc-bg-surface) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--tc-radius-sm);
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */
/* Text Colors */
.text-primary { color: var(--tc-text-primary) !important; }
.text-secondary { color: var(--tc-text-secondary) !important; }
.text-muted { color: var(--tc-text-muted) !important; }
.text-cyan { color: var(--tc-accent-cyan) !important; }
.text-green { color: var(--tc-accent-green) !important; }
.text-orange { color: var(--tc-accent-orange) !important; }
.text-red { color: var(--tc-accent-red) !important; }

/* Background Colors */
.bg-panel { background: var(--tc-bg-panel) !important; }
.bg-surface { background: var(--tc-bg-surface) !important; }
.bg-dark { background: var(--tc-bg-dark) !important; }

/* Font Families */
.font-display { font-family: var(--tc-font-display) !important; }
.font-mono { font-family: var(--tc-font-mono) !important; }
.font-body { font-family: var(--tc-font-body) !important; }

/* Spacing */
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mt-md { margin-top: var(--tc-space-md) !important; }
.mb-md { margin-bottom: var(--tc-space-md) !important; }
.mt-lg { margin-top: var(--tc-space-lg) !important; }
.mb-lg { margin-bottom: var(--tc-space-lg) !important; }

/* Flex */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--tc-space-sm); }
.gap-md { gap: var(--tc-space-md); }
.gap-lg { gap: var(--tc-space-lg); }

/* ============================================================================
   BLAZOR ERROR BOUNDARY
   ============================================================================ */
.blazor-error-boundary {
    background: var(--tc-accent-red-dim);
    border: 1px solid var(--tc-accent-red);
    border-radius: var(--tc-radius-md);
    padding: var(--tc-space-md) var(--tc-space-lg);
    color: var(--tc-accent-red);
    display: flex;
    align-items: center;
    gap: var(--tc-space-sm);
}

.blazor-error-boundary::before {
    content: '⚠';
    font-size: 1.25rem;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: var(--tc-space-lg);
    right: var(--tc-space-lg);
    background: var(--tc-accent-red-dim);
    border: 1px solid var(--tc-accent-red);
    border-radius: var(--tc-radius-md);
    padding: var(--tc-space-md) var(--tc-space-lg);
    color: var(--tc-accent-red);
    z-index: 9999;
}

#blazor-error-ui .reload {
    color: var(--tc-text-primary);
    margin-left: var(--tc-space-sm);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    margin-left: var(--tc-space-md);
}

/* ============================================================================
   LOGIN DISPLAY
   ============================================================================ */
.login-display {
    display: flex;
    align-items: center;
    gap: var(--tc-space-md);
}

.login-display .user-name {
    font-family: var(--tc-font-mono);
    font-size: 0.875rem;
    color: var(--tc-accent-cyan);
}

.login-display .btn-link,
.login-display a {
    color: var(--tc-text-secondary);
    font-size: 0.875rem;
}

.login-display .btn-link:hover,
.login-display a:hover {
    color: var(--tc-accent-cyan);
}

.logout-form {
    margin: 0;
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slide-up {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-in-left {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes glow-pulse {
    0%, 100% { box-shadow: 0 0 5px var(--tc-accent-cyan-dim); }
    50% { box-shadow: 0 0 20px var(--tc-accent-cyan-glow); }
}

.animate-fade-in {
    animation: fade-in 0.3s ease-out;
}

.animate-slide-up {
    animation: slide-up 0.3s ease-out;
}

.animate-slide-in-left {
    animation: slide-in-left 0.3s ease-out;
}

/* ============================================================================
   RESPONSIVE BREAKPOINTS
   ============================================================================ */
@media (max-width: 1024px) {
    :root {
        --tc-sidebar-width: 220px;
    }
}

@media (max-width: 768px) {
    :root {
        --tc-sidebar-width: 100%;
    }

    .page {
        flex-direction: column;
    }

    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--tc-border);
    }

    main {
        margin-left: 0;
    }

    .nav-scrollable {
        display: none;
    }

    .navbar-toggler:checked ~ .nav-scrollable {
        display: block;
    }
}

/* Video panel: stretch to fill available space in flex container */
.video-panel {
    flex: 1;
    min-width: 0;
}

/* ============================================================================
   SENTRY MISSION CONTROL REFRESH
   ============================================================================ */
:root {
    --mc-bg-0: #111820;
    --mc-bg-1: #151d26;
    --mc-bg-2: #1b2530;
    --mc-bg-3: #24303c;
    --mc-line: #34414d;
    --mc-line-soft: rgba(52, 65, 77, 0.62);
    --mc-ink-0: #f4f7f9;
    --mc-ink-1: #c7d0d8;
    --mc-ink-2: #8996a3;
    --mc-ink-3: #667482;
    --mc-accent: #f0a64e;
    --mc-accent-dim: rgba(240, 166, 78, 0.16);
    --mc-cyan: #4ad0e0;
    --mc-lime: #9ce05a;
    --mc-red: #ee5a4f;
    --mc-font-sans: "IBM Plex Sans", var(--tc-font-body);
    --mc-font-mono: "IBM Plex Mono", var(--tc-font-mono);
    --mc-rail: 64px;
    --mc-topbar: 44px;
}

body {
    background: var(--mc-bg-0);
    color: var(--mc-ink-0);
}

body:has(.mission-shell) {
    overflow-x: hidden;
}

.mission-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--mc-rail) minmax(0, 1fr);
    background:
        radial-gradient(ellipse at top, rgba(74, 208, 224, 0.08) 0%, transparent 48%),
        linear-gradient(180deg, #0f151c 0%, var(--mc-bg-0) 100%);
    color: var(--mc-ink-0);
    font-family: var(--mc-font-sans);
}

.mission-workspace {
    min-width: 0;
    min-height: 100vh;
    display: grid;
    grid-template-rows: var(--mc-topbar) minmax(0, 1fr);
}

.mission-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    height: var(--mc-topbar);
    padding: 0 16px;
    background: rgba(15, 21, 28, 0.94);
    border-bottom: 1px solid var(--mc-line-soft);
    backdrop-filter: blur(10px);
}

.mission-crumb,
.mission-stat,
.mission-user,
.mission-link-button {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    font-family: var(--mc-font-mono);
    font-size: 0.72rem;
}

.mission-crumb {
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.mission-crumb-id {
    color: var(--mc-accent);
}

.mission-crumb-name {
    color: var(--mc-ink-1);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mission-topbar-spacer {
    flex: 1 1 auto;
    min-width: 8px;
}

.mission-stat {
    gap: 7px;
    padding: 5px 8px;
    border: 1px solid var(--mc-line-soft);
    border-radius: 4px;
    background: rgba(27, 37, 48, 0.62);
}

.mission-stat-label {
    color: var(--mc-ink-3);
    letter-spacing: 0.08em;
}

.mission-stat-value {
    color: var(--mc-ink-1);
}

.mission-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--mc-ink-3);
}

.mission-dot.live {
    background: var(--mc-lime);
    box-shadow: 0 0 10px rgba(156, 224, 90, 0.55);
    animation: status-pulse 2.4s ease-in-out infinite;
}

.mission-main {
    min-width: 0;
    min-height: 0;
    margin-left: 0;
    display: block;
    background:
        linear-gradient(rgba(52, 65, 77, 0.18) 1px, transparent 1px),
        linear-gradient(90deg, rgba(52, 65, 77, 0.18) 1px, transparent 1px),
        var(--mc-bg-0);
    background-size: 48px 48px;
}

.mission-main::before {
    display: none;
}

.mission-content {
    min-width: 0;
    width: 100%;
    padding: 22px;
}

.mission-rail {
    position: sticky;
    top: 0;
    z-index: 50;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    background: #0b1117;
    border-right: 1px solid var(--mc-line-soft);
}

.mission-rail-logo {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    color: var(--mc-accent);
    border: 1px solid rgba(240, 166, 78, 0.56);
    border-radius: 4px;
    background: var(--mc-accent-dim);
    text-decoration: none;
}

.mission-rail-logo:hover {
    color: var(--mc-ink-0);
    text-decoration: none;
}

.mission-rail-mark {
    font-family: var(--mc-font-mono);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.mission-rail-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 100%;
}

.mission-rail-link {
    position: relative;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    color: var(--mc-ink-2);
    border-radius: 4px;
    text-decoration: none;
    transition: background var(--tc-transition-fast), color var(--tc-transition-fast);
}

.mission-rail-link:hover {
    color: var(--mc-ink-0);
    background: var(--mc-bg-2);
    text-decoration: none;
}

.mission-rail-link.active {
    color: var(--mc-accent);
    background: var(--mc-accent-dim);
}

.mission-rail-link.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 9px;
    bottom: 9px;
    width: 2px;
    background: var(--mc-accent);
}

.mission-nav-icon svg,
.mission-icon-button svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.mission-nav-icon circle:last-child {
    fill: currentColor;
}

.mission-nav-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.mission-user {
    gap: 8px;
}

.mission-avatar {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    color: var(--mc-bg-0);
    background: var(--mc-accent);
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 800;
}

.mission-user-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--mc-ink-1);
}

.mission-logout-form {
    margin: 0;
}

.mission-icon-button,
.mission-link-button {
    min-width: 32px;
    min-height: 32px;
    display: inline-grid;
    place-items: center;
    color: var(--mc-ink-2);
    border: 1px solid var(--mc-line-soft);
    border-radius: 4px;
    background: var(--mc-bg-2);
}

.mission-link-button {
    padding: 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    text-decoration: none;
}

.mission-icon-button:hover,
.mission-link-button:hover {
    color: var(--mc-accent);
    border-color: rgba(240, 166, 78, 0.55);
    text-decoration: none;
}

.mc-page {
    display: grid;
    gap: 18px;
    max-width: 1480px;
    margin: 0 auto;
}

.mc-page.full {
    max-width: none;
}

.mc-page-header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
}

.mc-meta {
    margin: 0 0 6px;
    color: var(--mc-accent);
    font-family: var(--mc-font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.mc-page-title {
    margin: 0;
    color: var(--mc-ink-0);
    font-family: var(--mc-font-sans);
    font-size: clamp(1.55rem, 3vw, 2.4rem);
    font-weight: 600;
    letter-spacing: 0;
}

.mc-page-title:focus {
    outline: none;
}

.mc-page-subtitle {
    max-width: 760px;
    margin: 8px 0 0;
    color: var(--mc-ink-2);
}

.mc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
}

.mc-card,
.mc-panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012)), var(--mc-bg-1);
    border: 1px solid var(--mc-line);
    border-radius: 6px;
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.22);
}

.mc-card {
    overflow: hidden;
}

.mc-card-header,
.mc-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--mc-line-soft);
    color: var(--mc-ink-1);
    font-family: var(--mc-font-mono);
    font-size: 0.73rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.mc-card-body,
.mc-panel-body {
    padding: 14px;
}

.mc-grid {
    display: grid;
    gap: 14px;
}

.mc-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mc-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mc-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    width: max-content;
    max-width: 100%;
    padding: 4px 8px;
    color: var(--mc-ink-1);
    background: var(--mc-bg-2);
    border: 1px solid var(--mc-line);
    border-radius: 999px;
    font-family: var(--mc-font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.mc-pill.live,
.mc-pill.success {
    color: var(--mc-lime);
    border-color: rgba(156, 224, 90, 0.42);
    background: rgba(156, 224, 90, 0.1);
}

.mc-pill.warn {
    color: var(--mc-accent);
    border-color: rgba(240, 166, 78, 0.42);
    background: var(--mc-accent-dim);
}

.mc-pill.danger,
.mc-pill.alert {
    color: var(--mc-red);
    border-color: rgba(238, 90, 79, 0.45);
    background: rgba(238, 90, 79, 0.1);
}

.mc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 12px;
    color: var(--mc-ink-1);
    background: var(--mc-bg-2);
    border: 1px solid var(--mc-line);
    border-radius: 4px;
    font-family: var(--mc-font-mono);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
}

.mc-btn:hover {
    color: var(--mc-ink-0);
    border-color: var(--mc-accent);
    text-decoration: none;
}

.mc-btn.primary {
    color: #161106;
    background: var(--mc-accent);
    border-color: var(--mc-accent);
}

.mc-btn.danger {
    color: #fff;
    background: rgba(238, 90, 79, 0.24);
    border-color: rgba(238, 90, 79, 0.62);
}

.mc-input,
.mc-select,
.mc-textarea {
    width: 100%;
    min-height: 36px;
    padding: 0 10px;
    color: var(--mc-ink-0);
    background: var(--mc-bg-2);
    border: 1px solid var(--mc-line);
    border-radius: 4px;
    font-family: var(--mc-font-sans);
}

.mc-textarea {
    min-height: 76px;
    padding-top: 9px;
}

.mc-input:focus,
.mc-select:focus,
.mc-textarea:focus,
.mc-btn:focus-visible,
.mission-rail-link:focus-visible,
.mission-icon-button:focus-visible {
    outline: 2px solid var(--mc-accent);
    outline-offset: 2px;
}

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

.mc-table th,
.mc-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--mc-line-soft);
    color: var(--mc-ink-1);
    text-align: left;
    vertical-align: middle;
}

.mc-table th {
    color: var(--mc-ink-3);
    font-family: var(--mc-font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.mc-table tr:last-child td {
    border-bottom: 0;
}

.mc-empty {
    padding: 28px;
    color: var(--mc-ink-2);
    text-align: center;
    border: 1px dashed var(--mc-line);
    border-radius: 6px;
    background: rgba(27, 37, 48, 0.42);
}

@media (max-width: 920px) {
    .mission-shell {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
    }

    .mission-workspace {
        order: 1;
    }

    .mission-rail {
        order: 2;
        position: static;
        width: 100%;
        height: 58px;
        flex-direction: row;
        justify-content: center;
        padding: 0 12px;
        border-right: 0;
        border-top: 1px solid var(--mc-line-soft);
    }

    .mission-rail-logo {
        display: none;
    }

    .mission-rail-nav {
        flex-direction: row;
        justify-content: space-around;
        gap: 0;
        max-width: 560px;
    }

    .mission-rail-link.active::before {
        left: 8px;
        right: 8px;
        top: -9px;
        bottom: auto;
        width: auto;
        height: 2px;
    }

    .mission-content {
        padding: 16px 14px 76px;
    }

    .hide-narrow {
        display: none;
    }

    .mc-grid.two,
    .mc-grid.three {
        grid-template-columns: 1fr;
    }

    .mc-page-header {
        flex-direction: column;
    }

    .mc-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 560px) {
    .hide-phone,
    .mission-user-name {
        display: none;
    }
}
