/* audio_enhance_service — competitor-grade dark theme.
 * Vanilla CSS, no build step. Inspired by LANDR / RoEx / Cryo Mix:
 * clean, trustworthy, modern, scientific. All UI copy in Vietnamese.
 */

:root {
  /* surfaces — DESIGN SYSTEM (user chốt 2026-06-10): near-black + card #1b1b27 + champagne accent */
  --bg: #0a0a0c;
  --bg-grad-1: #14141c;
  --bg-grad-2: #0a0a0c;
  --bg-alt: #121219;
  --card: #1b1b27;
  --card-2: #22222f;
  --card-3: #2a2a38;
  --border: #2b2b38;
  --border-soft: #232330;

  /* text */
  --text: #f3f3f6;
  --text-dim: #c4c4cf;
  --muted: #8a8a98;
  --faint: #5d5d6a;

  /* brand / accent = vàng champagne (màu thương hiệu) — 10/7: primary đồng bộ champagne theo /admin2
   * (nút/tab/focus hết blue; blue chỉ còn nghĩa "dịch vụ ngoài" qua --ext/--info) */
  --primary: #c9a84c;
  --primary-hover: #dcbb5e;
  --primary-soft: rgba(201, 168, 76, 0.14);
  --accent: #c9a84c;
  --accent-hover: #dcbb5e;
  --accent-soft: rgba(201, 168, 76, 0.14);
  --accent-2: #8b5cf6;            /* tím = AI */

  /* semantic — màu trạng thái CỐ ĐỊNH: xanh lá=tốt/hot, đỏ=loại, vàng=chờ, tím=AI, xanh dương=dịch vụ ngoài */
  --ok: #2fd07b;
  --ok-soft: rgba(47, 208, 123, 0.14);
  --warn: #e8b13a;
  --warn-soft: rgba(232, 177, 58, 0.14);
  --err: #f0563d;
  --err-soft: rgba(240, 86, 61, 0.14);
  --ai: #8b5cf6;
  --ai-soft: rgba(139, 92, 246, 0.16);
  --ext: #5b8cff;                 /* dịch vụ ngoài (Drive/sheet/box) */
  --ext-soft: rgba(91, 140, 255, 0.14);
  --info: #5b8cff;
  --gray: #6b7587;

  /* shape — card/toolbar bo góc 8px */
  --radius: 8px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.36);
  --ring: 0 0 0 3px rgba(201, 168, 76, 0.22);

  font-size: 15px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(1100px 560px at 78% -12%, var(--bg-grad-1) 0%, transparent 60%),
    radial-gradient(900px 520px at 8% 4%, rgba(139, 92, 246, 0.10) 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

/* ---------- utilities ---------- */
.hidden {
  display: none !important;
}
.muted {
  color: var(--muted);
}
.dim {
  color: var(--text-dim);
}
.mono {
  font-family: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  font-size: 0.85em;
}
.right {
  text-align: right;
}
.nowrap {
  white-space: nowrap;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}
h2 {
  margin: 0 0 4px;
  font-size: 1.18rem;
}
h3 {
  font-size: 0.96rem;
  color: var(--text-dim);
  font-weight: 600;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.section-head .sub {
  margin: 2px 0 0;
  font-size: 0.86rem;
  color: var(--muted);
}

/* ---------- cards ---------- */
.card {
  background: linear-gradient(180deg, var(--card) 0%, #141a25 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: rgba(15, 19, 28, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
}
.brand .logo {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #f2d580 0%, #c9a84c 100%);
  box-shadow: 0 4px 14px rgba(201, 168, 76, 0.35);
  font-size: 1rem;
}
.brand .logo svg {
  width: 17px;
  height: 17px;
  display: block;
}
.brand .tag {
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-left: 2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-label {
  color: var(--text-dim);
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.user-label .avatar {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--card-3);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
}

.navlink {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.14s, color 0.14s;
}
.navlink:hover {
  background: var(--card-2);
  color: var(--text);
}

/* ---------- main wrap ---------- */
.wrap {
  max-width: 1320px;
  margin: 0 auto;
  padding: 30px 24px 72px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ---------- auth / login ---------- */
.auth-shell {
  width: 100%;
  max-width: 940px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.auth-hero {
  position: relative;
  padding: 44px 40px;
  background:
    radial-gradient(600px 300px at 20% 0%, rgba(201, 168, 76, 0.25) 0%, transparent 60%),
    radial-gradient(500px 320px at 100% 100%, rgba(139, 92, 246, 0.22) 0%, transparent 60%),
    linear-gradient(160deg, #1a1712 0%, #0f0d09 100%);   /* nền warm-dark như /admin2 (gold=brand, tím=AI) */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 520px;
}
.auth-hero .brand {
  font-size: 1.25rem;
}
.auth-hero h1 {
  font-size: 2rem;
  line-height: 1.18;
  margin: 26px 0 14px;
  letter-spacing: -0.02em;
  /* chữ champagne gradient — cùng ngôn ngữ với tiêu đề /admin2 */
  background: linear-gradient(135deg, #f5e6c8 0%, #e5c168 55%, #c9a84c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.auth-hero .lead {
  color: var(--text-dim);
  font-size: 0.98rem;
  max-width: 32ch;
}
.hero-points {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.hero-points li {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  font-size: 0.92rem;
  color: var(--text-dim);
}
.hero-points .ic {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
  margin-top: 1px;
}
.hero-foot {
  margin-top: 30px;
  font-size: 0.78rem;
  color: var(--faint);
}

.auth-panel {
  background: linear-gradient(180deg, var(--card) 0%, #131825 100%);
  padding: 40px 38px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-panel .panel-head {
  margin-bottom: 22px;
}
.auth-panel .panel-head h2 {
  font-size: 1.4rem;
}
.auth-panel .panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
}
.auth-head {
  text-align: center;
  margin-bottom: 18px;
}

.tabs {
  display: flex;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 22px;
}
.tab {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 10px 0;
  font-size: 0.92rem;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.14s, color 0.14s;
}
.tab.active {
  background: var(--primary);
  color: #241a06;
  box-shadow: 0 4px 12px rgba(201, 168, 76, 0.3);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* ---------- labels & inputs ---------- */
label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

input,
select,
textarea {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 0.94rem;
  outline: none;
  width: 100%;
  font-family: inherit;
  transition: border-color 0.14s, box-shadow 0.14s, background 0.14s;
}
input::placeholder {
  color: var(--faint);
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--ring);
  background: var(--card);
}
select {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 53%,
    calc(100% - 13px) 53%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
input[type="file"] {
  padding: 9px;
}

/* ---------- buttons ---------- */
.btn {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 17px;
  font-size: 0.91rem;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.13s, border-color 0.13s, opacity 0.13s, transform 0.06s;
}
.btn:hover:not(:disabled) {
  background: var(--card-3);
  border-color: #4a4232;
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: linear-gradient(180deg, var(--primary-hover) 0%, var(--primary) 100%);
  border-color: var(--primary);
  color: #241a06;   /* chữ tối trên nền gold — đủ tương phản (trắng trên gold quá mờ) */
  box-shadow: 0 6px 18px rgba(201, 168, 76, 0.3);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #e8ca75 0%, var(--primary-hover) 100%);
  border-color: var(--primary-hover);
}
.btn-block {
  width: 100%;
}
.btn-small {
  padding: 7px 13px;
  font-size: 0.84rem;
}
.btn-icon {
  padding: 7px 11px;
  font-size: 0.95rem;
  line-height: 1;
}
.btn-ghost {
  background: transparent;
  border-color: var(--border);
}
.btn-danger {
  border-color: rgba(240, 86, 61, 0.5);
  color: #ff9d8c;
}
.btn-danger:hover:not(:disabled) {
  background: var(--err-soft);
  border-color: var(--err);
}
.btn-ok {
  border-color: rgba(47, 208, 123, 0.5);
  color: #7ee2af;
  background: var(--ok-soft);
}
.btn-muted {
  color: var(--muted);
}

/* spinner inside buttons / messages */
.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}
.spinner-dim {
  border-color: rgba(139, 149, 169, 0.35);
  border-top-color: var(--text);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- form messages ---------- */
.form-msg {
  margin: 14px 0 0;
  font-size: 0.87rem;
  min-height: 1.1em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-msg.error {
  color: var(--err);
}
.form-msg.ok {
  color: var(--ok);
}

/* ============================================================
 *  UPLOAD — drag & drop dropzone
 * ============================================================ */
.upload-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: stretch;
}

.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  background:
    radial-gradient(420px 200px at 50% -10%, var(--primary-soft) 0%, transparent 70%),
    var(--bg-alt);
  padding: 30px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s, box-shadow 0.16s;
  min-height: 168px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.dropzone:hover {
  border-color: #4a4232;
}
.dropzone.dragover {
  border-color: var(--primary);
  background:
    radial-gradient(420px 220px at 50% -10%, rgba(201, 168, 76, 0.22) 0%, transparent 70%),
    var(--card);
  box-shadow: var(--ring);
}
.dropzone.has-file {
  border-style: solid;
  border-color: rgba(47, 208, 123, 0.55);
}
.dropzone .dz-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 1.5rem;
  margin-bottom: 4px;
}
.dropzone.has-file .dz-icon {
  background: var(--ok-soft);
  color: var(--ok);
}
.dropzone .dz-title {
  font-weight: 700;
  color: var(--text);
  font-size: 1rem;
}
.dropzone .dz-sub {
  color: var(--muted);
  font-size: 0.85rem;
}
.dropzone .dz-formats {
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--faint);
}
.dropzone input[type="file"] {
  display: none;
}

.file-chip {
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  max-width: 100%;
}
.file-chip .fc-name {
  font-weight: 600;
  color: var(--text);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}
.file-chip .fc-size {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}
.file-chip .fc-clear {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  padding: 0 2px;
}
.file-chip .fc-clear:hover {
  color: var(--err);
}

.upload-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg-alt);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 18px;
}
.tier-hint {
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  line-height: 1.5;
  min-height: 2.4em;
}
.tier-hint b {
  color: var(--text-dim);
}
.tier-note {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}
.tier-note b {
  color: var(--text-dim);
}

/* ============================================================
 *  JOB CARDS
 * ============================================================ */
.jobs-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.job-card {
  background: linear-gradient(180deg, var(--card-2) 0%, #181f2c 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.job-card:hover {
  border-color: #4a4232;
}
.job-card.expanded {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(201, 168, 76, 0.3), var(--shadow-sm);
}

.job-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  cursor: default;
}
.job-head.clickable {
  cursor: pointer;
}
.job-head.clickable:hover {
  background: rgba(255, 255, 255, 0.018);
}
.job-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--card-3);
  border: 1px solid var(--border);
  color: var(--primary);
  font-size: 1.05rem;
}
.job-meta {
  flex: 1 1 auto;
  min-width: 0;
}
.job-name {
  font-weight: 650;
  font-size: 0.96rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job-sub {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 2px;
  flex-wrap: wrap;
}
.job-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.job-caret {
  color: var(--muted);
  font-size: 0.8rem;
  transition: transform 0.18s;
  margin-left: 2px;
}
.job-card.expanded .job-caret {
  transform: rotate(180deg);
}

.job-detail {
  border-top: 1px solid var(--border);
  padding: 20px 18px 22px;
  background: var(--bg-alt);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
}

.detail-block .block-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- A/B player ---------- */
.ab-player {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 16px 18px;
}
.ab-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.ab-switch {
  display: inline-flex;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  position: relative;
}
.ab-switch button {
  position: relative;
  z-index: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.86rem;
  padding: 8px 22px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.16s;
  font-family: inherit;
}
.ab-switch button.active {
  color: #fff;
}
.ab-switch .ab-thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--primary-hover), var(--primary));
  box-shadow: 0 4px 12px rgba(201, 168, 76, 0.35);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s;
}
.ab-switch.on-master .ab-thumb {
  transform: translateX(100%);
  background: linear-gradient(180deg, #36e0b6, var(--accent));
  box-shadow: 0 4px 12px rgba(34, 211, 170, 0.4);
}
.ab-now {
  font-size: 0.82rem;
  color: var(--muted);
}
.ab-now b {
  color: var(--text);
}

.waveform-wrap {
  position: relative;
  width: 100%;
  height: 72px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-alt);
  border: 1px solid var(--border-soft);
}
.waveform-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.waveform-progress {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  background: rgba(201, 168, 76, 0.14);
  border-right: 1px solid rgba(201, 168, 76, 0.6);
  pointer-events: none;
}

.transport {
  display: flex;
  align-items: center;
  gap: 12px;
}
.transport .play-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--primary-hover), var(--primary));
  border: 0;
  color: #241a06;
  font-size: 1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 5px 14px rgba(201, 168, 76, 0.35);
  transition: transform 0.07s;
}
.transport .play-btn:active {
  transform: scale(0.94);
}
.seek {
  flex: 1 1 auto;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: var(--card-3);
  cursor: pointer;
  padding: 0;
  border: 0;
}
.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.seek::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--primary);
  cursor: pointer;
}
.time-read {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  color: var(--muted);
  min-width: 86px;
  text-align: right;
}

