:root {
  --bg: #f4efe7;
  --ink: #1e2a22;
  --muted: #667067;
  --panel: #fffaf2;
  --line: rgba(30, 42, 34, 0.12);
  --gold: #be8a2f;
  --forest: #2f5d46;
  --rust: #b55a35;
  --sand: #e7d4af;
  --shadow: 0 18px 40px rgba(36, 31, 21, 0.12);
}
* { box-sizing: border-box; margin: 0; }
html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
body {
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f8f4ed 0%, #efe6d8 100%);
  min-height: 100vh;
}
img, video, iframe {
  max-width: 100%;
}
.hidden { display: none !important; }

/* ═══ Auth screen ═══ */
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-panel, .panel, .sidebar-card, .hero-card, .stat-card {
  background: rgba(255, 250, 242, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 24px;
}
.auth-panel {
  width: min(460px, 100%);
  padding: 36px;
}
.brand-mark {
  width: 60px; height: 60px;
  display: grid; place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--gold), #e7c37a);
  font-size: 30px;
  margin-bottom: 18px;
}
.eyebrow, .card-label {
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 12px;
  color: var(--forest);
  font-weight: 700;
}
.auth-panel h1 { margin: 10px 0 12px; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 1.6rem; }
.auth-panel p, .body-copy, .sidebar-card p, .stat-card p { color: var(--muted); line-height: 1.6; }
.auth-note {
  margin: 18px 0;
  background: rgba(47,93,70,0.08);
  border: 1px solid rgba(47,93,70,0.12);
  padding: 14px 16px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.5;
}
.auth-panel input {
  width: 100%;
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  font: inherit;
  font-size: 1rem;
  transition: border-color .2s;
}
.auth-panel input:focus { outline: none; border-color: var(--forest); }
.auth-panel button, .primary-btn, .ghost-btn, .nav-item, .logout-btn {
  font: inherit; border: 0; cursor: pointer;
}
.auth-panel button, .primary-btn {
  margin-top: 14px;
  width: 100%;
  padding: 14px 18px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--forest), #44785d);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  transition: opacity .2s;
}
.auth-panel button:hover, .primary-btn:hover { opacity: 0.9; }
.auth-panel button:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-error { margin-top: 10px; color: #a13d2d; min-height: 20px; font-size: 0.9rem; }
.auth-secondary-btn { width: 100%; margin-top: 10px; }
.auth-verify-panel {
  margin-top: 16px; padding: 16px; border-radius: 16px;
  background: rgba(47,93,70,0.06); border: 1px solid rgba(47,93,70,0.14);
}
.auth-verify-title { font-weight: 800; color: var(--forest); margin-bottom: 6px; }
.auth-verify-panel p { color: var(--muted); font-size: 0.9rem; margin-bottom: 10px; }
.auth-verify-actions { display: flex; gap: 10px; }
.access-checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 12px;
  margin: 10px 0 12px;
  font-size: 0.9rem;
  color: var(--ink);
}
.access-flag-card {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  min-width: 0;
  width: 100%;
  text-align: left;
}
.access-flag-card input {
  margin: 2px 0 0;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
}
.access-flag-card span {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.35;
  word-break: normal;
  overflow-wrap: anywhere;
  white-space: normal;
  writing-mode: horizontal-tb;
}

/* ═══ App shell ═══ */
.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* ═══ Sidebar ═══ */
.sidebar {
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(255,250,242,0.72);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.sidebar-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.sidebar-logo {
  width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--gold), #e5bf71); font-size: 24px; flex-shrink: 0;
}
.sidebar-title { font-weight: 800; font-size: 18px; font-family: 'Plus Jakarta Sans', sans-serif; }
.sidebar-subtitle { color: var(--muted); font-size: 13px; }
.nav-list { display: grid; gap: 4px; margin-bottom: 20px; }
.nav-item {
  text-align: left; padding: 12px 14px; border-radius: 12px; background: transparent;
  color: var(--ink); font-weight: 600; font-size: 0.95rem; transition: background .15s;
}
.nav-item:hover { background: rgba(47,93,70,0.06); }
.nav-item.active { background: rgba(47,93,70,0.12); color: var(--forest); }
.sidebar-card { padding: 18px; margin-bottom: 16px; font-size: 0.9rem; }
.sidebar-card h3 { font-size: 1rem; margin: 6px 0 8px; }
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
.user-info { font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.logout-btn {
  padding: 10px 14px; border-radius: 12px; background: rgba(161,61,45,0.08);
  color: #a13d2d; font-weight: 600; font-size: 0.85rem; width: 100%;
  transition: background .2s;
}
.logout-btn:hover { background: rgba(161,61,45,0.15); }
.topbar-logout-btn {
  color: #a13d2d;
  border-color: rgba(161,61,45,0.18);
  background: rgba(161,61,45,0.06);
}
.topbar-logout-btn:hover {
  background: rgba(161,61,45,0.12);
}

/* ═══ Main content ═══ */
.main-shell {
  padding: 28px;
  overflow-y: auto;
  min-width: 0;
}
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 16px 20px;
  margin-bottom: 28px;
}
.topbar h2 { font-family: 'Plus Jakarta Sans', sans-serif; margin-top: 4px; }
.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: flex-end;
}
.topbar-actions-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: min(100%, 290px);
}
.topbar-user-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.topbar-account-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar-account-label {
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1px;
}
.topbar-user-info {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--forest);
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}
.topbar-talk-btn {
  width: 100%;
  margin-top: 0;
}
.topbar-logout-btn {
  width: auto;
  margin-top: 0;
  white-space: nowrap;
}
/* Hide mobile menu button on desktop — sidebar is always visible */
#mobile-nav-btn { display: none; }
.ghost-btn {
  padding: 11px 16px; border-radius: 12px; background: rgba(255,255,255,0.6);
  border: 1px solid var(--line); font-weight: 600; font-size: 0.9rem; transition: background .15s;
}
.ghost-btn:hover { background: rgba(255,255,255,0.9); }
.primary-btn.topbar-btn { width: auto; margin-top: 0; padding: 11px 18px; font-size: 0.9rem; }

