:root {
  --bg: #080a14;
  --panel: rgba(20, 23, 43, .78);
  --panel-strong: #161a31;
  --line: rgba(255,255,255,.09);
  --text: #f6f7fb;
  --muted: #9aa1ba;
  --violet: #8b7cff;
  --cyan: #55d7e4;
  --green: #64d7a0;
  --amber: #f3c66a;
  --danger: #ff858e;
  font-family: 'Cairo', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 50% -10%, #1c2042 0, #0d1020 34%, var(--bg) 72%); }
body, button, input, select { font-family: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.shell { position: relative; z-index: 1; width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 34px; }
.glow { position: fixed; width: 420px; height: 420px; border-radius: 50%; filter: blur(100px); opacity: .13; pointer-events: none; }
.glow-one { top: -150px; right: -100px; background: #6e63ff; }
.glow-two { bottom: -180px; left: -90px; background: #09b6cc; }
.panel { background: linear-gradient(145deg, rgba(25,29,54,.87), rgba(16,19,37,.78)); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.18), inset 0 1px rgba(255,255,255,.025); border-radius: 22px; backdrop-filter: blur(18px); }

.login-view { min-height: calc(100vh - 62px); display: grid; place-items: center; }
.login-card { width: min(470px, 100%); padding: 42px; text-align: right; }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; color: #fff; font-weight: 800; letter-spacing: -.06em; border-radius: 17px; background: linear-gradient(135deg, #8b7cff, #4e50bd); box-shadow: 0 14px 30px rgba(106,95,255,.3); margin-bottom: 24px; }
.brand-mark.small { width: 42px; height: 42px; border-radius: 13px; font-size: 13px; margin: 0; }
.eyebrow { color: var(--violet); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(26px, 3vw, 39px); line-height: 1.3; letter-spacing: -.04em; }
h2 { margin: 4px 0 0; font-size: 20px; letter-spacing: -.03em; }
.muted { color: var(--muted); line-height: 1.9; font-size: 13px; }
.login-card .muted { margin-bottom: 28px; }
.stack-form { display: grid; gap: 10px; }
.stack-form label, .field-label { color: #dfe3f1; font-size: 12px; font-weight: 700; }
input[type=password], select { width: 100%; color: var(--text); background: rgba(5,7,17,.55); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; outline: 0; transition: border .2s, box-shadow .2s; }
input[type=password]:focus, select:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(139,124,255,.13); }
.primary-button, .secondary-button, .outline-button, .ghost-button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; border-radius: 12px; padding: 12px 17px; font-weight: 800; font-size: 12px; transition: transform .2s, background .2s, border .2s; }
.primary-button { color: white; background: linear-gradient(135deg, #8b7cff, #5c57c9); box-shadow: 0 12px 25px rgba(104,92,231,.26); }
.primary-button:hover, .secondary-button:hover, .outline-button:hover { transform: translateY(-2px); }
.primary-button.wide { padding-inline: 24px; white-space: nowrap; }
.secondary-button { color: #fff; background: rgba(139,124,255,.16); border: 1px solid rgba(139,124,255,.28); width: 100%; }
.outline-button { color: #dadcff; background: rgba(255,255,255,.035); border: 1px solid var(--line); white-space: nowrap; }
.ghost-button { color: var(--muted); background: transparent; padding: 8px 5px; }
.ghost-button:hover { color: #fff; }
.form-error { min-height: 20px; color: var(--danger); font-size: 12px; margin: 2px 0 0; }
.security-note { display: flex; align-items: center; gap: 8px; color: #747c98; font-size: 11px; margin-top: 25px; }
.dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(100,215,160,.1); }

.topbar, .brand, .top-actions, .hero-row, .section-heading, .channel-item, .metric-card, .footer { display: flex; align-items: center; }
.topbar { justify-content: space-between; margin-bottom: 70px; }
.brand { gap: 12px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 14px; }
.brand span { color: var(--muted); font-size: 10px; margin-top: 2px; }
.top-actions { gap: 17px; }
.live-badge { display: inline-flex; align-items: center; gap: 7px; color: #a7e9c8; font-size: 11px; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(100,215,160,.11); }
.hero-row { justify-content: space-between; gap: 30px; margin-bottom: 30px; }
.hero-copy { max-width: 600px; margin-bottom: 0; }
.toast { min-height: 0; height: 0; overflow: hidden; opacity: 0; display: flex; align-items: center; padding: 0 18px; margin-bottom: 0; color: #dfffee; background: rgba(36,111,79,.3); border: 1px solid rgba(100,215,160,.25); border-radius: 12px; font-size: 12px; transition: all .25s; }
.toast.show { height: 46px; opacity: 1; margin-bottom: 20px; }
.toast.error { color: #ffd9dc; background: rgba(126,48,61,.33); border-color: rgba(255,133,142,.28); }
.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.metric-card { position: relative; min-height: 120px; padding: 19px; gap: 13px; }
.metric-card > div:nth-child(2) { min-width: 0; }
.metric-card span, .metric-card strong, .metric-card small { display: block; }
.metric-card span { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.metric-card strong { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-card small { position: absolute; bottom: 16px; right: 67px; left: 14px; color: #707894; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-icon { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px; font-size: 20px; }
.metric-icon.violet { color: #bbb3ff; background: rgba(139,124,255,.13); }
.metric-icon.cyan { color: var(--cyan); background: rgba(85,215,228,.12); }
.metric-icon.amber { color: var(--amber); background: rgba(243,198,106,.12); }
.metric-icon.green { color: var(--green); background: rgba(100,215,160,.12); }
.main-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; margin-bottom: 18px; }
.setup-panel, .settings-panel, .history-panel { padding: 26px; }
.section-heading { justify-content: space-between; gap: 15px; margin-bottom: 12px; }
.step-count, .save-state { color: #a99fff; font-size: 10px; background: rgba(139,124,255,.1); border: 1px solid rgba(139,124,255,.17); border-radius: 20px; padding: 5px 9px; white-space: nowrap; }
.save-state { color: #75cfa7; background: rgba(100,215,160,.08); border-color: rgba(100,215,160,.15); }
.channel-list { display: grid; gap: 10px; margin: 25px 0 17px; }
.channel-item { gap: 12px; padding: 13px; border: 1px solid var(--line); background: rgba(255,255,255,.025); border-radius: 15px; }
.channel-badge { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 11px; font-size: 10px; font-weight: 800; }
.source-badge { color: var(--cyan); background: rgba(85,215,228,.1); }
.target-badge { color: var(--amber); background: rgba(243,198,106,.1); }
.channel-copy { flex: 1; min-width: 0; }
.channel-copy strong, .channel-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-copy strong { font-size: 12px; }
.channel-copy span { color: var(--muted); font-size: 10px; margin-top: 2px; }
.public-pill { color: var(--green); background: rgba(100,215,160,.09); border: 1px solid rgba(100,215,160,.16); border-radius: 20px; padding: 5px 9px; font-size: 9px; white-space: nowrap; }
.source-id-field { display: block; flex-basis: 100%; width: 100%; margin-top: 3px; }
.source-id-field small { display: block; color: #7d86a3; font-size: 9px; margin-bottom: 5px; }
.source-id-field input { width: 100%; color: #dfe3f1; background: rgba(5,7,17,.5); border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; outline: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; direction: ltr; }
.source-id-field input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(85,215,228,.1); }
.notice { display: flex; align-items: flex-start; gap: 9px; color: #9199b4; font-size: 10px; line-height: 1.8; background: rgba(85,215,228,.055); border: 1px solid rgba(85,215,228,.1); border-radius: 12px; padding: 10px 12px; }
.notice span { display: grid; place-items: center; width: 16px; height: 16px; flex: 0 0 auto; color: var(--cyan); border: 1px solid rgba(85,215,228,.45); border-radius: 50%; font-size: 10px; }
.notice p { margin: 0; }
.settings-form { display: grid; gap: 10px; margin-top: 22px; }
.toggle-row, .check-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; background: rgba(255,255,255,.025); border: 1px solid var(--line); border-radius: 13px; cursor: pointer; }
.toggle-row span, .check-row span { flex: 1; }
.toggle-row strong, .toggle-row small, .check-row strong, .check-row small { display: block; }
.toggle-row strong, .check-row strong { color: #e9ebf5; font-size: 11px; }
.toggle-row small, .check-row small { color: var(--muted); font-size: 9px; margin-top: 2px; }
.toggle-row input { display: none; }
.toggle { position: relative; width: 40px; height: 23px; border-radius: 20px; background: #30364d; transition: .2s; }
.toggle::after { content: ''; position: absolute; top: 3px; right: 3px; width: 17px; height: 17px; border-radius: 50%; background: #9aa1ba; transition: .2s; }
.toggle-row input:checked + .toggle { background: var(--violet); }
.toggle-row input:checked + .toggle::after { right: 20px; background: #fff; }
.check-row { justify-content: flex-start; }
.check-row input { accent-color: var(--violet); width: 16px; height: 16px; }
.range-row { display: flex; align-items: center; gap: 12px; direction: ltr; }
.range-row input { flex: 1; accent-color: var(--violet); }
.range-row output { direction: rtl; min-width: 75px; color: #c9c5ff; font-size: 11px; text-align: left; }
.history-panel { padding-bottom: 16px; }
.history-heading { margin-bottom: 20px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 650px; }
th { color: #7d86a3; font-size: 10px; font-weight: 600; text-align: right; padding: 10px 10px; border-bottom: 1px solid var(--line); }
td { color: #d8dced; font-size: 11px; padding: 15px 10px; border-bottom: 1px solid rgba(255,255,255,.055); }
.video-title { max-width: 330px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.video-id { color: #7f88a4; direction: ltr; text-align: right; font-size: 9px; margin-top: 3px; }
.status-chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 20px; padding: 5px 9px; font-size: 9px; }
.status-chip::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-completed { color: var(--green); background: rgba(100,215,160,.09); }
.status-downloading, .status-uploading, .status-pending { color: var(--amber); background: rgba(243,198,106,.09); }
.status-failed { color: var(--danger); background: rgba(255,133,142,.09); }
.status-blocked { color: var(--danger); background: rgba(255,133,142,.09); }
.empty-state { color: #77809d; text-align: center; padding: 30px 10px; }
.footer { justify-content: space-between; color: #6c7591; font-size: 10px; padding: 19px 3px 0; }

@media (max-width: 900px) { .metrics-grid { grid-template-columns: repeat(2, 1fr); } .main-grid { grid-template-columns: 1fr; } }
@media (max-width: 580px) { .shell { width: min(100% - 26px, 1180px); padding-top: 18px; } .login-card, .setup-panel, .settings-panel, .history-panel { padding: 21px; } .topbar { margin-bottom: 48px; } .top-actions .live-badge { display: none; } .hero-row { align-items: flex-start; flex-direction: column; gap: 18px; } .primary-button.wide { width: 100%; } .metrics-grid { gap: 10px; } .metric-card { padding: 14px; min-height: 112px; } .metric-icon { width: 32px; height: 32px; } .metric-card strong { font-size: 13px; } .metric-card small { right: 58px; bottom: 13px; } .channel-item { align-items: flex-start; flex-wrap: wrap; } .channel-copy { min-width: calc(100% - 50px); } .channel-item .outline-button { width: calc(100% - 47px); margin-right: 47px; } .footer { align-items: flex-start; flex-direction: column; gap: 6px; } }
