:root {
  --bg: #f5f2ec;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #1d2630;
  --muted: #68717d;
  --line: #ddd7cd;
  --teal: #0e7c74;
  --teal-dark: #075a56;
  --coral: #c85a45;
  --amber: #b5811f;
  --blue: #3a6ea5;
  --soft-teal: #dcecea;
  --soft-coral: #f4dfd8;
  --shadow: 0 18px 48px rgba(44, 37, 29, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

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

.brand-block,
.topbar,
.section-heading,
.provider-panel,
.sort-control {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 21px;
  line-height: 1.25;
}

h2 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.15;
}

h3 {
  margin-bottom: 0;
  font-size: 22px;
}

.filter-grid {
  display: grid;
  gap: 14px;
}

.main-nav {
  display: grid;
  gap: 6px;
  margin: 0 0 22px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--line);
}

.main-nav a {
  display: grid;
  gap: 2px;
  border-radius: 8px;
  color: var(--ink);
  padding: 9px 10px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 800;
}

.main-nav a:hover {
  background: #eef0f2;
}

.main-nav span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.admin-nav,
.admin-only {
  display: none;
}

body[data-role="admin"] .admin-nav,
body[data-role="admin"] .admin-only {
  display: grid;
}

.filter-group {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 48px;
  padding: 0 14px;
}

textarea {
  resize: vertical;
  padding: 13px 14px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14, 124, 116, 0.14);
}

.keyword-box {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.intake-panel {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(360px, 1.2fr);
  gap: 18px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 16px;
  box-shadow: 0 10px 24px rgba(44, 37, 29, 0.05);
}

.intake-panel.admin-only {
  display: none;
}

body[data-role="admin"] .intake-panel.admin-only {
  display: grid;
}

.intake-note,
.section-subnote {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.section-subnote {
  display: -webkit-box;
  max-width: 980px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.intake-form {
  display: grid;
  gap: 8px;
}

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

.primary-button,
.provider-panel button {
  min-height: 46px;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  margin-top: 10px;
}

.intake-actions .primary-button {
  width: auto;
  min-width: 148px;
  margin-top: 0;
}

#importHint {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.section-mini h2 {
  margin-bottom: 12px;
  font-size: 20px;
}

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

.keyword-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 10px;
}

.keyword-card strong {
  display: block;
  margin-bottom: 7px;
  font-size: 16px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  border-radius: 999px;
  background: #eef0f2;
  color: #3b4652;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 700;
}

.keyword-category {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.keyword-category-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.editable-tag button {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: rgba(29, 38, 48, 0.14);
  color: #3b4652;
  line-height: 1;
  font-weight: 900;
}

.keyword-add-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 58px;
  gap: 6px;
  margin-top: 10px;
}

.keyword-add-row select,
.keyword-add-row input,
.keyword-add-row button {
  min-height: 38px;
  border-radius: 8px;
  font-size: 13px;
}

.keyword-add-row button {
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.search-config-list {
  padding: 0 16px 16px;
}

.search-config-card {
  padding: 14px;
}

.search-config-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.search-config-head h4 {
  margin: 0;
  font-size: 22px;
}

.market-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.market-summary div {
  border: 1px solid #ece6dc;
  border-radius: 8px;
  background: #fbfaf6;
  padding: 10px;
}

.market-summary span,
.assignment-grid span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.market-summary strong,
.assignment-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 16px;
}

.search-term-scroll {
  max-width: 100%;
  overflow: auto;
  contain: paint;
  -webkit-overflow-scrolling: touch;
}

.search-term-table {
  min-width: 980px;
  border-collapse: collapse;
}

.search-term-table th,
.search-term-table td {
  white-space: normal;
}

.search-term-table th:first-child,
.search-term-table td:first-child {
  min-width: 180px;
}

.search-term-table .empty-row td {
  color: var(--muted);
}

.term-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.term-actions button,
.task-action-row button,
.task-action-row a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 8px;
  background: #eef0f2;
  color: #3b4652;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 850;
  text-decoration: none;
}

.term-actions button:hover,
.task-action-row button:hover,
.task-action-row a:hover {
  background: var(--soft-teal);
  color: var(--teal-dark);
}

.search-config-form {
  grid-template-columns: 150px minmax(220px, 1fr) 82px 112px;
  margin-top: 12px;
}

.keyword-notes,
.muted-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.keyword-notes {
  margin: 10px 0 0;
}

