/* ============================================================
   ReaDI — app shell, navigation, overlays, page chrome
   ============================================================ */

#app { min-height: 100vh; }

/* ---------- Shell grid ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar { background: var(--card); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar-hd { height: var(--topbar-h); display: flex; align-items: center; gap: 9px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; letter-spacing: -0.02em; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: var(--primary-foreground); display: grid; place-items: center; font-weight: 800; flex: none; box-shadow: var(--shadow-sm); }
.brand .logo svg { width: 17px; height: 17px; }

.sidebar-org { padding: 10px 12px; }
.org-pill { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--background); transition: background .15s, border-color .15s; }
.org-pill:hover { background: var(--secondary); border-color: var(--border-strong); }
.org-pill .org-logo { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff; flex: none; }
.org-pill .org-meta { display: flex; flex-direction: column; text-align: left; line-height: 1.3; min-width: 0; flex: 1; }
.org-pill .org-meta .nm { font-size: 12.5px; font-weight: 600; }
.org-pill .org-meta .sub { font-size: 11px; color: var(--muted-foreground); }
.org-pill .chev { color: var(--muted-foreground); width: 15px; height: 15px; flex: none; }

.nav { flex: 1; overflow-y: auto; padding: 6px 10px 16px; }
.nav-group { margin-top: 12px; }
.nav-group > .nav-label { padding: 6px 10px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; margin-bottom: 2px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--foreground); transition: background .12s, color .12s; position: relative; }
.nav-item:last-child { margin-bottom: 0; }
.nav-item .ico { width: 17px; height: 17px; color: var(--muted-foreground); flex: none; transition: color .12s; }
.nav-item:hover { background: var(--secondary); }
.nav-item.active { background: var(--secondary); color: var(--foreground); font-weight: 600; }
.nav-item.active .ico { color: var(--foreground); }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.nav-item .badge-count { margin-left: auto; font-size: 10.5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--secondary); color: var(--muted-foreground); display: inline-flex; align-items: center; justify-content: center; }
.nav-item.active .badge-count { background: var(--background); }
.nav-item .badge-count.alert { background: var(--destructive); color: #fff; }

.sidebar-ft { padding: 10px; border-top: 1px solid var(--border); }
.user-pill { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 8px; border-radius: 9px; transition: background .15s; }
.user-pill:hover { background: var(--secondary); }
.user-pill .meta { display: flex; flex-direction: column; text-align: left; line-height: 1.3; min-width: 0; flex: 1; }
.user-pill .meta .nm { font-size: 12.5px; font-weight: 600; }
.user-pill .meta .role { font-size: 11px; color: var(--muted-foreground); }

/* ---------- Main + topbar ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 0 22px; background: color-mix(in srgb, var(--background) 86%, transparent); backdrop-filter: saturate(140%) blur(10px); border-bottom: 1px solid var(--border); }
.topbar .crumbs { display: flex; align-items: center; gap: 7px; font-size: 13px; min-width: 0; }
.topbar .crumbs a { color: var(--muted-foreground); transition: color .12s; }
.topbar .crumbs a:hover { color: var(--foreground); }
.topbar .crumbs .sep { color: var(--border-strong); }
.topbar .crumbs .cur { font-weight: 600; }

.searchbar { display: flex; align-items: center; gap: 8px; height: 34px; width: 260px; max-width: 36vw; padding: 0 10px; border: 1px solid var(--input); border-radius: 9px; color: var(--muted-foreground); background: var(--background); transition: border-color .15s, background .15s; }
.searchbar:hover { background: var(--secondary); }
.searchbar svg { width: 15px; height: 15px; }
.searchbar .ph { font-size: 13px; flex: 1; text-align: left; }

.icon-btn { width: 34px; height: 34px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted-foreground); transition: background .12s, color .12s; position: relative; }
.icon-btn:hover { background: var(--secondary); color: var(--foreground); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .ind { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--destructive); border: 2px solid var(--background); }

.persona-switch { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px 0 6px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); transition: background .15s, border-color .15s; }
.persona-switch:hover { background: var(--secondary); border-color: var(--border-strong); }
.persona-switch .meta { display: flex; flex-direction: column; line-height: 1.25; text-align: left; }
.persona-switch .meta .nm { font-size: 12px; font-weight: 600; }
.persona-switch .meta .rl { font-size: 10px; color: var(--muted-foreground); }
.persona-switch svg { width: 14px; height: 14px; color: var(--muted-foreground); }

/* ---------- Page container ---------- */
.page { flex: 1; overflow-y: auto; }
.page-inner { max-width: 100%; margin: 0; padding: 26px 36px 64px; }
.page-inner.wide { max-width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.page-sub { color: var(--muted-foreground); font-size: 13.5px; margin-top: 3px; max-width: 64ch; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat { padding: 16px 18px; }
.stat .lbl { font-size: 12px; color: var(--muted-foreground); display: flex; align-items: center; gap: 7px; }
.stat .val { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 8px; line-height: 1; }
.stat .delta { font-size: 12px; margin-top: 8px; display: inline-flex; align-items: center; gap: 4px; }
.delta.up { color: var(--success-foreground); } .delta.down { color: var(--destructive-foreground); }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(296px, 1fr)); gap: 16px; }