/* ---------- QC scientific table ---------- */
.verdict-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.verdict {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.84rem;
  border: 1px solid transparent;
}
.verdict.ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: rgba(47, 208, 123, 0.4);
}
.verdict.fail {
  background: var(--err-soft);
  color: var(--err);
  border-color: rgba(240, 86, 61, 0.4);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.chip.good {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: rgba(47, 208, 123, 0.35);
}
.chip.bad {
  background: var(--err-soft);
  color: #ff8a76;
  border-color: rgba(240, 86, 61, 0.35);
}
.chip.warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: rgba(232, 177, 58, 0.35);
}

.qc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.qc-table th,
.qc-table td {
  padding: 10px 13px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}
.qc-table thead th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--card-2);
  font-weight: 700;
}
.qc-table tbody tr:last-child td {
  border-bottom: 0;
}
.qc-table td.num,
.qc-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.qc-metric {
  font-weight: 600;
  color: var(--text);
}
.qc-metric .qc-unit {
  color: var(--faint);
  font-weight: 400;
  font-size: 0.8em;
  margin-left: 4px;
}
.qc-metric .qc-desc {
  display: block;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.78rem;
  margin-top: 1px;
}
.qc-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.qc-delta.up-good,
.qc-delta.down-good {
  color: var(--ok);
}
.qc-delta.up-bad,
.qc-delta.down-bad {
  color: #ff8a76;
}
.qc-delta.flat {
  color: var(--faint);
}
.qc-arrow {
  font-size: 0.9em;
}

