:root {
  color: #1e2732;
  background: #eef1f4;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #172033;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  padding: 22px;
  gap: 22px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: #2da58d;
  color: white;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.profile small,
.muted {
  color: #738092;
}

.sidebar .brand small,
.profile small {
  color: #b8c1cc;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-group {
  display: grid;
  gap: 6px;
}

.nav-subnav {
  display: grid;
  gap: 4px;
  padding-left: 12px;
}

.nav-subgroup {
  display: grid;
  gap: 4px;
  margin-top: 2px;
}

.nav-subgroup-title {
  color: #8fa0b6;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 10px 0;
}

.nav-subgroup-items {
  display: grid;
  gap: 4px;
  padding-left: 8px;
}

.nav-button {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  background: transparent;
  color: #d8dee7;
  text-align: left;
}

.nav-master {
  font-weight: 850;
}

.nav-nested {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
}

.nav-button.active,
.nav-button:hover {
  background: #25324a;
  color: #ffffff;
}

.profile {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.workspace {
  padding: 24px;
  overflow: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

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

.client-filter-field {
  min-width: 220px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 16, 26, 0.48);
  backdrop-filter: blur(6px);
}

.loading-card {
  width: min(360px, 100%);
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
  padding: 26px 24px 22px;
  border-radius: 18px;
  border: 1px solid rgba(156, 219, 205, 0.28);
  background:
    radial-gradient(circle at top, rgba(45, 165, 141, 0.22), transparent 52%),
    linear-gradient(180deg, #102133 0%, #162b3f 100%);
  box-shadow: 0 22px 48px rgba(4, 10, 18, 0.35);
  color: #f3fbfb;
}

.loading-card strong {
  font-size: 20px;
  letter-spacing: 0.01em;
}

.loading-card p {
  margin: 0;
  color: #c7d9df;
  font-size: 14px;
}

.loading-visual {
  position: relative;
  width: 168px;
  height: 148px;
  display: grid;
  place-items: center;
}

.loading-ring {
  position: absolute;
  border: 1px solid rgba(116, 244, 215, 0.34);
  border-radius: 999px;
  animation: loader-pulse 2.4s ease-in-out infinite;
}

.loading-ring-a {
  width: 132px;
  height: 132px;
}

.loading-ring-b {
  width: 104px;
  height: 104px;
  animation-delay: 0.35s;
}

.loading-ring-c {
  width: 76px;
  height: 76px;
  animation-delay: 0.7s;
}

.loading-mic {
  position: relative;
  width: 56px;
  height: 86px;
  display: grid;
  justify-items: center;
  z-index: 1;
}

.loading-mic-head {
  width: 34px;
  height: 42px;
  border-radius: 18px;
  background: linear-gradient(180deg, #73f0d6 0%, #2da58d 100%);
  box-shadow: 0 0 18px rgba(74, 229, 193, 0.35);
}

.loading-mic-stem {
  width: 8px;
  height: 22px;
  margin-top: 5px;
  border-radius: 999px;
  background: #d8f6ef;
}

.loading-mic-base {
  width: 34px;
  height: 12px;
  margin-top: 4px;
  border-radius: 999px;
  border: 2px solid #d8f6ef;
  border-top: 0;
}

.loading-bars {
  position: absolute;
  bottom: 14px;
  display: flex;
  align-items: flex-end;
  gap: 7px;
}

.loading-bars span {
  width: 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, #89f6df 0%, #2da58d 100%);
  animation: loader-wave 0.95s ease-in-out infinite;
}

.loading-bars span:nth-child(1) {
  height: 18px;
  animation-delay: 0s;
}

.loading-bars span:nth-child(2) {
  height: 30px;
  animation-delay: 0.08s;
}

.loading-bars span:nth-child(3) {
  height: 42px;
  animation-delay: 0.16s;
}

.loading-bars span:nth-child(4) {
  height: 30px;
  animation-delay: 0.24s;
}

.loading-bars span:nth-child(5) {
  height: 18px;
  animation-delay: 0.32s;
}

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

h1 {
  font-size: 28px;
  line-height: 1.2;
  margin-bottom: 4px;
}

h2 {
  font-size: 18px;
  margin-bottom: 14px;
}

h3 {
  font-size: 14px;
  color: #485465;
  margin-bottom: 8px;
}

.content-band,
.split-layout {
  display: grid;
  gap: 18px;
}

.split-layout {
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
  align-items: start;
}

.split-layout.wide-right {
  grid-template-columns: minmax(420px, 0.95fr) minmax(440px, 1.05fr);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.metric,
.table-panel,
.panel-form,
.detail-panel,
.login-panel {
  background: #ffffff;
  border: 1px solid #d7dde5;
  border-radius: 8px;
}

.metric {
  padding: 14px;
}

.metric span {
  display: block;
  color: #5f6f81;
  font-size: 13px;
}

.metric strong {
  font-size: 28px;
}

.table-panel,
.panel-form,
.detail-panel {
  padding: 18px;
}

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

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

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

label {
  display: grid;
  gap: 6px;
  color: #435064;
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd3dd;
  border-radius: 8px;
  padding: 10px 11px;
  background: #ffffff;
  color: #182230;
}

textarea {
  min-height: 180px;
  resize: vertical;
}

.small-textarea {
  min-height: 80px;
}

.file-input {
  margin: 8px 0 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  min-width: 960px;
}

th,
td {
  border-bottom: 1px solid #e4e8ee;
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: break-word;
}

th {
  color: #687789;
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
.selected-row {
  background: #f2f6f8;
}

.empty-row {
  color: #758397;
  text-align: center;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.action-grid button {
  min-height: 40px;
  border-radius: 8px;
  padding: 9px 13px;
  font-weight: 750;
}

.primary-button {
  background: #217c69;
  color: white;
}

.secondary-button,
.action-grid button {
  background: #e8edf2;
  color: #1e2b3b;
}

.ghost-button {
  background: transparent;
  border: 1px solid #40506a;
  color: #f8fafc;
}

.danger-button {
  background: #b3404a;
  color: white;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
}

.pagination-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.voice-preview-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.csv-reference {
  display: grid;
  gap: 14px;
  margin: 14px 0;
}

.csv-reference-block {
  display: grid;
  gap: 8px;
}

.csv-reference-title {
  color: #4a5a6d;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.csv-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.csv-chip-grid.compact .csv-chip {
  min-width: 135px;
  padding: 7px 9px;
}

.csv-chip {
  min-width: 170px;
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid #d7dde5;
  border-radius: 8px;
  background: #f5f8fb;
}

.csv-chip strong {
  font-size: 12px;
  color: #172232;
}

.csv-chip small {
  color: #6a7889;
  font-size: 11px;
}

.voice-player {
  flex: 1 1 260px;
  min-width: 220px;
  height: 40px;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.detail-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: 34px 22px;
  background: rgba(11, 18, 32, 0.58);
  overflow: auto;
}

.detail-panel {
  max-height: calc(100vh - 112px);
  overflow: auto;
}

.detail-modal {
  width: min(1040px, 100%);
  max-height: calc(100vh - 68px);
  box-shadow: 0 24px 72px rgba(9, 18, 31, 0.35);
  position: relative;
}

.modal-close {
  position: sticky;
  top: 0;
  margin-left: auto;
  display: block;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #e8edf2;
  color: #1e2b3b;
  font-weight: 750;
  z-index: 1;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.detail-section {
  border-top: 1px solid #e6eaf0;
  padding-top: 14px;
  margin-top: 14px;
}

.video-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #111827;
  border-radius: 8px;
}

.video-block {
  display: grid;
  gap: 8px;
}

.video-link {
  color: #217c69;
  font-weight: 750;
}

.scene-list {
  display: grid;
  gap: 10px;
}

.scene-item {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px;
  align-items: start;
}

.scene-item img {
  grid-row: span 2;
  width: 96px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid #d7dde5;
  border-radius: 6px;
}

.scene-item span {
  font-weight: 800;
}

.scene-item p {
  margin: 0;
  color: #4b5b6d;
}

.asset-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.asset-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid #e4e8ee;
  border-radius: 8px;
  padding: 8px 10px;
}

.publish-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.publish-state {
  display: grid;
  gap: 5px;
  color: #2c3a4d;
}

.publish-state a {
  color: #217c69;
  font-weight: 750;
}

.publish-modal {
  width: min(720px, 100%);
}

.publish-modal-form {
  display: grid;
  gap: 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e7edf5;
  color: #304055;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status.PENDING,
.status.RETRY_PENDING {
  background: #fff2cc;
  color: #7a5608;
}

.status.REVIEW_PENDING {
  background: #e1f3ef;
  color: #196350;
}

.status.APPROVED,
.status.PUBLISHED {
  background: #dcefe2;
  color: #236433;
}

.status.REJECTED {
  background: #f8dfe2;
  color: #8d2c38;
}

.status.FAILED {
  background: #f9d9dc;
  color: #84252e;
}

.status.AUTOMATIC,
.status.MANUAL {
  background: #dbeafe;
  color: #1d4f91;
}

.status.AUTOMATIC_QUEUED {
  background: #ede9fe;
  color: #5b3aa4;
}

.processing-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid #c8d8ee;
  border-radius: 8px;
  background: #eef5ff;
  color: #274664;
  font-weight: 650;
}

.error-text {
  color: #9b2531;
  font-weight: 700;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #e9edf1;
  padding: 20px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
}

.login-brand {
  margin-bottom: 8px;
}

@keyframes loader-pulse {
  0%,
  100% {
    transform: scale(0.94);
    opacity: 0.28;
  }
  50% {
    transform: scale(1.04);
    opacity: 0.8;
  }
}

@keyframes loader-wave {
  0%,
  100% {
    transform: scaleY(0.72);
    opacity: 0.6;
  }
  50% {
    transform: scaleY(1.18);
    opacity: 1;
  }
}

@media (max-width: 1100px) {
  .app-shell,
  .split-layout,
  .split-layout.wide-right {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

  .detail-panel {
    max-height: none;
  }

  .detail-modal {
    max-height: calc(100vh - 44px);
  }
}

@media (max-width: 720px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .csv-chip {
    min-width: calc(50% - 8px);
  }

  table {
    font-size: 13px;
  }
}