.section-title { font-size: 15px; font-weight: 600; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }

/* filter bar */
.filterbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.chip-filter { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); font-size: 12.5px; font-weight: 500; color: var(--foreground); transition: background .15s, border-color .15s; }
.chip-filter:hover { background: var(--secondary); }
.chip-filter.active { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }
.chip-filter svg { width: 14px; height: 14px; }

/* timeline */
.timeline { position: relative; padding-left: 26px; }
.tl-item { position: relative; padding: 0 0 22px; }
.tl-item:last-child { padding-bottom: 0; }
/* connector runs from each dot down to the next — never below the last (or a lone) item */
.tl-item::before { content: ""; position: absolute; left: -14px; top: 11px; height: 100%; width: 2px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-item .tl-dot { position: absolute; left: -22px; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--card); border: 2px solid var(--border-strong); display: grid; place-items: center; }
.tl-item .tl-dot svg { width: 10px; height: 10px; color: var(--muted-foreground); }
.tl-item.accent .tl-dot { border-color: var(--primary); background: var(--primary); }
.tl-item.accent .tl-dot svg { color: var(--primary-foreground); }

/* ---------- Overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.42); backdrop-filter: blur(2px); display: flex; opacity: 0; transition: opacity .18s; }
.dark .overlay { background: rgba(0,0,0,.62); }
.overlay.show { opacity: 1; }
.overlay.center { align-items: center; justify-content: center; padding: 24px; }
.overlay.right { justify-content: flex-end; }
.overlay.top { align-items: flex-start; justify-content: center; padding-top: 12vh; }

.modal { background: var(--popover); color: var(--popover-foreground); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-pop); width: 100%; max-width: 520px; max-height: 86vh; display: flex; flex-direction: column; transform: scale(.97) translateY(6px); transition: transform .2s; overflow: hidden; }
.overlay.show .modal { transform: none; }
.modal-hd { padding: 18px 20px 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.modal-hd h3 { font-family: var(--font-heading); font-size: 17px; }
.modal-hd .sub { font-size: 13px; color: var(--muted-foreground); margin-top: 3px; }
.modal-bd { padding: 4px 20px 18px; overflow-y: auto; }
.modal-ft { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 9px; background: var(--card); }
.modal-x { color: var(--muted-foreground); }
.modal.lg { max-width: 720px; } .modal.xl { max-width: 940px; }

.sheet { background: var(--popover); border-left: 1px solid var(--border); box-shadow: var(--shadow-pop); width: 100%; max-width: 560px; height: 100vh; display: flex; flex-direction: column; transform: translateX(24px); transition: transform .22s ease; }
.overlay.show .sheet { transform: none; }
.sheet.wide { max-width: 720px; }
.sheet-hd { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-hd h3 { font-family: var(--font-heading); font-size: 16px; }
.sheet-bd { flex: 1; overflow-y: auto; padding: 18px 20px; }
.sheet-ft { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 9px; }

/* command palette */
.cmdk { width: 100%; max-width: 600px; background: var(--popover); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-pop); overflow: hidden; transform: scale(.98) translateY(-4px); transition: transform .18s; }
.overlay.show .cmdk { transform: none; }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.cmdk-input svg { width: 18px; height: 18px; color: var(--muted-foreground); }
.cmdk-input input { flex: 1; border: none; outline: none; background: none; font-size: 15px; }
.cmdk-list { max-height: 360px; overflow-y: auto; padding: 8px; }
.cmdk-group-label { padding: 8px 10px 4px; }
.cmdk-item { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; font-size: 13.5px; cursor: pointer; }
.cmdk-item .ico { width: 16px; height: 16px; color: var(--muted-foreground); flex: none; }
.cmdk-item.sel, .cmdk-item:hover { background: var(--secondary); }
.cmdk-item .meta-r { margin-left: auto; font-size: 11px; color: var(--muted-foreground); }