/* ═══ Pages ═══ */
.page { display: none; }
.page.active { display: block; }

/* ═══ Hero card ═══ */
.hero-card {
  display: grid; grid-template-columns: 1.4fr .8fr; gap: 24px;
  padding: 32px; margin-bottom: 20px;
}
.hero-card h1 { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 1.7rem; margin: 8px 0 14px; line-height: 1.25; }
.hero-card p { color: var(--muted); line-height: 1.6; }
.hero-kicker { color: var(--rust); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.hero-actions .primary-btn, .hero-actions .ghost-btn { width: auto; margin-top: 0; padding: 12px 20px; }
.hero-panel { display: grid; gap: 12px; }
.hero-stat { padding: 18px; background: rgba(255,255,255,0.6); border: 1px solid var(--line); border-radius: 16px; }
.hero-stat span { display: block; font-size: 28px; font-weight: 800; color: var(--forest); }

/* ═══ Stats grid ═══ */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card { padding: 20px; }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.stat-value { display: block; font-size: 1.5rem; font-weight: 800; color: var(--forest); margin: 8px 0; }

/* ═══ Content grids ═══ */
.content-grid.two-up { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.content-grid.split-hero { display: grid; gap: 16px; }
.upload-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.admin-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 16px; }
.language-grid { margin-top: 18px; }

/* ═══ Panels & cards ═══ */
.panel { padding: 24px; }
.panel.large { grid-column: 1 / -1; }
.panel.subpanel { margin-top: 16px; background: rgba(244,239,231,0.8); box-shadow: none; }
.panel-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 16px; }
.panel-head h3 { font-family: 'Plus Jakarta Sans', sans-serif; }
.pill {
  display: inline-flex; align-items: center; padding: 6px 12px; border-radius: 999px;
  background: rgba(190,138,47,0.12); color: var(--gold); font-size: 12px; font-weight: 700; white-space: nowrap;
}
.doc-file-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}
.doc-upload-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  border: 1px solid rgba(30, 42, 34, 0.1);
  background: rgba(255,255,255,0.7);
  color: var(--ink);
}
.doc-upload-badge.admin {
  background: rgba(190,138,47,0.16);
  color: #8a5a08;
  border-color: rgba(190,138,47,0.35);
}
.doc-upload-badge.supervisor {
  background: rgba(47,93,70,0.14);
  color: var(--forest);
  border-color: rgba(47,93,70,0.28);
}
.doc-upload-badge.trainee,
.doc-upload-badge.user {
  background: rgba(59,130,246,0.12);
  color: #1d4ed8;
  border-color: rgba(59,130,246,0.26);
}
.doc-file-download-link {
  color: var(--forest);
  font-weight: 800;
  text-decoration: none;
}
.doc-file-download-link:hover {
  text-decoration: underline;
}
.doc-audit-ok,
.doc-audit-summary {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(47,93,70,0.08);
  border: 1px solid rgba(47,93,70,0.16);
  color: var(--forest);
  margin-bottom: 12px;
}
.doc-audit-list {
  display: grid;
  gap: 12px;
}
.doc-audit-card {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.65);
}
.doc-audit-title {
  font-weight: 800;
  margin-bottom: 4px;
}
.doc-audit-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 4px;
}
.doc-audit-card ul {
  margin: 10px 0 0 18px;
}

