:root {
  --bg: #eef2f6;
  --card: #ffffff;
  --line: #d7dee8;
  --text: #182230;
  --muted: #5f6f85;
  --accent: #0b5fd7;
  --accent-strong: #0849a8;
  --error-bg: #ffe9ea;
  --error-border: #ffb6bc;
  --error-text: #9f1d2a;
}

:root[data-theme="dark"] {
  --bg: #0f1723;
  --card: #131f2f;
  --line: #2a3a4f;
  --text: #e6edf7;
  --muted: #93a6bf;
  --accent: #66b2ff;
  --accent-strong: #3d95ee;
  --error-bg: #3a1f22;
  --error-border: #7c3942;
  --error-text: #ffb8be;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top right, #f8fbff 0%, var(--bg) 70%);
}

:root[data-theme="dark"] body {
  background: radial-gradient(circle at top right, #18263b 0%, var(--bg) 70%);
}

.topbar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  background: #fff;
}

h1 {
  margin: 0;
  font-size: 1.25rem;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.container {
  max-width: 1000px;
  margin: 16px auto;
  padding: 0 16px 16px;
  display: grid;
  gap: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 14px;
}

.controls label {
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}

.controls label + .input-row,
.controls .input-row + label {
  margin-bottom: 10px;
}

.input-row {
  display: flex;
  gap: 8px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.95rem;
  background: var(--card);
  color: var(--text);
}

.btn {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
}

.btn:hover {
  background: var(--accent-strong);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-secondary:hover {
  background: color-mix(in srgb, var(--card) 75%, var(--line));
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.breadcrumbs button {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
}

.status {
  color: var(--muted);
  margin: 8px 0 10px;
}

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

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

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  white-space: nowrap;
}

.th-btn {
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.th-btn:hover {
  color: var(--accent);
}

td a,
td button.link,
.icon-btn {
  color: var(--accent);
  text-decoration: none;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

td.actions .actions-grid {
  display: grid;
  grid-template-columns: repeat(4, 20px);
  gap: 10px;
  justify-content: start;
}

td.actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  width: 20px;
  height: 20px;
}

.icon-slot {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px dashed var(--line);
  opacity: 0.5;
}

.icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  vertical-align: middle;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
  white-space: normal;
  padding: 18px 10px;
}

.error {
  margin-top: 12px;
  border: 1px solid var(--error-border);
  background: var(--error-bg);
  color: var(--error-text);
  border-radius: 8px;
  padding: 12px;
}

.error-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.error-msg {
  margin-bottom: 10px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(900px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1rem;
}

#closePreviewBtn {
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
}

#previewVideo {
  width: 100%;
  max-height: min(70vh, 700px);
  display: block;
  background: #000;
}

@media (max-width: 700px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions,
  .input-row {
    flex-direction: column;
    width: 100%;
  }

  .btn {
    width: 100%;
  }
}
