:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --line: #d8dee8;
  --line-strong: #b9c3d3;
  --text: #18202c;
  --muted: #667085;
  --blue: #2369d1;
  --blue-dark: #174ea6;
  --green: #14804a;
  --orange: #b35c00;
  --red: #b42318;
  --teal: #0f766e;
  --shadow: 0 10px 28px rgba(23, 34, 54, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 208px minmax(0, 1fr);
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  overflow-x: hidden;
}

.sidebar {
  background: #fbfbfc;
  border-right: 1px solid var(--line);
  padding: 16px 16px 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 28px;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
  padding-top: 22px;
}

.nav-item {
  height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #253044;
  text-align: left;
  padding: 0 14px;
}

.nav-item:hover,
.nav-item.is-active {
  background: #e9f0fb;
  border-color: #c2d5f2;
  color: var(--blue-dark);
}

.workspace {
  padding: 26px 28px 42px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.crumb {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 30px;
  font-weight: 650;
}

h2 {
  font-size: 18px;
  font-weight: 650;
}

.top-actions,
.form-row,
.table-filters {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section {
  margin-bottom: 22px;
  min-width: 0;
  max-width: 100%;
}

.section[hidden] {
  display: none !important;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.panel,
.table-wrap,
.log-list {
  min-width: 0;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 18px;
}

.panel-title,
.table-toolbar,
.log-head,
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-title {
  margin-bottom: 0;
}

label {
  display: grid;
  gap: 7px;
  color: #2f394b;
  font-size: 14px;
}

input,
select {
  height: 38px;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 11px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 105, 209, 0.14);
}

.manual-form {
  display: grid;
  gap: 14px;
}

.setting-grid,
.secret-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.setting-grid.single {
  grid-template-columns: 1fr;
}

.secret-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.path-field {
  grid-column: span 2;
}

.settings-wide {
  box-shadow: none;
}

.sync-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 14px;
}

.sync-status strong {
  color: var(--text);
  font-weight: 600;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn,
.row-btn {
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 13px;
  white-space: nowrap;
}

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

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

.secondary-btn {
  background: #0f766e;
  color: #fff;
}

.secondary-btn:hover {
  background: #0b615b;
}

.ghost-btn,
.icon-btn,
.row-btn {
  background: #fff;
  border-color: var(--line-strong);
  color: #253044;
}

.ghost-btn:hover,
.icon-btn:hover,
.row-btn:hover {
  border-color: var(--blue);
  color: var(--blue-dark);
}

.row-btn.danger:hover {
  border-color: var(--red);
  color: var(--red);
}

.badge,
.counter,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
}

.badge-ok,
.status-completed,
.status-uploaded {
  background: #e7f6ee;
  color: var(--green);
}

.badge-warn,
.status-cloud,
.status-queued,
.status-downloading,
.status-transcoding {
  background: #fff4e5;
  color: var(--orange);
}

.status-failed {
  background: #fdecec;
  color: var(--red);
}

.status-cloud_deleted {
  background: #f1f5f9;
  color: #475467;
}

.counter {
  background: #eef2f7;
  color: #475467;
}

.inline-msg {
  min-width: 120px;
  color: var(--muted);
  font-size: 13px;
}

.switch {
  display: inline-flex;
  align-items: center;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  position: relative;
  width: 48px;
  height: 26px;
  border-radius: 999px;
  background: #c8d0dc;
  transition: 0.16s;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  transition: 0.16s;
}

.switch input:checked + span {
  background: var(--green);
}

.switch input:checked + span::after {
  transform: translateX(22px);
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: end;
  min-height: 38px;
}

.check-line input {
  width: 17px;
  height: 17px;
}

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 62px;
  padding: 0 0 12px;
}

.table-toolbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.table-filters select {
  width: 128px;
}

.table-filters {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.table-filters input {
  width: 220px;
}

.table-wrap {
  overflow-x: hidden;
  box-shadow: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 0;
}

.col-check {
  width: 40px;
}

.col-name {
  width: 23%;
}

.col-created {
  width: 156px;
}

.col-duration {
  width: 86px;
}

.col-source {
  width: auto;
}

.col-format {
  width: 58px;
}

.col-size {
  width: 88px;
}

.col-status {
  width: 92px;
}

.col-progress {
  width: 128px;
}

.col-actions {
  width: 176px;
}

.col-actions-wide {
  width: 182px;
}

th,
td {
  border-bottom: 1px solid #edf0f4;
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  height: 44px;
  background: #f8fafc;
  color: #4b5565;
  font-weight: 650;
}

td {
  color: #253044;
}

td:not(:last-child) {
  overflow: hidden;
}

.check-cell,
th:first-child {
  padding-left: 8px;
  padding-right: 6px;
  text-align: center;
}

.check-cell input,
th:first-child input {
  width: 16px;
  height: 16px;
}

.truncate {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-line {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.progress {
  display: grid;
  grid-template-columns: 1fr 42px;
  align-items: center;
  gap: 8px;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: #e7ebf1;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--blue), var(--teal));
}

.progress span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.upload-progress {
  display: grid;
  gap: 8px;
}

.upload-progress-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.upload-table-toolbar {
  margin-top: 18px;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
}

.row-btn {
  min-height: 30px;
  min-width: 42px;
  padding: 0 8px;
  font-size: 13px;
}

.m3u8-table .col-name {
  width: 24%;
}

.m3u8-table .col-source {
  width: auto;
}

.m3u8-address {
  color: var(--blue-dark);
}

.empty-cell {
  height: 96px;
  color: var(--muted);
  text-align: center;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-height: 54px;
  color: var(--muted);
  font-size: 13px;
}

.page-size-label {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
}

.page-size-label select {
  width: 88px;
}

.log-head {
  margin-bottom: 10px;
}

.log-head span {
  color: var(--muted);
  font-size: 13px;
}

.log-list {
  display: grid;
  max-height: 300px;
  overflow: auto;
  box-shadow: none;
}

.log-row {
  display: grid;
  grid-template-columns: 156px 70px 1fr;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #edf0f4;
  font-size: 13px;
}

.log-row:last-child {
  border-bottom: 0;
}

.log-time,
.log-level {
  color: var(--muted);
}

.log-level.ERROR {
  color: var(--red);
  font-weight: 700;
}

.log-level.WARN {
  color: var(--orange);
  font-weight: 700;
}

.log-level.INFO {
  color: var(--green);
  font-weight: 700;
}

dialog {
  width: min(960px, calc(100vw - 60px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(17, 24, 39, 0.28);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.46);
}

.dialog-head {
  height: 54px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

video {
  display: block;
  width: 100%;
  max-height: 70vh;
  background: #111827;
}

@media (max-width: 1500px) {
  .control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    border-bottom: 0;
    padding-bottom: 0;
  }

  .nav {
    display: flex;
    padding-top: 0;
    overflow: auto;
  }

  .nav-item {
    text-align: center;
  }

  .workspace {
    padding: 20px 16px 34px;
  }

  .control-grid,
  .secret-grid {
    grid-template-columns: 1fr;
  }

  .path-field {
    grid-column: auto;
  }

  .table-wrap {
    overflow-x: auto;
  }

  table {
    min-width: 1120px;
  }
}
