/* ===== Self-hosted fonts (no external dependency for live demos) ===== */
@font-face { font-family: 'IBM Plex Sans'; src: url('fonts/IBMPlexSans-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('fonts/IBMPlexSans-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('fonts/IBMPlexSans-SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('fonts/IBMPlexSans-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('fonts/IBMPlexMono-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('fonts/IBMPlexMono-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('fonts/IBMPlexMono-SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }

/* ===== Design tokens ===== */
:root {
  --bg: #F5F7F7;
  --panel: #FFFFFF;
  --ink: #16232B;
  --ink-soft: #4A5A62;
  --ink-faint: #8A9AA0;
  --teal: #0C7C82;
  --teal-deep: #0A5B60;
  --teal-wash: #E6F1F1;
  --amber: #B8791E;
  --amber-wash: #FBF1E0;
  --green: #2F7D5E;
  --green-wash: #E7F3ED;
  --grey-wash: #EEF1F1;
  --line: #DCE3E3;
  --line-soft: #E9EEEE;
  --radius: 10px;
  --font-ui: 'IBM Plex Sans', -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
.mono { font-family: var(--font-mono); }
.hidden { display: none !important; }
.muted { color: var(--ink-soft); }

/* ===== View switching ===== */
.view { display: none; }
.view.active { display: block; }

/* ===== Login ===== */
.view-login {
  min-height: 100vh;
  align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 15% 15%, rgba(12,124,130,0.07), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(184,121,30,0.06), transparent 45%),
    var(--bg);
}
.view-login.active { display: flex; }
.login-card {
  width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 36px 32px 28px;
  box-shadow: 0 20px 50px -20px rgba(22,35,43,0.18);
}
.brand-lockup { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand-mark-img { height: 40px; width: auto; flex-shrink: 0; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: 0.2px; }
.brand-module { font-size: 11.5px; color: var(--amber); font-weight: 600; letter-spacing: 0.3px; }
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.login-sub { color: var(--ink-soft); font-size: 13px; margin: 0 0 24px; }
#login-form label { display: block; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 14px; font-weight: 500; }
#login-form input {
  display: block; width: 100%; margin-top: 6px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; background: #FBFCFC;
}
#login-form input:focus { outline: 2px solid var(--teal); outline-offset: 1px; border-color: var(--teal); }
.login-foot { margin-top: 18px; font-size: 11.5px; color: var(--ink-faint); text-align: center; }

/* ===== Buttons ===== */
.btn {
  border: none; border-radius: 8px; padding: 9px 16px;
  font-size: 13.5px; font-weight: 600; transition: background 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-deep); }
.btn-ghost { background: transparent; color: var(--teal); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--teal-wash); }
.btn-block { width: 100%; margin-top: 6px; padding: 11px; font-size: 14px; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-back {
  background: none; border: none; color: var(--ink-soft); font-size: 12.5px;
  padding: 0 0 8px; font-weight: 500;
}
.btn-back:hover { color: var(--teal); }

/* ===== App shell: real MaiTuLIMS chrome ===== */
.view-app { display: none; min-height: 100vh; flex-direction: column; }
.view-app.active { display: flex; }

/* --- Top bar (matches real product: dark charcoal-teal, logo + nav left, icons + user right) --- */
.topbar {
  height: 60px; flex-shrink: 0;
  background: #293333;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px 0 14px;
}
.topbar-left { display: flex; align-items: center; gap: 22px; }
.topbar-logo { height: 34px; display: block; }
.topbar-nav { display: flex; align-items: center; gap: 22px; }
.topbar-link {
  color: #E4E9E9; text-decoration: none; font-size: 13.5px; font-weight: 500;
  display: flex; align-items: center; gap: 5px; opacity: 0.9;
}
.topbar-link:hover { opacity: 1; }
.topbar-link .caret { width: 8px; height: 5px; opacity: 0.7; }
.topbar-right { display: flex; align-items: center; gap: 4px; }
.topbar-icon-btn {
  background: none; border: none; color: #C7D2D2; padding: 7px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.topbar-icon-btn svg { width: 18px; height: 18px; }
.topbar-icon-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.topbar-user {
  color: #E4E9E9; font-size: 13px; font-weight: 500; margin-left: 6px;
  display: flex; align-items: center; gap: 5px; padding: 6px 8px; border-radius: 6px;
}
.topbar-user:hover { background: rgba(255,255,255,0.08); cursor: pointer; }
.topbar-user .caret { width: 8px; height: 5px; opacity: 0.7; }

.body-row { flex: 1; display: flex; min-height: 0; }

/* --- Left sidebar: real Senaite modules (white bg, neutral icons) + AI Notebook entry --- */
.sidebar {
  width: 220px; flex-shrink: 0;
  background: #FFFFFF;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 16px 12px;
}
.sidebar-search {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px;
  color: var(--ink-faint); font-size: 12.5px; margin-bottom: 14px;
}
.sidebar-search svg { width: 15px; height: 15px; flex-shrink: 0; }
.sidebar-nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.sidebar-divider { height: 1px; background: var(--line-soft); margin: 10px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 7px;
  text-decoration: none; color: #46545C; font-size: 13.5px; font-weight: 500;
  position: relative;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.75; color: #5C6B73; }
.nav-item:hover { background: #F1F4F4; }
.nav-item-notebook.active { background: var(--teal-wash); color: var(--teal-deep); }
.nav-item-notebook.active svg { color: var(--teal); opacity: 1; }
.module-pill {
  margin-left: auto; font-size: 9px; font-weight: 700;
  background: var(--amber); color: #fff;
  padding: 2px 6px; border-radius: 20px; flex-shrink: 0;
}
.sidebar-note {
  font-size: 11px; line-height: 1.5; color: var(--ink-faint);
  border-top: 1px solid var(--line-soft); padding-top: 12px; margin-top: 10px;
}
.sidebar-note strong { color: var(--ink-soft); }

/* --- Notebook module area: subnav + content --- */
.notebook-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.subnav {
  display: flex; gap: 4px; padding: 0 32px; background: #FBFCFC;
  border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.subnav-item {
  padding: 13px 6px; color: var(--ink-soft); text-decoration: none;
  font-size: 13.5px; font-weight: 600; border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.subnav-item:hover { color: var(--ink); }
.subnav-item.active { color: var(--teal-deep); border-bottom-color: var(--teal); }

.main-col { flex: 1; min-width: 0; padding: 28px 40px 60px; overflow-y: auto; }

/* ===== Pages ===== */
.page { display: none; max-width: 1080px; }
.page.active { display: block; }

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 24px; gap: 20px;
}
.eyebrow {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--teal); margin-bottom: 6px;
}
.page-header h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -0.3px; }
.page-header h1.mono-title { font-family: var(--font-mono); font-size: 23px; }
.page-sub { color: var(--ink-soft); font-size: 13.5px; margin: 0; }

/* ===== Stat row ===== */
.stat-row { display: flex; gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 22px; flex: 1;
}
.stat-num { font-family: var(--font-mono); font-size: 30px; font-weight: 600; color: var(--ink); }
.stat-unit { font-size: 16px; color: var(--ink-soft); }
.stat-label { font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; }

/* ===== Panel ===== */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 20px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.panel-head h2 { font-size: 15.5px; margin: 0; }
.panel-sub { font-size: 12px; color: var(--ink-faint); }

/* ===== Draft queue (dashboard) ===== */
.draft-queue { display: flex; flex-direction: column; gap: 8px; }
.draft-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border: 1px solid var(--line-soft); border-radius: 8px;
  background: #FCFDFD; cursor: pointer; transition: border-color 0.15s;
}
.draft-row:hover { border-color: var(--teal); }
.draft-row-main { flex: 1; min-width: 0; }
.draft-row-title { font-weight: 600; font-size: 13.5px; }
.draft-row-sub { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

/* ===== Pills ===== */
.pill {
  display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 700;
  padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}
.pill-amber { background: var(--amber-wash); color: var(--amber); }
.pill-green { background: var(--green-wash); color: var(--green); }
.pill-grey { background: var(--grey-wash); color: var(--ink-soft); }
.pill-lg { font-size: 13px; padding: 5px 14px; }
.pill-sm { font-size: 10px; padding: 2px 7px; }

/* ===== Data table ===== */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--ink-faint); font-weight: 600; padding: 0 12px 10px; border-bottom: 1px solid var(--line);
}
.data-table td { padding: 12px; border-bottom: 1px solid var(--line-soft); }
.data-table tbody tr:hover { background: var(--teal-wash); cursor: pointer; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ===== Experiment detail layout ===== */
.exp-layout { display: flex; gap: 22px; align-items: flex-start; }
.exp-main { flex: 1; min-width: 0; }

.overview-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 24px;
}
.ov-label { font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 3px; }
.ov-value { font-size: 14px; font-weight: 500; }
.version-tag {
  font-family: var(--font-mono); font-size: 10.5px; background: var(--teal-wash); color: var(--teal-deep);
  padding: 1px 6px; border-radius: 4px; margin-left: 4px;
}

/* ===== Timeline ===== */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-step { display: flex; gap: 16px; position: relative; padding-bottom: 26px; }
.timeline-step:last-child { padding-bottom: 0; }
.timeline-step:not(:last-child)::before {
  content: ''; position: absolute; left: 5px; top: 14px; bottom: -12px; width: 1.5px;
  background: var(--line);
}
.timeline-dot {
  width: 11px; height: 11px; border-radius: 50%; background: var(--green);
  margin-top: 4px; flex-shrink: 0; z-index: 1;
}
.timeline-dot.dot-ai { background: var(--amber); }
.timeline-body { flex: 1; min-width: 0; }
.timeline-label { font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--ink-soft); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.timeline-body p { margin: 0 0 6px; font-size: 13.5px; }
.link { color: var(--teal); text-decoration: none; font-weight: 600; border-bottom: 1px solid var(--teal-wash); }
.link:hover { border-bottom-color: var(--teal); }

.attach-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.attach-chip {
  display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-family: var(--font-mono);
  background: var(--grey-wash); color: var(--ink-soft); padding: 5px 10px; border-radius: 6px;
}
.attach-chip svg { width: 12px; height: 12px; flex-shrink: 0; }
.attach-thumb { width: 16px; height: 16px; object-fit: cover; border-radius: 3px; flex-shrink: 0; }
.attach-remove {
  background: none; border: none; color: var(--ink-faint); font-size: 13px; line-height: 1;
  cursor: pointer; padding: 0 0 0 2px; margin-left: 2px;
}
.attach-remove:hover { color: #B8451E; }
.attach-add-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.attach-add-btn {
  display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  color: var(--teal-deep); background: none; border: 1px dashed var(--line); border-radius: 6px;
  padding: 5px 11px; cursor: pointer;
}
.attach-add-btn:hover { background: var(--teal-wash); border-color: var(--teal); }
.attach-add-btn svg { width: 13px; height: 13px; }

.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 8px; }
.result-cell { background: var(--grey-wash); border-radius: 8px; padding: 10px 12px; }
.result-k { font-size: 10.5px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.3px; }
.result-v { font-family: var(--font-mono); font-weight: 600; font-size: 15px; margin-top: 3px; }

/* ===== AI Draft generation ===== */
#btn-generate-draft { display: inline-flex; align-items: center; }

.chroma-loader {
  background: var(--ink); border-radius: 10px; padding: 14px 10px; margin: 10px 0 8px;
  overflow: hidden;
}
.chroma-svg { width: 100%; height: 60px; display: block; }
#chroma-path {
  stroke-dasharray: 900;
  stroke-dashoffset: 900;
  animation: draw-trace 1.8s ease-in-out forwards;
}
@keyframes draw-trace {
  to { stroke-dashoffset: 0; }
}
.loader-caption {
  font-size: 12.5px; color: var(--ink-soft); text-align: center; margin: 0;
  animation: pulse-text 1.4s ease-in-out infinite;
}
@keyframes pulse-text { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

.draft-card {
  border: 1.5px solid var(--amber); border-radius: 10px; background: var(--amber-wash);
  padding: 16px 18px; margin-top: 8px;
}
.draft-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.draft-meta { font-size: 11.5px; color: var(--ink-faint); }
.draft-field { margin-bottom: 12px; }
.draft-field-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; color: var(--amber); margin-bottom: 5px; }
.draft-field-body {
  background: #fff; border: 1px solid rgba(184,121,30,0.25); border-radius: 7px;
  padding: 10px 12px; font-size: 13.5px; line-height: 1.6;
}
.draft-field-body:focus { outline: 2px solid var(--amber); outline-offset: 1px; }
.draft-actions { display: flex; gap: 10px; margin-top: 14px; }

.confirmed-banner {
  display: flex; align-items: center; gap: 8px;
  background: var(--green-wash); color: var(--green); border: 1px solid rgba(47,125,94,0.25);
  border-radius: 8px; padding: 11px 14px; font-size: 13px; font-weight: 600;
}
.confirmed-banner svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ===== AI rail ===== */
.ai-rail {
  width: 300px; flex-shrink: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); display: flex; flex-direction: column; height: calc(100vh - 245px);
  position: sticky; top: 0;
}
.ai-rail-head {
  display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft);
  font-weight: 700; font-size: 13px; color: var(--teal-deep);
}
.ai-rail-head svg { width: 15px; height: 15px; }
.ai-chat-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { font-size: 12.5px; line-height: 1.6; padding: 9px 11px; border-radius: 8px; max-width: 100%; }
.chat-user { background: var(--grey-wash); align-self: flex-end; color: var(--ink); }
.chat-ai { background: var(--teal-wash); color: var(--ink); }
.ai-chat-input-row { display: flex; gap: 6px; padding: 12px; border-top: 1px solid var(--line-soft); }
#ai-chat-input {
  flex: 1; border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; font-size: 12.5px;
}
#ai-chat-input:focus { outline: 2px solid var(--teal); outline-offset: 1px; }