/* ═══ Module cards ═══ */
.module-list { display: grid; gap: 12px; }
.language-stack { display: grid; gap: 10px; }
.language-card, .phrase-card {
  border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; background: rgba(255,255,255,0.65);
}
.language-card strong, .phrase-label { color: var(--forest); font-size: 0.88rem; }
.language-card p, .phrase-line { color: var(--muted); margin-top: 6px; line-height: 1.5; }
.phrase-bank { display: grid; gap: 10px; }
.phrase-label.tagalog { color: var(--rust); margin-top: 10px; }
.phrase-line.alt { color: var(--ink); font-weight: 600; }
.module-card, .upload-card, .admin-card, .supervisor-card {
  border: 1px solid var(--line); border-radius: 18px; padding: 18px; background: rgba(255,255,255,0.55);
  transition: border-color .2s;
}
.module-card:hover, .upload-card:hover, .admin-card:hover { border-color: rgba(47,93,70,0.3); }
.module-card { display: flex; gap: 14px; align-items: flex-start; }
.module-card h4, .upload-card h4, .admin-card h4 { margin-bottom: 6px; font-size: 1rem; }
.module-card p, .upload-card p, .admin-card p { color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.module-no {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  font-weight: 800; background: rgba(47,93,70,0.1); color: var(--forest); flex-shrink: 0;
}

/* ═══ Phone preview ═══ */
.phone-preview {
  border: 1px solid var(--line); border-radius: 18px; padding: 20px; background: rgba(255,255,255,0.55);
  max-width: 440px;
}
.phone-top { font-weight: 800; margin-bottom: 14px; font-size: 1.1rem; }
.phone-bubble { padding: 12px 16px; border-radius: 16px; margin-bottom: 10px; max-width: 88%; font-size: 0.95rem; line-height: 1.5; }
.phone-bubble.assistant { background: rgba(47,93,70,0.1); }
.phone-bubble.trainee { background: rgba(190,138,47,0.12); margin-left: auto; }
.talk-button {
  margin-top: 14px; display: inline-flex; padding: 12px 20px; border-radius: 999px;
  background: var(--forest); color: #fff; font-weight: 700; font-size: 0.9rem;
}

/* ═══ Feed ═══ */
.feed-list { display: grid; gap: 12px; }
.feed-item {
  border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: rgba(255,255,255,0.55);
  font-size: 0.95rem; line-height: 1.5;
}

/* ═══ Supervisor cards ═══ */
.supervisor-cards { margin-top: 16px; display: grid; gap: 12px; }
.supervisor-card { display: flex; gap: 16px; align-items: flex-start; }
.supervisor-avatar {
  width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center;
  background: rgba(190,138,47,0.12); font-size: 24px; flex-shrink: 0;
}
.supervisor-card h4 { margin-bottom: 6px; }
.supervisor-card p { color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

/* ═══ Trainee empty state ═══ */
.trainee-empty {
  text-align: center; padding: 40px 20px; margin-top: 16px;
  border: 2px dashed var(--line); border-radius: 18px;
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.trainee-empty p { color: var(--muted); max-width: 400px; margin: 0 auto; line-height: 1.6; }

/* ═══ Mobile & Responsive ═══ */

/* ── Tablet / iPad portrait (≤980px) ── */
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  #mobile-nav-btn { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; left: -300px; width: min(280px, 86vw); height: 100vh;
    z-index: 100; transition: left .25s ease; background: var(--panel);
  }
  .sidebar.open { left: 0; }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 99;
  }
  .sidebar-overlay.visible { display: block; }
  .hero-card { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid.two-up, .content-grid.split-hero { grid-template-columns: 1fr; }
  .upload-grid, .admin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-card { padding: 22px; }
  .main-shell { padding: 20px; }
  .topbar {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }
  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .topbar-actions .primary-btn { font-size: 0.85rem; padding: 10px 16px; }
  .doc-item {
    flex-direction: column;
  }
  .doc-item-actions {
    width: 100%;
  }
}

/* ── Small tablet / large phone (≤768px) ── */
@media (max-width: 768px) {
  .chat-drawer { width: 100vw; }
  .chat-language-toolbar, .chat-quick-actions { padding: 10px 12px; }
  .language-toggle-group.right { margin-left: 0; }
  .vo-agent-emoji { font-size: 56px; }
  .vo-live-text { font-size: 0.9rem; padding: 0 20px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 16px; min-width: 0; }
  .stat-value { font-size: 1.3rem; }
  .hero-card h1 { font-size: 1.4rem; }
  .upload-grid, .admin-grid { grid-template-columns: 1fr; }
  .upload-form { flex-direction: column; }
  .upload-form input[type="file"],
  .upload-form input[type="text"],
  .upload-form select { min-width: 100%; }
  .supervisor-card { flex-direction: column; gap: 10px; }
  .supervisor-avatar { width: 40px; height: 40px; font-size: 20px; }
  .post-form-actions { flex-direction: column; }
  .post-form-actions select, .post-form-actions button { width: 100%; }
  .chat-inline .chat-messages { min-height: 250px; max-height: 400px; }
  .edit-form { padding: 16px; }
  .form-actions {
    flex-direction: column;
  }
  .form-actions .primary-btn,
  .form-actions .ghost-btn {
    width: 100%;
  }
  .doc-info-notes {
    flex-direction: column;
    gap: 0.5rem;
  }
  .doc-admin-select label {
    display: grid;
    gap: 0.4rem;
  }
  .doc-admin-select select {
    width: 100%;
  }
}

/* ── Phone (≤600px) — iPhone, small Android ── */
@media (max-width: 600px) {
  .auth-panel { padding: 24px; }
  .auth-panel h1 { font-size: 1.3rem; }
  .brand-mark { width: 50px; height: 50px; font-size: 24px; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .topbar-actions { width: 100%; display: grid; grid-template-columns: 1fr; }
  .topbar-actions-stack {
    min-width: 0;
    width: 100%;
  }
  .topbar-actions .primary-btn,
  .topbar-actions .ghost-btn {
    width: 100%;
    margin-top: 0;
    justify-content: center;
  }
  .topbar-user-actions {
    margin-left: 0;
    padding-left: 0;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    justify-content: stretch;
  }
  .topbar-user-info {
    max-width: 100%;
    text-align: left;
  }
  .topbar-account-label {
    text-align: left;
  }
  #mobile-nav-btn { order: -1; }
  .main-shell { padding: 14px; }
  .hero-card { padding: 18px; }
  .hero-card h1 { font-size: 1.2rem; }
  .hero-actions { flex-direction: column; }
  .hero-actions .primary-btn, .hero-actions .ghost-btn { width: 100%; text-align: center; }
  .hero-stat { padding: 14px; }
  .hero-stat span { font-size: 22px; }
  .stats-grid { grid-template-columns: 1fr; gap: 8px; }
  .stat-card { padding: 14px; }
  .stat-label { font-size: 10px; }
  .stat-value { font-size: 1.1rem; }
  .stat-card p { font-size: 0.8rem; }
  .panel { padding: 16px; border-radius: 18px; }
  .panel-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .module-card { padding: 14px; }
  .module-no { width: 36px; height: 36px; font-size: 0.85rem; }
  .phone-preview { padding: 14px; }
  .feed-item { padding: 12px; font-size: 0.88rem; }
  .chat-drawer-header { padding: 12px 14px; }
  .chat-drawer-avatar { width: 34px; height: 34px; font-size: 17px; }
  .chat-messages { padding: 12px 14px; }
  .chat-input-row {
    padding: 10px 12px;
    flex-wrap: wrap;
  }
  .chat-input-row input[type="text"] {
    min-width: 0;
    width: 100%;
    order: 2;
  }
  .chat-bubble { font-size: 0.88rem; padding: 9px 12px; max-width: 100%; }
  .vo-content { padding: 30px 20px; }
  .vo-agent-name { font-size: 1.2rem; }
  .vo-stop-btn { padding: 12px 22px; font-size: 0.9rem; }
  .access-checklist-grid {
    grid-template-columns: 1fr;
  }
  .doc-upload-modal-content {
    width: calc(100vw - 24px);
    padding: 1rem;
  }
}

/* ── Very small phone (≤380px) — iPhone SE, small screens ── */
@media (max-width: 380px) {
  .auth-panel { padding: 18px; }
  .auth-panel h1 { font-size: 1.15rem; }
  .auth-panel input { padding: 12px 14px; }
  .main-shell { padding: 10px; }
  .hero-card h1 { font-size: 1.05rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .topbar h2 { font-size: 1.1rem; }
  .chat-drawer-btn { padding: 4px 8px; font-size: 0.8rem; min-width: 28px; }
  .chat-drawer-actions {
    gap: 4px;
  }
  .access-flag-card {
    padding: 10px 12px;
  }
}

/* ── Landscape phones ── */
@media (max-height: 500px) and (orientation: landscape) {
  .auth-screen { padding: 12px; }
  .auth-panel { padding: 20px; }
  .vo-agent-emoji { font-size: 40px; margin-bottom: 8px; }
  .vo-visualizer { height: 40px; margin-bottom: 12px; }
  .vo-live-text { margin-bottom: 16px; }
}

/* ── Large desktop (≥1400px) ── */
@media (min-width: 1400px) {
  .app-shell { grid-template-columns: 300px 1fr; }
  .main-shell { padding: 36px 48px; }
  .hero-card { padding: 40px; }
  .hero-card h1 { font-size: 2rem; }
  .stats-grid { gap: 20px; }
}

/* ── Touch device helpers ── */
@media (hover: none) and (pointer: coarse) {
  .nav-item { padding: 14px 14px; }
  .module-card, .upload-card, .admin-card { padding: 16px; }
  .ghost-btn, .primary-btn { min-height: 44px; }
  .chat-input-row input { min-height: 44px; font-size: 16px; /* prevents iOS zoom on focus */ }
  .voice-btn, .send-btn { width: 44px; height: 44px; }
  .edit-form input, .edit-form textarea, .edit-form select { font-size: 16px; min-height: 44px; }
  .auth-panel input { font-size: 16px; }
}

/* ═══ Chat Drawer ═══ */
.chat-language-toolbar {
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,0.7);
}
.language-toggle-group { display: flex; gap: 8px; flex-wrap: wrap; }
.language-toggle-group.right { margin-left: auto; }
.lang-chip, .quick-action-btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px;
  padding: 7px 12px; font-size: 0.78rem; font-weight: 700; cursor: pointer;
}
.lang-chip.active { background: rgba(47,93,70,0.12); color: var(--forest); border-color: rgba(47,93,70,0.28); }
.chat-quick-actions {
  display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); background: rgba(244,239,231,0.85);
}
.quick-action-btn:hover, .lang-chip:hover { background: rgba(47,93,70,0.08); }
.chat-drawer {
  position: fixed; top: 0; right: 0; width: 440px; max-width: 100vw; height: 100vh;
  background: var(--panel); z-index: 200; display: flex; flex-direction: column;
  box-shadow: -8px 0 30px rgba(0,0,0,0.18); transform: translateX(0); transition: transform .3s ease;
  /* position context for history panel overlay */
}
.chat-drawer.closed { transform: translateX(100%); pointer-events: none; }
.chat-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 199; transition: opacity .25s; }
.chat-overlay.closed { opacity: 0; pointer-events: none; }
.chat-drawer-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; border-bottom: 1px solid rgba(255,255,255,0.1);
  background: linear-gradient(135deg, var(--forest), #3a7a5c); color: #fff;
}
.chat-drawer-title { display: flex; align-items: center; gap: 12px; }
.chat-drawer-avatar {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: rgba(255,255,255,0.15); font-size: 20px;
}
.chat-drawer-header h3 { margin: 0; font-size: 1.05rem; font-weight: 700; }
.chat-drawer-status { font-size: 0.75rem; opacity: 0.8; font-weight: 500; margin-top: 1px; }
.chat-drawer-actions { display: flex; gap: 6px; }
.chat-drawer-btn {
  color: #fff !important; border-color: rgba(255,255,255,0.25) !important;
  font-size: 0.9rem; padding: 6px 10px; border-radius: 8px; min-width: 34px; text-align: center;
}
.chat-drawer-btn:hover { background: rgba(255,255,255,0.15) !important; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px;
}
.chat-welcome {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 30px 20px; gap: 12px; opacity: 0.7;
}
.chat-welcome-emoji { font-size: 48px; }
.chat-welcome-text { font-size: 0.92rem; color: var(--muted); line-height: 1.5; max-width: 280px; }
.chat-bubble {
  padding: 10px 14px; border-radius: 14px; max-width: 85%; line-height: 1.55; font-size: 0.92rem;
  word-wrap: break-word; white-space: pre-wrap; animation: bubbleIn .2s ease;
}
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-bubble.user {
  background: var(--forest); color: #fff; align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
  background: var(--sand); color: var(--ink); align-self: flex-start;
  border-bottom-left-radius: 4px; position: relative;
}
.chat-bubble.streaming { opacity: 0.85; }
.chat-bubble .read-aloud-btn {
  display: inline-block; background: none; border: none; cursor: pointer;
  font-size: 14px; padding: 2px 4px; margin-left: 6px; opacity: 0.5;
  transition: opacity .15s; vertical-align: middle;
}
.chat-bubble .read-aloud-btn:hover { opacity: 1; }
.chat-bubble .read-aloud-btn.playing { opacity: 1; }
.chat-bubble-meta {
  display: flex; justify-content: flex-end; align-items: center; gap: 6px;
  margin-top: 4px; font-size: 0.72rem; opacity: 0.5;
}

