:root {
  --ink: #18201d;
  --muted: #68716d;
  --line: #dbe1de;
  --surface: #ffffff;
  --canvas: #f3f5f4;
  --nav: #17211e;
  --nav-muted: #aebbb6;
  --green: #197552;
  --green-soft: #e4f2ec;
  --amber: #9a5b06;
  --amber-soft: #fff1d8;
  --red: #a33b3b;
  --red-soft: #fbe8e8;
  --blue: #286a91;
  --blue-soft: #e7f1f7;
  --shadow: 0 12px 34px rgba(21, 31, 27, 0.12);
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--canvas); }
body { margin: 0; min-width: 320px; }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--green); text-decoration: none; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px; display: flex; flex-direction: column; background: var(--nav); color: white; }
.brand, .login-brand { display: flex; align-items: center; gap: 11px; color: inherit; }
.brand { padding: 0 8px 28px; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 6px; background: #d7ff65; color: #17211e; font-weight: 850; }
.brand strong, .login-brand strong { display: block; font-size: 15px; line-height: 1.05; }
.brand small, .login-brand small { display: block; margin-top: 3px; color: var(--nav-muted); font-size: 11px; text-transform: uppercase; }
.main-nav { display: grid; gap: 4px; }
.main-nav a, .nav-button { width: 100%; min-height: 44px; padding: 0 12px; display: flex; align-items: center; gap: 11px; border: 0; border-radius: 5px; background: transparent; color: var(--nav-muted); cursor: pointer; }
.main-nav a[aria-current="page"] { background: #293631; color: #fff; }
.main-nav a:hover, .nav-button:hover { color: #fff; background: #222f2a; }
.main-nav span, .nav-button span { width: 18px; text-align: center; }
.logout-form { margin-top: auto; }

.main-content { min-width: 0; padding: 34px clamp(20px, 4vw, 56px) 70px; }
.page-header { min-height: 62px; display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 28px; }
.page-header h1 { margin: 2px 0 0; font-size: 28px; line-height: 1.1; }
.eyebrow { margin: 0; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.primary-button, .secondary-button, .approve-button, .text-button { min-height: 42px; padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 5px; border: 1px solid transparent; font-weight: 700; cursor: pointer; }
.primary-button { background: var(--green); color: white; }
.primary-button:hover { background: #125e41; }
.secondary-button { background: white; border-color: var(--line); color: var(--ink); }
.approve-button { background: var(--green); color: white; }
.text-button { padding: 0; background: transparent; color: var(--green); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--surface); }
.stat { min-height: 112px; padding: 22px; display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat span { color: var(--muted); font-size: 13px; }
.stat strong { font-size: 30px; }
.stat.attention strong { color: var(--amber); }
.stat.success strong { color: var(--green); }

.section-block { margin-top: 32px; }
.section-heading { min-height: 38px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading h2 { margin: 0; font-size: 17px; }
.section-heading a, .section-heading span { font-size: 13px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { height: 42px; padding: 0 14px; color: var(--muted); background: #f8f9f8; text-align: left; font-size: 11px; text-transform: uppercase; }
td { height: 58px; padding: 8px 14px; border-top: 1px solid var(--line); white-space: nowrap; }
.icon-link { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); font-size: 18px; }
.source-url { display: block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.muted { color: var(--muted); }

.status { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 999px; background: #edf0ef; color: #53605b; font-size: 11px; font-weight: 750; text-transform: uppercase; }
.status-processing, .status-queued { background: var(--blue-soft); color: var(--blue); }
.status-review, .status-rework { background: var(--amber-soft); color: var(--amber); }
.status-approved, .status-complete { background: var(--green-soft); color: var(--green); }
.status-rejected, .status-failed, .status-cancelled { background: var(--red-soft); color: var(--red); }
.progress-cell { display: flex; align-items: center; gap: 8px; }
.progress-track { width: 92px; height: 6px; overflow: hidden; border-radius: 6px; background: #e7ebe9; }
.progress-track span { display: block; height: 100%; background: var(--green); }
.progress-cell small { width: 32px; color: var(--muted); }
.empty-state { min-height: 180px; display: grid; place-items: center; align-content: center; gap: 10px; border: 1px dashed #bcc7c2; background: rgba(255,255,255,.55); color: var(--muted); }
.empty-state strong { color: var(--ink); }

.client-list { border: 1px solid var(--line); background: var(--surface); }
.client-row { min-height: 94px; padding: 16px 18px; display: grid; grid-template-columns: 46px minmax(130px, .65fr) minmax(240px, 1.7fr) 80px; align-items: center; gap: 16px; border-top: 1px solid var(--line); }
.client-row:first-child { border-top: 0; }
.client-avatar { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 6px; background: #e9eeec; color: var(--green); font-weight: 850; }
.client-main strong, .client-main span, .client-meta strong, .client-meta span { display: block; }
.client-main span, .client-meta span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.client-row p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.client-meta { text-align: right; }

dialog { width: min(560px, calc(100vw - 30px)); padding: 0; border: 1px solid var(--line); border-radius: 7px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(13, 21, 18, .58); }
.dialog-form { padding: 22px; display: grid; gap: 17px; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; }
.dialog-header h2 { margin: 0; font-size: 20px; }
.close-button, .icon-button { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; background: white; cursor: pointer; font-size: 22px; }
.dialog-form label, .stack-form label { display: grid; gap: 7px; color: #3f4945; font-size: 12px; font-weight: 700; }
input, textarea, select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #bec8c3; border-radius: 4px; background: #fff; color: var(--ink); outline: none; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(25,117,82,.12); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }

.job-header { align-items: center; }
.back-link { color: var(--muted); font-size: 13px; }
.job-source { max-width: 620px; margin: 7px 0 0; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 13px; white-space: nowrap; }
.job-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--surface); }
.job-summary div { padding: 16px 18px; border-right: 1px solid var(--line); }
.job-summary div:last-child { border-right: 0; }
.job-summary span, .job-summary strong { display: block; }
.job-summary span { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.job-summary strong { margin-top: 5px; font-size: 18px; }
.activity-line { min-height: 42px; padding: 0 12px; margin-top: 10px; display: flex; align-items: center; gap: 9px; background: #edf4f1; color: #3b5449; font-size: 13px; }
.activity-line small { margin-left: auto; color: var(--muted); }
.activity-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }

.clip-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.clip-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.clip-preview { position: relative; aspect-ratio: 9 / 16; overflow: hidden; background: #111915; }
.clip-preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-placeholder { height: 100%; display: grid; place-items: center; align-content: center; gap: 8px; color: #aab5b0; }
.preview-placeholder span { font-size: 36px; font-weight: 800; }
.preview-placeholder small { font-size: 12px; }
.score { position: absolute; top: 10px; right: 10px; min-width: 36px; height: 30px; padding: 0 7px; display: grid; place-items: center; border-radius: 4px; background: #d7ff65; color: #17211e; font-weight: 850; }
.clip-content { padding: 15px; }
.clip-title { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; }
.clip-content h3 { margin: 13px 0 6px; font-size: 16px; line-height: 1.3; }
.hook { min-height: 38px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
details { margin-top: 13px; border-top: 1px solid var(--line); }
summary { padding: 12px 0; cursor: pointer; color: var(--muted); font-size: 12px; }
.caption-tabs strong { display: block; margin-top: 8px; font-size: 11px; text-transform: uppercase; }
.caption-tabs p { margin: 3px 0 10px; color: var(--muted); font-size: 12px; line-height: 1.45; white-space: pre-wrap; }
.clip-actions { margin-top: 14px; display: grid; grid-template-columns: 40px 1fr 1.25fr; gap: 7px; }
.clip-actions form { display: contents; }
.icon-button.danger { color: var(--red); }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #e9eeeb; }
.login-panel { width: min(400px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 7px; background: white; box-shadow: var(--shadow); }
.login-brand { color: var(--ink); }
.login-brand small { color: var(--muted); }
.login-panel h1 { margin: 34px 0 20px; font-size: 25px; }
.stack-form { display: grid; gap: 17px; }
.stack-form .primary-button { margin-top: 5px; }
.alert { margin-bottom: 16px; padding: 11px 12px; border-radius: 4px; font-size: 13px; }
.alert.error { background: var(--red-soft); color: var(--red); }

@media (max-width: 1050px) {
  .clip-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .client-row { grid-template-columns: 46px 1fr 80px; }
  .client-row p { grid-column: 2 / 4; }
}

@media (max-width: 760px) {
  .app-shell { height: 100vh; display: grid; grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 66px; }
  .sidebar { position: static; grid-row: 2; width: 100%; height: 66px; padding: 8px 12px; flex-direction: row; align-items: center; border-top: 1px solid #34433d; }
  .brand, .logout-form { display: none; }
  .main-nav { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
  .main-nav a { min-height: 50px; flex-direction: column; justify-content: center; gap: 2px; padding: 0 4px; font-size: 11px; }
  .main-nav span { height: 18px; }
  .main-content { grid-row: 1; overflow-y: auto; padding: 24px 16px 36px; }
  .page-header { align-items: center; }
  .page-header h1 { font-size: 24px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .job-summary { grid-template-columns: repeat(2, 1fr); }
  .job-summary div:nth-child(2) { border-right: 0; }
  .job-summary div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .clip-grid { grid-template-columns: 1fr; }
  .client-row { grid-template-columns: 42px 1fr 64px; padding: 14px; }
  .client-row p { grid-column: 1 / 4; }
}

@media (max-width: 440px) {
  .page-header { align-items: flex-start; }
  .page-header .primary-button, .page-header > button { min-width: 44px; padding: 0 11px; font-size: 0; }
  .page-header .primary-button span, .page-header > button span { font-size: 20px; }
  .stat { min-height: 96px; padding: 17px; }
  .stat strong { font-size: 26px; }
}
