/* ── Reset & Variables ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f1f5f9; --surface: #ffffff; --border: #dee2e6;
  --accent: #16a34a; --blue: #0369a1; --text: #0f172a; --muted: #6b7280;
  --error: #dc2626; --radius: 14px; --shadow: 0 1px 4px rgba(0,0,0,.08);
}
body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; min-height: 100vh; display: flex; flex-direction: column; }

/* Header */
.header { background: #fff; border-bottom: 1px solid var(--border); padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; box-shadow: var(--shadow); position: sticky; top: 0; z-index: 100; }
.header-left { display: flex; align-items: center; gap: 10px; }
.header-right { display:flex; align-items:center; gap:8px; }
.app-switcher { display:flex; align-items:center; gap:4px; padding:4px; border-radius:999px; background:#f1f5f9; border:1px solid #dbe2ea; box-shadow:inset 0 1px 0 rgba(255,255,255,.92); }
.app-switch-link { appearance:none; -webkit-appearance:none; border:0; outline:none; background:transparent; cursor:pointer; font:inherit; line-height:1; text-decoration:none; color:#64748b; font-size:.79rem; font-weight:700; padding:9px 16px; border-radius:999px; transition:background-color .2s ease,color .2s ease,box-shadow .2s ease; }
.app-switch-link:hover { color:#0f172a; background:rgba(255,255,255,.72); }
.app-switch-link.active { background:#ffffff; color:#166534; box-shadow:0 4px 12px rgba(15,23,42,.08); }
.logo { font-size: 1.6rem; }
.app-name { font-size: 1.1rem; font-weight: 700; }
.user-info { font-size: 0.8rem; color: var(--muted); margin-right: 8px; }

/* Layout */
.main-layout { display: grid; grid-template-columns: 420px 1fr; flex: 1; height: calc(100vh - 53px); overflow: hidden; }
.left-panel { overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; border-right: 1px solid var(--border); }
.right-panel { overflow-y: auto; padding: 16px; background: #f8fafc; display: flex; flex-direction: column; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.card-title { font-size: 0.88rem; font-weight: 700; margin-bottom: 10px; }
.card-desc { font-size: 0.77rem; color: var(--muted); margin-bottom: 10px; line-height: 1.5; }

/* Form */
.form-grid { display: grid; grid-template-columns: 150px 1fr; gap: 8px 10px; align-items: center; }
.form-grid label { font-size: 0.82rem; font-weight: 600; }
.field-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.field-row > label { font-size: 0.8rem; font-weight: 600; }
.input-btn-row { display: flex; gap: 6px; align-items: center; }
.input-btn-row input[type="text"], .input-btn-row input[type="password"] { flex: 1; min-width: 0; }
.input-note { font-size: 0.77rem; color: var(--muted); }

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  background: #fff; border: 1px solid #d0d7e2; border-radius: 10px;
  color: var(--text); padding: 8px 11px; font-size: 0.84rem; outline: none;
  transition: border-color .2s; width: 100%; font-family: inherit;
}
input:focus, textarea:focus, select:focus { border-color: var(--blue); }
textarea { resize: vertical; }

/* Radio */
.radio-group { display: flex; flex-direction: column; gap: 6px; }
.radio-label { display: flex; align-items: center; gap: 8px; font-size: 0.84rem; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.radio-label:hover { background: #f1f5f9; }
.radio-label input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; }

/* Buttons */
.btn { cursor: pointer; border: none; border-radius: 10px; font-weight: 600; font-size: 0.82rem; padding: 8px 13px; transition: opacity .2s, transform .1s; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-blue { background: #e0f2fe; color: var(--blue); border: 1px solid #7dd3fc; }
.btn-blue:hover:not(:disabled) { background: #bae6fd; }
.btn-green { background: #dcfce7; color: var(--accent); border: 1px solid #86efac; }
.btn-green:hover:not(:disabled) { background: #bbf7d0; }
.btn-red { background: #fee2e2; color: var(--error); border: 1px solid #fca5a5; }
.btn-outline { background: transparent; border: 1px solid var(--border); }
.btn-outline:hover { background: #f1f5f9; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); font-size: 0.77rem; padding: 5px 10px; }
.btn-ghost:hover { background: #f1f5f9; }

/* Action buttons */
.action-buttons { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.btn-run  { background: #16a34a; color: #fff; font-size: 0.88rem; padding: 12px; border-radius: 12px; }
.btn-run:hover:not(:disabled)  { background: #15803d; }
.btn-pause{ background: #eab308; color: #fff; font-size: 0.88rem; padding: 12px; border-radius: 12px; }
.btn-pause:hover:not(:disabled){ background: #ca8a04; }
.btn-stop { background: #dc2626; color: #fff; font-size: 0.88rem; padding: 12px; border-radius: 12px; }
.btn-stop:hover:not(:disabled) { background: #b91c1c; }
.auto-download-card { padding: 12px 14px; }
.retry-card { display:grid; gap:12px; }
.retry-card-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.retry-actions { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.retry-actions .btn:last-child { grid-column:1/-1; }
.row-review { box-shadow: inset 3px 0 0 #f59e0b; }
.video-action-stack { display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
.btn-chip { padding:5px 9px; border-radius:999px; font-size:0.72rem; border:1px solid var(--border); background:#fff; color:var(--muted); cursor:pointer; }
.btn-chip.active { background:#fef3c7; border-color:#f59e0b; color:#92400e; }
.retry-note { font-size:0.7rem; color:var(--muted); margin-top:6px; line-height:1.45; }
.toggle-row { display:flex; align-items:center; justify-content:space-between; gap:16px; cursor:pointer; }
.toggle-title { font-size:0.84rem; font-weight:700; color:var(--text); }
.toggle-note { margin-top:4px; font-size:0.75rem; color:var(--muted); line-height:1.5; max-width:280px; }
.toggle-row input[type="checkbox"] { width:46px; height:24px; accent-color:var(--accent); cursor:pointer; }

.guide-popup { text-align:left; }
.guide-shell { display:grid; grid-template-columns:220px minmax(0,1fr); gap:16px; min-height:420px; }
.guide-tabs { display:grid; gap:8px; align-content:start; }
.guide-tab-btn { width:100%; text-align:left; border:1px solid #dbe2ea; background:#f8fafc; color:#475569; border-radius:14px; padding:11px 12px; font:inherit; font-size:.82rem; font-weight:700; cursor:pointer; transition:all .18s ease; }
.guide-tab-btn:hover { background:#eef2ff; color:#0f172a; border-color:#bfdbfe; }
.guide-tab-btn.active { background:#0f172a; color:#fff; border-color:#0f172a; box-shadow:0 10px 20px rgba(15,23,42,.12); }
.guide-panel-wrap { background:#f8fafc; border:1px solid #e2e8f0; border-radius:18px; padding:18px; min-height:100%; }
.guide-panel { display:none; }
.guide-panel.active { display:block; }
.guide-panel h3 { font-size:1rem; font-weight:800; margin-bottom:8px; color:#0f172a; }
.guide-panel p { font-size:.85rem; line-height:1.65; color:#334155; margin-bottom:10px; }
.guide-panel ol, .guide-panel ul { padding-left:18px; display:grid; gap:8px; margin-bottom:12px; }
.guide-panel li { font-size:.84rem; line-height:1.65; color:#334155; }
.guide-note-box { background:#eff6ff; border:1px solid #bfdbfe; border-radius:14px; padding:12px 14px; font-size:.8rem; line-height:1.6; color:#1e3a8a; margin-top:10px; }
.guide-code { display:block; padding:10px 12px; border-radius:12px; background:#0f172a; color:#f8fafc; font-size:.78rem; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; overflow:auto; margin:10px 0; }
.guide-actions { display:flex; gap:8px; flex-wrap:wrap; margin-top:12px; }
.guide-link-btn { display:inline-flex; align-items:center; justify-content:center; text-decoration:none; border-radius:10px; padding:9px 12px; font-size:.8rem; font-weight:700; border:1px solid #7dd3fc; color:#0369a1; background:#e0f2fe; }
.guide-link-btn:hover { background:#bae6fd; }

/* Progress */
.progress-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 0.84rem; font-weight: 600; }
.progress-bar-bg { background: #e2e8f0; border-radius: 99px; height: 8px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg,#16a34a,#22c55e); border-radius: 99px; transition: width .4s; width: 0%; }
.progress-text { font-size: 0.77rem; color: var(--muted); margin-top: 4px; }

/* Badge */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 0.71rem; font-weight: 700; }
.badge-pending { background: #fef9c3; color: #854d0e; }
.badge-running { background: #dbeafe; color: #1d4ed8; }
.badge-done    { background: #dcfce7; color: #15803d; }
.badge-error   { background: #fee2e2; color: #dc2626; }

/* Tables */
.batch-table, .cookie-table { width: 100%; border-collapse: collapse; font-size: 0.79rem; margin-top: 8px; }
.batch-table th, .cookie-table th { background: #f8fafc; padding: 6px 8px; text-align: left; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); }
.batch-table td, .cookie-table td { padding: 6px 8px; border-bottom: 1px solid #f1f5f9; }
.batch-table tr:hover td { background: #f8fafc; cursor: pointer; }
.batch-table tr.active-row td { background: #eff6ff; }

/* Ref preview */
.ref-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ref-preview img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

/* Results */
.results-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.results-header h2 { font-size: 0.95rem; font-weight: 700; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px,1fr)); gap: 12px; }
.empty-state { grid-column: 1/-1; text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-icon { font-size: 2.8rem; margin-bottom: 10px; }

/* Image card */
.img-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); transition: transform .15s; position: relative; }
.hist-cb { position: absolute; top: 6px; left: 6px; z-index: 2; background: rgba(255,255,255,.85); border-radius: 4px; padding: 2px 4px; cursor: pointer; }
.hist-cb input { cursor: pointer; width: 16px; height: 16px; }
.img-card:hover { transform: translateY(-2px); }
.img-card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: #f1f5f9; }
.img-card-body { padding: 7px 10px; }
.img-card-prompt { font-size: 0.74rem; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.img-card-error { font-size: 0.74rem; color: var(--error); padding: 7px 10px; }
.img-card-actions { padding: 6px 10px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.img-card-actions a { font-size: 0.74rem; color: var(--blue); text-decoration: none; font-weight: 600; }
.img-card-actions a:hover { text-decoration: underline; }
.video-history-preview { width:100%; aspect-ratio:16/9; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px; background:linear-gradient(135deg,#0f172a,#1e293b); color:#fff; cursor:pointer; }
.video-history-play { width:56px; height:56px; border-radius:999px; display:flex; align-items:center; justify-content:center; background:rgba(255,255,255,.14); border:1px solid rgba(255,255,255,.2); font-size:1.25rem; }
.video-history-label { font-size:0.82rem; font-weight:600; letter-spacing:.2px; }

/* Error */
.error-msg { background: #fee2e2; border: 1px solid #fca5a5; border-radius: 10px; padding: 10px 14px; color: var(--error); font-size: 0.82rem; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: var(--radius); width: 680px; max-width: 95vw; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 0.95rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: #f1f5f9; }
.modal-body { padding: 14px 18px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.modal-footer { padding: 10px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }
.cookie-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cookie-help { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 10px 12px; font-size: 0.77rem; color: #1e40af; line-height: 1.6; }
.cookie-help a { color: #1d4ed8; }
.status-ok  { color: #16a34a; font-weight: 600; }
.status-err { color: #dc2626; font-weight: 600; }
.status-pending { color: #6b7280; }

@media (max-width: 768px) {
  .main-layout { grid-template-columns: 1fr; height: auto; }
  .left-panel, .right-panel { height: auto; }
  .app-switcher { width:100%; justify-content:center; }
  .retry-actions { grid-template-columns:1fr; }
  .guide-shell { grid-template-columns:1fr; }
  .guide-tabs { grid-template-columns:1fr 1fr; }
}

/* ── Login Screen ──────────────────────────────────────────────────────────── */
.login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #f0fdf4 0%, #ecfeff 50%, #eff6ff 100%); }
.login-card { background: #fff; border-radius: 20px; padding: 40px 36px; width: 380px; max-width: 95vw; box-shadow: 0 8px 40px rgba(0,0,0,.1); text-align: center; }
.login-logo { font-size: 3rem; margin-bottom: 8px; }
.login-card h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: 4px; }
.login-subtitle { color: var(--muted); font-size: 0.84rem; margin-bottom: 20px; }
.login-tabs { display: flex; gap: 0; margin-bottom: 20px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.login-tab { flex: 1; padding: 9px; border: none; background: #f8fafc; cursor: pointer; font-weight: 600; font-size: 0.84rem; transition: background .2s, color .2s; }
.login-tab.active { background: var(--accent); color: #fff; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input { padding: 11px 14px; border-radius: 10px; border: 1px solid #d0d7e2; font-size: 0.88rem; }
.login-btn { padding: 12px; font-size: 0.92rem; border-radius: 12px; background: var(--accent); color: #fff; border: none; cursor: pointer; font-weight: 700; }
.login-btn:hover { background: #15803d; }
.auth-error { background: #fee2e2; color: var(--error); padding: 8px 12px; border-radius: 8px; font-size: 0.82rem; text-align: left; }

/* ── Header Nav ────────────────────────────────────────────────────────────── */
.header-nav { display: flex; gap: 4px; }
.nav-btn { background: none; border: none; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 0.82rem; font-weight: 600; color: var(--muted); transition: background .2s, color .2s; }
.nav-btn:hover { background: #f1f5f9; }
.nav-btn.active { background: #dcfce7; color: var(--accent); }

/* ── Tab Content ───────────────────────────────────────────────────────────── */
.tab-content { flex: 1; }

/* ── History / Admin Container ─────────────────────────────────────────────── */
.history-container, .admin-container { max-width: 1440px; margin: 0 auto; padding: 24px 26px; }
.history-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.history-header h2 { font-size: 1rem; font-weight: 700; }
.history-tip-banner { display:flex; align-items:center; gap:8px; padding:8px 12px; border-radius:999px; background:#fff; border:1px solid #dbeafe; box-shadow:var(--shadow); }
.history-tip-date { font-size:.76rem; font-weight:700; color:#1d4ed8; }
.history-tip-count { font-size:.76rem; font-weight:700; color:#166534; }
.admin-container h2 { font-size: 1rem; font-weight: 700; }
.admin-container select { padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border); font-size: 0.78rem; }
.admin-shell { display:grid; grid-template-columns:228px minmax(0,1fr); gap:20px; align-items:start; }
.admin-sidebar { position:sticky; top:74px; background:rgba(255,255,255,.88); backdrop-filter:blur(14px); color:#0f172a; border-radius:24px; padding:20px 16px; box-shadow:0 16px 34px rgba(15,23,42,.06); border:1px solid rgba(148,163,184,.16); display:flex; flex-direction:column; gap:16px; }
.admin-sidebar-head { padding-bottom:16px; border-bottom:1px solid #e6edf5; }
.admin-sidebar-kicker { font-size:.7rem; text-transform:uppercase; letter-spacing:.14em; color:#0f766e; font-weight:700; }
.admin-sidebar-title { font-size:1.15rem; line-height:1.25; font-weight:800; color:#0f172a; margin-top:7px; }
.admin-sidebar-meta { font-size:.8rem; line-height:1.6; color:#64748b; margin-top:8px; }
.admin-sidebar-nav { display:grid; gap:8px; margin-bottom:18px; }
.admin-side-link { border:none; border-radius:14px; padding:11px 12px; text-align:left; background:transparent; color:#475569; font-size:.84rem; font-weight:700; transition:all .18s ease; }
.admin-side-link:hover { background:#f8fafc; color:#0f172a; }
.admin-side-link.active { background:#0f172a; color:#fff; box-shadow:0 10px 22px rgba(15,23,42,.12); }
.admin-side-card { background:#f8fafc; border:1px solid #e2e8f0; border-radius:18px; padding:14px; display:grid; gap:8px; }
.admin-side-card-label { font-size:.7rem; text-transform:uppercase; letter-spacing:.12em; color:#64748b; font-weight:700; }
.admin-side-card-value { font-size:.88rem; line-height:1.5; font-weight:700; color:#0f172a; }
.admin-content { display:grid; gap:18px; min-width:0; }
.admin-topbar { display:flex; align-items:flex-start; justify-content:space-between; gap:18px; padding:10px 2px 2px; }
.admin-topbar-kicker { font-size:.72rem; text-transform:uppercase; letter-spacing:.16em; color:#0f766e; font-weight:700; margin-bottom:8px; }
.admin-topbar h2 { font-size:1.7rem; line-height:1.1; font-weight:800; color:#0f172a; margin-bottom:8px; }
.admin-topbar p { max-width:72ch; font-size:.9rem; line-height:1.7; color:#64748b; }
.admin-topbar-meta { display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end; }
.admin-topbar-chip { padding:8px 13px; border-radius:999px; background:#fff; border:1px solid #d8e4f0; color:#334155; font-size:.76rem; font-weight:700; }
.admin-pane { display:grid; gap:18px; }
.admin-overview-grid { display:grid; grid-template-columns:minmax(0,1.65fr) minmax(300px,.85fr); gap:18px; align-items:start; }
.admin-overview-main, .admin-overview-side { display:grid; gap:18px; }
.admin-stats { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; }
.admin-stat-card { padding:18px; border-radius:20px; background:#fff; border:1px solid rgba(148,163,184,.14); box-shadow:0 10px 24px rgba(15,23,42,.04); display:flex; flex-direction:column; gap:10px; min-height:144px; }
.admin-stat-label { font-size:.75rem; text-transform:uppercase; letter-spacing:.08em; color:#64748b; font-weight:700; }
.admin-stat-value { font-size:2rem; line-height:1; color:#0f172a; }
.admin-stat-note { font-size:.78rem; color:#64748b; line-height:1.5; }
.admin-layout { display:grid; grid-template-columns:minmax(0,1.7fr) minmax(300px,.9fr); gap:18px; margin-top:18px; align-items:start; }
.admin-main, .admin-side { display:flex; flex-direction:column; gap:18px; }
.admin-section { background:#fff; border:1px solid rgba(148,163,184,.14); border-radius:22px; padding:20px; box-shadow:0 10px 24px rgba(15,23,42,.04); }
.admin-section-tight { padding:18px; }
.admin-section-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:16px; }
.admin-section-head h3 { font-size:1.06rem; font-weight:800; color:#0f172a; margin-bottom:4px; }
.admin-section-head p { font-size:.83rem; color:#64748b; line-height:1.6; max-width:60ch; }
.admin-inline-note { font-size:.76rem; color:#166534; background:#ecfdf5; border:1px solid #bbf7d0; padding:8px 12px; border-radius:999px; white-space:nowrap; }
.admin-table-wrap { overflow:auto; border:1px solid #eef2f7; border-radius:18px; }
.admin-user-table { margin-top:0; }
.admin-user-table th { position:sticky; top:0; z-index:1; }
.admin-user-table th { background:#f8fafc; color:#64748b; font-size:.78rem; padding:11px 12px; }
.admin-user-table td { padding:11px 12px; vertical-align:middle; }
.admin-user-table select { min-width:132px; border-radius:12px; background:#fff; border:1px solid #dbe2ea; padding:8px 10px; font-size:.8rem; }
.admin-form { display:grid; gap:10px; }
.admin-submit-btn { width:100%; justify-content:center; }
.admin-bulk-demo { margin-top:14px; padding-top:14px; border-top:1px dashed #dbe2ea; display:grid; gap:10px; }
.admin-bulk-demo-head h4 { font-size:.88rem; font-weight:800; color:#0f172a; margin-bottom:4px; }
.admin-bulk-demo-head p { font-size:.77rem; line-height:1.55; color:#64748b; }
.admin-summary-list { display:flex; flex-direction:column; gap:12px; }
.admin-summary-item { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:14px 15px; border-radius:18px; background:#f8fafc; border:1px solid #e2e8f0; font-size:.82rem; color:#334155; }
.admin-summary-item strong { color:#0f172a; }
.admin-summary-item span:last-child { color:#64748b; text-align:right; }
.admin-ops-list { display:grid; gap:12px; }
.admin-ops-item { display:grid; grid-template-columns:34px minmax(0,1fr); gap:12px; align-items:start; padding:12px 0; border-top:1px solid #edf2f7; }
.admin-ops-item:first-child { border-top:none; padding-top:0; }
.admin-ops-item strong { width:34px; height:34px; border-radius:12px; background:#dcfce7; color:#166534; display:flex; align-items:center; justify-content:center; font-size:.86rem; }
.admin-ops-item span { font-size:.82rem; line-height:1.6; color:#475569; }
.admin-history-section { margin-top:18px; }
.admin-history-grid { margin-top:0; }
.admin-folder-list { display:flex; flex-direction:column; gap:8px; }
.admin-filter-row { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:12px; }

/* ── Results Table ──────────────────────────────────────────────────────────── */
.results-table-wrap { flex: 1; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.results-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.results-table thead { position: sticky; top: 0; z-index: 2; }
.results-table th { background: #f8fafc; padding: 8px 6px; text-align: left; font-weight: 600; color: var(--muted); border-bottom: 2px solid var(--border); font-size: 0.76rem; white-space: nowrap; }
.results-table td { padding: 6px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.results-table tr:hover td { background: #f8fafc; }
.results-table td:first-child { text-align: center; color: var(--muted); font-weight: 600; }
.col-prompt { }
.results-table .prompt-cell { font-size: 0.76rem; line-height: 1.4; max-height: 44px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.results-table .ref-thumb, .results-table .result-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; transition: transform .15s; }
.results-table .result-thumb:hover { transform: scale(1.05); box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.ref-add-btn:hover { text-decoration: underline; background: #eff6ff; }
.results-table .status-cell { text-align: center; font-size: 0.76rem; }
.results-table tr.row-done td { background: #f0fdf4; }
.results-table tr.row-error td { background: #fef2f2; }
.results-table tr.row-running td { background: #eff6ff; }
.results-table .result-actions { display: flex; gap: 4px; margin-top: 4px; }
.results-table .result-actions a { font-size: 0.68rem; color: var(--blue); text-decoration: none; font-weight: 600; }
.results-table .result-actions a:hover { text-decoration: underline; }
/* Ref image cell: thumbnails nằm ngang, tối đa 2 hàng */
.ref-cell { display: flex; flex-wrap: wrap; gap: 3px; max-height: 98px; overflow: hidden; align-content: flex-start; justify-content: center; align-items: center; }
.ref-add-btn { color: var(--blue); cursor: pointer; font-size: 0.72rem; font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 1.5px dashed var(--blue); border-radius: 6px; }
.results-table th, .results-table td { text-align: center; vertical-align: middle; }
.results-table th.col-prompt, .results-table td:nth-child(2) { text-align: left; }

/* ── History Folder View ──────────────────────────────────────────────────── */
.hist-folder { display:flex; align-items:center; gap:12px; padding:14px 16px; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); cursor:pointer; transition:all .15s; }
.hist-folder:hover { border-color:var(--accent); box-shadow:0 2px 8px rgba(22,163,74,.12); transform:translateY(-1px); }
.hist-folder-icon { font-size:2rem; flex-shrink:0; }
.hist-folder-info { flex:1; min-width:0; }
.hist-folder-name { font-weight:600; font-size:0.92rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.hist-folder-meta { font-size:0.75rem; color:var(--muted); margin-top:2px; }
.hist-folder-badges { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.hist-badge { display:inline-flex; align-items:center; padding:4px 9px; border-radius:999px; font-size:0.72rem; font-weight:700; }
.hist-badge-blue { background:#dbeafe; color:#1d4ed8; }
.hist-badge-green { background:#dcfce7; color:#15803d; }
.hist-badge-red { background:#fee2e2; color:#dc2626; }
.hist-folder-del { flex-shrink:0; opacity:0; transition:opacity .15s; }
.hist-folder:hover .hist-folder-del { opacity:1; }
#historyGrid.results-grid { display:flex; flex-direction:column; gap:8px; }
.hist-folder + .hist-folder { }
/* When viewing images inside folder, switch to grid */
#historyGrid.results-grid.grid-mode { display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:12px; flex-direction:unset; }
.btn-sm { padding:4px 10px; font-size:0.75rem; }
.btn-red { background:var(--error); color:#fff; border:none; border-radius:8px; padding:6px 14px; cursor:pointer; font-size:0.82rem; }
.btn-red:hover { background:#b91c1c; }

/* ── Plan Badge ───────────────────────────────────────────────────────────── */
.plan-badge { font-size:0.72rem; padding:3px 10px; border-radius:20px; font-weight:600; }
.plan-active { background:#dcfce7; color:#166534; }
.plan-expiring { background:#fef3c7; color:#92400e; }
.plan-expired { background:#fee2e2; color:#991b1b; }

/* ── File Separator in Results Table ──────────────────────────────────────── */
.file-separator td { background:#e0f2fe; font-weight:600; font-size:0.82rem; color:#0369a1; padding:8px 12px !important; border-bottom:2px solid #7dd3fc; }

/* ── Ref Image Delete Button ──────────────────────────────────────────────── */
.ref-wrap { position:relative; display:inline-block; margin:2px; }
.ref-del { position:absolute; top:-4px; right:-4px; background:#dc2626; color:#fff; border-radius:50%; width:16px; height:16px; font-size:10px; line-height:16px; text-align:center; cursor:pointer; display:none; }
.ref-wrap:hover .ref-del { display:block; }
/* v2 */

/* ── Video Mode Switcher ──────────────────────────────────────────────────── */
.mode-switcher { display:flex; gap:6px; margin-bottom:4px; }
.mode-btn { flex:1; display:flex; flex-direction:column; align-items:center; gap:3px; padding:8px 4px; border:1.5px solid var(--border); border-radius:10px; background:#f8fafc; cursor:pointer; transition:all .18s; font-size:0.72rem; font-weight:600; color:var(--muted); }
.mode-btn:hover { border-color:var(--accent); background:#f0fdf4; color:var(--accent); }
.mode-btn.active { border-color:var(--accent); background:#dcfce7; color:var(--accent); box-shadow:0 0 0 2px rgba(22,163,74,.15); }
.mode-icon { font-size:1.2rem; line-height:1; }
.mode-label { font-size:0.68rem; font-weight:700; letter-spacing:.3px; }
.mode-desc { font-size:0.75rem; color:var(--muted); background:#f8fafc; border-radius:8px; padding:6px 10px; line-height:1.5; border:1px solid var(--border); }

@media (max-width: 768px) {
  .header { flex-wrap:wrap; gap:10px; }
  .header-right { width:100%; justify-content:flex-end; flex-wrap:wrap; }
  .admin-shell, .admin-layout, .admin-stats { grid-template-columns:1fr; }
  .admin-sidebar { position:static; }
  .admin-overview-grid { grid-template-columns:1fr; }
  .admin-topbar { flex-direction:column; }
  .admin-topbar-meta { justify-content:flex-start; }
}
