/* ============================================================
   KEN OCR - Cổng gửi hồ sơ
   UI theo A2D Solutions Partner Portal:
   sidebar tối cố định trái + workspace sáng phải, accent xanh dương.
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  color-scheme: light;

  /* Bề mặt workspace (sáng) */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  /* Chữ */
  --text: #1a2b3c;
  --muted: #64748b;
  --faint: #94a3b8;

  /* Accent: xanh dương A2D */
  --accent: #2688c4;
  --accent-strong: #1e7ab8;
  --accent-soft: #eef6fc;
  --accent-soft-border: #c7e2f2;
  --on-accent: #ffffff;
  --blue-deep: #0b85d1;
  --blue-tint: #eef6fc;

  /* Nút chính tối (khớp portal) */
  --dark: #111827;
  --dark-hover: #1f2937;
  --navy: #1a2b3c;

  /* Trạng thái (semantic) */
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --warn: #b45309;
  --warn-soft: #ffedd5;

  /* Sidebar tối */
  --sidebar-bg: #111827;
  --sidebar-bg-2: #0d1420;
  --sidebar-text: rgba(255, 255, 255, 0.94);
  --sidebar-muted: rgba(255, 255, 255, 0.58);
  --sidebar-faint: rgba(255, 255, 255, 0.4);
  --sidebar-panel: rgba(255, 255, 255, 0.06);
  --sidebar-panel-hover: rgba(255, 255, 255, 0.1);
  --sidebar-border: rgba(255, 255, 255, 0.1);
  --sidebar-width: 300px;

  /* Bo góc */
  --r-lg: 24px;
  --r-card: 16px;
  --r-ctl: 10px;

  --shadow-sm: 0 4px 16px rgba(15, 23, 42, 0.04);
  --shadow: 0 20px 40px rgba(15, 23, 42, 0.06);
  --shadow-3: 0 24px 60px rgba(15, 23, 42, 0.24);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html { height: 100%; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-soft-border); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-ctl);
}

/* ---------- Shell 2 cột ---------- */
.shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar tối ---------- */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--sidebar-border);
}
.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 24px 22px 18px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-brand { display: block; }
.sidebar-logo {
  height: 34px;
  width: auto;
  display: block;
}
.sidebar-eyebrow {
  margin-top: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}
.sidebar-close {
  display: none;
  color: var(--sidebar-text);
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.sidebar-panel {
  background: var(--sidebar-panel);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--r-card);
  padding: 14px;
}
.sidebar-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.sidebar-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--sidebar-text);
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 22px 18px;
  border-top: 1px solid var(--sidebar-border);
  background: rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-footer-link {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  padding: 6px 0;
  color: var(--sidebar-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.22s var(--ease);
}
.sidebar-footer-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 3px;
  width: 100%;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.22s var(--ease);
}
.sidebar-footer-link:hover { color: #fff; }
.sidebar-footer-link:hover::after { transform: scaleX(1); }
.sidebar-footer .sidebar-section-label { color: var(--accent); }

/* Icon button dùng chung */
.icon-btn {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 6px 9px;
  border-radius: var(--r-ctl);
  transition: background-color 0.15s ease;
}
.icon-btn:hover { background: var(--sidebar-panel-hover); }

/* ---------- Workspace sáng ---------- */
.workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 30px 40px 22px;
}
.menu-toggle {
  display: none;
  color: var(--text);
  font-size: 20px;
  margin-top: 2px;
}
.topbar-titles { flex: 1; min-width: 0; }
.topbar-actions { flex-shrink: 0; margin-top: 2px; }

/* Icon-button khi nằm trên workspace sáng */
.workspace .icon-btn { color: var(--muted); font-size: 18px; }
.workspace .icon-btn:hover { background: var(--surface-2); color: var(--text); }
.page-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.page-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.page-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-top: 6px;
  max-width: 62ch;
}

.main {
  flex: 1;
  padding: 8px 40px 40px;
}
.workspace-footer {
  padding: 16px 40px 24px;
  color: var(--faint);
  font-size: 12px;
  border-top: 1px solid var(--border);
}

/* ---------- Khu nộp hồ sơ trong sidebar tối ---------- */
.sidebar-upload-title { margin-bottom: 12px; }

