:root {
  --navy: #0B2650;
  --navy-light: #163a72;
  --gold: #C9A227;
  --gold-dark: #a5831c;
  --surface: #ffffff;
  --surface-off: #f6f7fb;
  --text: #1a2233;
  --text-muted: #6b7280;
  --border: #e2e5ec;
  --danger: #b3261e;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-off);
  color: var(--text);
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
}

.hidden { display: none !important; }

/* Topbar */
.topbar {
  background: var(--navy);
  color: #fff;
  padding: 18px 28px;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.wordmark {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.06em;
}
.wordmark-sub {
  font-weight: 400;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.7);
  margin-left: 10px;
}
.session-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.85);
}
.session-logout {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  cursor: pointer;
}
.session-logout:hover { border-color: var(--gold); color: var(--gold); }

.gate-fallback {
  margin-top: 16px;
  text-align: left;
}
.gate-fallback summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 10px;
}
.gate-card .btn-block { display: block; width: 100%; text-decoration: none; }

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px;
}

/* Gate */
.gate {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}
.gate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 4px 24px rgba(11,38,80,0.06);
}
.gate-card h1 {
  font-size: 1.3rem;
  margin: 0 0 8px;
  color: var(--navy);
}
.gate-card p {
  color: var(--text-muted);
  margin: 0 0 20px;
  font-size: 0.92rem;
}
.gate-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  margin-bottom: 12px;
}

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--navy);
  color: #fff;
}
.btn-primary:hover { background: var(--navy-light); }
.btn-gold {
  background: var(--gold);
  color: #1a1a1a;
}
.btn-gold:hover { background: var(--gold-dark); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: #eee; }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid #e8b4b0;
}
.btn-danger:hover { background: #fbeceb; }
.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* DAM entry banner */
.dam-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  margin-bottom: 24px;
  border-radius: var(--radius);
  background: linear-gradient(120deg, var(--navy), var(--navy-light));
  color: #fff;
  text-decoration: none;
  box-shadow: 0 4px 18px rgba(11,38,80,0.12);
  transition: transform 0.1s ease, box-shadow 0.12s ease;
}
.dam-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(11,38,80,0.2);
}
.dam-banner-text { display: flex; flex-direction: column; gap: 3px; }
.dam-banner-title { font-weight: 700; font-size: 1.05rem; }
.dam-banner-sub { font-size: 0.85rem; color: rgba(255,255,255,0.78); }
.dam-banner-cta {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 8px 16px;
}
.dam-banner:hover .dam-banner-cta { background: var(--gold); color: var(--navy); }

/* An <a> styled as a .btn (DAM link in the panel header) */
a.btn { display: inline-flex; align-items: center; text-decoration: none; }

@media (max-width: 560px) {
  .dam-banner { flex-direction: column; align-items: flex-start; }
}

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 12px rgba(11,38,80,0.04);
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
}
.panel-header h2 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--navy);
}
.panel-actions {
  display: flex;
  gap: 8px;
}

/* Reviews list */
.reviews-list table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.reviews-list th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
}
.reviews-list td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.reviews-list tr:last-child td { border-bottom: none; }
.reviews-list .row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.muted { color: var(--text-muted); }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-in-review { background: #eaf0fc; color: var(--navy); }
.badge-changes-requested { background: #fdecea; color: var(--danger); }
.badge-approved { background: #e8f6ec; color: #1e7e34; }

.type-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-off);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Forms */
.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 560px;
}
.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.form input,
.form select,
.form textarea {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 400;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.form textarea { resize: vertical; font-family: 'SF Mono', monospace; font-size: 0.85rem; }
.hint {
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.create-result {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.create-result h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--navy);
}
.link-row {
  display: flex;
  gap: 8px;
}
.link-row input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--gold);
  border-radius: 8px;
  font-family: 'SF Mono', monospace;
  font-size: 0.85rem;
  background: #fffbea;
}

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
}