.qc-empty {
  color: var(--muted);
  font-size: 0.86rem;
  padding: 10px 0;
}

.detail-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.btn-release {
  border-color: rgba(34, 211, 170, 0.5);
  color: #7ee2cf;
  background: var(--ok-soft);
}
.btn-release:hover:not(:disabled) {
  background: rgba(34, 211, 170, 0.18);
  border-color: var(--accent);
}
.pkg-note {
  font-size: 0.8rem;
  color: var(--warn);
}

/* ---------- empty / loading states ---------- */
.empty-state {
  text-align: center;
  padding: 44px 20px;
  color: var(--muted);
}
.empty-state .es-icon {
  font-size: 2.2rem;
  opacity: 0.55;
  margin-bottom: 8px;
}
.loading-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  padding: 14px 2px;
}

/* ============================================================
 *  TABLES (admin)
 * ============================================================ */
.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.89rem;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
.data-table th {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--card-2);
}
.data-table tbody tr:last-child td {
  border-bottom: 0;
}
.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.022);
}
.data-table .qc-cell {
  white-space: normal;
  max-width: 320px;
  color: var(--muted);
}
.data-table .right {
  text-align: right;
}

.mini-select,
.mini-input {
  width: auto;
  min-width: 72px;
  padding: 6px 9px;
  font-size: 0.84rem;
}
.mini-input {
  width: 88px;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  margin-top: 6px;
}
.inline-form label {
  flex: 1 1 170px;
}
.inline-form .btn {
  flex: 0 0 auto;
}