/* ═══ Typing indicator ═══ */
.typing-indicator {
  display: none; align-items: center; gap: 10px; padding: 8px 20px;
  font-size: 0.85rem; color: var(--muted);
}
.typing-indicator.show { display: flex; }
.typing-avatar { font-size: 18px; }
.typing-content { display: flex; align-items: center; gap: 3px; }
.typing-name { font-weight: 600; color: var(--forest); }
.typing-dots { display: inline-flex; gap: 2px; margin-left: 2px; }
.typing-dots span {
  display: inline-block; animation: typingBounce 1.4s infinite;
  font-weight: 800; font-size: 1.1em;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ═══ Chat session history panel ═══ */
.chat-history-panel {
  display: none; flex-direction: column;
  position: absolute; top: 62px; left: 0; right: 0; bottom: 56px;
  background: var(--panel); z-index: 10;
  border-top: 1px solid var(--line);
}
.chat-history-panel.open { display: flex; }
.chat-history-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: 0.95rem; color: var(--forest);
}
.chat-history-list { flex: 1; overflow-y: auto; padding: 12px 16px; }
.chat-history-empty { text-align: center; padding: 30px; color: var(--muted); font-size: 0.9rem; }
.chat-history-item {
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 8px; cursor: pointer; transition: all .15s; background: rgba(255,255,255,0.6);
}
.chat-history-item:hover { border-color: var(--forest); background: rgba(47,93,70,0.04); }
.chat-history-item.active { border-color: var(--forest); background: rgba(47,93,70,0.08); }
.chat-history-item-preview {
  font-size: 0.88rem; color: var(--ink); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; font-weight: 600;
}
.chat-history-item-meta {
  font-size: 0.75rem; color: var(--muted); margin-top: 4px;
  display: flex; justify-content: space-between;
}

