:root {
  color-scheme: dark;
  --bg: #07111d;
  --surface: rgba(14, 29, 46, 0.86);
  --surface-strong: #102238;
  --surface-soft: #142b45;
  --line: rgba(166, 206, 223, 0.14);
  --line-bright: rgba(63, 224, 194, 0.34);
  --text: #eef8f8;
  --muted: #91a8b6;
  --primary: #31ddbd;
  --primary-dark: #17a98f;
  --blue: #62a8ff;
  --danger: #ff7f91;
  --warning: #ffc96b;
  --success: #58e0a2;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  --radius: 22px;
  font-family: Tahoma, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 85% -10%, rgba(38, 184, 164, 0.14), transparent 32%),
    radial-gradient(circle at -5% 42%, rgba(57, 112, 209, 0.13), transparent 34%),
    var(--bg);
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.muted { color: var(--muted); line-height: 1.85; }
.hidden { display: none !important; }

.brand-mark {
  position: relative;
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  border: 1px solid rgba(87, 235, 209, 0.35);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(48, 222, 188, 0.22), rgba(52, 113, 185, 0.16));
  box-shadow: inset 0 0 26px rgba(74, 238, 208, 0.09), 0 12px 34px rgba(0, 0, 0, 0.25);
  transform: rotate(8deg);
}

.brand-mark::before,
.brand-mark span {
  position: absolute;
  content: "";
  border: 3px solid var(--primary);
  border-radius: 50% 50% 50% 12%;
}

.brand-mark::before { width: 27px; height: 27px; transform: rotate(-53deg); }
.brand-mark span { width: 10px; height: 10px; background: var(--primary); transform: rotate(-53deg); }
.brand-mark-small { width: 42px; height: 42px; border-radius: 14px; }
.brand-mark-small::before { width: 19px; height: 19px; border-width: 2px; }
.brand-mark-small span { width: 7px; height: 7px; border-width: 2px; }

/* Login */
.login-body { display: grid; place-items: center; padding: 32px; overflow-x: hidden; }
.login-body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: 0.28;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, #000, transparent 88%);
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.72fr);
  width: min(1040px, 100%);
  min-height: 650px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: rgba(8, 20, 34, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.login-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(48px, 7vw, 88px);
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(26, 63, 87, 0.68), rgba(11, 28, 48, 0.7)),
    radial-gradient(circle at 20% 20%, rgba(49, 221, 189, 0.24), transparent 36%);
}

.login-visual::after {
  position: absolute;
  width: 340px;
  height: 340px;
  left: -150px;
  bottom: -150px;
  content: "";
  border: 1px solid rgba(74, 232, 204, 0.22);
  border-radius: 50%;
  box-shadow: 0 0 0 48px rgba(74, 232, 204, 0.025), 0 0 0 96px rgba(74, 232, 204, 0.02);
}