/* ===== Role switcher ===== */
.topbar-user { position: relative; }
.role-tag {
  font-size: 10px; font-weight: 700; background: rgba(255,255,255,0.15); color: #DDEAEA;
  padding: 2px 7px; border-radius: 20px; margin-left: 2px;
}
.role-dropdown {
  display: none; position: absolute; top: calc(100% + 8px); right: 0; width: 240px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 30px -10px rgba(22,35,43,0.28); z-index: 200; overflow: hidden;
}
.topbar-user.open .role-dropdown { display: block; }
.role-option { padding: 11px 14px; cursor: pointer; border-bottom: 1px solid var(--line-soft); }
.role-option:last-child { border-bottom: none; }
.role-option:hover { background: var(--teal-wash); }
.role-option.active { background: var(--grey-wash); }
.role-option-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.role-option-desc { font-size: 11px; color: var(--ink-faint); margin-top: 2px; }

/* ===== Modals ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(22,35,43,0.55);
  align-items: center; justify-content: center; z-index: 300; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 14px; width: 480px; max-width: 100%;
  max-height: 88vh; overflow-y: auto; padding: 22px 26px 26px;
  box-shadow: 0 30px 60px -20px rgba(22,35,43,0.4);
}
.modal-box-lg { width: 560px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { font-size: 17px; margin: 0; display: flex; align-items: center; gap: 8px; }
.modal-close {
  background: none; border: none; font-size: 22px; line-height: 1; color: var(--ink-faint);
  cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.modal-close:hover { background: var(--grey-wash); color: var(--ink); }
.modal-hint { font-size: 13px; color: var(--ink-soft); margin: 0 0 12px; }
.modal-footnote { font-size: 11.5px; color: var(--ink-faint); margin: 10px 0 0; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.field-row { margin-bottom: 14px; }
.field-row label {
  display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600;
  color: var(--ink-soft); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.3px;
}
.ai-hint {
  font-size: 10px; font-weight: 700; text-transform: none; letter-spacing: 0;
  background: var(--amber-wash); color: var(--amber); padding: 1px 7px; border-radius: 20px;
}
.field-row input, .field-row select, .field-row textarea, #newexp-goal-input {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
  font-size: 13.5px; font-family: inherit; background: #fff; color: var(--ink);
}
.field-row input:focus, .field-row select:focus, .field-row textarea:focus, #newexp-goal-input:focus {
  outline: 2px solid var(--teal); outline-offset: 1px; border-color: var(--teal);
}
.field-row input[readonly] { background: var(--grey-wash); color: var(--ink-soft); }
#newexp-goal-input { margin-bottom: 4px; resize: vertical; }

.version-preview {
  font-size: 12.5px; color: var(--ink-soft); background: var(--grey-wash);
  border-radius: 8px; padding: 10px 12px; margin: 4px 0 12px; line-height: 1.6;
}
.version-tag-new { background: var(--green-wash); color: var(--green); }

.notice-box {
  font-size: 12.5px; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; line-height: 1.5;
}
.notice-box:not(.notice-box-muted) { background: var(--amber-wash); color: #8A5A16; }
.notice-box-muted { background: var(--grey-wash); color: var(--ink-faint); }
.notice-box-muted strong { color: var(--ink-soft); }

.btn-edit-protocol {
  background: none; border: 1px solid var(--line); border-radius: 6px; padding: 5px 12px;
  font-size: 12px; font-weight: 600; color: var(--teal-deep); cursor: pointer;
}
.btn-edit-protocol:hover { background: var(--teal-wash); }
.btn-edit-protocol:disabled { color: var(--ink-faint); cursor: not-allowed; }
.btn-edit-protocol:disabled:hover { background: none; }
.timeline-dot.dot-chem { background: var(--ink-faint); }

.route-frame-wrap {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; height: 460px; margin: 10px 0 8px;
}
.route-frame-wrap iframe { width: 100%; height: 100%; border: none; }
.route-toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 4px; }

.askcos-notice {
  font-size: 12px; line-height: 1.7; color: var(--ink-soft);
  background: var(--amber-wash); border-radius: 8px; padding: 10px 12px; margin-top: 4px;
}
.askcos-notice strong { color: #8A5A16; }

.entry-textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
  font-size: 13.5px; font-family: inherit; resize: vertical; color: var(--ink);
}
.entry-textarea:focus { outline: 2px solid var(--teal); outline-offset: 1px; border-color: var(--teal); }

.entry-row {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 10px;
}
.entry-row label {
  font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.3px;
  display: flex; flex-direction: column; gap: 4px;
}
.entry-input {
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; font-size: 13.5px;
  font-family: var(--font-mono); width: 90px; color: var(--ink);
}
.entry-input:focus { outline: 2px solid var(--teal); outline-offset: 1px; border-color: var(--teal); }
.calc-footnote { font-size: 11.5px; color: var(--ink-faint); margin-top: 8px; }

.entry-row-wrap { row-gap: 10px; }
.entry-input-sm { width: 62px; }

.line-chart-svg { width: 100%; height: auto; display: block; }

.qv-summary-box {
  background: var(--grey-wash); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px;
}
.qv-summary-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
  color: var(--ink-soft); margin-bottom: 6px;
}
.qv-summary-box p { font-size: 13.5px; line-height: 1.7; color: var(--ink); margin: 0; }
.qv-footnote { font-size: 11.5px; color: var(--ink-faint); line-height: 1.5; }
.row-clickable { cursor: pointer; }

.import-dropzone {
  border: 2px dashed var(--line); border-radius: 12px; padding: 36px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--ink-faint); cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.import-dropzone:hover, .import-dropzone.dragover { border-color: var(--teal); background: var(--teal-wash); color: var(--teal-deep); }
.import-dropzone-text { font-size: 13.5px; font-weight: 500; }
.import-note { font-size: 12px; color: #B8451E; margin-top: 8px; min-height: 16px; }

.ask-ai-toolbar { margin-top: 10px; }
.ask-ai-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ask-ai-row .entry-input { width: 170px; }
.ai-result { margin-top: 10px; padding: 10px 12px; background: var(--grey-wash); border-radius: 8px; font-size: 13px; line-height: 1.6; }
.ai-result-ok { color: var(--ink); }
.ai-result-warn { color: #8A5A16; }
.ai-result-footnote { font-size: 11px; color: var(--ink-faint); margin-top: 6px; }

.chart-wrap {
  background: #fff; border: 1px solid var(--line-soft); border-radius: 8px;
  padding: 12px; margin: 6px 0;
}
.bar-chart-svg { width: 100%; height: auto; display: block; }

/* ===== Report modal / printable document ===== */
.modal-box-report { width: 640px; max-width: 100%; }
.report-doc { padding: 4px 6px; }
.report-doc-header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 2px solid var(--ink); }
.report-logo { height: 34px; width: auto; }
.report-doc-title { font-size: 19px; font-weight: 700; color: var(--ink); }
.report-doc-sub { font-size: 12px; color: var(--ink-faint); }
.report-meta-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 12.5px; }
.report-meta-table td { padding: 6px 8px; border: 1px solid var(--line-soft); }
.report-meta-table td:nth-child(1), .report-meta-table td:nth-child(3) { background: var(--grey-wash); font-weight: 600; width: 18%; color: var(--ink-soft); }
.report-doc h4 { font-size: 13.5px; margin: 16px 0 6px; color: var(--teal-deep); }
.report-doc p { font-size: 13px; line-height: 1.7; margin: 0; color: var(--ink); }
.report-chart-wrap { margin: 8px 0; }
.report-sign-row { display: flex; gap: 40px; margin-top: 28px; }
.report-sign-block { flex: 1; }
.report-sign-line { border-bottom: 1px solid var(--ink-faint); height: 36px; }
.report-sign-label { font-size: 11.5px; color: var(--ink-faint); margin-top: 4px; text-align: center; }
.report-footer-note { font-size: 10.5px; color: var(--ink-faint); margin-top: 20px; border-top: 1px solid var(--line-soft); padding-top: 8px; }