/* Comments view */
.comments-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.comment-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--surface-off);
}
.comment-card.resolved {
  opacity: 0.6;
}
.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 8px;
  flex-wrap: wrap;
}
.comment-anchor {
  font-weight: 700;
  color: var(--navy);
  font-size: 0.82rem;
  background: #eaf0fc;
  padding: 2px 8px;
  border-radius: 6px;
}
.comment-author {
  font-weight: 600;
  font-size: 0.85rem;
}
.comment-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.comment-body {
  font-size: 0.92rem;
  margin: 4px 0 6px;
  line-height: 1.4;
}
.resolved-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: #1e7e34;
  text-transform: uppercase;
}
.replies {
  margin-top: 8px;
  padding-left: 16px;
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.reply-card .comment-author { font-size: 0.8rem; }
.reply-card .comment-body { font-size: 0.85rem; margin: 2px 0; }

/* Uploads */
.uploads-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.uploads-section h3 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  color: var(--navy);
}
.uploads-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.upload-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-off);
  font-size: 0.85rem;
  flex-wrap: wrap;
}
.upload-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.upload-name {
  font-weight: 600;
}
.upload-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Projects */
.project-section {
  margin-bottom: 26px;
}
.project-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 2px solid var(--navy);
}
.project-section-header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--navy);
}
.move-select {
  font-family: inherit;
  font-size: 0.78rem;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-muted);
  max-width: 130px;
}

/* User project assignment */
.user-projects {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.user-project-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

/* Versions */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}
.version-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  max-width: 480px;
}
.version-form input[type="text"] {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 140px;
}
.version-form textarea {
  font-family: 'SF Mono', monospace;
  font-size: 0.8rem;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
}
.version-form button { align-self: flex-start; }
.version-latest-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gold-dark);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.version-internal-tag {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-off);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.version-client-row {
  display: flex; align-items: center; gap: 10px; margin-top: 7px; flex-wrap: wrap;
}
.ver-vis-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.78rem; color: var(--text-muted); cursor: pointer; white-space: nowrap;
}
.ver-client-label {
  font-family: inherit; font-size: 0.78rem; padding: 4px 8px;
  border: 1px solid var(--border); border-radius: 6px; min-width: 190px; flex: 1;
}
.ver-client-label:focus { outline: none; border-color: var(--gold); }
.version-file-row {
  display: flex; align-items: center; gap: 10px; margin-top: 7px; flex-wrap: wrap;
}
.ver-file-link {
  font-size: 0.78rem; color: var(--gold-dark); font-weight: 600; text-decoration: none;
}
.ver-file-link:hover { text-decoration: underline; }
.ver-file-attach { font-weight: 500; }

/* Internal comments */
.comment-card.internal {
  background: #eef2fa;
  border-color: #c3cfe8;
}
.internal-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background: var(--navy);
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Version group headers in comments list */
.version-group-header {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 10px 0 2px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* Captions */
.caption-upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.caption-upload-row input[type="text"] {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 140px;
}
.caption-upload-row input[type="file"] {
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.88rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 999;
}

@media (max-width: 700px) {
  .app { padding: 16px; }
  .panel { padding: 16px; }
  .reviews-list { overflow-x: auto; }
}

/* Per-project b-roll uploads (folder-level) */
.project-uploads {
  margin-top: 10px;
}
.project-uploads summary {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  padding: 4px 0;
}
.project-uploads .uploads-list {
  margin-top: 8px;
}

/* ---- Drag-drop video upload (v2.4) ---- */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 18px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.drop-zone.dragover {
  border-color: var(--gold);
  background: #fffdf4;
}
.drop-zone-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
}
.drop-zone-icon {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: var(--navy);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
}
.drop-zone.dragover .drop-zone-icon { background: var(--gold); color: var(--navy); }
.drop-zone-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.drop-zone-text strong { color: var(--navy); font-size: 0.98rem; }
.drop-zone-text span { color: var(--text-muted); font-size: 0.82rem; }

.upload-queue { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.upload-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 14px;
}
.upload-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}
.upload-item-name { font-weight: 600; color: var(--navy); font-size: 0.88rem; word-break: break-all; }
.upload-item-status { font-size: 0.78rem; color: var(--text-muted); flex: none; }
.upload-item.done .upload-item-status { color: #1f7a44; }
.upload-item.error .upload-item-status { color: var(--danger); }
.upload-bar { height: 6px; border-radius: 3px; background: var(--surface-off); overflow: hidden; }
.upload-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--gold);
  border-radius: 3px;
  transition: width 0.2s ease;
}
.upload-item.done .upload-bar-fill { background: #1f7a44; }
.upload-item.error .upload-bar-fill { background: var(--danger); }

.create-file-note {
  background: #fffdf4;
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  color: var(--navy);
  margin-bottom: 4px;
}

/* Drag-to-stack: highlight a review row as a drop target */
tr[data-id].drop-target > td { background: #fffdf4 !important; box-shadow: inset 0 0 0 2px var(--gold); }

@media (max-width: 640px) {
  .drop-zone-inner { flex-wrap: wrap; }
  .drop-zone-text { flex-basis: 100%; order: 3; }
}
