:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  background: #09111f;
  color: #edf3ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-block-size: 100vh;
  min-block-size: 100dvh;
  background: radial-gradient(circle at 20% 0%, #1f3b64, #09111f 50%);
  overflow-y: auto;
  overflow-x: hidden;
}
body.voice-mode-open { overflow: hidden; }
.admin-shell { min-height: 0; }

.shell {
  width: min(760px, calc(100% - 32px));
  margin: 32px auto;
  padding: 0 max(0px, env(safe-area-inset-right)) 0 max(0px, env(safe-area-inset-left));
}

.shell:not(.admin-shell) {
  min-block-size: calc(100dvh - 64px);
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto auto;
}

header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; }
.shell.chat-shell {
  height: calc(100dvh - 64px);
  min-block-size: 0;
  overflow: hidden;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}
.chat-shell header { align-items: flex-start; flex-wrap: wrap; }
.chat-shell .header-links { flex: 1 1 auto; flex-wrap: wrap; justify-content: flex-end; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.8rem, 5vw, 2.3rem); line-height: 1.08; }
h2 { margin-top: 32px; }
.eyebrow { color: #78d9c6; font-size: .74rem; letter-spacing: .12em; margin-bottom: 5px; }
.version-pill { display: inline-flex; align-items: center; margin-left: 7px; padding: 2px 7px; border: 1px solid #4c6887; border-radius: 999px; color: #c7d8ed; font-size: .68rem; font-weight: 700; letter-spacing: .04em; vertical-align: middle; }
a { color: #a9d5ff; }
header a { min-height: 44px; display: inline-flex; align-items: center; }
.header-links { display: flex; align-items: center; gap: 14px; }
.nav-toggle { display: none; }
.link-button { min-height: 44px; padding: 6px 0; border: 0; border-radius: 0; background: transparent; color: #a9d5ff; font-weight: 400; text-decoration: underline; }
.person-picker { display: inline-flex; align-items: center; gap: 7px; margin-top: 10px; color: #9fb6d0; font-size: .9rem; }

button {
  min-height: 46px;
  border: 0;
  border-radius: 10px;
  background: #56d4b7;
  color: #06211d;
  font: inherit;
  font-weight: 700;
  padding: 12px 16px;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled { opacity: .5; cursor: wait; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid #a9d5ff; outline-offset: 3px; }

.messages {
  min-height: 0;
  overflow-y: auto;
  border: 1px solid #35506e;
  border-radius: 16px;
  padding: 18px;
  background: #0d1a2b;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
}

.message { max-width: 78%; padding: 12px 14px; border-radius: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.bot { align-self: flex-start; background: #1a3450; }
.user { align-self: flex-end; background: #276d64; }

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content max-content;
  gap: 8px;
  margin-top: 14px;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(#09111f00, #09111f 22%);
}

.composer input { min-width: 0; margin-top: 0; }
.voice-mode-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 92px; padding: 8px 12px; background: #8067d8; color: #fff; }
.voice-mode-toggle span { font-size: 1.1rem; color: #d7ccff; }

.voice-mode { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); background: #050b16e8; backdrop-filter: blur(12px); }
.voice-mode[hidden] { display: none; }
.voice-mode-card { position: relative; width: min(100%, 580px); min-height: min(680px, 100%); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: clamp(28px, 7vw, 56px); overflow: auto; border: 1px solid #476783; border-radius: 28px; background: radial-gradient(circle at 50% 40%, #223f72, #101d32 48%, #09111f 100%); box-shadow: 0 30px 90px #000a; text-align: center; }
.voice-mode-card h2 { margin: 0 0 28px; font-size: clamp(2rem, 7vw, 3.1rem); }
.voice-mode-close { position: absolute; top: 14px; right: 14px; display: grid; place-items: center; width: 44px; min-height: 44px; padding: 0; border-radius: 50%; background: #27425d; color: #edf3ff; font-size: 2rem; font-weight: 400; line-height: 1; }
.voice-orb { position: relative; isolation: isolate; display: grid; place-items: center; width: clamp(174px, 48vw, 244px); min-height: clamp(174px, 48vw, 244px); margin: 8px 0 30px; padding: 0; border: 0; border-radius: 50%; background: radial-gradient(circle at 35% 28%, #d7ffff, #70e9ec 12%, #297fc8 42%, #5042a0 69%, #18264d 100%); box-shadow: 0 0 18px #83f8ffcc, 0 0 48px #5c6de8b3, inset -22px -25px 42px #10184dbb, inset 12px 10px 22px #e7ffff80; transition: transform .2s ease, box-shadow .25s ease, filter .25s ease; }
.voice-orb:hover { transform: scale(1.03); }
.voice-orb:focus-visible { outline: 4px solid #fff; outline-offset: 7px; }
.voice-orb-core { position: absolute; inset: 23%; z-index: 2; border-radius: inherit; background: radial-gradient(circle at 33% 25%, #fff, #a0ffff 16%, #499de1 56%, #33418c); opacity: .85; filter: blur(.5px); }
.voice-orb-ring { position: absolute; z-index: -1; inset: -11%; border: 1px solid #8af8ff99; border-radius: 50%; opacity: 0; }
.voice-orb-ring-two { inset: -25%; border-color: #aa95ff88; }
.voice-orb[data-state='listening'] { transform: scale(1.05); box-shadow: 0 0 24px #b4ffff, 0 0 76px #6c75ff, inset -22px -25px 42px #10184dbb, inset 12px 10px 22px #e7ffff80; animation: orb-breathe 1.5s ease-in-out infinite; }
.voice-orb[data-state='listening'] .voice-orb-ring { opacity: 1; animation: orb-ripple 1.5s ease-out infinite; }
.voice-orb[data-state='listening'] .voice-orb-ring-two { animation-delay: .5s; }
.voice-orb[data-state='thinking'] { filter: hue-rotate(26deg); animation: orb-think 1s linear infinite; }
.voice-orb[data-state='speaking'] { filter: hue-rotate(285deg) saturate(1.15); animation: orb-breathe .7s ease-in-out infinite alternate; }
.voice-orb[data-state='speaking'] .voice-orb-ring { opacity: .9; animation: orb-ripple .85s ease-out infinite; }
.voice-mode-status { min-height: 1.5em; margin: 0; color: #effbff; font-size: clamp(1rem, 3vw, 1.18rem); font-weight: 700; }
.voice-transcript { min-height: 1.5em; max-width: 38ch; margin: 10px 0 0; color: #b9d4ee; font-style: italic; }
.voice-mode-hint { max-width: 42ch; margin: 22px 0; color: #9fb6d0; line-height: 1.5; }
.voice-mode-end { min-width: 158px; }

input, textarea, select {
  width: 100%;
  min-height: 46px;
  margin-top: 7px;
  padding: 11px;
  border-radius: 9px;
  border: 1px solid #4c6887;
  background: #101f31;
  color: inherit;
  font: inherit;
  font-size: 16px;
}

textarea { resize: vertical; }
.status { min-height: 1.4em; color: #9fb6d0; margin: 4px 0 12px; }
.error { color: #ff9b9b; }
.sr-only { position: absolute; left: -9999px; }

.notice, .training-bar, .resource-form, .resource-card { border: 1px solid #35506e; background: #0d1a2b; border-radius: 14px; padding: 18px; }
.login-shell { min-block-size: calc(100dvh - 64px); display: grid; place-items: center; }
.login-card { width: min(100%, 460px); }
.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: center;
  margin-top: 7px;
  border: 1px solid #4c6887;
  border-radius: 9px;
  background: #101f31;
}
.password-field:focus-within { outline: 3px solid #a9d5ff; outline-offset: 3px; }
.password-field input { width: 100%; min-width: 0; margin-top: 0; border: 0; border-radius: 9px 0 0 9px; background: transparent; }
.password-field input:focus-visible { outline: 0; }
.password-toggle {
  display: grid;
  place-items: center;
  width: 42px;
  height: 44px;
  cursor: pointer;
  color: #a9d5ff;
}
.password-toggle:hover, .password-toggle.is-visible { color: #edf3ff; }
.password-toggle:focus-visible { outline: 2px solid #a9d5ff; outline-offset: -3px; border-radius: 7px; }
.password-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.password-toggle .eye-slash { display: none; }
.password-toggle.is-visible .eye-slash { display: block; }
.muted, .inline-note { color: #9fb6d0; }
.inline-note { margin: 6px 0 0; }
.resource-form { display: grid; gap: 16px; }
.user-form { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
.user-form button { height: 46px; }
.task-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.task-form .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; }
.secondary { background: #304861; color: #edf3ff; }
.resource-form label { font-weight: 650; }
.resource-form span, .keywords { color: #9fb6d0; font-size: .85rem; font-weight: 400; }
.training-bar { margin-top: 20px; display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.training-bar p { color: #9fb6d0; margin-bottom: 0; }
.resources { display: grid; gap: 10px; }
.document-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.document-card, .document-detail { border: 1px solid #35506e; border-radius: 14px; background: #0d1a2b; }
.document-card { display: block; padding: 18px; color: inherit; text-decoration: none; transition: border-color .15s ease, transform .15s ease, background .15s ease; }
.document-card:hover, .document-card:focus-visible { border-color: #78d9c6; background: #10243a; transform: translateY(-2px); }
.document-card h3 { color: #edf3ff; margin-bottom: 7px; }
.document-card .answer { display: -webkit-box; overflow: hidden; margin-bottom: 14px; -webkit-box-orient: vertical; -webkit-line-clamp: 4; }
.document-open { color: #78d9c6; font-weight: 700; font-size: .9rem; }
.document-detail { padding: 22px; }
.document-detail h2 { margin-top: 24px; }
.document-overview, .document-excerpt { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.document-excerpt { max-height: 520px; overflow: auto; padding: 14px; border-radius: 9px; background: #101f31; color: #c7d8ed; }
.document-detail details summary { cursor: pointer; color: #a9d5ff; font-weight: 700; }
.button-link { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 12px 16px; border-radius: 10px; background: #56d4b7; color: #06211d; font-weight: 700; text-decoration: none; }
.back-link { font-weight: 700; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.section-heading h2 { margin-bottom: 6px; }
.library-summary { flex: 0 0 auto; padding: 7px 10px; border: 1px solid #4c6887; border-radius: 999px; color: #78d9c6; font-size: .85rem; white-space: nowrap; }
.search-form { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; margin-bottom: 16px; }
.search-form input { margin-top: 0; }
.resource-card { display: flex; justify-content: space-between; gap: 16px; }
.resource-card h3 { margin-bottom: 6px; }
.resource-card .answer { margin-bottom: 0; white-space: pre-wrap; }
.resource-card button { background: #f28b8b; height: fit-content; }
.qr-card { align-items: flex-start; }
.qr-card img { width: 10rem; max-width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: 8px; padding: 8px; }
.qr-card > div:nth-child(2) { flex: 1; min-width: 0; }
.qr-content { display: block; max-height: 8rem; overflow: auto; overflow-wrap: anywhere; white-space: pre-wrap; margin-top: 10px; }
.user-card { align-items: flex-start; }
.user-card > div:first-child { flex: 1; }
.user-card label { display: block; margin-top: 12px; font-weight: 650; }
.user-card label span { color: #9fb6d0; font-size: .85rem; font-weight: 400; }
.user-card .active-toggle { display: flex; align-items: center; gap: 8px; }
.user-card .active { width: auto; min-height: 18px; margin: 0; }
.card-actions { display: grid; gap: 8px; min-width: 90px; }
.card-actions .save { background: #56d4b7; }
.card-actions .edit { background: #56d4b7; }
.task-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.task-heading h3 { margin: 0; }
.task-status { border-radius: 999px; padding: 4px 8px; font-size: .72rem; font-weight: 750; letter-spacing: .05em; background: #304861; }
.status-todo { background: #304861; }
.status-in_progress { background: #3966a8; }
.status-blocked { background: #ae5151; }
.status-done { background: #377a5f; }
.task-meta, .task-id { color: #9fb6d0; font-size: .85rem; }
.task-card .description, .task-card .blockers, .task-card .notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.task-card .blockers { color: #ffca8a; }
.dashboard-shell { width: min(1120px, calc(100% - 32px)); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.metric-grid article, .panel { border: 1px solid #35506e; background: #0d1a2b; border-radius: 14px; padding: 18px; }
.metric-grid span { display: block; color: #9fb6d0; font-size: .85rem; }
.metric-grid strong { display: block; margin-top: 8px; color: #78d9c6; font-size: clamp(1.8rem, 5vw, 2.5rem); }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.help-shell { width: min(1040px, calc(100% - 32px)); }
.help-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.help-grid .panel h2 { margin-top: 0; }
.help-grid .panel p:last-child { margin-bottom: 0; }
.help-wide { grid-column: 1 / -1; }
.help-hero { margin-bottom: 20px; }
.help-hero .button-link { margin-top: 8px; }
.help-example-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.help-example-grid section, .help-gates { border: 1px solid #35506e; border-radius: 10px; padding: 14px; background: #101f31; }
.help-example-grid h3 { margin: 0 0 8px; color: #78d9c6; font-size: .96rem; }
.help-example-grid ul, .help-checklist { margin: 0; padding-left: 20px; }
.help-example-grid li, .help-checklist li { margin: 0 0 8px; line-height: 1.42; }
.help-example-grid li:last-child, .help-checklist li:last-child { margin-bottom: 0; }
.help-gates { display: grid; gap: 10px; }
.help-gates p { margin: 0; line-height: 1.48; }
.panel h2 { margin: 0 0 14px; font-size: 1.1rem; }
.integration-form { display: grid; gap: 12px; }
.integration-form fieldset { margin: 0; border: 1px solid #35506e; border-radius: 9px; display: grid; gap: 8px; padding: 12px; }
.integration-form legend { color: #9fb6d0; padding: 0 4px; }
.integration-form .active-toggle { display: flex; align-items: center; gap: 8px; }
.integration-form .active-toggle input { width: auto; min-height: 18px; margin: 0; }
.panel-list { display: grid; gap: 10px; }
.panel-list > p { margin: 0; padding-bottom: 10px; border-bottom: 1px solid #27425d; overflow-wrap: anywhere; }
.panel-list > p:last-child { border-bottom: 0; padding-bottom: 0; }
.badge { display: inline-block; min-width: 24px; padding: 2px 7px; border-radius: 999px; background: #ae5151; color: #fff; font-size: .75rem; vertical-align: middle; }
.alert { border-left: 4px solid #4c6887; padding: 10px 12px; border-radius: 8px; background: #101f31; }
.alert p { margin: 6px 0 10px; color: #c1d0e1; white-space: pre-wrap; }
.alert.high { border-color: #ffbd6a; }
.alert.critical { border-color: #f28b8b; }
.alert.read { opacity: .65; }
.compact { min-height: 36px; padding: 7px 10px; font-size: .85rem; }
.health-healthy { color: #78d9c6; }
.health-unavailable, .health-unhealthy { color: #ff9b9b; }

@media (min-width: 861px) {
  body:has(.header-links) { padding-left: 252px; }
  .header-links {
    position: fixed;
    z-index: 10;
    inset: 20px auto 20px 20px;
    width: 212px;
    padding: 16px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    border: 1px solid #35506e;
    border-radius: 16px;
    background: #0d1a2b;
    box-shadow: 0 18px 42px #02081366;
  }
  .header-links::before { content: "ELISA\A WORKSPACE"; white-space: pre; margin: 4px 8px 14px; color: #78d9c6; font-size: .72rem; font-weight: 800; letter-spacing: .12em; line-height: 1.55; }
  .header-links a, .header-links .link-button { width: 100%; min-height: 40px; padding: 9px 10px; border-radius: 8px; color: #d9e9fc; text-decoration: none; text-align: left; }
  .header-links a:hover, .header-links a:focus-visible, .header-links .link-button:hover, .header-links .link-button:focus-visible { background: #1f3b64; color: #fff; }
  .header-links .link-button { margin-top: auto; border-top: 1px solid #35506e; border-radius: 0; }
}

@keyframes orb-breathe { from { transform: scale(1); } to { transform: scale(1.07); } }
@keyframes orb-ripple { from { transform: scale(.74); opacity: .85; } to { transform: scale(1.16); opacity: 0; } }
@keyframes orb-think { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .shell { width: min(100% - 22px, 760px); margin: 14px auto; }
  .shell.chat-shell { height: var(--chat-viewport, 100dvh); min-block-size: 0; margin: 0 auto; padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: 0; overflow: hidden; grid-template-rows: auto minmax(0, 1fr) auto auto; }
  header { align-items: flex-start; flex-direction: column; margin-bottom: 16px; }
  .chat-shell header { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 10px; margin-bottom: 10px; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 8px 12px; background: #304861; color: #edf3ff; }
  .nav-toggle::before { content: '☰'; font-size: 1.25rem; line-height: 1; }
  .nav-toggle[aria-expanded='true']::before { content: '×'; font-size: 1.5rem; }
  .header-links { display: none; width: 100%; grid-column: 1 / -1; flex-direction: column; align-items: stretch; gap: 2px; padding: 8px 0 0; border-top: 1px solid #35506e; }
  .header-links.is-open { display: flex; }
  .header-links a, .header-links .link-button { min-height: 38px; }
  .person-picker { display: flex; }
  .section-heading { flex-direction: column; gap: 8px; }
  h2 { margin-top: 26px; }
  .messages { min-height: 0; padding: 14px; border-radius: 14px; }
  .message { max-width: 88%; }
  .composer { grid-template-columns: minmax(0, 1fr) max-content max-content; gap: 6px; margin-top: 8px; position: relative; z-index: 1; }
  .composer button { padding-inline: 10px; }
  .voice-mode { display: block; padding: 0; overflow-y: auto; overscroll-behavior: contain; }
  .voice-mode-card { width: 100%; min-height: 100dvh; padding: max(28px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); border: 0; border-radius: 0; }
  .voice-mode-close { top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); width: 48px; min-height: 48px; }
  .voice-orb { width: clamp(164px, 48vw, 224px); min-height: clamp(164px, 48vw, 224px); margin-bottom: 24px; }
  .voice-mode-end { min-height: 48px; }
  .notice, .training-bar, .resource-form, .resource-card { padding: 14px; }
  .user-form { grid-template-columns: 1fr; }
  .task-form { grid-template-columns: 1fr; }
  .task-form .wide { grid-column: auto; }
  .metric-grid, .dashboard-grid, .help-grid, .help-example-grid, .search-form, .document-grid { grid-template-columns: 1fr; }
  .training-bar, .resource-card { align-items: stretch; flex-direction: column; }
  .training-bar button, .resource-form > button, .resource-card button { width: 100%; }
  .admin-shell section, .panel { min-width: 0; }
  .panel-list, .resource-card, .task-card { overflow-wrap: anywhere; }
}

@media (max-width: 360px) {
  .composer { grid-template-columns: minmax(0, 1fr) max-content max-content; }
  .composer button { font-size: .86rem; padding-inline: 6px; }
  .eyebrow { font-size: .65rem; }
  .voice-mode-card { justify-content: flex-start; padding-top: max(76px, calc(env(safe-area-inset-top) + 58px)); }
  .voice-orb { width: 154px; min-height: 154px; margin-bottom: 18px; }
  .voice-mode-card h2 { margin-bottom: 18px; }
  .voice-mode-hint { margin: 16px 0; font-size: .92rem; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .voice-mode-card { justify-content: flex-start; padding-top: max(64px, calc(env(safe-area-inset-top) + 50px)); }
  .voice-mode-card h2 { margin-bottom: 14px; font-size: 1.75rem; }
  .voice-orb { width: 136px; min-height: 136px; margin: 0 0 14px; }
  .voice-mode-hint { margin: 12px 0; font-size: .9rem; }
  .voice-transcript { margin-top: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .voice-orb, .voice-orb-ring { animation: none !important; }
}