.login-visual .brand-mark { margin-bottom: 42px; }
.login-visual h1 { margin: 0; font-size: clamp(3rem, 6vw, 5.2rem); letter-spacing: -0.08em; }
.login-lead { max-width: 560px; margin: 20px 0 46px; color: #b9cbd4; font-size: 1.05rem; line-height: 2; }
.security-points { display: grid; gap: 16px; }
.security-points div { display: flex; align-items: center; gap: 14px; color: #ccdbdf; }
.security-points i {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(49, 221, 189, 0.26);
  border-radius: 10px;
  color: var(--primary);
  font-size: 0.68rem;
  font-style: normal;
}

.login-card { align-self: center; padding: clamp(34px, 5vw, 62px); }
.login-card-head { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.login-card h2 { margin: 0; font-size: 1.75rem; }
.lock-badge { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 15px; color: var(--primary); background: rgba(49, 221, 189, 0.1); }
.login-form { display: grid; gap: 11px; margin-top: 32px; }
.login-form label, .composer-panel label, .route-form label { margin-top: 8px; color: #d5e2e6; font-size: 0.84rem; font-weight: 700; }
.field-wrap { position: relative; }
.field-wrap span { position: absolute; top: 50%; right: 17px; color: var(--primary); font-size: 0.65rem; transform: translateY(-50%); }
.field-wrap input { width: 100%; padding-right: 44px; }
.login-foot { margin: 22px 0 0; color: #718a99; font-size: 0.76rem; text-align: center; }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
  color: var(--text);
  background: rgba(5, 15, 27, 0.62);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
input, select { height: 49px; padding: 0 15px; }
textarea { padding: 14px 15px; line-height: 1.9; resize: vertical; }
input::placeholder, textarea::placeholder { color: #587080; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); background: rgba(7, 22, 35, .9); box-shadow: 0 0 0 3px rgba(49, 221, 189, .09); }
select { cursor: pointer; }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 800;
  transition: transform .18s ease, filter .18s ease, border-color .18s ease;
}
.button:hover { transform: translateY(-1px); filter: brightness(1.06); }
.button:disabled { cursor: wait; opacity: .55; transform: none; }
.button-primary { margin-top: 16px; color: #05231e; background: linear-gradient(135deg, #50e4c8, #28c5a7); box-shadow: 0 10px 28px rgba(30, 192, 161, .18); }
.button-secondary { border-color: rgba(87, 218, 197, .28); color: #cffff5; background: rgba(38, 166, 145, .13); }
.button-ghost { border-color: var(--line); color: #bdd0d7; background: rgba(255, 255, 255, .025); }
.button-block { width: 100%; }

.alert { margin: 18px 0; padding: 13px 15px; border: 1px solid var(--line); border-radius: 13px; font-size: .84rem; line-height: 1.75; }
.alert-error { border-color: rgba(255, 127, 145, .28); color: #ffd1d8; background: rgba(255, 72, 99, .09); }
.alert-warning { border-color: rgba(255, 201, 107, .28); color: #ffe4b5; background: rgba(255, 177, 44, .08); }
.alert-success { border-color: rgba(88, 224, 162, .28); color: #caffea; background: rgba(46, 198, 127, .08); }
.alert code, .field-help code { direction: ltr; color: #9ef3e2; }

/* Dashboard */
.dashboard-body { position: relative; min-width: 320px; overflow-x: hidden; }
.ambient { position: fixed; z-index: -1; width: 380px; height: 380px; border-radius: 50%; filter: blur(110px); opacity: .14; }
.ambient-one { top: 150px; right: -180px; background: #2be1bd; }
.ambient-two { bottom: 0; left: -200px; background: #397ee5; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  padding: 10px max(24px, calc((100vw - 1280px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 29, .82);
  backdrop-filter: blur(20px);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand > span:last-child { display: flex; flex-direction: column; gap: 3px; }
.brand b { font-size: 1.05rem; }
.brand small { color: var(--muted); font-size: .68rem; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.live-pill, .auto-refresh { padding: 8px 11px; border: 1px solid rgba(58, 218, 171, .18); border-radius: 999px; color: #aeead6; background: rgba(38, 174, 129, .08); font-size: .72rem; }
.live-pill i { display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 10px var(--success); }
.admin-name { color: #abc0ca; font-size: .78rem; }
.icon-button { min-height: 38px; padding: 0 13px; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; color: #c4d6dc; background: rgba(255,255,255,.025); }

.page-shell { width: min(1280px, calc(100% - 48px)); margin: 0 auto; padding: 54px 0 80px; }
.hero-row { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.hero-row h1 { margin: 0; font-size: clamp(1.8rem, 3.2vw, 3.1rem); letter-spacing: -.045em; }
.hero-row p:not(.eyebrow) { max-width: 700px; margin: 16px 0 0; color: var(--muted); line-height: 1.9; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
.stat-card { position: relative; display: grid; min-height: 132px; padding: 21px; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: rgba(14, 29, 46, .64); box-shadow: 0 12px 40px rgba(0,0,0,.13); }
.stat-card span { color: #aec0c8; font-size: .78rem; }
.stat-card strong { align-self: center; font-size: 2.15rem; letter-spacing: -.04em; }
.stat-card small { color: #718b9a; font-size: .68rem; }
.stat-accent { border-color: rgba(49, 221, 189, .24); background: linear-gradient(145deg, rgba(34, 114, 105, .25), rgba(14, 29, 46, .68)); }
.stat-accent::after { position: absolute; width: 96px; height: 96px; top: -48px; left: -42px; content: ""; border-radius: 50%; background: var(--primary); filter: blur(38px); opacity: .18; }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 16px 50px rgba(0,0,0,.16); backdrop-filter: blur(15px); }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); gap: 20px; }
.composer-panel, .preview-panel, .route-panel, .jobs-panel { padding: clamp(20px, 3vw, 30px); }
.panel-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 25px; }
.panel-head h2 { margin: 0; font-size: 1.25rem; }
.step-badge { display: grid; width: 35px; height: 35px; place-items: center; flex: 0 0 auto; border: 1px solid var(--line-bright); border-radius: 11px; color: var(--primary); background: rgba(49,221,189,.07); font-size: .8rem; font-weight: 900; }
.composer-panel form, .route-form { display: grid; gap: 10px; }
.field-help { margin: 1px 0 8px; color: #708b99; font-size: .72rem; line-height: 1.75; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.field-grid > div { display: grid; gap: 10px; }
.field-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.counter { margin-top: -5px; direction: rtl; color: #698392; font-size: .69rem; text-align: left; }

.source-switch { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; margin: 6px 0; padding: 4px; border: 1px solid var(--line); border-radius: 13px; background: rgba(3, 12, 22, .55); }
.source-tab { min-height: 40px; border: 0; border-radius: 9px; cursor: pointer; color: #819aa7; background: transparent; font-size: .78rem; font-weight: 800; }
.source-tab.active { color: #dcfff8; background: rgba(49,221,189,.12); box-shadow: inset 0 0 0 1px rgba(49,221,189,.15); }
.source-pane { display: none; }
.source-pane.active { display: block; }

.drop-zone { display: grid; min-height: 140px; place-items: center; align-content: center; gap: 8px; margin: 0 !important; border: 1px dashed rgba(108, 209, 193, .3); border-radius: 16px; cursor: pointer; color: #cce3e4; background: rgba(28, 85, 85, .07); transition: border-color .2s, background .2s; }
.drop-zone:hover, .drop-zone.has-file { border-color: var(--primary); background: rgba(49,221,189,.09); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone small { color: #7894a0; font-size: .7rem; }
.drop-icon { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 12px; color: var(--primary); background: rgba(49,221,189,.1); font-size: 1.15rem; }

.phone-frame { overflow: hidden; border: 1px solid rgba(151, 194, 207, .17); border-radius: 20px; background: linear-gradient(170deg, #10263a, #0a1a2a); box-shadow: inset 0 1px rgba(255,255,255,.025), 0 22px 50px rgba(0,0,0,.23); }
.post-head { display: flex; align-items: center; gap: 11px; padding: 15px; }
.channel-avatar { display: grid; width: 41px; height: 41px; place-items: center; border-radius: 50%; color: #05251f; background: linear-gradient(145deg, #61edd1, #2bc1a4); font-weight: 900; }
.post-head > span:nth-child(2) { display: flex; flex-direction: column; gap: 4px; }
.post-head b { font-size: .84rem; }
.post-head small { color: #758e9d; font-size: .64rem; }
.post-head i { margin-right: auto; color: #66808f; font-style: normal; letter-spacing: .12em; }
.video-preview { position: relative; display: grid; min-height: 230px; place-items: center; align-content: center; gap: 28px; overflow: hidden; background: radial-gradient(circle at 50% 32%, rgba(65,205,181,.18), transparent 33%), linear-gradient(135deg, #163653, #0b2136); }
.video-preview::before { position: absolute; inset: 0; content: ""; opacity: .18; background-image: linear-gradient(120deg, transparent 48%, rgba(255,255,255,.08) 49%, transparent 51%); background-size: 40px 40px; }
.play-button { z-index: 1; display: grid; width: 56px; height: 56px; place-items: center; padding-right: 3px; border: 1px solid rgba(255,255,255,.32); border-radius: 50%; color: #06231e; background: rgba(82,231,203,.92); box-shadow: 0 10px 35px rgba(49,221,189,.25); }
.video-preview small { z-index: 1; max-width: 80%; overflow: hidden; color: #9db4bd; text-overflow: ellipsis; white-space: nowrap; }
.caption-preview { min-height: 160px; margin: 0; padding: 18px; overflow: auto; color: #dfebed; font: .82rem/2 Tahoma, sans-serif; text-align: right; white-space: pre-wrap; word-break: break-word; }
.post-meta { display: flex; align-items: center; gap: 14px; padding: 0 18px 18px; color: #79929f; }
.post-meta small { margin-right: auto; font-size: .62rem; }
.destination-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.destination-chips span { padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; color: #9db4be; background: rgba(255,255,255,.025); font-size: .68rem; }

.route-panel, .jobs-panel { margin-top: 20px; }
.route-form { padding-top: 4px; border-top: 1px solid var(--line); }
.route-form > *:first-child { margin-top: 18px; }
.jobs-panel { padding-bottom: 10px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 15px 12px; border-top: 1px solid var(--line); text-align: right; font-size: .76rem; }
th { color: #748e9b; font-size: .68rem; font-weight: 700; }
td { color: #bcd0d6; }
.job-title { display: flex; max-width: 320px; flex-direction: column; gap: 5px; }
.job-title b { overflow: hidden; color: #e4eff1; text-overflow: ellipsis; white-space: nowrap; }
.job-title small { direction: ltr; color: #607987; }
.status-chip { display: inline-flex; padding: 6px 9px; border-radius: 999px; font-size: .65rem; font-weight: 800; }
.status-succeeded { color: #bfffe0; background: rgba(47,202,128,.12); }
.status-processing, .status-queued, .status-retrying { color: #c8e5ff; background: rgba(67,151,237,.12); }
.status-failed, .status-partially_failed { color: #ffd0d7; background: rgba(240,80,104,.12); }
.retry-button { min-height: 31px; padding: 0 10px; border: 1px solid rgba(255,127,145,.2); border-radius: 9px; cursor: pointer; color: #ffc3cd; background: rgba(255,95,120,.07); font-size: .68rem; }
.empty-state { height: 100px; color: #6f8996; text-align: center; }

.toast { position: fixed; z-index: 50; right: 24px; bottom: 24px; max-width: min(420px, calc(100vw - 48px)); padding: 14px 18px; border: 1px solid var(--line-bright); border-radius: 13px; color: #dffbf5; background: #102c36; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(18px); transition: opacity .2s, transform .2s; }
.toast.error { border-color: rgba(255,127,145,.4); color: #ffd7dd; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 940px) {
  .login-shell { grid-template-columns: 1fr; width: min(560px, 100%); }
  .login-visual { min-height: 310px; padding: 42px; }
  .login-visual .brand-mark { margin-bottom: 26px; }
  .login-visual h1 { font-size: 3.4rem; }
  .login-lead { margin: 12px 0 20px; }
  .security-points { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .workspace-grid { grid-template-columns: 1fr; }
  .preview-panel { order: 2; }
}

@media (max-width: 640px) {
  .login-body { padding: 14px; }
  .login-shell { min-height: auto; border-radius: 22px; }
  .login-visual { min-height: 250px; padding: 30px; }
  .login-lead { font-size: .88rem; }
  .login-card { padding: 30px; }
  .topbar { min-height: 66px; padding: 9px 16px; }
  .brand small, .admin-name, .live-pill { display: none; }
  .page-shell { width: min(100% - 28px, 1280px); padding-top: 34px; }
  .hero-row { align-items: start; flex-direction: column; }
  .hero-row .button { width: 100%; }
  .stats-grid { gap: 9px; }
  .stat-card { min-height: 112px; padding: 16px; }
  .stat-card strong { font-size: 1.7rem; }
  .composer-panel, .preview-panel, .route-panel, .jobs-panel { padding: 18px; border-radius: 17px; }
  .field-grid, .field-grid-three { grid-template-columns: 1fr; }
  .video-preview { min-height: 190px; }
  .panel-head { align-items: center; }
  .route-panel .panel-head { align-items: start; flex-direction: column; }
  .route-panel .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