.main-panel {
  min-width: 0;
  padding: 24px;
}

.module-draggable {
  position: relative;
}

.module-drag-handle {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 8;
  display: none;
  width: 28px;
  height: 28px;
  border: 1px solid #d9d2c7;
  border-radius: 8px;
  background: #fffdf8;
  color: var(--muted);
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  cursor: grab;
}

.module-dragging {
  opacity: 0.72;
  outline: 2px solid rgba(14, 124, 116, 0.35);
}

@media (min-width: 1181px) {
  .module-draggable {
    resize: vertical;
    overflow: auto;
  }

  .module-draggable:hover > .module-drag-handle,
  .module-drag-handle:focus {
    display: grid;
    place-items: center;
  }
}

.main-panel > section,
.market-settings-panel > *,
.task-panel > *,
.search-config-card,
.search-config-card > *,
.search-term-scroll,
.data-task-layout > * {
  min-width: 0;
}

.market-settings-panel,
.task-panel {
  overflow: hidden;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.provider-panel {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.provider-panel select {
  width: 170px;
}

.provider-panel button {
  padding: 0 14px;
  background: var(--ink);
}

.provider-status {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.provider-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
}

.provider-pill strong {
  display: block;
  font-size: 16px;
}

.provider-pill span {
  color: var(--muted);
  font-size: 15px;
}

.provider-pill.ready {
  border-color: rgba(14, 124, 116, 0.35);
  background: var(--soft-teal);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  min-width: 0;
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 16px;
  box-shadow: 0 10px 24px rgba(44, 37, 29, 0.05);
}

.kpi p,
.kpi strong,
.kpi small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.kpi p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.kpi strong {
  display: block;
  font-size: 32px;
  line-height: 1.1;
}

.kpi small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.35;
}

.search-monitor,
.section-board,
.script-panel,
.winning-panel,
.task-panel,
.verification-panel,
.market-settings-panel,
.asset-center-panel,
.role-dashboard {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: 0 10px 24px rgba(44, 37, 29, 0.05);
}

.role-dashboard {
  padding: 16px;
}

.role-hero {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(480px, 1.1fr);
  gap: 16px;
  align-items: stretch;
}

.role-hero h3 {
  margin-bottom: 0;
  font-size: 28px;
}

.role-hero p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
}

.role-scoreboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.role-scoreboard div,
.role-action-grid div {
  border: 1px solid #ece6dc;
  border-radius: 8px;
  background: #fbfaf6;
  padding: 12px;
}

.role-scoreboard span,
.role-action-grid span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.role-scoreboard strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
}

.top-candidate-brief {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  border: 1px solid #ece6dc;
  border-radius: 8px;
  background: #fbfaf6;
  padding: 10px;
  color: var(--ink);
  text-decoration: none;
}

.top-candidate-brief:hover {
  border-color: rgba(14, 124, 116, 0.5);
}

.top-candidate-thumb {
  display: block;
  width: 58px;
}

.top-candidate-thumb .thumb,
.top-candidate-thumb img {
  display: block;
  width: 58px;
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  object-fit: cover;
}

.top-candidate-copy {
  min-width: 0;
}

.top-candidate-copy small,
.top-candidate-copy em {
  display: block;
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.top-candidate-copy strong {
  display: block;
  margin: 3px 0;
  overflow-wrap: anywhere;
  font-size: 22px;
  line-height: 1.1;
}

.market-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.market-strip span {
  min-width: 0;
  border: 1px solid #ece6dc;
  border-radius: 8px;
  background: #fbfaf6;
  padding: 10px 12px;
}

.market-strip strong,
.market-strip small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.market-strip small {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 750;
}

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

.role-action-grid strong {
  display: block;
  margin-bottom: 6px;
}

.monitor-head,
.script-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

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

.monitor-head button,
.script-head button,
.section-tabs button {
  min-height: 42px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 0 12px;
  font-weight: 800;
}

.monitor-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 16px;
}

.monitor-item {
  border: 1px solid #ece6dc;
  border-radius: 8px;
  background: #fbfaf6;
  padding: 10px;
}

.monitor-item span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.monitor-item strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.monitor-note,
.script-note {
  margin: 0;
  padding: 0 16px 16px;
  color: var(--muted);
  line-height: 1.5;
}

.ai-feedback {
  margin: 0 16px 16px;
  border: 1px solid #ece6dc;
  border-radius: 8px;
  background: #fbfaf6;
  padding: 12px;
}

