/* ------- VLPL Chatbot — minimalist, mobile-first ------- */

:root {
  --bg: #0f1419;
  --bg-card: #1a2028;
  --bg-elev: #232a33;
  --bg-sidebar: #151a21;
  --fg: #e9eef5;
  --fg-muted: #8a96a5;
  --accent: #ff6b35;
  --accent-hover: #ff8350;
  --accent-soft: #ff6b3522;
  --user-bubble: #2d3a4a;
  --bot-bubble: #1a2028;
  --citation: #4dd4ac;
  --border: #2c3540;
  --error: #ff6b6b;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Noto Sans Bengali", sans-serif; font-size: 16px; line-height: 1.5; }

#app { height: 100%; }
.view { height: 100%; display: flex; flex-direction: column; }
.view.hidden { display: none; }
.hidden { display: none !important; }

/* ----- Login & onboarding cards ----- */
#view-login, #view-onboard { align-items: center; justify-content: center; padding: 24px; }
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.brand { text-align: center; margin-bottom: 24px; }
.logo {
  width: 56px; height: 56px;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--accent), #ff4d1a);
  color: white;
  font-weight: 800; font-size: 28px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
}

h1 { margin: 0 0 6px; font-size: 22px; font-weight: 700; }
.tagline { margin: 0 0 8px; color: var(--fg-muted); font-size: 14px; }

form { display: flex; flex-direction: column; gap: 12px; }
form label { font-size: 13px; color: var(--fg-muted); font-weight: 500; margin-top: 6px; }
form input[type=text], form input[type=password], form textarea, form select {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  outline: none;
  transition: border .15s;
}
form input:focus, form textarea:focus { border-color: var(--accent); }
form button[type=submit], .primary-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: background .15s;
}
form button[type=submit]:hover:not(:disabled), .primary-btn:hover:not(:disabled) { background: var(--accent-hover); }
form button[type=submit]:disabled { opacity: 0.5; cursor: not-allowed; }

.error { color: var(--error); font-size: 13px; min-height: 18px; margin: 4px 0 0; }

/* ----- Onboarding pills ----- */
.lang-grid, .dept-grid { display: grid; gap: 8px; }
.lang-grid { grid-template-columns: repeat(3, 1fr); }
.dept-grid { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 480px) { .dept-grid { grid-template-columns: repeat(2, 1fr); } }

.lang-pill, .dept-pill {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  font-size: 14px;
}
.lang-pill input, .dept-pill input { position: absolute; opacity: 0; }
.lang-pill:hover, .dept-pill:hover { border-color: var(--accent); }
.lang-pill:has(input:checked), .dept-pill:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dept-pill small { display: block; color: var(--fg-muted); font-size: 11px; margin-top: 2px; }

/* ----- Chat layout: sidebar + main ----- */
#view-chat {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100%;
}

#sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.sidebar-head { padding: 14px; border-bottom: 1px solid var(--border); }
.sidebar-head button { width: 100%; margin: 0; }

.chats-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.chat-row {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: transparent;
  border: 1px solid transparent;
  transition: background .12s, border .12s;
}
.chat-row:hover { background: var(--bg-elev); }
.chat-row.active { background: var(--bg-elev); border-color: var(--accent); }
.chat-row .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row .meta { color: var(--fg-muted); font-size: 11px; }
.chat-row .del {
  opacity: 0;
  background: transparent; border: none; color: var(--fg-muted);
  cursor: pointer; padding: 2px 6px; border-radius: 4px;
}
.chat-row:hover .del { opacity: 1; }
.chat-row .del:hover { background: var(--error); color: white; }