/* ---------- badges & tags ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.77rem;
  font-weight: 700;
  border: 1px solid transparent;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-queued {
  background: rgba(107, 117, 135, 0.16);
  color: #aab3c4;
  border-color: rgba(107, 117, 135, 0.4);
}
.badge-processing {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: rgba(232, 177, 58, 0.4);
}
.badge-processing::before {
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}
.badge-done {
  background: var(--ok-soft);
  color: #56d398;
  border-color: rgba(47, 208, 123, 0.4);
}
.badge-error {
  background: var(--err-soft);
  color: #ff8a76;
  border-color: rgba(240, 86, 61, 0.4);
}

.tier-tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--card-3);
  border: 1px solid var(--border);
  color: var(--text-dim);
  text-transform: uppercase;
}
.tier-tag.tier-max {
  color: var(--accent-2);
  border-color: rgba(139, 92, 246, 0.4);
  background: rgba(139, 92, 246, 0.12);
}
.tier-tag.tier-fast {
  color: var(--accent);
  border-color: rgba(34, 211, 170, 0.35);
  background: rgba(34, 211, 170, 0.1);
}
.tier-tag.tier-release {
  color: var(--accent);
  border-color: rgba(34, 211, 170, 0.35);
  background: rgba(34, 211, 170, 0.1);
}
.tier-tag.tier-max_release {
  color: var(--accent-2);
  border-color: rgba(139, 92, 246, 0.4);
  background: rgba(139, 92, 246, 0.12);
}

/* ---------- responsive ---------- */
@media (min-width: 760px) {
  .detail-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .detail-grid .full {
    grid-column: 1 / -1;
  }
}

