.bg-video {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
object-fit: cover;
z-index: -2;
opacity: 0.35;
pointer-events: none;
}

.bg-video-overlay {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: -1;
background: linear-gradient(180deg, rgba(26,26,46,0.45) 0%, rgba(22,33,62,0.65) 100%);
pointer-events: none;
}

:root {
--primary-color: #27C286;
--secondary-color: #3EA2F3;
--accent-color: #89E7D1;
--bg-color: #FFFFFF;
--bg-color2: #F5F5F5;
--bg-color3: #E8E8E8;
--bg-color4: #E0E0E0;
--text-color: #1A1A1A;
--secondary-text-color: #666666;
--title-text-color: #1A1A1A;
--accent-text-color: #27C286;

--separator-color: #E0E0E0;
--text-field-border-color: #D0D0D0;
--text-field-focus-border-color: #27C286;
--text-field-bg-color: #FFFFFF;
--text-field-placeholder-color: #999999;
--text-field-border-radius: 8px;

--scroll-bar-thumb-bg-color: #C0C0C0;

--side-padding: 16px;
--side-padding2: 12px;
--topline-height: 56px;
--bottomline-height: 56px;
--highlight-delta: 4px;

--transition-speed: 0.2s;
--transition-speed2: 0.3s;
--transition-speed3: 0.4s;

--font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
--title-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html[theme=dark] {
--bg-color: #1A1A2E;
--bg-color2: #16213E;
--bg-color3: #0F3460;
--bg-color4: #0A1F3D;
--text-color: #FFFFFF;
--secondary-text-color: #A0A0A0;
--title-text-color: #FFFFFF;
--separator-color: #2A2A4E;
--text-field-border-color: #3A3A5E;
--text-field-bg-color: #1A1A2E;
--text-field-placeholder-color: #666666;
--scroll-bar-thumb-bg-color: #4A4A6E;
}

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

html, body {
height: 100%;
-webkit-overflow-scrolling: touch;
overscroll-behavior: none;
}

body {
font-family: var(--font-family);
font-size: 14px;
line-height: 1.5;
color: var(--text-color);
background-color: var(--bg-color);
transition: background-color var(--transition-speed), color var(--transition-speed);
}

.app-layout {
display: flex;
flex-direction: column;
min-height: 100vh;
min-height: -webkit-fill-available;
}

.app-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 var(--side-padding);
height: var(--topline-height);
border-bottom: 1px solid var(--separator-color);
background-color: var(--bg-color);
transition: border-color var(--transition-speed);
flex-shrink: 0;
position: sticky;
top: 0;
z-index: 100;
}

.app-header-logo {
display: flex;
align-items: center;
gap: 10px;
min-width: 0;
}

.app-header-logo-icon {
width: 50px;
height: 50px;
border-radius: 50%;
overflow: hidden;
flex-shrink: 0;
background: var(--bg-color2);
display: flex;
align-items: center;
justify-content: center;
}

.app-header-logo-icon img {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 50%;
}

.app-header-title {
font-family: var(--title-font-family);
font-size: 18px;
font-weight: 800;
color: var(--title-text-color);
}

.app-header-subtitle {
font-size: 12px;
color: var(--secondary-text-color);
margin-left: 4px;
}

.app-header-actions {
display: flex;
align-items: center;
gap: 10px;
flex-shrink: 0;
}

.app-body {
display: flex;
flex: 1;
overflow: hidden;
position: relative;
}

.app-footer {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 var(--side-padding);
height: var(--bottomline-height);
border-top: 1px solid var(--separator-color);
font-size: 12px;
color: var(--secondary-text-color);
background-color: var(--bg-color);
flex-shrink: 0;
}

.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 8px 16px;
border: none;
border-radius: 8px;
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: background-color var(--transition-speed), transform var(--transition-speed);
text-decoration: none;
color: #FFFFFF;
-webkit-tap-highlight-color: transparent;
touch-action: manipulation;
}

.btn:hover {
transform: translateY(-1px);
}

.btn:active {
transform: translateY(0);
}

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

.btn-primary:hover {
background-color: #22A876;
}

.btn-secondary {
background-color: var(--bg-color3);
color: var(--text-color);
}

.btn-secondary:hover {
background-color: var(--bg-color4);
}

.btn-blue {
background-color: var(--secondary-color);
}

.btn-blue:hover {
background-color: #2E8FE3;
}

.btn-danger {
background-color: #E74C3C;
}

.btn-danger:hover {
background-color: #D13B2B;
}

.btn-sm {
padding: 6px 12px;
font-size: 12px;
}

.btn-icon {
padding: 8px;
width: 36px;
height: 36px;
}

.theme-toggle {
display: inline-flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
border-radius: 50%;
border: 1px solid var(--separator-color);
background-color: var(--bg-color2);
color: var(--text-color);
cursor: pointer;
transition: background-color var(--transition-speed), border-color var(--transition-speed);
font-size: 18px;
}

.theme-toggle:hover {
background-color: var(--bg-color3);
border-color: var(--text-field-border-color);
}

.status-dot {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
margin-right: 6px;
}

.status-dot.active {
background-color: var(--primary-color);
box-shadow: 0 0 8px var(--primary-color);
}

.status-dot.idle {
background-color: var(--secondary-text-color);
}

.badge {
display: inline-block;
padding: 4px 8px;
border-radius: 4px;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.5px;
}

.badge-green {
background-color: rgba(39, 194, 134, 0.15);
color: #27C286;
}

.badge-blue {
background-color: rgba(62, 162, 243, 0.15);
color: #3EA2F3;
}

.badge-orange {
background-color: rgba(255, 152, 0, 0.15);
color: #FF9800;
}