.dropzone {
  background: var(--sidebar-panel);
  border: 1.5px dashed var(--sidebar-border);
  border-radius: var(--r-card);
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}
.dropzone:hover,
.dropzone:focus-visible { border-color: var(--accent); background: var(--sidebar-panel-hover); }
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(38, 136, 196, 0.16);
}
.dropzone-icon {
  font-size: 22px;
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(38, 136, 196, 0.18);
  border: 1px solid rgba(38, 136, 196, 0.34);
  border-radius: 999px;
}
.dropzone-title {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--sidebar-text);
}
.dropzone-title .link {
  color: #7cc0ea;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.dropzone-hint {
  color: var(--sidebar-muted);
  font-size: 11.5px;
  margin-top: 7px;
  line-height: 1.5;
}
.dropzone-hint b { color: var(--sidebar-text); font-weight: 600; }
.dropzone-hint + .dropzone-hint { margin-top: 4px; }

/* ---------- Sections (khu file chờ trong sidebar) ---------- */
.section { margin-top: 18px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 10px;
}
.section-head h2 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--sidebar-text);
}
.actions { display: flex; gap: 8px; }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    transform 0.1s ease, opacity 0.15s ease;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--dark);
  color: #fff;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.12);
}
.btn-primary:hover:not(:disabled) { background: var(--dark-hover); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 13px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; margin-top: 12px; }
.btn-grow { flex: 1; justify-content: center; }
.btn-ico { width: 17px; height: 17px; flex-shrink: 0; }

/* Nút ghost khi nằm trên nền tối (sidebar / auth modal) */
.sidebar .btn-ghost,
.modal--auth .btn-ghost {
  color: var(--sidebar-muted);
  border-color: var(--sidebar-border);
}
.sidebar .btn-ghost:hover,
.modal--auth .btn-ghost:hover {
  background: var(--sidebar-panel-hover);
  color: var(--sidebar-text);
}

/* ---------- File list chờ upload (trong sidebar tối) ---------- */
.file-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.file-item {
  background: var(--sidebar-panel);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--r-ctl);
  padding: 9px 11px;
  display: flex;
  align-items: center;
  gap: 11px;
}
.file-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--r-ctl);
  object-fit: cover;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.file-thumb.icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.file-info { flex: 1; min-width: 0; }