@media (max-width: 880px) {
  .auth-shell {
    grid-template-columns: 1fr;
    max-width: 460px;
  }
  .auth-hero {
    min-height: auto;
    padding: 32px 30px;
  }
  .auth-hero .hide-sm {
    display: none;
  }
}

@media (max-width: 720px) {
  .upload-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  :root {
    font-size: 14.5px;
  }
  .topbar {
    padding: 12px 16px;
  }
  .brand .tag {
    display: none;
  }
  .wrap {
    padding: 20px 14px 56px;
  }
  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }
  .file-chip .fc-name {
    max-width: 150px;
  }
}

/* ---------- entities (P7 producer / network) ---------- */
.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--card-2);
}
.seg-btn {
  background: transparent;
  border: none;
  padding: 6px 14px;
  color: var(--text-dim);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}
.seg-btn + .seg-btn {
  border-left: 1px solid var(--border);
}
.seg-btn:hover {
  background: var(--card-3);
  color: var(--text);
}
.seg-btn.active {
  background: var(--primary);
  color: #fff;
}
.ent-actions {
  display: inline-flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* Producer & Network = lưới THẺ (mỗi entity 1 thẻ) — KHÔNG cuộn ngang, tự xuống dòng */
.entity-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.entity-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-2);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.entity-card.is-off { opacity: 0.55; }
.ec-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ec-name {
  font-weight: 700;
  font-size: 1rem;
  margin-right: auto;
  word-break: break-word;
}
.ec-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ec-field {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
  border-top: 1px solid var(--border-soft);
  padding-top: 6px;
}
.ec-field:first-child { border-top: 0; padding-top: 0; }
.ec-k { color: var(--muted); }
.ec-v { font-weight: 600; text-align: right; word-break: break-word; }
.ec-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}
#entity-form label {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--muted);
}
#entity-form textarea {
  vertical-align: top;
}
.ent-hint {
  color: var(--faint);
  font-size: 12px;
  margin: 4px 0 0;
}

/* ============================================================================
 * Dashboard A-Z data management (Pha A) — design system: champagne accent,
 * card #1b1b27, 8px radius, card quan trọng viền trái 3px accent.
 * ========================================================================== */
.tabbar {
  display: flex; gap: 6px; margin-bottom: 18px;
  border-bottom: 1px solid var(--border); padding-bottom: 0;
}
.tab-btn {
  background: transparent; border: none; color: var(--muted);
  font-size: 15px; font-weight: 600; padding: 10px 18px; cursor: pointer;
  border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0; transition: .15s;
}
.tab-btn:hover { color: var(--text-dim); background: rgba(255, 255, 255, 0.03); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabpane[hidden] { display: none; }

/* card quan trọng = viền trái 3px accent */
.card-accent { border-left: 3px solid var(--accent); }

/* stats row — overview */
.stats-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; }
.stat-card {
  flex: 1 1 130px; min-width: 120px; background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-soft); border-radius: 8px; padding: 12px 14px;
  cursor: pointer; transition: .15s; border-left: 3px solid var(--gray);
}
.stat-card:hover { background: rgba(255, 255, 255, 0.06); transform: translateY(-1px); }
.stat-card.active { border-color: var(--accent); box-shadow: var(--ring); }
.stat-card .num { font-size: 24px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-card .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .4px; }
.stat-card.s-done { border-left-color: var(--ok); }
.stat-card.s-error { border-left-color: var(--err); }
.stat-card.s-leased, .stat-card.s-ingested { border-left-color: var(--warn); }
.stat-card.s-published, .stat-card.s-noted, .stat-card.s-sent { border-left-color: var(--ext); }
.stat-card.s-total { border-left-color: var(--accent); }