/* ═══ Chat input row ═══ */
.chat-input-row {
  display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line);
  background: var(--bg); align-items: center;
}
.chat-input-row input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 0.95rem; background: #fff; color: var(--ink); transition: border-color .2s;
}
.chat-input-row input:focus { outline: none; border-color: var(--forest); }
.voice-btn, .send-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.6); display: grid; place-items: center; cursor: pointer;
  transition: all .15s; flex-shrink: 0; color: var(--ink);
}
.voice-btn:hover, .send-btn:hover { background: var(--forest); color: #fff; border-color: var(--forest); }
.voice-btn.active { background: #c0392b; color: #fff; border-color: #c0392b; animation: voicePulse 1.5s infinite; }
@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192,57,43,0.3); }
  50% { box-shadow: 0 0 0 8px rgba(192,57,43,0); }
}
.send-btn { background: var(--forest); color: #fff; border-color: var(--forest); }
.send-btn:hover { opacity: 0.85; }

/* ═══ Voice Overlay ═══ */
.vo-language-badge {
  color: rgba(255,255,255,0.82); background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12);
  padding: 6px 12px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; margin-bottom: 12px;
}
.vo-hint {
  color: rgba(255,255,255,0.72); font-size: 0.86rem; line-height: 1.5; text-align: center;
  max-width: 420px; margin: 0 auto 18px;
}
.voice-overlay {
  display: none; position: fixed; inset: 0; z-index: 300;
}
.voice-overlay.active { display: flex; }
.vo-backdrop {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(30,42,34,0.92) 0%, rgba(15,20,16,0.97) 100%);
}
.vo-content {
  position: relative; z-index: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; width: 100%; padding: 40px;
}
.vo-agent-emoji {
  font-size: 72px; margin-bottom: 16px;
  animation: voiceFloat 3s ease-in-out infinite;
}
@keyframes voiceFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.vo-agent-name {
  color: #fff; font-size: 1.4rem; font-weight: 800;
  font-family: 'Plus Jakarta Sans', sans-serif; margin-bottom: 8px;
}
.vo-status {
  color: rgba(255,255,255,0.7); font-size: 0.95rem; font-weight: 600;
  margin-bottom: 24px; transition: color .3s;
}
.vo-status.listening { color: #63f5c6; }
.vo-status.thinking { color: #f5c463; }
.vo-status.speaking { color: #60a5fa; }
.vo-visualizer {
  display: flex; align-items: center; gap: 6px; height: 60px; margin-bottom: 24px;
}
.vo-bar {
  width: 6px; background: rgba(255,255,255,0.2); border-radius: 3px;
  transition: height .15s, background .3s; height: 12px;
}
.vo-visualizer.listening .vo-bar { background: #63f5c6; animation: voiceBar 0.8s ease-in-out infinite; }
.vo-visualizer.listening .vo-bar:nth-child(1) { animation-delay: 0s; }
.vo-visualizer.listening .vo-bar:nth-child(2) { animation-delay: 0.1s; }
.vo-visualizer.listening .vo-bar:nth-child(3) { animation-delay: 0.2s; }
.vo-visualizer.listening .vo-bar:nth-child(4) { animation-delay: 0.3s; }
.vo-visualizer.listening .vo-bar:nth-child(5) { animation-delay: 0.2s; }
.vo-visualizer.listening .vo-bar:nth-child(6) { animation-delay: 0.1s; }
.vo-visualizer.listening .vo-bar:nth-child(7) { animation-delay: 0s; }
.vo-visualizer.thinking .vo-bar { background: #f5c463; animation: voiceBar 1.2s ease-in-out infinite; }
.vo-visualizer.speaking .vo-bar { background: #60a5fa; animation: voiceBar 0.6s ease-in-out infinite; }
@keyframes voiceBar {
  0%, 100% { height: 12px; }
  50% { height: 40px; }
}
.vo-live-text {
  color: rgba(255,255,255,0.85); font-size: 1rem; max-width: 500px;
  text-align: center; line-height: 1.6; min-height: 24px; margin-bottom: 30px;
}
.vo-stop-btn {
  display: flex; align-items: center; gap: 10px; padding: 14px 28px;
  border: 2px solid rgba(255,255,255,0.3); border-radius: 999px;
  background: rgba(255,255,255,0.08); color: #fff; font-size: 1rem;
  font-weight: 700; cursor: pointer; transition: all .2s;
}
.vo-stop-btn:hover { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.5); }

/* ═══ Chat inline (for check-in page) ═══ */
.chat-inline {
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff;
}
.chat-inline .chat-messages { min-height: 300px; max-height: 500px; }

/* ═══ Edit forms ═══ */
.edit-form {
  margin-top: 1rem; padding: 20px; background: var(--bg); border-radius: 12px; border: 1px solid var(--line);
}
.edit-form h4 { margin-bottom: 12px; color: var(--forest); }
.edit-form input, .edit-form textarea, .edit-form select {
  display: block; width: 100%; padding: 10px 14px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 0.95rem;
  background: #fff; color: var(--ink); font-family: inherit;
}
.access-checklist-grid input[type="checkbox"] {
  display: inline-block;
  width: 16px;
  min-width: 16px;
  height: 16px;
  margin: 2px 0 0;
  padding: 0;
}
.edit-form input:focus, .edit-form textarea:focus, .edit-form select:focus { outline: none; border-color: var(--forest); }
.form-actions { display: flex; gap: 8px; margin-top: 4px; }

/* ═══ Upload form ═══ */
.upload-form {
  display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 1.5rem; align-items: center;
}
.upload-form input[type="file"] { flex: 1; min-width: 200px; }
.upload-form input[type="text"], .upload-form select { flex: 1; min-width: 150px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 0.9rem; }

/* ═══ Post form ═══ */
.post-form { margin-bottom: 1.5rem; }
.post-form textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 0.95rem; font-family: inherit; resize: vertical; background: #fff; color: var(--ink);
}
.post-form textarea:focus { outline: none; border-color: var(--forest); }
.post-form-actions { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.post-form-actions select { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 0.9rem; }

/* ═══ Progress bar ═══ */
.progress-bar {
  height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 6px 0;
}
.progress-fill { height: 100%; background: var(--forest); border-radius: 4px; transition: width 0.3s; }

/* ═══ Trainee cards ═══ */
.trainee-cards { display: flex; flex-direction: column; gap: 1rem; }

/* ═══ Lesson cards ═══ */
.lesson-view { padding: 0.5rem 0; }
.lesson-card {
  padding: 16px; margin: 12px 0; background: var(--bg); border-radius: 10px; border: 1px solid var(--line);
}
.lesson-card h4 { margin-bottom: 8px; color: var(--forest); }

/* ═══ Signoff badge ═══ */
.signoff { color: var(--forest); font-weight: 600; margin-top: 6px; font-size: 0.85rem; }

/* ═══ Chat attachment preview ═══ */
.attachment-preview { display: none; padding: 8px 14px; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); background: var(--bg); }
.attachment-preview.has-files { display: flex; }
.att-thumb { position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.att-thumb img, .att-thumb video { width: 100%; height: 100%; object-fit: cover; }
.att-file { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: .6rem; color: var(--muted); text-align: center; padding: 4px; }
.att-icon { font-size: 1.3rem; margin-bottom: 2px; }
.att-status { position: absolute; left: 3px; right: 3px; bottom: 3px; background: rgba(0,0,0,.65); color: #fff; font-size: .54rem; border-radius: 5px; padding: 2px 4px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-status.ok { color: #86efac; }
.att-status.error { color: #fca5a5; }
.att-remove { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 50%; cursor: pointer; font-size: .65rem; display: flex; align-items: center; justify-content: center; line-height: 1; }
.att-remove:hover { background: #ef4444; }
.msg-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin: 0.4rem 0; }
.msg-att-img { max-width: 200px; max-height: 160px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); }
.msg-att-video { max-width: 220px; max-height: 160px; border-radius: 8px; border: 1px solid var(--line); }
.msg-att-file { display: inline-block; padding: 6px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--forest); text-decoration: none; font-size: .8rem; }
.msg-att-file:hover { background: var(--sand); }

/* ═══ Documents Page ═══ */
.doc-info-panel {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.doc-info-panel h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  color: #1e40af;
}
.doc-info-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.doc-info-notes span {
  font-size: 0.85rem;
  color: #475569;
  background: #fff;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}
.doc-reason-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
}
.doc-reason-section textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
}
.doc-reason-hint {
  font-size: 0.85rem;
  color: #64748b;
  margin: 0 0 0.5rem 0;
}
.doc-reason-info {
  font-size: 0.8rem;
  color: #b45309;
  margin-top: 0.25rem;
  font-style: italic;
}
.doc-item-desc {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 0.25rem;
  line-height: 1.4;
}
.doc-admin-select { margin-bottom: 1rem; }
.doc-admin-select select { padding: 0.4rem 0.6rem; border-radius: 8px; border: 1px solid var(--line); font-size: 0.9rem; }
.doc-category { margin-bottom: 1.5rem; }
.doc-category-title { font-size: 1rem; font-weight: 700; margin-bottom: 0.5rem; padding-bottom: 0.4rem; border-bottom: 2px solid var(--line); }
/* .doc-item styles moved to bottom of file (Dynamic Documents section) */
.doc-item-desc { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }
.doc-badge { font-size: 0.65rem; font-weight: 700; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.03em; }
.doc-badge.required { background: #fee2e2; color: #dc2626; }
.doc-badge.optional { background: #e0f2fe; color: #0284c7; }
.doc-status-badge { font-size: 0.65rem; font-weight: 700; padding: 2px 6px; border-radius: 4px; color: #fff; text-transform: capitalize; }
.doc-expiry-warn { color: #ea580c; font-weight: 700; font-size: 0.75rem; }
.doc-expiry { color: var(--muted); font-size: 0.75rem; }
.doc-filename { font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; }
.doc-review-info { font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; font-style: italic; }
.doc-upload-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.doc-upload-modal.hidden { display: none; }
.doc-upload-modal-content { background: #fff; border-radius: 12px; padding: 1.5rem; max-width: 440px; width: 90%; }
.doc-upload-modal-content h4 { margin-bottom: 1rem; }
.doc-upload-modal-content input[type="file"] { margin-bottom: 0.75rem; }
#doc-upload-status { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.5rem; }
#doc-field-status { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.5rem; }

/* ── Document File Preview ── */
.doc-file-preview {
  margin-top: 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}
.doc-preview-img {
  max-width: 100%;
  max-height: 200px;
  display: block;
  object-fit: contain;
  cursor: pointer;
  transition: opacity 0.15s;
  padding: 0.5rem;
}
.doc-preview-img:hover { opacity: 0.85; }
.doc-preview-pdf {
  width: 100%;
  height: 250px;
  border: none;
  display: block;
}
.doc-file-preview-pdf-fallback {
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}
.doc-pdf-fallback-body {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
}
.doc-pdf-icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}
.doc-pdf-text strong {
  display: block;
  margin-bottom: 4px;
}
.doc-pdf-text p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.9rem;
}
.doc-preview-open-link {
  display: block;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.8rem;
  color: var(--forest);
  text-decoration: none;
  border-top: 1px solid #e2e8f0;
}
.doc-preview-open-link:hover { background: #f0fdf4; }

/* ── Full-screen Document Viewer ── */
.doc-fullscreen-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.doc-fullscreen-container {
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.doc-fullscreen-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
.doc-fullscreen-toolbar .ghost-btn {
  color: #fff;
  border-color: rgba(255,255,255,0.3);
  font-size: 0.85rem;
}
.doc-fullscreen-toolbar .ghost-btn:hover { background: rgba(255,255,255,0.1); }
.doc-fullscreen-img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
}
.doc-fullscreen-pdf {
  width: 90vw;
  height: 85vh;
  border: none;
  border-radius: 8px;
  background: #fff;
}
.doc-fullscreen-pdf-fallback {
  width: min(92vw, 1100px);
}
.doc-fullscreen-pdf-card {
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
}
.doc-fullscreen-pdf-card h3 {
  margin: 8px 0 6px;
}
.doc-fullscreen-pdf-card p {
  color: var(--muted);
  margin-bottom: 12px;
}

/* ── Rechange status styling ── */
.doc-review-info {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.2rem;
  font-style: italic;
}

/* ── Video/Audio Preview ── */
.doc-preview-video {
  width: 100%;
  max-height: 260px;
  background: #000;
  display: block;
}
.doc-preview-audio {
  width: 100%;
  display: block;
}
.doc-file-preview-audio {
  padding: 0.75rem;
}
.doc-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}
.doc-preview-actions .ghost-btn {
  font-size: 0.75rem;
  padding: 0.3rem 0.55rem;
}
.doc-fullscreen-video {
  max-width: 90vw;
  max-height: 85vh;
  background: #000;
  border-radius: 8px;
}
.doc-fullscreen-audio-wrap {
  width: min(720px, 90vw);
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
}
.doc-fullscreen-audio {
  width: 100%;
}

@media (max-width: 640px) {
  .doc-preview-pdf { height: 180px; }
  .doc-fullscreen-pdf { width: 95vw; height: 80vh; }
  .doc-fullscreen-img { max-width: 95vw; max-height: 80vh; }
  .doc-fullscreen-video { max-width: 95vw; max-height: 80vh; }
}

.doc-context-banner {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}
.doc-context-title {
  font-weight: 700;
  color: #166534;
  margin-bottom: 0.2rem;
}
.doc-context-meta {
  font-size: 0.85rem;
  color: #166534;
  opacity: 0.85;
  margin-bottom: 0.35rem;
}
.doc-context-note {
  font-size: 0.85rem;
  color: #365314;
  line-height: 1.4;
}

/* ── Dynamic Documents: New Styles ── */
.doc-category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.doc-category-header .doc-category-title {
  margin-bottom: 0;
}
.doc-add-field-btn {
  font-size: 0.78rem !important;
  padding: 0.35rem 0.65rem !important;
  white-space: nowrap;
}
.doc-item {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 0.75rem;
  background: var(--bg);
}
.doc-item:hover {
  border-color: var(--forest);
}
.doc-item-header {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.doc-item-header .doc-item-label {
  font-weight: 700;
  font-size: 1rem;
  flex: 1 1 220px;
  min-width: 0;
  line-height: 1.3;
}
.doc-field-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}
.ghost-btn-sm {
  font-size: 0.78rem !important;
  padding: 0.42rem 0.62rem !important;
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.doc-files-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.doc-file-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.75rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,0.45);
}
.doc-file-thumb {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(255,255,255,0.8);
  border: 1px solid rgba(30,42,34,0.08);
}
.doc-file-thumb .doc-thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
}
.doc-file-thumb .doc-thumb-icon {
  font-size: 1.5rem;
}
.doc-file-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}
.doc-file-name {
  display: inline-block;
  max-width: 100%;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.doc-review-inline {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}
.doc-file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: flex-start;
  justify-content: flex-end;
}
.doc-file-actions .ghost-btn {
  min-width: 42px;
  min-height: 42px;
  padding: 0.45rem 0.65rem;
}
.doc-no-files {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.5rem 0;
  font-style: italic;
}
.doc-item-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.doc-item-actions .doc-upload-btn {
  min-height: 44px;
}
.doc-add-field-bottom {
  margin-top: 0.5rem;
  margin-bottom: 1rem;
  text-align: center;
}
.doc-add-field-bottom .ghost-btn {
  font-size: 0.8rem;
  opacity: 0.85;
}
.doc-add-field-bottom .ghost-btn:hover {
  opacity: 1;
}
.doc-form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}
.doc-form-label input[type="text"],
.doc-form-label select {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.85rem;
}
.doc-form-label input[type="checkbox"] {
  margin-right: 0.4rem;
}
.doc-upload-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
@media (max-width: 900px) {
  .doc-info-notes {
    flex-direction: column;
    align-items: stretch;
  }
  .doc-info-notes span {
    width: 100%;
  }
}
@media (max-width: 700px) {
  .doc-file-row {
    grid-template-columns: 46px minmax(0, 1fr);
  }
  .doc-file-actions {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: stretch;
  }
  .doc-file-actions .ghost-btn {
    flex: 1 1 0;
    min-width: 0;
  }
}
@media (max-width: 520px) {
  .doc-category-title {
    font-size: 0.95rem;
    line-height: 1.35;
  }
  .doc-item {
    padding: 0.75rem;
    border-radius: 10px;
  }
  .doc-item-header .doc-item-label {
    font-size: 0.95rem;
    flex-basis: 100%;
  }
  .doc-file-row {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }
  .doc-file-thumb {
    width: 48px;
    height: 48px;
  }
  .doc-file-thumb .doc-thumb {
    width: 48px;
    height: 48px;
  }
  .doc-file-info {
    width: 100%;
  }
  .doc-file-meta-row {
    width: 100%;
    gap: 6px;
  }
  .doc-upload-badge,
  .doc-status-badge {
    font-size: 0.68rem;
  }
  .doc-file-actions {
    width: 100%;
    justify-content: stretch;
  }
  .doc-file-actions .ghost-btn {
    flex: 1 1 0;
    min-height: 44px;
    font-size: 0.9rem;
  }
  .doc-item-actions {
    width: 100%;
  }
  .doc-item-actions .ghost-btn,
  .doc-item-actions .primary-btn {
    width: 100%;
    justify-content: center;
  }
}