.badge-purple {
background-color: rgba(156, 39, 176, 0.15);
color: #9C27B0;
}

.badge-grey {
background-color: rgba(128, 128, 128, 0.15);
color: #808080;
}

.spinner {
display: inline-block;
width: 20px;
height: 20px;
border: 2px solid var(--bg-color3);
border-top-color: var(--primary-color);
border-radius: 50%;
animation: spin 0.8s linear infinite;
}

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

.toast-container {
position: fixed;
top: 20px;
right: 20px;
z-index: 10000;
display: flex;
flex-direction: column;
gap: 10px;
}

.toast {
padding: 12px 16px;
border-radius: 8px;
background-color: var(--bg-color);
color: var(--text-color);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
font-size: 14px;
opacity: 0;
transform: translateX(100%);
transition: opacity 0.3s ease, transform 0.3s ease;
border-left: 4px solid var(--primary-color);
max-width: 90vw;
}

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

.toast.success {
border-left-color: var(--primary-color);
}

.toast.error {
border-left-color: #E74C3C;
}

.toast.info {
border-left-color: var(--secondary-color);
}

.modal-backdrop {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 9999;
opacity: 0;
visibility: hidden;
transition: opacity var(--transition-speed), visibility var(--transition-speed);
}

.modal-backdrop.visible {
opacity: 1;
visibility: visible;
}

.modal {
background-color: var(--bg-color);
border-radius: 12px;
padding: 24px;
max-width: 400px;
width: 90%;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
transform: scale(0.9);
transition: transform var(--transition-speed);
}

.modal-backdrop.visible .modal {
transform: scale(1);
}

.modal-title {
font-size: 18px;
font-weight: 700;
margin-bottom: 20px;
color: var(--title-text-color);
}

.modal-field {
margin-bottom: 16px;
}

.modal-actions {
display: flex;
gap: 10px;
justify-content: flex-end;
margin-top: 20px;
}

.text-field {
width: 100%;
display: block;
box-sizing: border-box;
position: relative;
}

.text-field__input {
font-family: var(--font-family);
width: 100%;
height: 40px;
display: block;
box-sizing: border-box;
border: none;
color: var(--text-color);
padding: 8px var(--side-padding2);
box-shadow: 0 0 0 1px var(--text-field-border-color);
border-radius: var(--text-field-border-radius);
background-color: var(--text-field-bg-color);
transition: box-shadow var(--transition-speed);
font-size: 16px; /* 16px prevents iOS zoom on focus */
}

.text-field__input::placeholder {
color: var(--text-field-placeholder-color);
}

.text-field__input:focus {
outline: none;
box-shadow: 0 0 0 2px var(--text-field-focus-border-color);
}

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

.data-table thead {
background-color: var(--bg-color2);
}

.data-table th {
padding: 12px var(--side-padding);
text-align: left;
font-size: 12px;
font-weight: 600;
text-transform: uppercase;
color: var(--secondary-text-color);
border-bottom: 1px solid var(--separator-color);
}

.data-table td {
padding: 12px var(--side-padding);
border-bottom: 1px solid var(--separator-color);
font-size: 13px;
}

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

.data-table tr:hover td {
background-color: var(--bg-color2);
}

.td-actions {
white-space: nowrap;
}

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

.stat-card {
background-color: var(--bg-color2);
border-radius: 12px;
padding: 20px;
text-align: center;
border: 1px solid var(--separator-color);
}

.stat-card-value {
font-size: 32px;
font-weight: 700;
color: var(--primary-color);
margin-bottom: 8px;
}

.stat-card-label {
font-size: 12px;
color: var(--secondary-text-color);
text-transform: uppercase;
letter-spacing: 0.5px;
}

.section {
margin-bottom: 24px;
}

.section-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
flex-wrap: wrap;
gap: 8px;
}

.section-title {
font-size: 18px;
font-weight: 700;
color: var(--title-text-color);
}

.section-subtitle {
font-size: 12px;
color: var(--secondary-text-color);
margin-top: 4px;
}

select, input[type="url"], input[type="text"], input[type="number"], input[type="password"] {
font-size: 16px !important; /* Prevents iOS zoom on focus */
}

::-webkit-scrollbar {
width: 12px;
background-color: transparent;
}

::-webkit-scrollbar-thumb {
background-color: var(--scroll-bar-thumb-bg-color);
border-radius: 6px;
border: 3px solid transparent;
background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
background-color: var(--text-field-border-color);
}

/* ─── Mobile Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
.app-header {
padding: 0 12px;
}

.app-header-title {
font-size: 16px;
}

.app-header-subtitle {
display: none;
}

.app-header-actions {
gap: 6px;
}

/* Stack sidebar on top of main content, allow full scroll */
.app-body {
flex-direction: column;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}

.sidebar {
width: 100%;
max-height: none;
border-right: none;
border-bottom: 1px solid var(--separator-color);
overflow-y: auto;
flex-shrink: 0;
}

.sidebar-header {
padding: 12px 16px;
}

.main-content {
padding: 12px;
overflow-y: visible; /* let app-body handle scrolling */
flex: none;
}

.video-grid {
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 12px;
}

.stat-cards {
grid-template-columns: repeat(2, 1fr);
}

.modal {
width: 95%;
padding: 16px;
}

.toast-container {
top: 10px;
right: 10px;
left: 10px;
}
}

@media (max-width: 480px) {
.stat-cards {
grid-template-columns: 1fr;
}

.section-header {
flex-direction: column;
align-items: flex-start;
gap: 8px;
}

.video-grid {
grid-template-columns: 1fr;
}

.video-card-actions {
flex-wrap: wrap;
}

.video-card-actions .btn {
flex: 1;
}

.app-footer {
height: auto;
padding: 12px;
}

.data-table {
display: block;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
}