/* dropdown menu */
.menu { background: var(--popover); border: 1px solid var(--border); border-radius: 11px; box-shadow: var(--shadow-pop); padding: 6px; min-width: 200px; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; font-size: 13px; width: 100%; text-align: left; transition: background .12s; }
.menu-item:hover { background: var(--secondary); }
.menu-item svg { width: 15px; height: 15px; color: var(--muted-foreground); }
.menu-item.danger { color: var(--destructive); } .menu-item.danger svg { color: var(--destructive); }
.menu-sep { height: 1px; background: var(--border); margin: 5px -2px; }
.menu-label { padding: 6px 10px 3px; }

/* toast */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.toast { display: flex; align-items: flex-start; gap: 11px; background: var(--popover); border: 1px solid var(--border); border-radius: 11px; box-shadow: var(--shadow-lg); padding: 13px 14px; min-width: 280px; max-width: 380px; transform: translateX(20px); opacity: 0; transition: transform .24s, opacity .24s; }
.toast.show { transform: none; opacity: 1; }
.toast .ico { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast.success .ico { color: var(--success); } .toast.error .ico { color: var(--destructive); } .toast.info .ico { color: var(--info); }
.toast .tt { font-size: 13px; font-weight: 600; }
.toast .ds { font-size: 12.5px; color: var(--muted-foreground); margin-top: 1px; }

/* ---------- Assistant launcher (floating) ---------- */
.assistant-fab { position: fixed; bottom: 24px; right: 24px; z-index: 40; height: 46px; padding: 0 16px 0 14px; border-radius: 999px; background: var(--primary); color: var(--primary-foreground); display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-lg); transition: transform .15s, box-shadow .15s; }
.assistant-fab:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); }
.assistant-fab svg { width: 18px; height: 18px; }
.assistant-fab .spark { width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,.16); display: grid; place-items: center; }