/* data-grid toolbar + pager */
.dg-toolbar { gap: 10px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.dg-toolbar .dg-date { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.dg-pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 10px; font-size: 13px; color: var(--muted); }
.dg-pager .btn { padding: 4px 12px; }
.cell-ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr.clickable:hover { background: var(--accent-soft); }
.dg-empty { padding: 28px; text-align: center; color: var(--muted); }
.th-sortable { cursor: pointer; user-select: none; }
.th-sortable:hover { color: var(--accent); }

/* status badges — fixed palette */
.badge-ingested, .badge-leased { background: var(--warn-soft); color: var(--warn); }
.badge-published, .badge-noted, .badge-sent { background: var(--ext-soft); color: var(--ext); }
.badge-done { background: var(--ok-soft); color: var(--ok); }
.badge-error { background: var(--err-soft); color: var(--err); }
.badge-ai { background: var(--ai-soft); color: var(--ai); }

/* drawer (chi tiết 1 link) */
.drawer { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.drawer.open { pointer-events: auto; }
.drawer-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); opacity: 0; transition: .2s; }
.drawer.open .drawer-overlay { opacity: 1; }
.drawer-panel {
  position: absolute; top: 0; right: 0; height: 100%; width: min(540px, 94vw);
  background: var(--card); border-left: 3px solid var(--accent); box-shadow: var(--shadow);
  transform: translateX(100%); transition: transform .22s ease; overflow-y: auto; padding: 22px;
}
.drawer.open .drawer-panel { transform: translateX(0); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.drawer-head h3 { margin: 0; color: var(--accent); }
.drawer-section { margin: 16px 0; }
.drawer-section h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.kv { display: flex; gap: 10px; font-size: 13px; padding: 3px 0; }
.kv .k { color: var(--muted); flex: 0 0 120px; }
.kv .v { color: var(--text); word-break: break-all; }

/* timeline */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline-step { position: relative; padding: 6px 0; font-size: 13px; color: var(--faint); }
.timeline-step::before { content: ""; position: absolute; left: -19px; top: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--border); border: 2px solid var(--card); }
.timeline-step.done { color: var(--text); }
.timeline-step.done::before { background: var(--accent); }
.timeline-step .ts { color: var(--muted); font-size: 12px; margin-left: 8px; }

/* Pha B — chip công đoạn pipeline trong drawer */
.stage-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-chip { font-size: 12px; padding: 4px 10px; border-radius: 12px; border: 1px solid var(--border); color: var(--faint); background: rgba(255, 255, 255, 0.02); }
.stage-chip.done { color: var(--ok); border-color: rgba(47, 208, 123, 0.5); background: var(--ok-soft); }
.stage-chip.current { color: var(--ai); border-color: rgba(139, 92, 246, 0.6); background: var(--ai-soft); animation: stagepulse 1.3s ease-in-out infinite; }
.stage-chip.pending { color: var(--faint); }
.stage-hint { color: var(--ai); font-size: 12px; }
@keyframes stagepulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* Pha C — thao tác quản trị trong drawer + nút cảnh báo */
.btn-warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(232, 177, 58, 0.5); }
.btn-warn:hover:not(:disabled) { background: rgba(232, 177, 58, 0.24); }
.drawer-actions { border-top: 1px solid var(--border); padding-top: 14px; }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.action-row .mini-input { flex: 1 1 130px; width: auto; min-width: 110px; }
.action-row .mini-select { flex: 0 0 auto; }

/* ---------- quality floor (10/7): keyboard focus + reduced motion ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