@media print {
  body * { visibility: hidden; }
  #report-print-area, #report-print-area * { visibility: visible; }
  #report-print-area { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; }
  .modal-head-noprint { display: none !important; }
}

.phase2-notice {
  font-size: 13px; line-height: 1.7; color: var(--ink-soft);
  background: var(--grey-wash); border-radius: 10px; padding: 14px 16px; margin-bottom: 18px;
}
.phase2-notice strong { color: var(--ink); }

.ketcher-toolbar {
  display: flex; align-items: center; gap: 14px; margin-bottom: 12px; flex-wrap: wrap;
}
.ketcher-hint { font-size: 11.5px; color: var(--ink-faint); }

.ketcher-frame-wrap {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; height: 640px;
}
.ketcher-frame-wrap iframe { width: 100%; height: 100%; border: none; }

.search-box-row {
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 14px; margin-bottom: 18px;
}
.search-box-row svg { width: 17px; height: 17px; color: var(--ink-faint); flex-shrink: 0; }
#search-input { flex: 1; border: none; font-size: 14px; background: transparent; }
#search-input:focus { outline: none; }
.search-results { display: flex; flex-direction: column; gap: 10px; }
.search-result-item {
  border: 1px solid var(--line-soft); border-radius: 8px; padding: 13px 15px;
}
.sr-title { font-weight: 600; font-size: 13.5px; }
.sr-meta { font-size: 12px; color: var(--ink-faint); margin-top: 3px; }
.sr-snippet { font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; }

.stub-note { color: var(--ink-soft); font-size: 13.5px; padding: 10px 0; }

/* ===== Responsive ===== */
@media (max-width: 980px) {
  .exp-layout { flex-direction: column; }
  .ai-rail { width: 100%; height: 420px; position: static; }
  .overview-grid, .result-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .sidebar { width: 64px; padding: 12px 8px; }
  .sidebar-search span, .nav-item span:not(.module-pill), .sidebar-note { display: none; }
  .module-pill { display: none; }
  .topbar { padding: 0 8px; }
  .topbar-left { gap: 8px; }
  .topbar-nav { display: none; }
  .topbar-right { gap: 0; }
  .topbar-user span { display: none; }
  .subnav { padding: 0 12px; overflow-x: auto; }
  .main-col { padding: 20px; }
  .stat-row { flex-direction: column; }
  .overview-grid, .result-grid { grid-template-columns: 1fr 1fr; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  #chroma-path { animation: none; stroke-dashoffset: 0; }
  .loader-caption { animation: none; }
}