.ai-feedback-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.ai-feedback-head span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.ai-feedback p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

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

.ai-feedback-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.ai-feedback-card strong,
.ai-feedback-card p {
  display: block;
  font-size: 15px;
}

.ai-feedback-card p {
  margin-top: 6px;
}

.section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.section-tabs,
.script-market-tabs,
.data-task-tabs {
  max-width: 100%;
  min-width: 0;
  contain: paint;
}

.section-tabs button {
  background: #eef0f2;
  color: #3b4652;
}

.section-tabs button.active {
  background: var(--teal);
  color: #fff;
}

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

.section-card {
  min-width: 0;
  border: 1px solid #ece6dc;
  border-radius: 8px;
  background: #fbfaf6;
  padding: 12px;
}

.section-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.section-card-head span {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--soft-teal);
  color: var(--teal-dark);
  font-weight: 800;
}

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

.mini-video {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
  padding: 6px;
  color: var(--ink);
  text-align: left;
}

.mini-video:hover {
  border-color: rgba(14, 124, 116, 0.35);
}

.mini-video img {
  width: 38px;
  aspect-ratio: 3 / 4;
  border-radius: 6px;
  object-fit: cover;
}

.mini-video strong,
.mini-video small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-video small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.script-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.script-card,
.script-empty {
  border: 1px solid #ece6dc;
  border-radius: 8px;
  background: #fbfaf6;
  padding: 14px;
}

.script-card strong {
  display: block;
  color: var(--teal-dark);
  margin-bottom: 6px;
}

.script-card p {
  margin-bottom: 10px;
  font-weight: 800;
  line-height: 1.35;
}

.script-card ol {
  margin: 0;
  padding-left: 18px;
}

.script-card li {
  margin-bottom: 8px;
  color: #37414d;
  line-height: 1.45;
  font-size: 16px;
}

.script-empty {
  grid-column: 1 / -1;
  color: var(--muted);
}

.script-empty.compact {
  margin: 14px 0 0;
}

.script-market-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 16px;
}

.script-market-tabs button {
  min-height: 40px;
  border-radius: 999px;
  background: #eef0f2;
  color: #3b4652;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 800;
}

.script-market-tabs button.active {
  background: var(--teal);
  color: #fff;
}

.script-library-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  padding: 0 16px 16px;
}

.script-video-list {
  display: grid;
  align-content: start;
  gap: 10px;
}

.script-video-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  border: 1px solid #ece6dc;
  border-radius: 8px;
  background: #fbfaf6;
  padding: 8px;
  color: var(--ink);
  text-align: left;
}

.script-video-card:hover,
.script-video-card.selected {
  border-color: rgba(14, 124, 116, 0.45);
  background: #f3fbf8;
}

.script-video-card img {
  width: 54px;
  aspect-ratio: 3 / 4;
  border-radius: 6px;
  object-fit: cover;
}

.script-video-body,
.script-video-body strong,
.script-video-body small {
  display: block;
  min-width: 0;
}

.script-video-body strong,
.script-video-body small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.script-video-body small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.script-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.script-tags span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: #eef0f2;
  color: #3b4652;
  padding: 0 8px;
  font-size: 14px;
  font-weight: 800;
}

.script-tags.prominent {
  margin: 10px 0 12px;
}

.script-tags.prominent span {
  background: var(--soft-teal);
  color: var(--teal-dark);
}

.script-breakdown {
  min-width: 0;
  border: 1px solid #ece6dc;
  border-radius: 8px;
  background: #fbfaf6;
  padding: 14px;
}

.script-breakdown-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.script-breakdown-head h4 {
  margin: 0;
  font-size: 24px;
}

.script-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.script-metrics div,
.script-source-box,
.script-analysis-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.script-metrics span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.script-metrics strong {
  display: block;
  margin-top: 5px;
  font-size: 16px;
}

.script-source-box {
  margin-bottom: 12px;
}

.script-source-box p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}

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

.script-analysis-grid h5 {
  margin: 0 0 8px;
  font-size: 17px;
}

.script-analysis-grid ul,
.script-analysis-grid ol {
  margin: 0;
  padding-left: 18px;
}

.script-analysis-grid li {
  margin-bottom: 8px;
  font-size: 16px;
  line-height: 1.45;
}

.script-grid.generated {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 14px 0 0;
}

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