.file-name {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-meta {
  color: var(--sidebar-muted);
  font-size: 11px;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.file-remove {
  background: none;
  border: none;
  color: var(--sidebar-faint);
  font-size: 14px;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--r-ctl);
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.file-remove:hover { color: #f4a9a0; background: rgba(239, 68, 68, 0.18); }

/* ---------- Progress ---------- */
.progress {
  height: 5px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  margin-top: 12px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease;
}

/* ---------- Hồ sơ đã gửi: block trên workspace sáng ---------- */
.result-group { margin-bottom: 26px; }
.group-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 12px;
}
.doc-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.doc-item {
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--surface);
  padding: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.doc-item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.doc-thumb-wrap {
  flex-shrink: 0;
  cursor: zoom-in;
  border-radius: var(--r-ctl);
}
.doc-thumb {
  width: 52px;
  height: 52px;
  border-radius: var(--r-ctl);
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: block;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.doc-thumb.icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}
.doc-thumb-wrap:hover .doc-thumb {
  border-color: var(--accent);
  transform: scale(1.04);
}

.doc-info { flex: 1; min-width: 0; }
.doc-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  overflow-wrap: anywhere;
}
.doc-meta {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.doc-meta2 {
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 600;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

/* Nút xem nội dung */
.doc-actions { margin-top: 10px; }
.btn-view {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-soft-border);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.btn-view:hover { background: var(--accent-soft-border); }
.btn-view:active { transform: scale(0.98); }
.btn-view-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}
.btn-view-error:hover { filter: brightness(0.97); }
.doc-waiting { font-size: 11.5px; color: var(--warn); }

/* Cột phải: badge + xoá */
.doc-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.error { background: var(--danger-soft); color: var(--danger); }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

.doc-delete {
  background: none;
  border: none;
  color: var(--faint);
  font-size: 13px;
  cursor: pointer;
  padding: 5px;
  border-radius: var(--r-ctl);
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.doc-delete:hover { color: var(--danger); background: var(--danger-soft); }

.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 28px 16px;
  line-height: 1.7;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--r-card);
}

/* ---------- Modal (trên workspace sáng) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  width: 100%;
  max-width: 700px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-3);
  animation: modal-in 0.22s var(--ease);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
.preview-modal { max-width: 860px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modal-close {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--faint);
  cursor: pointer;
  padding: 7px 11px;
  border-radius: var(--r-ctl);
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-meta {
  padding: 10px 20px 0;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.modal-body {
  flex: 1;
  overflow: auto;
  margin: 12px 20px;
  min-height: 120px;
  font-size: 13px;
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.modal-body.error-text {
  color: var(--danger);
  white-space: pre-wrap;
  padding: 16px;
  background: var(--danger-soft);
  border-radius: var(--r-card);
}
.modal-foot {
  display: flex;
  gap: 10px;
  padding: 0 20px 18px;
}

/* ---------- Thẻ phân tích AI ---------- */
.ai-card {
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  border-radius: var(--r-card);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.ai-card.ai-error {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}
.ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.ai-doctype { font-weight: 700; font-size: 14px; letter-spacing: -0.01em; }
.ai-score {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 999px;
}
.score-high { background: var(--ok-soft); color: var(--ok); }
.score-mid { background: var(--warn-soft); color: var(--warn); }
.score-low { background: var(--danger-soft); color: var(--danger); }

.profile-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
  background: var(--surface);
  border-radius: var(--r-ctl);
  overflow: hidden;
  border: 1px solid var(--border);
}
.profile-table th,
.profile-table td {
  text-align: left;
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.profile-table tr:last-child th,
.profile-table tr:last-child td { border-bottom: none; }
.profile-table th {
  width: 132px;
  color: var(--muted);
  font-weight: 600;
  background: var(--surface-2);
  white-space: nowrap;
}

.ai-para { margin: 8px 0 0; font-size: 13px; }
.ai-notes { margin: 6px 0 0 20px; }
.ai-notes li { margin-bottom: 3px; }

/* ---------- Highlight độ tin cậy OCR ---------- */
.ai-legend {
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}
.legend-chip {
  padding: 1px 7px;
  border-radius: 4px;
  font-weight: 600;
}
.conf-mid {
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: 4px;
  padding: 0 3px;
  cursor: help;
}
.conf-low {
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
  border-radius: 4px;
  padding: 0 3px;
  cursor: help;
}
.ocr-text {
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Bộ hồ sơ: trạng thái + checklist + chips ---------- */
.batch-status {
  font-size: 14px;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: var(--r-ctl);
  margin-bottom: 10px;
}
.batch-ok { background: var(--ok-soft); color: var(--ok); }
.batch-conflict { background: var(--danger-soft); color: var(--danger); }
.batch-warn { background: var(--warn-soft); color: var(--warn); }

/* Checklist braki (praca — zmiana lub kontynuacja) */
/* Checklist braki — card gọn, icon badge solid (không emoji) */
.check-title {
  font-weight: 700;
  color: var(--text);
  margin: 14px 0 10px;
  font-size: 13px;
}
.check-list { display: flex; flex-direction: column; gap: 8px; }
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}
.check-ico {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.check-ico svg { width: 20px; height: 20px; display: block; }
.check-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.check-muc { font-weight: 700; font-size: 13px; color: var(--text); letter-spacing: -0.005em; }
.check-detail { font-size: 12.5px; color: var(--muted); line-height: 1.5; }

.check-row.check-ok .check-ico { background: var(--ok-soft); color: var(--ok); }
.check-row.check-fail .check-ico { background: var(--danger-soft); color: var(--danger); }
.check-row.check-fail { border-color: var(--danger-line, #f4c9c2); }
.check-row.check-warn .check-ico { background: var(--warn-soft); color: var(--warn); }
.check-row.check-na .check-ico { background: var(--surface-2); color: var(--faint); }
.check-row.check-na { opacity: 0.72; }

.todo-item {
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: var(--r-ctl);
  padding: 8px 12px;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
}

.conflict-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--danger);
  border-radius: var(--r-ctl);
  padding: 9px 12px;
  margin-bottom: 8px;
  font-size: 13px;
}
.conflict-item b { color: var(--danger); }

.chip {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 11px;
  border-radius: 999px;
  margin: 2px 4px 2px 0;
}
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-missing { background: var(--danger-soft); color: var(--danger); }

/* ---------- Preview file gốc ---------- */
.preview-body {
  padding: 16px 20px 20px;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}
.preview-img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: var(--r-ctl);
  border: 1px solid var(--border);
}
.preview-frame {
  width: 100%;
  height: 70vh;
  border: 1px solid var(--border);
  border-radius: var(--r-ctl);
  background: var(--surface-2);
}
.preview-note {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 2.2;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 22px;
  border-radius: var(--r-card);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-3);
  z-index: 200;
  max-width: 90vw;
  animation: toast-in 0.25s var(--ease);
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.toast.success { background: var(--ok); color: #f4faf5; }
.toast.error { background: var(--danger); color: #fdf3f2; }

.hidden { display: none !important; }

/* ---------- Auth modal: card SÁNG như portal ---------- */
.modal--auth {
  position: relative;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: var(--navy);
  padding: 36px 36px 30px;
}
.auth-close {
  position: absolute;
  top: 16px;
  right: 16px;
  color: var(--muted);
}
.auth-close:hover { background: var(--surface-2); color: var(--navy); }
.auth-head { margin-bottom: 22px; }
.auth-eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--blue-deep);
  margin-bottom: 8px;
}
.auth-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--navy);
}
.auth-sub {
  font-size: 14px;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.5;
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }

