:root {
  color-scheme: light;
  --ink: #141915;
  --muted: #67716b;
  --paper: #f4f6f7;
  --white: #ffffff;
  --line: #d9dfdc;
  --line-strong: #bcc6c0;
  --soft: #ecefed;
  --soft-hover: #e4e8e6;
  --charcoal: #373d39;
  --green: #54b900;
  --green-deep: #318300;
  --green-soft: #e9f6df;
  --danger: #a1362f;
  --shadow: 0 22px 65px rgba(18, 27, 21, .13);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body {
  margin: 0;
  min-width: 320px;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, Aptos, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, select, textarea, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 10px 14px; background: var(--ink); color: white; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 3px solid rgba(49, 131, 0, .42); outline-offset: 2px; }

.boot-screen { height: 100vh; height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--muted); }
.boot-screen img { width: 72px; height: 72px; border-radius: 18px; }
.boot-screen strong { color: var(--ink); font-size: 19px; }
.boot-screen span { font-size: 14px; }

.app-shell { height: 100vh; height: 100dvh; display: grid; grid-template-columns: 278px minmax(0, 1fr); overflow: hidden; }
.sidebar { min-height: 0; display: flex; flex-direction: column; padding: 19px 14px 13px; border-right: 1px solid var(--line); background: #fafbfb; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 7px 17px; color: inherit; text-decoration: none; }
.brand img { width: 47px; height: 47px; border-radius: 11px; object-fit: contain; }
.brand > span { display: grid; line-height: 1; }
.brand strong { font-size: 18px; letter-spacing: -.025em; }
.brand small { margin-top: 5px; color: var(--green-deep); font-size: 10px; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.new-request { min-height: 46px; display: flex; align-items: center; gap: 11px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--charcoal); color: white; font-weight: 800; text-align: left; }
.new-request span:first-child { color: var(--green); font-size: 23px; font-weight: 400; }
.new-request:hover { background: #292f2b; }
.sidebar-scroll { min-height: 0; overflow-y: auto; padding: 7px 1px 12px; scrollbar-width: thin; scrollbar-color: #cbd2ce transparent; }
.side-group { display: grid; gap: 3px; }
.side-heading { display: flex; align-items: center; justify-content: space-between; padding-right: 8px; }
.side-group p { margin: 16px 10px 7px; color: #858f89; font-size: 11px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.side-heading > span { min-width: 23px; padding: 2px 6px; border-radius: 999px; background: var(--soft); color: #657069; font-size: 10px; font-weight: 900; text-align: center; }
.case-list { display: grid; gap: 3px; }
.empty-cases { padding: 8px 3px 12px; line-height: 1.4; text-transform: none !important; letter-spacing: 0 !important; font-weight: 600 !important; }
.case-button, .side-link { width: 100%; min-height: 42px; display: flex; align-items: center; gap: 9px; padding: 7px 9px; border: 0; border-radius: 10px; background: transparent; color: #4d5751; text-align: left; }
.case-button:hover, .side-link:hover, .case-button.active, .side-link.active { background: var(--soft); }
.case-button.active { color: var(--ink); }
.case-button > span:first-child, .side-icon { flex: 0 0 29px; width: 29px; height: 29px; display: grid; place-items: center; border-radius: 8px; background: var(--white); color: var(--green-deep); font-size: 8px; font-weight: 900; }
.case-button > span:nth-child(2), .side-link b { min-width: 0; overflow: hidden; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.case-button time { margin-left: auto; color: #929b96; font-size: 9px; white-space: nowrap; }
.side-link em { min-width: 23px; margin-left: auto; padding: 2px 6px; border-radius: 999px; background: var(--green-soft); color: var(--green-deep); font-size: 9px; font-style: normal; font-weight: 900; text-align: center; }
.resources { margin-top: 4px; }
.module-menu { margin-top: 15px; border-top: 1px solid var(--line); }
.module-menu summary { min-height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; color: #606a64; font-size: 12px; font-weight: 800; list-style: none; cursor: pointer; }
.module-menu summary::-webkit-details-marker { display: none; }
.module-menu[open] summary b { transform: rotate(180deg); }
.module-menu > div { display: grid; gap: 2px; padding-bottom: 7px; }
.sidebar-module { min-height: 36px; display: flex; align-items: center; gap: 9px; padding: 5px 9px; border: 0; border-radius: 9px; background: transparent; color: #5d6761; font-size: 12px; text-align: left; }
.sidebar-module:hover, .sidebar-module.active { background: var(--soft); color: var(--ink); }
.sidebar-module span { min-width: 31px; color: var(--green-deep); font-size: 8px; font-weight: 900; }
.sidebar-account { width: 100%; display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 9px; padding: 13px 6px 0; border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; }
.avatar { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: #132209; font-size: 10px; font-weight: 900; }
.sidebar-account > span:nth-child(2) { min-width: 0; display: grid; }
.sidebar-account strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account small { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; }
.sidebar-account small i, .sync-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(84,185,0,.14); }
.sidebar-account > b { color: #89928d; font-size: 15px; }

.workspace { min-width: 0; min-height: 0; display: grid; grid-template-rows: 64px minmax(0, 1fr); background: var(--paper); }
.topbar { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 9px 21px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.82); backdrop-filter: blur(12px); }
.current-case { min-width: 0; display: flex; align-items: center; gap: 10px; }
.current-case-icon { flex: 0 0 34px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--charcoal); color: white; font-size: 9px; font-weight: 900; }
.current-case > div { min-width: 0; display: grid; line-height: 1.2; }
.current-case small { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.current-case strong { max-width: 480px; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.mobile-menu { display: none; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.sync-state { display: flex; align-items: center; gap: 7px; color: #516058; font-size: 10px; font-weight: 800; }
.language-control select { height: 37px; min-width: 62px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: white; color: var(--ink); font-size: 11px; font-weight: 900; }
.account-button { height: 38px; display: flex; align-items: center; gap: 8px; padding: 3px 10px 3px 3px; border: 1px solid var(--line); border-radius: 999px; background: white; }
.account-button span { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--green); font-size: 9px; font-weight: 900; }
.account-button b { font-size: 10px; }

.conversation { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; }
.conversation-controls { padding: 14px clamp(18px, 4vw, 54px) 11px; border-bottom: 1px solid var(--line); background: #f8faf9; }
.compact-intro { display: flex; align-items: baseline; gap: 14px; max-width: 1220px; margin: 0 auto 11px; }
.compact-intro h1 { margin: 0; font-size: clamp(17px, 1.65vw, 23px); line-height: 1.2; letter-spacing: -.025em; white-space: nowrap; }
.compact-intro p { margin: 0; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.module-selector { max-width: 1220px; display: grid; grid-template-columns: repeat(7, minmax(86px, 1fr)); gap: 7px; margin: 0 auto; }
.module-choice { min-width: 0; min-height: 49px; display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 7px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: white; color: #475149; text-align: left; }
.module-choice:hover { border-color: #9fbf8f; transform: translateY(-1px); }
.module-choice[aria-pressed="true"] { border-color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); color: #214f09; }
.module-choice span { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; background: var(--soft); color: var(--green-deep); font-size: 7px; font-weight: 900; }
.module-choice[aria-pressed="true"] span { background: var(--green); color: #142608; }
.module-choice strong { min-width: 0; overflow: hidden; font-size: 10px; line-height: 1.15; text-overflow: ellipsis; }
.auto-routing { max-width: 1220px; min-height: 22px; display: flex; align-items: center; gap: 7px; margin: 7px auto 0; color: var(--muted); font-size: 10px; }
.auto-routing i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.auto-routing strong { color: #3e4a42; }
.auto-routing.manual i { background: var(--ink); }

.conversation-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; padding: 18px clamp(18px, 4vw, 54px); scrollbar-width: thin; scrollbar-color: #c8cfcb transparent; }
.conversation-notice { position: sticky; z-index: 3; top: 0; max-width: 920px; width: 100%; margin: 0 auto 12px; padding: 11px 14px; border: 1px solid #e6b8b4; border-radius: 11px; background: #fff0ef; color: #812b26; font-size: 12px; font-weight: 750; box-shadow: 0 8px 22px rgba(80,25,20,.08); }
.welcome-state { min-height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 11px; padding: 25px 0 3px; color: var(--muted); }
.welcome-state > span { width: 37px; height: 37px; display: grid; place-items: center; border-radius: 10px; background: var(--green); color: #173009; font-size: 9px; font-weight: 900; }
.welcome-state > div { display: grid; }
.welcome-state strong { color: #414b45; font-size: 13px; }
.welcome-state p { margin: 2px 0 0; font-size: 11px; }
.message-stream { width: min(920px, 100%); display: grid; gap: 18px; margin: auto auto 0; }
.message { display: grid; grid-template-columns: 36px minmax(0,1fr); gap: 11px; align-items: start; }
.message-avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--green); color: #173009; font-size: 9px; font-weight: 900; }
.message.user .message-avatar { border-radius: 50%; background: var(--charcoal); color: white; }
.message-content { min-width: 0; }
.message-content > header { display: flex; align-items: center; gap: 8px; min-height: 20px; }
.message-content > header strong { font-size: 11px; }
.message-content > header span, .message-content > header time { color: var(--muted); font-size: 9px; }
.message-copy { margin-top: 5px; color: #2d3631; font-size: 14px; line-height: 1.65; overflow-wrap: anywhere; }
.message-copy p { margin: 0 0 10px; }
.message-copy p:last-child { margin-bottom: 0; }
.message-copy ul, .message-copy ol { margin: 7px 0 10px; padding-left: 22px; }
.message-copy li { margin: 4px 0; }
.message-copy a { color: var(--green-deep); font-weight: 750; text-underline-offset: 3px; }
.message.user .message-copy { width: fit-content; max-width: 100%; padding: 10px 13px; border-radius: 4px 15px 15px 15px; background: white; border: 1px solid var(--line); }
.message-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.message-files span { padding: 5px 8px; border-radius: 7px; background: var(--soft); color: #58625c; font-size: 9px; font-weight: 800; }
.message-files a { padding: 5px 8px; border-radius: 7px; background: var(--green-soft); color: var(--green-deep); font-size: 9px; font-weight: 800; text-decoration: none; }
.message-files a:hover { text-decoration: underline; }
.message.thinking .message-copy { color: var(--muted); }
.thinking-dots { display: inline-flex; gap: 4px; margin-left: 6px; }
.thinking-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--green); animation: pulse 1.1s infinite ease-in-out; }
.thinking-dots i:nth-child(2) { animation-delay: .14s; }
.thinking-dots i:nth-child(3) { animation-delay: .28s; }
@keyframes pulse { 0%,80%,100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.composer-zone { padding: 9px clamp(18px, 4vw, 54px) calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(217,223,220,.85); background: linear-gradient(to bottom, rgba(244,246,247,.93), var(--paper) 22%); }
.composer { width: min(920px, 100%); margin: 0 auto; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 17px; background: white; box-shadow: 0 10px 28px rgba(18,27,21,.08); }
.composer:focus-within { border-color: #7fad69; box-shadow: 0 0 0 3px rgba(84,185,0,.1), 0 10px 28px rgba(18,27,21,.08); }
.attachment-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px 0; }
.attachment-chip { display: flex; align-items: center; gap: 6px; max-width: 250px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); color: #4d5751; font-size: 9px; font-weight: 800; }
.attachment-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip b { color: var(--green-deep); font-size: 11px; }
.attachment-chip:disabled { cursor: wait; opacity: .7; }
.composer-input { display: block; }
.composer textarea { width: 100%; min-height: 58px; max-height: 110px; display: block; resize: none; overflow-y: auto; padding: 13px 15px 7px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; line-height: 1.45; }
.composer textarea::placeholder { color: #929b96; }
.composer-actions { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 7px 7px 9px; }
.attachment-actions, .send-actions { display: flex; align-items: center; gap: 5px; }
.attachment-actions button { min-height: 31px; display: flex; align-items: center; gap: 5px; padding: 0 8px; border: 0; border-radius: 8px; background: transparent; color: #5e6862; font-size: 10px; font-weight: 800; }
.attachment-actions button:hover { background: var(--soft); color: var(--ink); }
.attachment-actions button span:first-child { color: var(--green-deep); font-size: 13px; }
.composer-status { max-width: 300px; overflow: hidden; color: #8a938e; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.microphone, .send-button { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; }
.microphone { border: 1px solid var(--line); background: white; color: #78817c; font-size: 10px; }
.microphone[aria-pressed="true"] { border-color: #e09a95; background: #fff0ef; color: var(--danger); animation: record 1.2s infinite; }
@keyframes record { 50% { box-shadow: 0 0 0 4px rgba(161,54,47,.12); } }
.send-button { border: 0; background: var(--green); color: #142608; font-size: 18px; font-weight: 900; }
.send-button:hover { background: #60c70a; }
.send-button:disabled, .composer button:disabled { cursor: wait; opacity: .55; }
.safety-note { margin: 4px auto 0; color: #8b948f; font-size: 8px; text-align: center; }

.drawer { position: fixed; z-index: 80; top: 0; right: 0; width: min(390px, calc(100% - 28px)); height: 100vh; height: 100dvh; padding: 25px; overflow-y: auto; border-left: 1px solid var(--line); background: white; box-shadow: -18px 0 55px rgba(18,27,21,.16); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.drawer-head > span:not(.avatar) { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 11px; background: var(--green); font-size: 10px; font-weight: 900; }
.drawer-head button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: white; font-size: 21px; }
.drawer > small { color: var(--green-deep); font-size: 10px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.drawer h2 { margin: 7px 0 13px; font-size: 31px; letter-spacing: -.04em; }
.drawer > p { color: var(--muted); font-size: 14px; }
.drawer-action, .drawer-link { width: 100%; min-height: 45px; display: flex; align-items: center; justify-content: center; margin-top: 22px; padding: 10px 15px; border: 0; border-radius: 11px; background: var(--charcoal); color: white; font-size: 12px; font-weight: 850; text-decoration: none; }
.drawer-action.danger { background: #f8e9e8; color: var(--danger); }
.drawer-link { background: var(--soft); color: var(--ink); }
.billing-status-banner { margin: 0 0 14px; padding: 12px 14px; border: 1px solid #b8d8a4; border-radius: 12px; background: #edf8e7; color: #235f05; font-size: 13px; font-weight: 750; }
.account-details { display: grid; gap: 0; margin: 22px 0; border-top: 1px solid var(--line); }
.account-details div { display: flex; justify-content: space-between; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.account-details dt { color: var(--muted); font-size: 11px; }
.account-details dd { margin: 0; overflow-wrap: anywhere; font-size: 11px; font-weight: 800; text-align: right; }
.drawer-backdrop, .sidebar-backdrop { position: fixed; z-index: 70; inset: 0; border: 0; background: rgba(18,23,20,.32); backdrop-filter: blur(2px); }
.sidebar-backdrop { z-index: 25; }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 248px minmax(0,1fr); }
  .sidebar { padding-inline: 11px; }
  .module-selector { display: flex; overflow-x: auto; padding-bottom: 3px; scrollbar-width: thin; }
  .module-choice { flex: 0 0 132px; }
  .compact-intro p { display: none; }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(284px, calc(100% - 42px)); transform: translateX(-105%); transition: transform .2s ease; box-shadow: 18px 0 50px rgba(18,27,21,.16); }
  .sidebar.open { transform: translateX(0); }
  .workspace { height: 100vh; height: 100dvh; }
  .mobile-menu { display: grid; place-items: center; }
  .sync-state { display: none; }
  .topbar { padding-inline: 10px; }
  .current-case-icon { display: none; }
  .current-case strong { max-width: 43vw; }
  .conversation-controls { padding: 11px 11px 8px; }
  .compact-intro { margin-bottom: 8px; }
  .compact-intro h1 { overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
  .module-choice { flex-basis: 124px; min-height: 45px; }
  .auto-routing { margin-top: 5px; }
  .conversation-body { padding: 13px 12px; }
  .composer-zone { padding: 7px 8px calc(6px + env(safe-area-inset-bottom)); }
  .composer { border-radius: 14px; }
  .composer textarea { min-height: 52px; padding-top: 11px; }
  .composer-actions { align-items: flex-end; }
  .attachment-actions button { width: 32px; padding: 0; justify-content: center; }
  .attachment-actions button span:last-child { display: none; }
  .composer-status { max-width: 125px; }
  .safety-note { display: none; }
}

@media (max-width: 480px) {
  .top-actions { gap: 5px; }
  .account-button b { display: none; }
  .account-button { padding-right: 3px; }
  .language-control select { min-width: 56px; }
  .message { grid-template-columns: 31px minmax(0,1fr); gap: 8px; }
  .message-avatar { width: 31px; height: 31px; }
  .message-copy { font-size: 13px; }
  .composer-status { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
