:root {
  --bg: #f4f6f4;
  --panel: #ffffff;
  --ink: #15211f;
  --muted: #66736f;
  --line: #dce4df;
  --accent: #126b5b;
  --accent-2: #b44d2c;
  --accent-3: #315f9e;
  --soft: #eaf3ef;
  --warning: #fff4da;
  --danger: #fce7e2;
  --shadow: 0 18px 60px rgba(21, 33, 31, 0.12);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

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

.control-panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 24px;
  overflow-y: auto;
}

.brand-block {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 26px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.15;
}

.brand-block p,
.field-note,
.status-box,
.creator-description,
.meta,
.detail-body p {
  color: var(--muted);
}

.brand-block p {
  margin-top: 5px;
  font-size: 14px;
  line-height: 1.45;
}

.panel-section,
.grid-two,
.button-stack {
  margin-top: 18px;
}

.panel-section.compact {
  margin-top: 28px;
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label,
.panel-section h2 {
  display: block;
  margin-bottom: 7px;
  color: #31413d;
  font-size: 13px;
  font-weight: 700;
}

.panel-section h2 {
  margin-bottom: 10px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(18, 107, 91, 0.13);
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 8px;
}

.field-note {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.45;
}

.button-stack {
  display: grid;
  gap: 10px;
}

.primary-button,
.secondary-button,
.tool-button,
.icon-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
}

.primary-button,
.secondary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:disabled {
  cursor: progress;
  opacity: 0.7;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.secondary-button,
.tool-button,
.icon-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.button-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 12px;
}

.secondary-button .button-icon {
  background: var(--soft);
}

.template-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #334642;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
}

.workspace {
  min-width: 0;
  padding: 26px;
}

.topbar,
.filter-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 18px;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h2 {
  font-size: 28px;
  line-height: 1.1;
}

.toolbar {
  display: flex;
  gap: 8px;
}

.tool-button,
.icon-button {
  min-width: 44px;
  padding: 0 12px;
}

.tool-button {
  min-width: 96px;
}

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

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

.metric {
  min-height: 92px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 26px;
  line-height: 1.1;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr);
  align-items: end;
  margin-bottom: 14px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 0 0 14px;
}

.pager span {
  min-width: 130px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.status-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 13px 14px;
  font-size: 14px;
  line-height: 1.45;
}

.status-box.loading {
  border-color: rgba(49, 95, 158, 0.35);
  background: #eef4ff;
  color: #243f68;
}

.status-box.error {
  border-color: rgba(180, 77, 44, 0.4);
  background: var(--danger);
  color: #81331c;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.creator-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  box-shadow: 0 6px 22px rgba(21, 33, 31, 0.05);
}

.creator-head {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  align-items: center;
}

.thumb {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--soft);
}

.thumb-fallback {
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  background: var(--accent-3);
}

.creator-card h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}

.creator-card a {
  color: inherit;
  text-decoration: none;
}

.creator-card a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.meta {
  margin-top: 5px;
  font-size: 12px;
  font-weight: 700;
}

.score-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

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

.score-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.fit-badge {
  border-radius: 999px;
  padding: 5px 8px;
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.fit-badge.good {
  background: #eaf0fb;
  color: var(--accent-3);
}

.fit-badge.watch {
  background: var(--warning);
  color: #8b5a00;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat {
  min-width: 0;
  border-radius: 8px;
  background: #f7f9f7;
  padding: 9px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

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

.tag {
  border-radius: 999px;
  background: #eef2ef;
  padding: 5px 8px;
  color: #40504c;
  font-size: 12px;
  font-weight: 800;
}

.creator-description {
  display: -webkit-box;
  overflow: hidden;
  min-height: 42px;
  font-size: 14px;
  line-height: 1.5;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

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

.small-button {
  flex: 1;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.detail-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: min(780px, calc(100vh - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.detail-dialog::backdrop {
  background: rgba(15, 24, 22, 0.38);
}

.dialog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  font-size: 24px;
}

.detail-body {
  display: grid;
  gap: 16px;
  padding: 20px;
}

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

.detail-block h3 {
  margin: 0;
  font-size: 15px;
}

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

.video-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  line-height: 1.35;
}

.empty-state {
  border: 1px dashed #b9c5bf;
  border-radius: 8px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
  text-align: center;
}

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

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

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

@media (max-width: 640px) {
  .control-panel,
  .workspace {
    padding: 18px;
  }

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

  .toolbar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .filter-row,
  .grid-two {
    grid-template-columns: 1fr;
  }

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