* { box-sizing: border-box; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: #f4f5f7;
  margin: 0;
  color: #1f2937;
}

/* ---- Auth (modal) ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  padding: 16px;
}
.auth-card {
  background: #fff; padding: 32px; border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25); width: 360px; max-width: 100%;
  position: relative;
}
.modal-close-btn {
  position: absolute; top: 10px; right: 10px; border: none; background: none;
  font-size: 16px; cursor: pointer; color: #888; padding: 4px 8px;
}
.modal-close-btn:hover { color: #333; }
.auth-modal-hint {
  font-size: 13px; color: #2563eb; background: #eff6ff; padding: 8px 10px;
  border-radius: 6px; margin-bottom: 14px; text-align: center; display: none;
}
.auth-card h1 { text-align: center; font-size: 22px; margin-bottom: 16px; }
.tabs { display: flex; margin-bottom: 16px; }
.tab-btn {
  flex: 1; padding: 8px; border: none; background: #eee; cursor: pointer;
  border-radius: 6px; margin: 0 4px; font-weight: 600;
}
.tab-btn.active { background: #2563eb; color: #fff; }
.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-form label { font-size: 13px; color: #555; margin-top: 6px; }
.auth-form input {
  padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px;
}
.auth-form button {
  margin-top: 14px; padding: 10px; border: none; border-radius: 6px;
  background: #2563eb; color: #fff; font-weight: 600; cursor: pointer;
}
.auth-error { color: #dc2626; font-size: 13px; min-height: 18px; }

/* ---- Auth: mục mới (Gmail/SĐT, quên mật khẩu) ---- */
.auth-panel { display: flex; flex-direction: column; }
.google-btn-slot { display: flex; justify-content: center; min-height: 40px; margin-bottom: 4px; }
.auth-or-divider {
  display: flex; align-items: center; text-align: center; color: #9ca3af;
  font-size: 12px; margin: 14px 0;
}
.auth-or-divider::before, .auth-or-divider::after {
  content: ""; flex: 1; border-bottom: 1px solid #e5e7eb;
}
.auth-or-divider span { padding: 0 10px; }
.subtabs { display: flex; margin-bottom: 14px; gap: 6px; }
.subtab-btn {
  flex: 1; padding: 7px 4px; border: 1px solid #d1d5db; background: #fff;
  cursor: pointer; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: #374151;
}
.subtab-btn.active { background: #eff6ff; border-color: #2563eb; color: #2563eb; }
.auth-note { font-size: 12.5px; color: #6b7280; line-height: 1.5; margin: 0 0 10px; }
.link-btn {
  background: none; border: none; color: #2563eb; font-size: 13px; cursor: pointer;
  padding: 6px 0; text-align: center; font-weight: 600;
}
.link-btn:hover { text-decoration: underline; }
.auth-subheading { font-size: 17px; margin: 4px 0 16px; text-align: center; }
#register-gmail-step1, #register-gmail-step2,
#register-phone-step1, #register-phone-step2 { display: flex; flex-direction: column; }
#register-phone-step1, #register-gmail-step1 { margin-top: 0; }


/* ---- 1. Header ---- */
.app-header {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
  background: #fff; padding: 10px 24px; box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  position: sticky; top: 0; z-index: 100;
}
.app-logo { font-size: 19px; font-weight: 800; color: #1e3a8a; letter-spacing: -0.02em; }
.header-nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.header-nav-link {
  font-size: 13px; font-weight: 600; color: #444; text-decoration: none;
}
.header-nav-link:hover { color: #2563eb; }
.header-right { display: flex; align-items: center; gap: 12px; font-size: 14px; color: #555; flex-wrap: wrap; justify-content: flex-end; }

.app-body {
  max-width: 1140px; margin: 20px auto; padding: 0 16px;
  display: flex; flex-direction: column; gap: 16px;
}
.panel {
  background: #fff; border-radius: 12px; padding: 18px 22px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.panel h2 { font-size: 15px; margin: 0 0 10px; color: #1e3a8a; }
.panel h3 { font-size: 13px; margin: 12px 0 6px; color: #555; }

/* ---- Numbered step sections (①②③④⑤) ---- */
.step-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.step-badge {
  flex: none; width: 32px; height: 32px; border-radius: 999px; background: #eff6ff;
  color: #2563eb; font-weight: 800; font-size: 14px; display: flex;
  align-items: center; justify-content: center;
}
.step-header h2 { margin: 0 0 2px; font-size: 16px; }
.step-desc { margin: 0; font-size: 12px; color: #888; }

.grid-3 {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 16px;
}
.grid-3 label { display: flex; flex-direction: column; font-size: 12px; color: #555; gap: 4px; }
.grid-3 input, .grid-3 select { padding: 7px 8px; border: 1px solid #d1d5db; border-radius: 6px; }
label.block { display: block; margin-top: 12px; font-size: 13px; color: #555; }
input[type="range"] { width: 100%; }
textarea {
  width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 6px;
  font-family: inherit; resize: vertical; margin-top: 4px;
}
input[type="file"] { margin: 6px 0; }
input[type="color"] { width: 48px; height: 30px; padding: 0; border: none; }

.file-list { list-style: none; padding: 0; margin: 8px 0; font-size: 13px; }
.file-list li { padding: 2px 0; color: #333; }
.file-name { font-size: 13px; color: #333; margin-top: 4px; }

/* ---- Cấu hình nâng cao (accordion, chỉ áp dụng cho mục 3) ---- */
.advanced-settings { margin-top: 16px; border-top: 1px solid #f0f1f3; padding-top: 12px; }
.advanced-settings summary {
  cursor: pointer; font-size: 13px; font-weight: 700; color: #444; list-style: none;
  padding: 4px 0; user-select: none;
}
.advanced-settings summary::-webkit-details-marker { display: none; }
.advanced-settings summary::before { content: "▸ "; color: #2563eb; }
.advanced-settings[open] summary::before { content: "▾ "; }
.advanced-settings-body { padding-top: 12px; }

/* ---- Video nền: upload / link ---- */
.video-source-tabs { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.video-source-tab-btn {
  padding: 8px 14px; border: 1px solid #d1d5db; background: #fff; cursor: pointer;
  border-radius: 6px; font-size: 13px; font-weight: 600; color: #444;
}
.video-source-tab-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.video-source-pane { padding-top: 2px; }
.video-count-label { font-size: 12px; color: #888; margin-top: 8px; }
.video-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; background: #f9fafb; border-radius: 6px; margin-bottom: 4px;
}
.remove-video-btn {
  background: none; border: none; color: #dc2626; cursor: pointer; font-size: 13px;
  padding: 0 4px; font-weight: 700;
}
.url-fetch-status { margin-top: 8px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.url-status-row { color: #555; }
.url-status-ok { color: #16a34a; }
.url-status-err { color: #dc2626; }
.jobs-login-hint { font-size: 13px; color: #666; background: #f3f4f6; padding: 10px 12px; border-radius: 6px; }

.btn-primary {
  background: #16a34a; color: #fff; border: none; padding: 10px 22px;
  border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 14px;
}
.btn-primary:disabled { background: #9ca3af; cursor: not-allowed; }
.btn-secondary {
  background: #e5e7eb; color: #333; border: none; padding: 7px 14px;
  border-radius: 6px; cursor: pointer; font-size: 13px; text-decoration: none;
  display: inline-block;
}
.btn-secondary:disabled { background: #f3f4f6; color: #9ca3af; cursor: not-allowed; }
.tag-downloaded { color: #16a34a; font-size: 12px; margin-left: 4px; }
.expires-hint { color: #9ca3af; font-size: 11px; margin-left: 4px; }
.expires-hint.expires-soon { color: #d97706; font-weight: 600; }
.btn-danger { color: #dc2626; border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }

/* ---- Render CTA (mục 10) ---- */
.render-panel { text-align: center; }
.btn-render {
  width: 100%; background: linear-gradient(135deg, #16a34a, #15803d); color: #fff;
  border: none; padding: 18px 24px; border-radius: 10px; font-weight: 800;
  font-size: 17px; letter-spacing: 0.02em; cursor: pointer;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.3);
}
.btn-render:hover { filter: brightness(1.04); }
.btn-render:disabled { background: #9ca3af; box-shadow: none; cursor: not-allowed; }

/* ---- Ước tính sử dụng (mục 9) ---- */
.estimate-box {
  background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 14px 16px; margin-bottom: 16px; text-align: left; font-size: 13px;
}
.estimate-title { font-weight: 700; color: #1e3a8a; margin-bottom: 8px; }
.estimate-row { display: flex; justify-content: space-between; margin-bottom: 4px; color: #555; }
.estimate-strong { font-weight: 700; color: #111; }
.estimate-note { color: #888; font-size: 12px; margin-top: 4px; }

/* ---- Lịch sử render: job cards (mục 11-14) ---- */
.jobs-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.job-card {
  border: 1px solid #eee; border-radius: 10px; padding: 12px 14px; background: #fafafa;
}
.job-card-head {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px;
  margin-bottom: 8px;
}
.job-card-status { font-weight: 700; font-size: 13px; }
.job-card-status.status-completed { color: #16a34a; }
.job-card-status.status-failed { color: #dc2626; }
.job-card-status.status-running { color: #2563eb; }
.job-card-status.status-cancelled { color: #92400e; }
.job-card-status.status-queued { color: #6b7280; }
.job-card-date { font-size: 12px; color: #9ca3af; }
.job-progress-track { background: #e5e7eb; border-radius: 999px; height: 8px; overflow: hidden; margin: 8px 0; }
.job-progress-fill { background: #2563eb; height: 100%; border-radius: 999px; transition: width 0.3s; }
.job-progress-fill.job-progress-done { background: #16a34a; }
.job-progress-fill.job-progress-failed { background: #dc2626; }
.job-progress-pct { font-size: 12px; color: #888; }
.job-queue-position { font-size: 12px; color: #6b7280; margin-bottom: 6px; }
.job-card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.job-error-note { font-size: 12px; color: #dc2626; margin-bottom: 6px; }

#job-log-box {
  background: #111827; color: #d1d5db; padding: 10px; border-radius: 6px;
  font-size: 12px; max-height: 260px; overflow: auto; white-space: pre-wrap;
}

/* ---- MP3 / TTS ---- */
.mp3-status {
  font-size: 13px; color: #1e3a8a; background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 6px; padding: 8px 10px; margin-bottom: 10px;
}
.mp3-tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.mp3-tab-btn {
  padding: 8px 14px; border: 1px solid #d1d5db; background: #fff; cursor: pointer;
  border-radius: 6px; font-size: 13px; font-weight: 600; color: #444;
}
.mp3-tab-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.mp3-pane { padding-top: 4px; }
.char-count { font-size: 12px; color: #888; text-align: right; margin-top: 2px; }
.tts-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.tts-result {
  margin-top: 14px; padding: 10px 12px; background: #f0fdf4; border: 1px solid #bbf7d0;
  border-radius: 8px; font-size: 13px; color: #166534;
}

.plan-badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700;
  background: #eff6ff; color: #1e3a8a; border: 1px solid #bfdbfe; border-radius: 999px;
  padding: 4px 10px;
}

/* ---- 2. Dashboard gói & tài nguyên ---- */
.dashboard-panel { padding-top: 18px; }
.dashboard-usage-card { margin-bottom: 16px; }
.account-plan-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 14px;
}
.account-plan-name { font-size: 18px; font-weight: 800; color: #1e3a8a; }
.account-plan-expires { font-size: 12px; color: #9ca3af; }
.dashboard-upgrade-btn { font-weight: 700; }

.usage-block { margin-bottom: 2px; }
.usage-label {
  display: flex; justify-content: space-between; font-size: 12px; font-weight: 700;
  color: #555; letter-spacing: 0.03em; margin-bottom: 6px; text-transform: uppercase;
}
.usage-bar-track { background: #e5e7eb; border-radius: 999px; height: 12px; overflow: hidden; }
.usage-bar-fill { background: #16a34a; height: 100%; border-radius: 999px; transition: width 0.3s; }
.usage-bar-fill.usage-bar-warn { background: #f59e0b; }
.usage-bar-fill.usage-bar-full { background: #dc2626; }
.usage-hint { font-size: 12px; color: #888; margin-top: 6px; }
.usage-hint a { color: #2563eb; font-weight: 600; text-decoration: none; }
.usage-hint a:hover { text-decoration: underline; }

.usage-mini-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.usage-mini-item {
  background: #f9fafb; border-radius: 8px; padding: 12px 8px; text-align: center;
}
.usage-mini-icon { display: block; font-size: 15px; margin-bottom: 2px; }
.usage-mini-item span:not(.usage-mini-icon) { display: block; font-size: 18px; font-weight: 700; color: #1e3a8a; }
.usage-mini-item label { display: block; font-size: 11px; color: #888; margin-top: 2px; }

/* ---- Bảng giá ---- */
.pricing-title { font-size: 20px !important; text-align: center; color: #111 !important; }
.pricing-subtitle { text-align: center; color: #666; font-size: 14px; margin: 0 0 20px; }

.pricing-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px;
  margin-bottom: 24px;
}
.pricing-card {
  position: relative; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 22px 16px; text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 4px;
}
.pricing-card-popular {
  border: 2px solid #2563eb; box-shadow: 0 4px 16px rgba(37, 99, 235, 0.15);
  transform: translateY(-4px);
}
.pricing-card-current { border-color: #16a34a; background: #f0fdf4; }
.pricing-badge {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: #2563eb; color: #fff; font-size: 11px; font-weight: 700;
  padding: 4px 12px; border-radius: 999px; white-space: nowrap;
}
.pricing-card-icon { font-size: 28px; }
.pricing-card-name { font-size: 15px; font-weight: 700; color: #333; }
.pricing-card-price { font-size: 24px; font-weight: 800; color: #111; margin: 4px 0 12px; }
.pricing-card-price span { font-size: 12px; font-weight: 500; color: #999; }
.pricing-card-limits {
  list-style: none; padding: 0; margin: 0 0 16px; font-size: 13px; color: #555;
  display: flex; flex-direction: column; gap: 6px; width: 100%;
}
.pricing-card-btn { width: 100%; }

.pricing-table-wrap { overflow-x: auto; margin-bottom: 24px; }
.pricing-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 480px; }
.pricing-table th, .pricing-table td {
  padding: 8px 10px; text-align: center; border-bottom: 1px solid #eee;
}
.pricing-table th:first-child, .pricing-table td:first-child { text-align: left; color: #555; }
.pricing-table thead th { color: #1e3a8a; font-weight: 700; }

.pricing-common h3 { font-size: 14px; color: #1e3a8a; margin-bottom: 10px; }
.pricing-common-list {
  list-style: none; padding: 0; margin: 0; font-size: 13px; color: #444;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 16px;
}

.upgrade-toast {
  margin-top: 16px; padding: 10px 14px; border-radius: 8px; font-size: 13px;
}
.upgrade-toast-ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.upgrade-toast-err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ---- 18. Responsive: Tablet ---- */
@media (max-width: 860px) {
  .app-body { max-width: 100%; }
  .usage-mini-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---- 18. Responsive: Mobile ---- */
@media (max-width: 640px) {
  .app-header { padding: 10px 14px; }
  .header-nav { order: 3; width: 100%; justify-content: space-between; gap: 10px; }
  .app-body { margin: 14px auto; padding: 0 10px; gap: 12px; }
  .panel { padding: 14px 14px; border-radius: 10px; }

  .usage-mini-grid { grid-template-columns: 1fr 1fr; }
  .video-source-tabs, .mp3-tabs { flex-direction: column; }
  .video-source-tab-btn, .mp3-tab-btn { width: 100%; text-align: center; }

  .grid-3 { grid-template-columns: 1fr; }
  .job-card-actions .btn-secondary { flex: 1 1 auto; text-align: center; }

  .pricing-cards { grid-template-columns: 1fr; }
  .pricing-card-popular { transform: none; }
}

/* ---- Trang thanh toán /payment/{order_code} ---- */
.payment-page {
  min-height: 100vh; display: flex; justify-content: center; align-items: flex-start;
  padding: 40px 16px; background: #f5f6f8; box-sizing: border-box;
}
.payment-card {
  background: #fff; border-radius: 14px; box-shadow: 0 2px 16px rgba(0,0,0,.08);
  padding: 28px 26px; width: 100%; max-width: 440px;
}
.payment-back-link { color: #6b7280; font-size: 13px; text-decoration: none; display: inline-block; margin-bottom: 10px; }
.payment-back-link:hover { text-decoration: underline; }
.payment-title { font-size: 20px; margin: 0 0 18px; text-align: center; }
.payment-loading { text-align: center; color: #6b7280; padding: 30px 0; }

.payment-plan-row { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.payment-plan-icon { font-size: 30px; }
.payment-plan-name { font-weight: 700; font-size: 16px; }
.payment-plan-price { color: #6b7280; font-size: 13px; }

.payment-qr-wrap { display: flex; justify-content: center; margin-bottom: 18px; }
.payment-qr-img {
  width: 240px; height: 240px; object-fit: contain; border: 1px solid #e5e7eb;
  border-radius: 10px; background: #fff;
}

.payment-detail-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px dashed #e5e7eb; font-size: 13.5px;
}
.payment-detail-row span { color: #6b7280; }
.payment-detail-highlight strong { color: #16a34a; font-size: 15px; }

.payment-note { font-size: 12px; color: #9ca3af; line-height: 1.5; margin: 14px 0; }

.payment-status {
  border-radius: 8px; padding: 12px 14px; font-size: 13.5px; text-align: center;
  margin-top: 8px; line-height: 1.6;
}
.payment-status-pending { background: #eff6ff; color: #1d4ed8; }
.payment-status-success { background: #ecfdf5; color: #047857; font-size: 15px; }
.payment-status-error { background: #fef2f2; color: #b91c1c; }

.payment-cta { display: block; text-align: center; margin-top: 16px; text-decoration: none; }

@media (max-width: 480px) {
  .payment-card { padding: 20px 16px; }
  .payment-qr-img { width: 200px; height: 200px; }
}