.sidebar-quick {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.quick-action {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg);
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
.quick-action:hover {
  background: var(--bg-elev);
  border-color: var(--accent);
  color: var(--accent);
}
.sidebar-foot { padding: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.user-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elev);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.user-meta strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { font-size: 11px; color: var(--fg-muted); }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.ghost-btn:hover { background: var(--bg-elev); }
.icon-btn { background: transparent; border: none; color: var(--fg); cursor: pointer; padding: 4px 8px; font-size: 16px; }
.icon-btn:hover { color: var(--accent); }
.link-btn { background: transparent; border: none; color: var(--fg-muted); cursor: pointer; padding: 0 4px; font-size: 11px; text-decoration: underline; }
.link-btn:hover { color: var(--accent); }

/* ----- Chat main ----- */
.chat-main { display: flex; flex-direction: column; min-width: 0; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-title-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.chat-title-wrap strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header .actions { display: flex; gap: 8px; }
.chat-header .actions button {
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.chat-header .actions button:hover { background: var(--border); }

.messages { flex: 1; overflow-y: auto; padding: 20px 16px; display: flex; flex-direction: column; gap: 14px; }

.msg { display: flex; flex-direction: column; max-width: 78%; font-size: 15px; }
.msg .bubble {
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.55;
}
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.user .bubble { background: var(--user-bubble); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; align-items: flex-start; }
.msg.bot .bubble { background: var(--bot-bubble); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.system .bubble { background: var(--accent-soft); border: 1px dashed var(--accent); color: var(--accent); font-style: italic; font-size: 13px; }
.msg.system { align-self: center; max-width: 90%; }

.msg .citations { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.citations-label { color: var(--fg-muted); font-size: 11px; font-weight: 500; margin-right: 4px; }
.citation-chip {
  background: transparent;
  border: 1px solid var(--citation);
  color: var(--citation);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.citation-chip:hover { background: var(--citation); color: var(--bg); }
.msg.bot .bubble .inline-cite { color: var(--citation); font-weight: 500; font-size: 0.85em; margin-left: 2px; }

/* ----- Markdown rendering inside bot bubbles ----- */
.msg .bubble h1, .msg .bubble h2, .msg .bubble h3, .msg .bubble h4, .msg .bubble h5, .msg .bubble h6 {
  margin: 8px 0 6px;
  line-height: 1.25;
  color: var(--fg);
  font-weight: 700;
}
.msg .bubble h1 { font-size: 1.45em; color: var(--accent); border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.msg .bubble h2 { font-size: 1.25em; color: var(--accent); }
.msg .bubble h3 { font-size: 1.10em; }
.msg .bubble h4, .msg .bubble h5, .msg .bubble h6 { font-size: 1em; }
.msg .bubble p { margin: 6px 0; }
.msg .bubble p:first-child { margin-top: 0; }
.msg .bubble p:last-child { margin-bottom: 0; }
.msg .bubble ul, .msg .bubble ol { margin: 8px 0; padding-left: 22px; }
.msg .bubble li { margin: 3px 0; }
.msg .bubble strong { color: #ffd9a8; font-weight: 700; }
.msg .bubble em { color: #b8d4f0; font-style: italic; }
.msg .bubble code {
  background: var(--bg-elev);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.9em;
  color: var(--citation);
}
.msg .bubble blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 12px;
  margin: 8px 0;
  background: var(--bg-elev);
  color: var(--fg-muted);
}
.msg .bubble table {
  border-collapse: collapse;
  margin: 10px 0;
  width: 100%;
  font-size: 0.95em;
}
.msg .bubble th, .msg .bubble td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.msg .bubble th { background: var(--bg-elev); color: var(--accent); font-weight: 600; }
.msg .bubble tr:nth-child(even) td { background: rgba(255,255,255,0.02); }

/* Criticality badges — used by Gemini in headers */
.msg .bubble .badge-critical { background: #ff5470; color: white; padding: 2px 8px; border-radius: 999px; font-size: 0.75em; font-weight: 700; margin-left: 6px; }
.msg .bubble .badge-major { background: #ffaa3e; color: white; padding: 2px 8px; border-radius: 999px; font-size: 0.75em; font-weight: 700; margin-left: 6px; }
.msg .bubble .badge-minor { background: #4dd4ac; color: white; padding: 2px 8px; border-radius: 999px; font-size: 0.75em; font-weight: 700; margin-left: 6px; }

.play-btn {
  margin-top: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
  align-self: flex-start;
}
.play-btn:hover { border-color: var(--accent); color: var(--accent); }
.play-btn.playing { background: var(--accent); color: white; border-color: var(--accent); }
.play-btn.loading { background: var(--bg-elev); color: var(--fg-muted); cursor: progress; }

/* Quick-start pills */
.pills-bubble { max-width: 95%; align-self: stretch; }
.pills-bubble .bubble.pills-greeting { background: linear-gradient(135deg, rgba(255,107,53,0.18), rgba(255,107,53,0.05)); border-color: var(--accent); }
.quick-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.quick-pills.post-brief { margin-top: 8px; }
.quick-pills.menu-buttons {
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.quick-pills.menu-buttons .quick-pill {
  width: 100%;
  text-align: left;
  font-size: 13px;
}

.know-more-btn {
  display: block !important;
  margin: 8px 0 14px !important;
  width: 100% !important;
  font-size: 13px !important;
}

.explain-simpler-btn {
  display: block;
  margin: 6px 0 14px 0 !important;
  width: auto;
  max-width: 100%;
  background: rgba(255, 170, 62, 0.1) !important;
  border: 1px dashed #ffaa3e !important;
  color: #ffaa3e !important;
  text-align: left;
  font-size: 12px !important;
}
.explain-simpler-btn:hover {
  background: #ffaa3e !important;
  color: white !important;
}
.explain-simpler-btn:disabled {
  cursor: progress;
  opacity: 0.7;
}

.simpler-inline {
  margin: 6px 0 12px 12px;
  padding: 10px 12px;
  background: rgba(255, 170, 62, 0.08);
  border-left: 3px solid #ffaa3e;
  border-radius: 0 8px 8px 0;
}
.simpler-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #ffaa3e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.simpler-text {
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg);
}
.quick-pill {
  background: var(--bg-elev);
  border: 2px solid var(--accent);
  color: var(--fg);
  padding: 11px 16px 11px 36px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  text-align: left;
  position: relative;
  box-shadow: 0 2px 6px rgba(255, 107, 53, 0.15);
}
.quick-pill::before {
  content: "👉";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
}
.quick-pill:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.35);
}
.quick-pill:active { transform: translateY(0); box-shadow: 0 1px 3px rgba(255, 107, 53, 0.2); }
.chunk-next-btn {
  display: inline-block;
  margin: 12px 0 4px 0;
  padding: 9px 18px 9px 32px;
  font-size: 13px;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  border: 2px solid var(--accent);
  box-shadow: 0 3px 10px rgba(255, 107, 53, 0.35);
}
.chunk-next-btn::before { content: ""; }
.chunk-next-btn:hover { background: var(--accent-hover, #e55a2b); color: white; }
.pills-hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--fg-muted);
  font-style: italic;
}

.chat-input { display: flex; gap: 8px; padding: 12px; background: var(--bg-card); border-top: 1px solid var(--border); flex-shrink: 0; }
.chat-input textarea { flex: 1; resize: none; font-family: inherit; font-size: 15px; max-height: 160px; min-height: 44px; }
.chat-input button { align-self: stretch; min-width: 60px; font-size: 15px; font-weight: 600; margin: 0; }
#btn-mic {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--fg);
  min-width: 48px;
  font-size: 18px;
  cursor: pointer;
  transition: all .15s;
}
#btn-mic:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
#btn-mic.listening {
  background: var(--accent); color: white; border-color: var(--accent);
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 53, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(255, 107, 53, 0); }
}
#btn-speaker { font-size: 16px; }
#btn-speaker[data-on="false"] { opacity: 0.4; }

.voice-status {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  z-index: 100;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--fg-muted); animation: blink 1.4s infinite both; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

.messages::-webkit-scrollbar, .chats-list::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb, .chats-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ----- Admin modal ----- */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-body h3 { margin: 16px 0 8px; font-size: 14px; color: var(--fg-muted); font-weight: 600; }
.modal-body h3:first-child { margin-top: 0; }
.admin-form { display: flex; flex-direction: column; gap: 8px; }
.admin-form input { font-size: 14px; padding: 10px 12px; }
.admin-form label.check { color: var(--fg-muted); font-size: 13px; }
.admin-list { list-style: none; padding: 0; margin: 0; }
.admin-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.admin-list li:last-child { border-bottom: none; }
.admin-list .name { flex: 1; }
.admin-list .badge {
  background: var(--accent); color: white;
  font-size: 10px; padding: 2px 8px; border-radius: 999px;
}
.admin-list .row-actions { display: flex; gap: 6px; }
.admin-list .row-actions button {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--fg);
  font-size: 12px; padding: 4px 10px; border-radius: 6px; cursor: pointer;
}
.admin-list .row-actions button.danger { color: var(--error); border-color: var(--error); }
.admin-list .row-actions button:hover { background: var(--border); }

.muted-help { color: var(--fg-muted); font-size: 12px; margin: 4px 0 8px; }
#settings-voice {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  width: 100%;
}
.font-buttons { display: flex; gap: 8px; }
.font-buttons button { flex: 1; font-weight: 700; }

/* SOP picker modal */
.sop-picker-card { max-width: 760px; }
.sop-picker-card .modal-body { padding-top: 14px; }
.progress-summary {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  background: var(--bg-elev);
  border-radius: var(--radius);
  font-size: 13px;
}
.progress-stat { display: flex; flex-direction: column; align-items: center; flex: 1; }
.progress-stat .num { font-size: 22px; font-weight: 700; color: var(--accent); }
.progress-stat .label { font-size: 11px; color: var(--fg-muted); margin-top: 2px; }
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}
.progress-bar > .seg-deep { background: #4dd4ac; }
.progress-bar > .seg-brief { background: #ffaa3e; }

.sop-filter-row { display: flex; gap: 8px; margin-bottom: 12px; }
.sop-filter-row input, .sop-filter-row select {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--fg);
  padding: 8px 10px; border-radius: 8px; font-size: 13px; flex: 1;
}
.sop-filter-row input { flex: 2; }

.sop-picker-list {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 60vh; overflow-y: auto;
}
.sop-picker-group-head {
  font-size: 11px; font-weight: 700; color: var(--fg-muted); text-transform: uppercase;
  padding: 12px 4px 4px; letter-spacing: 0.5px;
}
.sop-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all .12s;
}
.sop-row:hover { border-color: var(--accent); background: var(--accent-soft); }
.sop-row .status-dot {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--fg-muted); background: transparent;
}
.sop-row[data-depth="brief"] .status-dot { background: #ffaa3e; border-color: #ffaa3e; }
.sop-row[data-depth="in_depth"] .status-dot { background: #4dd4ac; border-color: #4dd4ac; }
.sop-row .sop-id-cell { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--fg-muted); min-width: 130px; }
.sop-row .sop-title-cell { flex: 1; font-size: 14px; }
.sop-row .sop-actions { display: flex; gap: 6px; opacity: 0; transition: opacity .12s; }
.sop-row:hover .sop-actions { opacity: 1; }
.sop-row .sop-actions button {
  background: transparent; border: 1px solid var(--accent); color: var(--accent);
  padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.sop-row .sop-actions button:hover { background: var(--accent); color: white; }

/* Sidebar close button (mobile) */
.sidebar-close-btn { display: none; margin-left: 6px; }
.sidebar-head { display: flex; align-items: center; gap: 4px; }
.sidebar-head .primary-btn { flex: 1; }

/* Backdrop overlay when mobile sidebar is open */
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9;
  display: none;
}
.sidebar-backdrop.visible { display: block; }

/* ----- Mobile ----- */
@media (max-width: 700px) {
  #view-chat { grid-template-columns: 1fr; }
  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 82vw; max-width: 320px;
    z-index: 10;
    transform: translateX(-100%);
    transition: transform .22s ease-out;
    box-shadow: 4px 0 16px rgba(0,0,0,0.3);
  }
  #sidebar.open { transform: translateX(0); }
  .sidebar-close-btn { display: inline-flex; }
  .msg { max-width: 90%; }

  /* SOP picker becomes near-fullscreen */
  .modal { padding: 8px; align-items: stretch; }
  .modal-card { max-height: 96vh; max-width: 100%; }
  .sop-picker-card .modal-body { padding: 14px 10px; }
  .progress-summary { flex-wrap: wrap; padding: 8px; }
  .progress-stat .num { font-size: 18px; }
  .sop-filter-row { flex-direction: column; gap: 6px; }
  .sop-filter-row input, .sop-filter-row select { width: 100%; }
  .sop-row {
    flex-wrap: wrap;
    padding: 12px;
    gap: 6px;
  }
  .sop-row .sop-id-cell { min-width: 0; flex-basis: auto; font-size: 11px; }
  .sop-row .sop-title-cell {
    flex-basis: 100%;
    font-size: 14px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .sop-row .sop-actions {
    opacity: 1 !important;
    flex-basis: 100%;
    margin-top: 4px;
  }
  .sop-row .sop-actions button { flex: 1; padding: 8px; font-size: 13px; }
}

@media (max-width: 600px) {
  .card { padding: 24px 20px; }
  h1 { font-size: 20px; }
}
