:root {
  --bg: #07111f;
  --panel: rgba(11, 24, 40, 0.9);
  --panel-soft: rgba(255, 255, 255, 0.03);
  --line: rgba(138, 190, 255, 0.16);
  --line-strong: rgba(138, 190, 255, 0.34);
  --text: #eff6ff;
  --muted: #9db4cf;
  --accent: #75f0c7;
  --accent-strong: #38d39f;
  --danger: #ff8d6b;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI Variable Display", "Bahnschrift", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(85, 181, 255, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(117, 240, 199, 0.14), transparent 24%),
    linear-gradient(135deg, #06101b 0%, #0a1526 42%, #081523 100%);
  color: var(--text);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.background-glow {
  position: fixed;
  width: 34rem;
  height: 34rem;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.24;
  pointer-events: none;
}

.background-glow-left {
  top: -10rem;
  left: -12rem;
  background: #37d4ff;
}

.background-glow-right {
  right: -10rem;
  bottom: -10rem;
  background: #4bf0b6;
}

.shell {
  position: relative;
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-panel {
  width: min(520px, 100%);
  margin: 10vh auto 0;
  padding: 36px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(117, 240, 199, 0.08);
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.stack-form,
.inline-form,
.workspace-form,
.assign-form {
  display: grid;
  gap: 16px;
}

.stack-form {
  margin-top: 28px;
}

.inline-form {
  grid-template-columns: 1fr auto;
  margin-top: 20px;
}

.workspace-form {
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
  align-items: end;
}

.assign-form {
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field input,
.inline-form input,
select {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.field input:focus,
.inline-form input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.06);
}

select option {
  background: #1a1f2e;
  color: var(--text);
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 13px 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

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

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.button-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #37d4ff 100%);
  color: #052033;
}

.button-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.button-danger {
  background: rgba(255, 141, 107, 0.15);
  color: #ffd0c4;
  border: 1px solid rgba(255, 141, 107, 0.22);
}

.compact-button {
  padding: 10px 14px;
  font-size: 12px;
}

.dashboard {
  display: grid;
  gap: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 28px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.topbar-location {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
}

.topbar-location .eyebrow {
  font-size: 10px;
  opacity: 0.45;
  border-color: transparent;
  background: transparent;
  padding: 2px 0;
}

.topbar-location h3 {
  margin-top: 6px;
  color: var(--accent);
  font-size: 1.2rem;
  max-width: 420px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.content-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
}

.sidebar,
.workspace {
  padding: 24px;
}

.sidebar {
  display: grid;
  align-content: start;
  gap: 16px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.sidebar-search {
  gap: 8px;
}

.locations-list,
.table-body {
  display: grid;
  gap: 12px;
}

.view-section {
  display: grid;
  gap: 18px;
}

.workspace-stack {
  display: grid;
  gap: 18px;
}

.workspace-panel {
  display: grid;
  gap: 16px;
  padding: 20px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--panel-soft);
}

.location-card,
.empty-state,
.table-row {
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.035);
}

.location-card {
  width: 100%;
  padding: 16px 18px;
  text-align: left;
  color: var(--text);
}

.location-card span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.location-current-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(117, 240, 199, 0.14);
  border: 1px solid rgba(117, 240, 199, 0.24);
  color: var(--accent);
  font-size: 12px;
}

.location-card.active {
  border-color: var(--accent-strong);
  background: rgba(117, 240, 199, 0.1);
}

.location-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
}

.location-delete-button {
  align-self: center;
}

.table-wrap {
  display: grid;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.table-wrap-assigned {
  overflow-x: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.table-toolbar p {
  margin: 0;
  color: var(--muted);
  max-width: 720px;
}

.table-toolbar-assigned {
  padding: 0 2px;
}

.assign-library-panel {
  display: grid;
  gap: 14px;
}

.assign-library-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.assign-library-label {
  display: inline-flex;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.assign-library-head p {
  margin-top: 8px;
  color: var(--muted);
  max-width: 720px;
}

.workspace-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.workspace-actions .button {
  min-width: 220px;
}

.editor-note {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.checkbox-list {
  display: grid;
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.checkbox-toggle-all {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--text);
}

.checkbox-toggle-all input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.checkbox-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.checkbox-card {
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: border-color 160ms ease, background 160ms ease;
}

.checkbox-card:hover {
  border-color: rgba(117, 240, 199, 0.26);
  background: rgba(117, 240, 199, 0.08);
}

.checkbox-card-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.checkbox-card-main strong,
.checkbox-card-main small {
  overflow-wrap: anywhere;
}

.checkbox-card-main small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.checkbox-item input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.checkbox-list-empty {
  color: var(--muted);
  padding: 8px 4px;
}

.table-head,
.table-row {
  display: grid;
  gap: 14px;
  align-items: start;
}

.assigned-head,
.assigned-row {
  grid-template-columns: 80px minmax(0, 1.5fr) 120px 180px 120px;
}

.library-head-row,
.library-row {
  grid-template-columns: 90px minmax(260px, 1.1fr) minmax(260px, 1fr) 220px;
  min-width: 920px;
}

.table-head {
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.table-row {
  padding: 16px 18px;
}

.table-cell {
  min-width: 0;
}

.table-id {
  display: flex;
  align-items: center;
}

.table-id,
.table-name strong {
  overflow-wrap: anywhere;
}

.table-name {
  display: grid;
  gap: 6px;
}

.table-file {
  display: grid;
  gap: 6px;
}

.table-file-name {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.duration-editor {
  display: grid;
  gap: 6px;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.ad-link {
  color: var(--accent);
  text-decoration: none;
}

.ad-link:hover {
  text-decoration: underline;
}

.compact-field input {
  padding: 12px 14px;
}

.order-stack {
  display: grid;
  gap: 8px;
}

.order-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

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

.assigned-row {
  cursor: grab;
  grid-template-columns: 88px minmax(0, 1.7fr) 160px 180px 130px;
}

.assigned-row.is-dragging {
  opacity: 0.45;
}

.assigned-row.is-drop-target {
  border-color: var(--accent-strong);
  background: rgba(117, 240, 199, 0.12);
}

.empty-state {
  min-height: 220px;
  display: grid;
  place-content: center;
  padding: 28px;
  text-align: center;
  gap: 14px;
  color: var(--muted);
}

.compact-empty {
  min-height: 160px;
}

body.modal-open {
  overflow: hidden;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 10, 18, 0.82);
  backdrop-filter: blur(6px);
}

.preview-dialog {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  max-height: min(90vh, 920px);
  display: grid;
  gap: 16px;
  padding: 18px;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 18, 30, 0.96);
  box-shadow: var(--shadow);
}

.preview-close {
  justify-self: end;
  padding: 10px 14px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
}

.preview-content {
  min-height: 240px;
  display: grid;
  place-items: center;
}

.preview-media {
  max-width: 100%;
  max-height: calc(90vh - 120px);
  border-radius: 18px;
  background: #000;
}

.preview-image {
  object-fit: contain;
}

.preview-video {
  width: 100%;
}

.preview-fallback {
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100% - 24px));
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(5, 17, 31, 0.9);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}

.toast.error {
  border-color: rgba(255, 141, 107, 0.4);
  color: #ffd7cc;
}

@media (max-width: 1100px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .workspace-form,
  .assign-form,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .assign-library-head,
  .workspace-actions {
    align-items: stretch;
  }

  .table-toolbar {
    align-items: stretch;
  }

  .table-toolbar .button {
    width: 100%;
  }

  .assigned-head,
  .assigned-row {
    grid-template-columns: 72px minmax(0, 1fr) 130px 160px 110px;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 100%);
    padding-top: 16px;
  }

  .auth-panel,
  .topbar,
  .sidebar,
  .workspace {
    padding: 20px;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .row-actions,
  .order-actions,
  .workspace-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .table-head {
    display: none;
  }

  .table-wrap {
    overflow: visible;
  }

  .table-row,
  .assigned-row,
  .library-row {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .table-actions {
    justify-content: stretch;
  }

  .location-row {
    grid-template-columns: 1fr;
  }

  .preview-modal {
    padding: 14px;
  }

  .preview-dialog {
    padding: 14px;
  }
}