/* ---------- Auth screens ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-aside { position: relative; overflow: hidden; background: var(--color-neutral-900); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-aside::before { content: ""; position: absolute; inset: 0; background: radial-gradient(900px 500px at 12% 8%, rgba(59,130,246,.22), transparent 60%), radial-gradient(700px 600px at 90% 90%, rgba(16,185,129,.16), transparent 55%); }
.auth-aside > * { position: relative; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; overflow-y: auto; }
.auth-card { width: 100%; max-width: 400px; }
.persona-card { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--card); text-align: left; transition: border-color .15s, box-shadow .15s, transform .1s, background .15s; }
.persona-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.persona-card .meta { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; line-height: 1.3; }
.persona-card .meta .nm { font-size: 13.5px; font-weight: 600; }
.persona-card .meta .rl { font-size: 12px; color: var(--muted-foreground); }
.persona-card .go { color: var(--muted-foreground); width: 16px; height: 16px; transition: transform .15s; }
.persona-card:hover .go { transform: translateX(2px); color: var(--foreground); }

/* split chat layout */
.chat-split { display: grid; grid-template-columns: 1fr 1fr; height: calc(100vh - var(--topbar-h)); }
.chat-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--border); }
.report-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--card); }
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 22px; }
.msg { display: flex; gap: 11px; margin-bottom: 20px; max-width: 100%; }
.msg .bubble { padding: 11px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.55; max-width: 86%; }
.msg.user { flex-direction: row-reverse; }
.msg.user .bubble { background: var(--primary); color: var(--primary-foreground); border-bottom-right-radius: 4px; }
.msg.ai .bubble { background: var(--secondary); border-bottom-left-radius: 4px; }
.chat-input { border-top: 1px solid var(--border); padding: 14px 18px; }
.chat-box { display: flex; align-items: flex-end; gap: 9px; border: 1px solid var(--input); border-radius: 12px; padding: 8px 8px 8px 12px; background: var(--background); transition: border-color .15s; }
.chat-box:focus-within { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 26%, transparent); }
.chat-box textarea { flex: 1; border: none; outline: none; background: none; resize: none; font-size: 13.5px; max-height: 120px; line-height: 1.5; }

.report-section { border: 1px solid var(--border); border-radius: 11px; margin-bottom: 14px; overflow: hidden; transition: border-color .15s; }
.report-section.approved { border-color: color-mix(in srgb, var(--success) 40%, var(--border)); }
.report-section.review { border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); }
.report-section-hd { display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: var(--secondary); }
.report-section-bd { padding: 14px; font-size: 13.5px; line-height: 1.62; }
.report-section-bd p { margin-bottom: 10px; } .report-section-bd p:last-child { margin-bottom: 0; }
.report-section-ft { padding: 11px 14px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

/* source chip */
.source-chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 9px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); font-size: 12px; }
.source-chip svg { width: 13px; height: 13px; color: var(--muted-foreground); }
.source-chip .x { color: var(--muted-foreground); margin-left: 2px; }

/* readiness checklist */
.check-item { display: flex; align-items: flex-start; gap: 11px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.check-item:last-child { border-bottom: none; }
.check-item .mk { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.check-item .mk svg { width: 13px; height: 13px; }
.mk.done { background: var(--success-soft); color: var(--success-foreground); }
.mk.todo { background: var(--secondary); color: var(--muted-foreground); }
.mk.warn { background: var(--warning-soft); color: var(--warning-foreground); }

/* settings two-col */
.settings-layout { display: grid; grid-template-columns: 216px 1fr; gap: 28px; align-items: start; }
.settings-nav { position: sticky; top: 78px; display: flex; flex-direction: column; gap: 2px; }
.settings-nav .nav-item { font-size: 13px; }

/* bar chart (analytics) */
.bars-chart { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 10px; }
.bars-chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bars-chart .bar { width: 70%; max-width: 34px; border-radius: 6px 6px 0 0; background: var(--primary); transition: height .5s ease; }
.bars-chart .bar.alt { background: var(--info); }
.bars-chart .bar-lbl { font-size: 11px; color: var(--muted-foreground); }

.spark-svg { width: 100%; height: 44px; }

/* responsive */
.menu-toggle { display: none; }
@media (max-width: 1080px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 90; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-pop); }
  .menu-toggle { display: inline-flex; }
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .chat-split { grid-template-columns: 1fr; height: auto; }
  .report-pane { border-top: 1px solid var(--border); }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; }
  .searchbar { width: auto; flex: 1; }
}
@media (max-width: 620px) {
  .grid-3, .grid-cards { grid-template-columns: 1fr; }
  .page-inner { padding: 18px 16px 56px; }
  .searchbar .ph, .persona-switch .meta { display: none; }
}
.sidebar-scrim { display: none; }
@media (max-width: 900px) { .sidebar-scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 85; } }