.winning-card,
.verification-card,
.task-row {
  width: 100%;
  border: 1px solid #ece6dc;
  border-radius: 8px;
  background: #fbfaf6;
  color: var(--ink);
  text-align: left;
}

.winning-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
}

.winning-card:hover,
.verification-card:hover,
.task-row:hover {
  border-color: rgba(14, 124, 116, 0.45);
  background: #f3fbf8;
}

.winning-card img {
  width: 72px;
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  object-fit: cover;
}

.winning-card strong,
.winning-card small,
.winning-card em {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.winning-card small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
  white-space: normal;
}

.winning-card em {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--soft-teal);
  color: var(--teal-dark);
  padding: 0 9px;
  font-style: normal;
  font-size: 13px;
  font-weight: 900;
}

.task-list {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.task-row {
  display: grid;
  grid-template-columns: 260px 90px 90px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 10px 12px;
}

.task-row strong,
.task-row small,
.task-row em {
  display: block;
}

.task-row small,
.task-row em {
  color: var(--muted);
  font-style: normal;
  line-height: 1.35;
}

.task-row > span:nth-child(2),
.task-row > span:nth-child(3) {
  display: inline-flex;
  justify-content: center;
  min-height: 30px;
  border-radius: 999px;
  background: #eef0f2;
  color: #3b4652;
  padding: 5px 10px;
  font-size: 14px;
  font-weight: 900;
}

.verification-card {
  display: grid;
  gap: 7px;
  padding: 12px;
}

.verification-card strong {
  font-size: 18px;
}

.verification-card span,
.verification-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.data-task-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 16px;
}

.data-task-tabs button {
  min-height: 40px;
  border-radius: 999px;
  background: #eef0f2;
  color: #3b4652;
  padding: 0 12px;
  font-weight: 850;
}

.data-task-tabs button.active {
  background: var(--teal);
  color: #fff;
}

.data-task-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.85fr);
  gap: 16px;
  padding: 0 16px 16px;
}

.task-section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.task-section-title h4 {
  margin: 0;
  font-size: 20px;
}

.issue-grid,
.assignment-list {
  display: grid;
  gap: 12px;
}

.issue-card,
.assignment-card {
  border: 1px solid #ece6dc;
  border-radius: 8px;
  background: #fbfaf6;
  padding: 12px;
}

.issue-media,
.assignment-video,
.assignment-head {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.assignment-head {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-start;
}

.issue-thumb {
  width: 72px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f3ea;
  padding: 0;
}

.issue-thumb.compact {
  width: 58px;
}

.issue-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.issue-media h4,
.assignment-head h4 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.issue-media span,
.assignment-video span,
.assignment-note {
  display: block;
  color: var(--muted);
  line-height: 1.45;
}

.issue-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0;
}

.issue-section {
  margin-top: 10px;
}

.issue-section strong {
  display: block;
  margin-bottom: 4px;
  color: #344050;
}

.issue-section p,
.issue-section ul {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.issue-section ul {
  padding-left: 18px;
}

.task-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

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

.assignment-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px;
}

.assignment-note {
  margin: 10px 0 0;
}

.phase-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  background: #eef0f2;
  color: #3b4652;
  padding: 0 12px;
  font-weight: 800;
}

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

.asset-grid div {
  border: 1px solid #ece6dc;
  border-radius: 8px;
  background: #fbfaf6;
  padding: 14px;
}

.asset-grid strong {
  display: block;
  margin-bottom: 8px;
  color: var(--teal-dark);
}

.asset-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.table-panel,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.table-panel {
  min-width: 0;
  overflow: hidden;
}

.section-heading {
  justify-content: space-between;
  gap: 16px;
  min-height: 88px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.sort-control {
  gap: 8px;
}

.sort-control select {
  width: 140px;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  max-height: min(74vh, 820px);
  overflow-x: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  contain: paint;
  scrollbar-gutter: stable both-edges;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
}

.table-scroll-hint {
  display: none;
  border-bottom: 1px solid #ece6dc;
  background: #fffdf8;
  color: var(--muted);
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 800;
}

.table-wrap.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.table-wrap::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.table-wrap::-webkit-scrollbar-thumb {
  border: 3px solid #fbfaf6;
  border-radius: 999px;
  background: #b8c0c7;
}

.table-wrap::-webkit-scrollbar-track {
  background: #fbfaf6;
}

table {
  width: max-content;
  min-width: 1780px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #ece6dc;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fffdf8;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
}

td {
  font-size: 15px;
}

tbody tr {
  transition: background 0.16s ease, box-shadow 0.16s ease;
}

tbody tr:hover,
tbody tr.selected {
  background: #f5fbf9;
}

.table-wrap th:nth-child(1),
.table-wrap td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 64px;
  min-width: 64px;
  background: var(--surface-strong);
}