/* Mặc định (tông tối) — dùng ở sidebar dashboard */
.auth-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--sidebar-muted);
}
.auth-input {
  width: 100%;
  background: var(--sidebar-panel);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--r-ctl);
  padding: 11px 13px;
  font-family: inherit;
  font-size: 14px;
  color: var(--sidebar-text);
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.18s ease;
}
.auth-input::placeholder { color: var(--sidebar-faint); }
.auth-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--sidebar-panel-hover);
}

/* Trong card đăng nhập sáng (portal) — ghi đè sang light */
.modal--auth .auth-label {
  font-size: 13px;
  color: var(--navy);
}
.modal--auth .auth-input {
  background: var(--surface-muted);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 15px;
  color: var(--navy);
}
.modal--auth .auth-input::placeholder { color: var(--faint); }
.modal--auth .auth-input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(38, 136, 196, 0.12);
}
.auth-error {
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--r-ctl);
  padding: 9px 12px;
  margin: 2px 0 0;
}

/* Hàng "Quên mật khẩu?" căn phải */
.auth-row-right {
  display: flex;
  justify-content: flex-end;
  margin: -4px 0 2px;
}
.auth-submit {
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 14px;
}

/* Khối "HOẶC" + nút nhân viên */
.auth-alt { margin-top: 18px; text-align: center; }
.auth-divider {
  display: block;
  font-size: 11px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
  position: relative;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(50% - 28px);
  height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

/* Nút kiểu OAuth (nhân viên) — trắng viền */
.auth-oauth {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--navy);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 12px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.auth-oauth:hover { background: var(--surface-2); border-color: var(--border-strong); }
.auth-oauth-icon { font-size: 16px; line-height: 1; }

.auth-guest-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}

/* Dòng chuyển đăng nhập/đăng ký ở dưới cùng */
.auth-switch {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.auth-link,
.auth-link-strong {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.auth-link-strong { font-weight: 700; padding-left: 4px; }
.auth-link:hover,
.auth-link-strong:hover { text-decoration: underline; }

/* ---------- ACCOUNT pill + LANGUAGE trong sidebar tối ---------- */
.account-pill {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(38, 136, 196, 0.22), rgba(255, 255, 255, 0.05));
  border: 1px solid rgba(38, 136, 196, 0.3);
  border-radius: var(--r-ctl);
  padding: 12px 14px;
  cursor: pointer;
  color: var(--sidebar-text);
  font-family: inherit;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
  margin-bottom: 18px;
}
.account-pill:hover { border-color: rgba(38, 136, 196, 0.5); }
.account-avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(38, 136, 196, 0.28);
  color: #cbe6f7;
}
.account-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.account-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-muted);
}
.account-action {
  font-size: 14px;
  font-weight: 700;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-logout { flex-shrink: 0; color: var(--sidebar-muted); }

.sidebar-section { margin-bottom: 20px; }
.sidebar-section-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-muted);
  margin-bottom: 8px;
}

.locale-switch {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--sidebar-border);
  background: rgba(0, 0, 0, 0.18);
}
.locale-btn {
  border: none;
  background: transparent;
  color: var(--sidebar-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.locale-btn:hover { color: var(--sidebar-text); }
.locale-btn.is-active { background: var(--accent); color: #fff; }

/* ---------- Backdrop cho sidebar mobile ---------- */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 90;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.28s var(--ease);
    box-shadow: var(--shadow-3);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .sidebar-backdrop:not(.hidden) { display: block; }

  .menu-toggle { display: inline-flex; }
  .topbar { padding: 20px 20px 16px; }
  .main { padding: 8px 20px 32px; }
  .workspace-footer { padding: 14px 20px 20px; }
  .page-title { font-size: 22px; }
  .file-thumb { width: 42px; height: 42px; }
  .section-head { flex-direction: column; align-items: flex-start; }
}
