/* Self-hosted, hand-written styles. No CDN / no inline styles so the strict CSP
   (style-src 'self') holds on every page. System font stack avoids web fonts. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #2c5fd6;
  --primary-hover: #234dad;
  --danger: #c0392b;
  --success: #1f8a4c;
  --radius: 10px;
  --space: 1rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
}

a {
  color: var(--primary);
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

/* Layout */
.container {
  max-width: 720px;
  margin: 2rem auto;
  padding: 0 1rem;
}
.auth-card {
  max-width: 26rem;
  margin: 3rem auto;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}
.card h1 {
  margin-top: 0;
  font-size: 1.4rem;
}

/* Forms */
form label {
  display: block;
  margin: 1rem 0 0.3rem;
  font-weight: 600;
  font-size: 0.92rem;
}
input[type="email"],
input[type="password"],
input[type="text"],
input[type="date"],
input[type="file"],
select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
}
input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44, 95, 214, 0.15);
}

/* Buttons */
.btn {
  display: inline-block;
  border: 0;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn--primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
  margin-top: 1.25rem;
}
.btn--primary:hover {
  background: var(--primary-hover);
}
.btn--link {
  background: none;
  color: var(--primary);
  padding: 0;
  width: auto;
}
.form-footer {
  margin-top: 1.25rem;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Flash + banners */
.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1.25rem;
  border: 1px solid transparent;
}
.flash--info {
  background: #eef2ff;
  border-color: #c7d2fe;
}
.flash--success {
  background: #e8f6ee;
  border-color: #bfe3cd;
  color: var(--success);
}
.flash--error {
  background: #fdecea;
  border-color: #f5c6c0;
  color: var(--danger);
}
.banner {
  background: #fff7e6;
  border: 1px solid #f5d9a0;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Tables / misc (upload history, etc.) */
table {
  border-collapse: collapse;
  width: 100%;
}
th,
td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  text-align: left;
}
.note {
  color: var(--muted);
  font-size: 0.9rem;
}
.verdict-na {
  color: #888;
}

/* --- Management UI (Stage 6a) ------------------------------------------------ */

.container--wide {
  max-width: 1040px;
}

/* Header user menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.user-menu__name {
  font-weight: 600;
}
.user-menu__org {
  display: inline;
}

/* Section nav */
.app-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.app-nav__link {
  display: inline-block;
  padding: 0.5rem 0.1rem;
  text-decoration: none;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
.app-nav__link.is-active {
  color: var(--text);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.app-nav__link.is-disabled {
  color: #b3b8c2;
  cursor: not-allowed;
}

/* Page heading row */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.page-head h1 {
  margin: 0;
  font-size: 1.4rem;
}

/* Filters */
.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.filters__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
}
.filters__row + .filters__row {
  margin-top: 0.75rem;
}
.filters label {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.filters select,
.filters input[type="date"] {
  width: auto;
  min-width: 9rem;
}
.filters__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

/* Buttons (extra variants) */
.btn--secondary {
  background: #eef1f6;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn--secondary:hover {
  background: #e2e6ee;
}
.btn--danger {
  background: var(--danger);
  color: #fff;
}
.btn--sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  width: auto;
  margin-top: 0;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.table-wrap table {
  margin: 0;
}
.table-wrap th {
  background: #f0f2f6;
  font-size: 0.85rem;
}
.table-wrap td {
  vertical-align: top;
}
td.empty {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem;
}

/* Status pills */
.status {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: #eceff4;
  color: var(--muted);
}
.status--pending {
  background: #eef2ff;
  color: #3a4cc0;
}
.status--processing {
  background: #fff4e0;
  color: #9a6700;
}
.status--completed,
.status--active {
  background: #e8f6ee;
  color: var(--success);
}
.status--failed,
.status--error {
  background: #fdecea;
  color: var(--danger);
}
.tag {
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 0.35rem;
  white-space: nowrap;
}

/* Pagination */
.pager {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

/* Video player + progress (Stage 7d) */
.job-video {
  width: 100%;
  max-width: 640px;
  border-radius: 8px;
  background: #000;
  margin-bottom: 1rem;
  display: block;
}
#job-progress progress {
  width: 100%;
  max-width: 480px;
  height: 1rem;
}
.seek-btn {
  font-size: 0.85rem;
}

/* Check result + judgment UI (Stage 7c) */
.judge-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  margin-bottom: 1rem;
}
.hit {
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.75rem;
  background: #fff;
}
.hit--ng_confirmed,
.hit--auto_ng,
.hit--ng {
  border-left-color: var(--danger);
}
.hit--review {
  border-left-color: #9a6700;
}
.hit--ok_confirmed {
  border-left-color: var(--success);
}
.hit--hold {
  border-left-color: var(--muted);
}
.hit__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.hit__time {
  color: var(--muted);
  font-size: 0.85rem;
}
.hit__text {
  font-weight: 600;
  margin: 0.5rem 0 0.25rem;
}
.hit__frame {
  max-width: 320px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 0.5rem;
}
.level {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
}
.level--ng_confirmed,
.level--auto_ng,
.level--ng {
  background: var(--danger);
}
.level--review {
  background: #9a6700;
}
.level--ok_confirmed {
  background: var(--success);
}
.level--hold {
  background: var(--muted);
}
.judge-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.judge-note {
  flex: 1 1 12rem;
  min-width: 8rem;
}
.transcript {
  margin: 0.25rem 0 1rem;
  padding-left: 1rem;
  font-size: 0.9rem;
}
.raw-sections {
  margin-top: 1rem;
}
.raw-sections summary {
  cursor: pointer;
  color: var(--primary);
}

/* Inline row actions (edit link + delete form) in master tables */
.row-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  font-weight: 600;
  font-size: 0.92rem;
}
.checkbox-label input {
  width: auto;
}

/* Detail definition list */
.detail {
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
}
.detail dt {
  color: var(--muted);
  font-size: 0.9rem;
}
.detail dd {
  margin: 0;
}
.card + .card {
  margin-top: 1.25rem;
}
.card h2 {
  margin-top: 0;
  font-size: 1.1rem;
}
.result {
  background: #f0f2f6;
  border-radius: 8px;
  padding: 0.75rem;
  overflow-x: auto;
  font-size: 0.85rem;
}
.share-form {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.share-form label {
  margin: 0;
}
.share-form select {
  width: auto;
}
.share-url {
  min-width: 16rem;
  font-size: 0.82rem;
  background: #f0f2f6;
}

@media (max-width: 480px) {
  .container {
    margin: 1rem auto;
  }
  .auth-card {
    margin: 1.5rem auto;
  }
  .card {
    padding: 1.25rem;
  }
  .detail {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
  .detail dt {
    margin-top: 0.5rem;
  }
  .filters__actions {
    margin-left: 0;
  }
}