.table-wrap th:nth-child(2),
.table-wrap td:nth-child(2) {
  position: sticky;
  left: 64px;
  z-index: 3;
  width: 92px;
  min-width: 92px;
  background: var(--surface-strong);
}

.table-wrap th:nth-child(3),
.table-wrap td:nth-child(3) {
  position: sticky;
  left: 156px;
  z-index: 3;
  width: 420px;
  min-width: 420px;
  max-width: 420px;
  background: var(--surface-strong);
  box-shadow: 10px 0 16px rgba(44, 37, 29, 0.07);
  white-space: normal;
}

.table-wrap thead th:nth-child(1),
.table-wrap thead th:nth-child(2),
.table-wrap thead th:nth-child(3) {
  z-index: 4;
  background: #fffdf8;
}

tbody tr:hover td:nth-child(1),
tbody tr:hover td:nth-child(2),
tbody tr:hover td:nth-child(3),
tbody tr.selected td:nth-child(1),
tbody tr.selected td:nth-child(2),
tbody tr.selected td:nth-child(3) {
  background: #f5fbf9;
}

.video-code {
  display: grid;
  gap: 4px;
  max-width: 380px;
}

.video-code strong {
  color: var(--ink);
  font-size: 16px;
  overflow-wrap: anywhere;
}

.video-code span {
  color: var(--muted);
  display: -webkit-box;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: normal;
}

.thumb-cell {
  width: 92px;
}

.thumb {
  position: relative;
  display: block;
  width: 74px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f3ea;
  box-shadow: 0 2px 8px rgba(29, 38, 48, 0.12);
}

.thumb-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.thumb-link:hover {
  border-color: var(--teal);
  box-shadow: 0 4px 14px rgba(16, 132, 120, 0.24);
  transform: translateY(-1px);
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb img.thumbnail-fallback,
.thumb img.thumbnail-unavailable {
  background: #f7f3ea;
}

.play-dot {
  position: absolute;
  right: 7px;
  bottom: 7px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(29, 38, 48, 0.86);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.score-badge,
.mode-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-weight: 800;
  font-size: 14px;
}

.score-badge {
  background: var(--soft-teal);
  color: var(--teal-dark);
}

.score-badge.mid {
  background: #f2e6c7;
  color: #6d4a0d;
}

.score-badge.low {
  background: var(--soft-coral);
  color: #8f3325;
}

.mode-badge {
  min-width: 58px;
  background: #edf2f7;
  color: #334155;
  font-size: 14px;
}

.mode-badge.human {
  background: var(--soft-teal);
  color: var(--teal-dark);
}

.mode-badge.ai {
  background: #e5e7f7;
  color: #3730a3;
}

.mode-badge.hybrid {
  background: #f2e6c7;
  color: #6d4a0d;
}

.detail-panel {
  position: sticky;
  top: 16px;
  padding: 18px;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

.detail-header {
  display: grid;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.detail-header h3 {
  font-size: 24px;
  line-height: 1.25;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-badge {
  background: #eef0f2;
  color: var(--muted);
  font-size: 14px;
}

.table-badge {
  min-width: auto;
  min-height: 24px;
  padding: 0 8px;
  white-space: nowrap;
}

.status-badge.hot {
  background: var(--soft-coral);
  color: var(--coral);
}

.status-badge.scale {
  background: var(--soft-teal);
  color: var(--teal-dark);
}

.detail-section {
  padding-top: 14px;
}

.detail-section h4 {
  margin: 0 0 8px;
  font-size: 17px;
}

.detail-section ul {
  margin: 0;
  padding-left: 18px;
}

.detail-section li {
  margin-bottom: 8px;
  color: #37414d;
  font-size: 16px;
  line-height: 1.45;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.mini-metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfaf6;
}

.mini-metric span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.mini-metric strong {
  display: block;
  margin-top: 5px;
  font-size: 16px;
}

.source-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin-top: 10px;
  border-radius: 8px;
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.video-viewer {
  position: relative;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1720;
}

.video-viewer img {
  display: block;
  width: 100%;
  max-height: min(58vh, 620px);
  aspect-ratio: 9 / 16;
  border: 0;
  object-fit: cover;
}

.video-preview-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.big-play {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 25px;
  font-weight: 900;
  transform: translate(-50%, -50%);
}

.viewer-note {
  margin: 0;
  padding: 10px 12px;
  background: #fffdf8;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.source-link.disabled {
  color: var(--muted);
  pointer-events: none;
}

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .intake-panel,
  .role-hero,
  .script-library-layout,
  .data-task-layout {
    grid-template-columns: 1fr;
  }

  .market-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }
}

@media (max-width: 820px) {
  .main-panel,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .provider-panel {
    justify-content: flex-start;
    width: 100%;
  }

  .provider-panel select,
  .provider-panel button {
    width: 100%;
  }

  .provider-status,
  .kpi-grid,
  .role-scoreboard,
  .role-action-grid,
  .monitor-grid,
  .section-summary,
  .script-grid,
  .winning-grid,
  .verification-grid,
  .market-summary,
  .assignment-grid,
  .asset-grid,
  .ai-feedback-grid,
  .script-metrics,
  .script-analysis-grid,
  .filter-grid {
    grid-template-columns: 1fr;
  }

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

  .market-strip {
    grid-template-columns: 1fr;
  }

  .role-dashboard,
  .kpi {
    padding: 12px;
  }

  .kpi {
    min-height: 92px;
  }

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

  .kpi small {
    font-size: 14px;
  }

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

  .monitor-head,
  .script-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .monitor-head button,
  .script-head button,
  .intake-actions .primary-button {
    width: 100%;
  }

  .section-tabs,
  .script-market-tabs,
  .data-task-tabs {
    flex-wrap: nowrap;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .section-tabs button,
  .script-market-tabs button,
  .data-task-tabs button {
    flex: 0 0 auto;
  }

  .search-config-form {
    grid-template-columns: 1fr;
  }

  .search-term-scroll {
    overflow: visible;
    contain: none;
  }

  .search-term-table,
  .search-term-table thead,
  .search-term-table tbody,
  .search-term-table tr,
  .search-term-table th,
  .search-term-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .search-term-table {
    min-width: 0;
  }

  .search-term-table thead {
    display: none;
  }

  .search-term-table tr {
    margin-bottom: 10px;
    border: 1px solid #ece6dc;
    border-radius: 8px;
    background: #fff;
    padding: 10px;
  }

  .search-term-table td {
    border-bottom: 0;
    padding: 5px 0;
    white-space: normal;
  }

  .search-term-table td::before {
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 850;
  }

  .search-term-table td:nth-child(1)::before {
    content: "關鍵詞";
  }

  .search-term-table td:nth-child(2)::before {
    content: "分類";
  }

  .search-term-table td:nth-child(3)::before {
    content: "狀態";
  }

  .search-term-table td:nth-child(4)::before {
    content: "本月發現";
  }

  .search-term-table td:nth-child(5)::before {
    content: "有效影片";
  }

  .search-term-table td:nth-child(6)::before {
    content: "最後執行";
  }

  .search-term-table td:nth-child(7)::before {
    content: "操作";
  }

  .issue-media,
  .assignment-video {
    grid-template-columns: 60px minmax(0, 1fr);
  }

  .issue-thumb {
    width: 60px;
  }

  .assignment-head {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    max-height: 70vh;
    cursor: auto;
    touch-action: pan-x pan-y;
  }

  .table-scroll-hint {
    display: block;
  }

  table {
    min-width: 1360px;
  }

  .table-wrap th:nth-child(1),
  .table-wrap td:nth-child(1) {
    width: 44px;
    min-width: 44px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .table-wrap th:nth-child(2),
  .table-wrap td:nth-child(2) {
    left: 44px;
    width: 70px;
    min-width: 70px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .table-wrap th:nth-child(3),
  .table-wrap td:nth-child(3) {
    position: static;
    left: auto;
    z-index: auto;
    min-width: 300px;
    background: inherit;
    box-shadow: none;
  }

  .table-wrap thead th:nth-child(3) {
    z-index: 2;
    background: #fffdf8;
  }

  .thumb {
    width: 54px;
  }

  .thumb-cell {
    width: 72px;
  }

  h2 {
    font-size: 24px;
  }
}
