:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #059669;
  --warn: #d97706;
  --danger: #dc2626;
  --indigo-soft: #eff6ff;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  background: #f1f5f9;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.full { width: 100%; }

/* Login */
.login-backdrop {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
}
.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.brand-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #10b981);
  flex-shrink: 0;
}
.brand-title { font-size: 17px; font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--muted); }
.scope-pill-box {
  margin-top: 14px; padding: 10px;
  background: var(--surface-soft); border: 1px solid var(--border);
  border-radius: 8px; font-size: 12px; color: var(--muted); text-align: center;
}

/* Topbar */
.app-shell { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  background: #0f172a; color: #f8fafc;
  padding: 10px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.topbar-sub { font-size: 11px; color: #94a3b8; }
.ver-tag {
  background: #1d4ed8; color: #dbeafe;
  font-size: 11px; padding: 1px 7px; border-radius: 999px;
}
.nav-tabs { display: flex; gap: 6px; }
.nav-btn {
  background: transparent; border: 1px solid transparent; color: #cbd5e1;
  padding: 7px 13px; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: 13px;
}
.nav-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-btn.active { background: #2563eb; color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.operator-pill { font-size: 12px; color: #cbd5e1; background: rgba(255,255,255,0.08); padding: 4px 10px; border-radius: 999px; }

/* Buttons & Forms */
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 7px 12px; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: 13px;
}
.btn:hover { background: var(--surface-soft); }
.btn.small { padding: 5px 9px; font-size: 12px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.secondary { background: #0f172a; border-color: #0f172a; color: #fff; }
.btn.secondary:hover { background: #1e293b; }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger-outline { border-color: #fecaca; color: var(--danger); background: #fff; }
.btn.danger-outline:hover { background: #fef2f2; }
.btn.ghost { background: transparent; border-color: var(--border); }
.topbar .btn.ghost { color: #e2e8f0; border-color: #334155; }
.topbar .btn.ghost:hover { background: #1e293b; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 13px; font-weight: 600; }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field select,
.search-row input, .state-advance-row input, .state-advance-row select, .chat-input-bar input {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; font-family: inherit;
}
.checkbox-field { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }

/* Main Layout */
.tab-view { flex: 1; overflow: hidden; }
.workspace-grid {
  display: grid;
  grid-template-columns: 290px 1fr 370px;
  gap: 12px;
  padding: 12px;
  height: 100%;
}
.single-scroll { overflow-y: auto; padding: 16px 24px; max-width: 1360px; margin: 0 auto; width: 100%; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden;
}
.panel-head {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 700; }

/* Sidebar */
.search-row { padding: 10px; display: flex; gap: 6px; border-bottom: 1px solid var(--border); }
.search-row input { flex: 1; }
.case-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.case-item {
  border: 1px solid var(--border); border-radius: 8px; padding: 10px; cursor: pointer;
  background: var(--surface); transition: border-color .15s, background .15s;
}
.case-item:hover { background: var(--surface-soft); }
.case-item.active { border-color: var(--primary); background: var(--indigo-soft); }
.case-item-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 4px; }
.case-item-name { font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-item-sub { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }

/* Badges */
.badge {
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: #e0f2fe; color: #0369a1; white-space: nowrap;
}
.badge.neutral { background: #f1f5f9; color: #334155; }
.badge.NEW { background: #e0e7ff; color: #3730a3; }
.badge.INVITED { background: #dbeafe; color: #1d4ed8; }
.badge.IN_PROGRESS, .badge.AWAITING_CUSTOMER, .badge.AWAITING_SAFI { background: #fef3c7; color: #b45309; }
.badge.READY_FOR_TECHNICAL_HANDOFF, .badge.PASS, .badge.SENT, .badge.DELIVERED_VERIFIED { background: #d1fae5; color: #065f46; }
.badge.SUSPENDED, .badge.PENDING_MAILBOX_CONFIRMATION, .badge.PENDING_SAFI_INDEPENDENT_DRILL { background: #ffedd5; color: #9a3412; }
.badge.CANCELLED, .badge.FAIL, .badge.DELIVERY_UNKNOWN, .badge.FAILED_PRE_SEND, .badge.danger { background: #fee2e2; color: #991b1b; }

/* Detail Panel */
.detail-panel { overflow-y: auto; padding: 14px 16px; gap: 12px; }
.empty-state { margin: auto; text-align: center; padding: 40px 20px; }
.case-id-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.detail-title { font-size: 18px; font-weight: 700; }
.meta-line { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.stepper { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin: 12px 0; }
.step-box {
  background: var(--surface-soft); border: 1px solid var(--border); border-radius: 7px;
  padding: 6px 8px; text-align: center; font-size: 11px; font-weight: 600; color: var(--muted);
}
.step-box { padding: 7px 5px; line-height: 1.25; }
.step-box.done { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.step-box.current { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }

.action-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.card {
  border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px;
  background: var(--surface); margin-bottom: 12px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.card h3 { margin: 0; font-size: 14px; }
.inline-actions { display: flex; gap: 6px; }

.state-advance-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.state-advance-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; }
.state-advance-row .grow { flex: 1; min-width: 180px; }

.checklist-grid { display: flex; flex-direction: column; gap: 8px; }
.chk-row {
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; background: var(--surface-soft);
  display: grid; grid-template-columns: 190px 1fr; gap: 10px; align-items: center;
}
.chk-flags { display: flex; flex-direction: column; gap: 4px; }
.chk-flags label { font-size: 12px; display: flex; align-items: center; gap: 6px; }
.chk-ref input { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }

.notif-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px;
}
.evidence-list { max-height: 210px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.ev-row {
  border-left: 3px solid var(--primary); background: var(--surface-soft);
  padding: 6px 10px; border-radius: 0 6px 6px 0; font-size: 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.btn.xs { padding: 3px 7px; font-size: 11px; }
.ev-row.REJECTED, .ev-row.FAILED_SAFE { border-left-color: var(--danger); }

/* AI Chat Panel */
.chat-head { background: var(--surface-soft); }
.quick-prompts { padding: 8px 10px; display: flex; flex-wrap: wrap; gap: 5px; border-bottom: 1px solid var(--border); }
.chip-btn {
  background: var(--indigo-soft); color: #1d4ed8; border: 1px solid #bfdbfe;
  border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 600; cursor: pointer;
}
.chip-btn:hover { background: #dbeafe; }
.chat-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: #fbfcfe; }
.msg { display: flex; flex-direction: column; max-width: 92%; }
.msg.user { align-self: flex-end; }
.msg.assistant { align-self: flex-start; }
.msg-bubble {
  padding: 9px 12px; border-radius: 10px; font-size: 13px; white-space: pre-wrap;
  border: 1px solid var(--border); background: var(--surface);
}
.msg.user .msg-bubble { background: #2563eb; border-color: #2563eb; color: #fff; }
.msg-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.msg-action-btn { margin-top: 6px; align-self: flex-start; }
.chat-input-bar { padding: 10px; border-top: 1px solid var(--border); display: flex; gap: 6px; }
.chat-input-bar input { flex: 1; }

/* Guards & Evidence Tabs */
.guards-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 14px; }
.guards-header h2 { margin: 0 0 4px; }
.guards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 12px; }
.guard-out {
  margin: 10px 0 0; padding: 10px; background: #0f172a; color: #e2e8f0;
  border-radius: 7px; font-size: 11px; overflow-x: auto; max-height: 170px;
}

.evidence-top-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.health-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.health-tile { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--surface-soft); }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-soft); font-weight: 700; }

/* Modals & Toast */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 40;
}
.modal-card {
  width: 100%; max-width: 500px; background: var(--surface); border-radius: 12px; padding: 18px 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.alert.error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 8px 10px; border-radius: 7px; margin-bottom: 10px; font-size: 12px; }
.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25); z-index: 60;
}
.toast.err { background: #991b1b; }

@media (max-width: 1120px) {
  .workspace-grid { grid-template-columns: 240px 1fr; }
  .chat-panel { grid-column: 1 / -1; height: 360px; }
}

/* Workspace polish: clear hierarchy, calmer surfaces, and useful room at desktop sizes. */
:root {
  --bg: #f3f6fa;
  --surface-soft: #f7f9fc;
  --border: #dce4ee;
  --text: #172536;
  --muted: #66778b;
  --primary: #176b87;
  --primary-hover: #12566d;
  --success: #16745b;
  --radius: 12px;
}
body { background: #f3f6fa; }
.topbar {
  min-height: 70px;
  padding: 10px 24px;
  color: #172536;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 3px 14px rgba(24, 46, 67, .04);
}
.brand-dot { background: linear-gradient(135deg, #176b87, #4a9d82); }
.topbar-sub { color: var(--muted); }
.topbar .ver-tag { background: #e8f3f5; color: #17627b; }
.nav-btn { color: #526276; border-radius: 8px; }
.nav-btn.active { color: #12566d; background: #e6f2f4; }
.nav-btn:hover { color: #12566d; background: #f1f6f7; }
.operator-pill { color: #405166; background: #f1f4f7; }
.topbar .btn.ghost { color: #405166; border-color: var(--border); }
.topbar .btn.ghost:hover { background: #f1f5f8; }
.tab-view { min-height: 0; }
.workspace-grid {
  grid-template-columns: minmax(250px, .78fr) minmax(480px, 1.65fr) minmax(310px, .98fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  padding: 18px 22px 20px;
}
.workspace-overview {
  grid-column: 1 / -1;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 2px 2px 0;
}
.workspace-intro { min-width: 240px; }
.workspace-intro h1 { margin: 0; font-size: clamp(22px, 2vw, 28px); letter-spacing: -.035em; }
.workspace-intro p { margin: 5px 0 0; }
.eyebrow { color: #176b87; font-size: 10px; font-weight: 800; letter-spacing: .13em; margin: 0 0 4px !important; }
.metric-strip { display: grid; grid-template-columns: repeat(4, minmax(115px, 1fr)); gap: 9px; width: min(660px, 62%); }
.metric-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 54px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: rgba(255,255,255,.9); color: var(--muted); font-size: 11px; font-weight: 600;
}
.metric-card strong { color: var(--text); font-size: 20px; line-height: 1; }
.panel { border-color: #dce4ee; border-radius: 13px; box-shadow: 0 5px 20px rgba(24, 46, 67, .035); }
.panel-head { padding: 14px 15px; }
.panel-head h2 { font-size: 14px; letter-spacing: -.01em; }
.detail-panel { padding: 20px; gap: 13px; }
.detail-title { font-size: 21px; letter-spacing: -.02em; }
.case-item { padding: 12px; border-radius: 10px; }
.case-item.active { border-color: #67a6b6; background: #eff8f8; box-shadow: inset 3px 0 #176b87; }
.card { padding: 15px 16px; border-color: #e0e7ef; border-radius: 11px; }
.card h3 { font-size: 14px; }
.action-bar { padding: 2px 0 4px; }
.btn { min-height: 36px; border-radius: 8px; transition: background .15s, border-color .15s, transform .15s; }
.btn:not(:disabled):active { transform: translateY(1px); }
.btn.primary { background: #176b87; border-color: #176b87; }
.btn.primary:hover { background: #12566d; }
.btn.secondary { background: #304457; border-color: #304457; }
.btn.success { background: #16745b; border-color: #16745b; }
.field input:focus, .field select:focus, .search-row input:focus,
.state-advance-row input:focus, .state-advance-row select:focus, .chat-input-bar input:focus {
  outline: 3px solid rgba(23, 107, 135, .15); border-color: #4a94a8;
}
.login-backdrop { background: radial-gradient(ellipse at 15% 15%, #2d6578, #173244 52%, #102331); }
.login-card { border: 1px solid rgba(255,255,255,.35); border-radius: 16px; }
.chat-panel { min-height: 0; }
.chat-messages { min-height: 150px; }
.badge { letter-spacing: .015em; }
.single-scroll { max-width: 1500px; }
.evidence-notice {
  display: flex; flex-direction: column; gap: 3px; margin: 0 0 14px; padding: 12px 14px;
  border: 1px solid #d6e5eb; border-left: 4px solid #176b87; border-radius: 9px;
  color: #526579; background: #f5fafb; font-size: 12px;
}
.evidence-notice strong { color: #254456; }

@media (max-width: 1380px) {
  .workspace-grid { grid-template-columns: minmax(230px, .75fr) minmax(420px, 1.6fr) minmax(290px, .95fr); padding-inline: 14px; gap: 10px; }
  .metric-strip { width: min(600px, 60%); }
  .detail-panel { padding: 15px; }
}
@media (max-width: 1120px) {
  .app-shell { height: auto; min-height: 100vh; }
  .workspace-grid { height: auto; min-height: 0; grid-template-rows: auto auto auto auto; grid-template-columns: minmax(230px, .75fr) minmax(0, 1.5fr); }
  .sidebar { min-height: 470px; }
  .detail-panel { min-height: 470px; }
  .chat-panel { grid-column: 1 / -1; height: 420px; }
  .workspace-overview { align-items: start; }
  .metric-strip { width: min(580px, 58%); }
}
@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-wrap: wrap; padding: 12px 14px; }
  .topbar-left { flex: 1 1 100%; }
  .nav-tabs { order: 3; width: 100%; overflow-x: auto; }
  .topbar-right { position: absolute; right: 14px; top: 15px; }
  .operator-pill { display: none; }
  .workspace-grid { display: flex; flex-direction: column; padding: 14px; }
  .workspace-overview { display: flex; flex-direction: column; gap: 12px; }
  .metric-strip { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar { min-height: 320px; }
  .detail-panel { min-height: 0; overflow: visible; }
  .chat-panel { height: 430px; }
  .stepper { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chk-row { grid-template-columns: 1fr; }
  .card-head, .detail-header { align-items: flex-start; flex-direction: column; }
  .inline-actions { flex-wrap: wrap; }
  .single-scroll { padding: 14px; }
  .evidence-top-grid { grid-template-columns: 1fr; }
  .guards-grid { grid-template-columns: 1fr; }
}

/* Case workspace */
:root {
  --bg: #eef1f7;
  --surface: #fff;
  --surface-soft: #f5f7fc;
  --border: #dce3ef;
  --text: #171d36;
  --muted: #525f78;
  --primary: #5040b5;
  --primary-hover: #3f3197;
  --indigo-soft: #efedfc;
}
body { background: var(--bg); color: var(--text); }
:focus-visible { outline: 3px solid #785fe2; outline-offset: 3px; }
button, input, select { font: inherit; }
button:disabled { cursor: not-allowed; }
[hidden] { display: none !important; }
.topbar { min-height: 68px; padding: 10px clamp(14px, 2vw, 34px); background: #191d38; color: #fff; }
.topbar-sub { color: #c5c7df; }
.brand-dot { width: 30px; height: 30px; border-radius: 10px; background: #bdb3ff; position: relative; }
.brand-dot::after { content: 'S'; color: #20184f; font-size: 16px; font-weight: 800; position: absolute; inset: 3px 0 0; text-align: center; }
.topbar .ver-tag, .operator-pill { background: #333752; color: #e7e5ff; }
.nav-btn { color: #e1dff5; }
.nav-btn.active, .nav-btn:hover { color: #fff; background: #41406d; }
.topbar .btn.ghost { color: #fff; border-color: #626582; }
.topbar .btn.ghost:hover { background: #333752; }

.workspace-grid { grid-template-columns: minmax(220px, .78fr) minmax(0, 2.45fr) minmax(272px, 1fr); gap: 16px; padding: 18px clamp(12px, 2vw, 32px); }
.workspace-overview { display: grid; grid-template-columns: 1fr auto 1fr; padding: 0 0 4px; gap: 20px; align-items: center; }
.workspace-intro { min-width: 0; justify-self: start; }
.workspace-intro h1 { font-size: clamp(24px, 2.5vw, 34px); font-weight: 780; letter-spacing: -.04em; }
.metric-strip { width: min(620px, 100%); justify-self: center; }
.metric-card { flex-direction: column; justify-content: center; text-align: center; gap: 4px; border-radius: 12px; min-height: 64px; font-size: 12px; background: #f9faff; }
.metric-card strong { color: #443999; font-size: 24px; }
.panel { min-width: 0; border-radius: 16px; }
.detail-panel { padding: clamp(15px, 2vw, 26px); }
.detail-title { margin: 0; font-size: clamp(24px, 2.2vw, 34px); overflow-wrap: anywhere; font-weight: 760; }
.meta-line { gap: 4px 18px; font-size: 12px; overflow-wrap: anywhere; }
#detail-case-id { background: #f4f5fc; }
.queue-filter { padding: 0 11px 8px; display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.queue-filter select { width: 100%; }
.case-list { gap: 5px; padding: 8px 10px; }
.case-item { width: 100%; min-width: 0; color: inherit; font: inherit; text-align: left; }
.case-item-top { align-items: flex-start; flex-wrap: wrap; }
.case-item-name { flex: 1 0 100%; }
.case-item-sub { margin-top: 6px; }
.case-item.active { border-color: #a496e8; background: #f0edff; box-shadow: inset 3px 0 #5644bf; }
.badge.AWAITING_SAFI { color: #4b328c; background: #eee7fb; }
.badge.IN_PROGRESS { color: #1d4c95; background: #e5edff; }
.badge.SENT { background: #ecedfa; color: #3b4175; }
.btn.primary, .btn.success { background: var(--primary); border-color: var(--primary); }
.btn.primary:hover, .btn.success:hover { background: var(--primary-hover); }
.btn.secondary { color: #443691; background: #efebff; border-color: #d8cff9; }
.btn.secondary:hover { color: #30236f; background: #e1d8ff; }
.queue-filter select, .chk-ref-input, .state-advance-row input, .state-advance-row select {
  min-width: 0; border: 1px solid #cdd6e7; border-radius: 8px; padding: 8px 10px; color: var(--text); background: #fff;
}

.stepper { gap: 5px; margin: 16px 0; }
.step-box { display: grid; justify-items: center; gap: 6px; background: transparent; border: 0; padding: 10px 4px; color: #5b6680; font-weight: 600; }
.stage-marker { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; border: 1px solid #cfd6e8; background: #fff; }
.step-box.done { color: #17614e; background: #edf7f3; }
.step-box.done .stage-marker { background: #d9eee5; border-color: #aed7c7; }
.step-box.current { color: #412d97; background: #eeeaff; }
.step-box.current .stage-marker { background: #5140ac; color: #fff; border-color: #5140ac; }
.case-brief { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 12px 0 19px; padding: 20px; border-radius: 14px; background: linear-gradient(115deg, #252047, #4b3789); color: #fff; }
.case-brief h2 { margin: 0; font-size: clamp(19px, 2vw, 24px); letter-spacing: -.02em; }
.case-brief p { margin: 5px 0 0; max-width: 56ch; color: #e2dbff; }
.case-brief .btn { flex-shrink: 0; color: #352674; white-space: normal; }

.case-tools { display: flex; justify-content: space-between; align-items: start; gap: 10px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.case-tabs { display: flex; gap: 8px; }
.case-tabs button, .action-menu > summary { padding: 9px 10px; color: var(--muted); background: transparent; border: 0; border-bottom: 3px solid transparent; cursor: pointer; font-size: 13px; font-weight: 650; }
.case-tabs button.active { color: #49369f; border-bottom-color: #6850c8; }
.case-tabs button span { margin-left: 2px; border-radius: 10px; padding: 2px 5px; color: #4a3b92; background: #eeebfb; font-size: 10px; }
.action-menu { position: relative; flex-shrink: 0; }
.action-popover { position: absolute; z-index: 3; right: 0; top: 100%; min-width: 145px; display: grid; gap: 5px; padding: 6px; border-radius: 10px; background: #fff; border: 1px solid var(--border); box-shadow: 0 10px 28px #191d3824; }
.case-section { border: 0; padding: 2px 0; }
.case-section h3, .single-scroll .card h3 { font-size: 16px; margin: 0; }
.case-section .card-head p { margin: 4px 0; }
.state-advance-row { padding: 12px; margin-block: 12px; background: #f6f6fd; border: 1px solid #e4e1f3; border-radius: 10px; }
.state-advance-row label { flex: 1 1 150px; min-width: 0; }
.state-advance-row .grow { flex: 2 1 215px; min-width: 0; }
.checklist-columns, .chk-row { display: grid; grid-template-columns: 1.35fr minmax(105px, .88fr) minmax(74px, .65fr) 1.4fr; align-items: center; gap: 8px; padding: 10px; }
.checklist-columns { font-size: 12px; font-weight: 650; color: var(--muted); background: #f0f1f9; border-radius: 9px 9px 0 0; }
.checklist-grid { gap: 0; border: 1px solid var(--border); border-top: 0; border-radius: 0 0 10px 10px; overflow: hidden; }
.chk-row { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; min-height: 60px; background: #fff; }
.chk-row:last-child { border-bottom: 0; }
.chk-row:nth-child(even) { background: #f9faff; }
.chk-row strong { font-size: 13px; }
.check-control { display: flex; align-items: center; gap: 5px; font-size: 12px; min-height: 32px; }
.check-control input { margin: 0; accent-color: #5140ac; width: 16px; height: 16px; }
.chk-ref-input { width: 100%; font-size: 12px; }
.checklist-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.checklist-footer p { flex: 1 1 210px; margin: 0; }
.service-options { min-width: 0; padding: 8px 12px 10px; border: 1px solid var(--border); border-radius: 8px; }
.service-options legend { padding: 0 4px; }
.service-options p { margin: 0 0 4px; }
.service-options label { display: flex; align-items: center; gap: 8px; min-height: 26px; cursor: pointer; font-weight: 500; }
.service-options input { margin: 0; accent-color: var(--primary); }

.reminder-status { margin: 10px 0 13px; padding: 10px 12px; border-radius: 8px; background: #f0f1f9; color: #4a536d; }
.reminder-status.due { color: #17614e; background: #e7f4ee; }
.notif-row, .ev-row { padding: 12px; align-items: flex-start; margin-bottom: 6px; overflow-wrap: anywhere; }
.notif-row strong, .ev-row strong { text-transform: capitalize; }
.item-details { font-size: 11px; color: var(--muted); margin-top: 6px; }
.item-details summary { cursor: pointer; }
.item-details p { margin: 4px 0; }
.evidence-list { max-height: none; }
.chat-head { background: #f4f1ff; gap: 8px; }
.chat-panel .chip-btn { background: #f0ecff; color: #443691; border-color: #ded6fa; }
.chat-panel .msg.user .msg-bubble { background: #5040b5; border-color: #5040b5; }
.chat-messages { background: #f9faff; }
.chat-input-bar input { min-width: 0; }
.single-scroll .card { overflow-wrap: anywhere; }
.single-scroll table { width: 100%; border-collapse: collapse; }
.single-scroll table thead { background: #f0eff8; color: #372b72; }
.single-scroll table tbody tr:nth-child(even) { background: #f8f9fd; }
.single-scroll td, .single-scroll th { padding: 10px; text-align: left; vertical-align: top; }
.modal-card { max-height: calc(100dvh - 30px); overflow: auto; }

@media (max-width: 1120px) {
  .workspace-grid { grid-template-columns: minmax(205px, .75fr) minmax(0, 2fr); }
  .workspace-overview { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
  .metric-strip { width: min(620px, 100%); }
  .sidebar { min-height: 0; max-height: 650px; }
  .case-list { max-height: 480px; }
}
@media (max-width: 760px) {
  .workspace-overview { align-items: stretch; gap: 10px; }
  .metric-strip { width: 100%; }
  .sidebar { max-height: 330px; }
  .case-list { max-height: 190px; }
  .stepper { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .case-brief, .notif-row, .ev-row { flex-direction: column; align-items: flex-start; }
  .detail-panel { padding: 13px; }
  .case-tabs { gap: 1px; }
  .case-tabs button, .action-menu > summary { padding-inline: 5px; font-size: 12px; }
  .checklist-columns { display: none; }
  .checklist-grid { border-top: 1px solid var(--border); border-radius: 10px; }
  .chk-row { grid-template-columns: 1fr 1fr; }
  .chk-row strong, .chk-row .chk-ref-input { grid-column: 1 / -1; }
}

.brief-actions { display: flex; flex-direction: column; align-items: stretch; gap: 6px; max-width: 205px; }
.case-brief .brief-secondary { background: transparent; border-color: #a99cd9; color: #f4efff; }
.case-brief .brief-secondary:hover { background: #ffffff19; }
@media (max-width: 480px) {
  .topbar { align-items: center; }
  .topbar-left { flex: 1; min-width: 0; }
  .topbar-right { position: static; }
  .topbar-title { flex-wrap: wrap; gap: 3px; }
  .topbar-title .ver-tag { display: none; }
  .metric-card { min-height: 50px; }
}

.checklist-guidance { margin: 0 0 12px; font-size: 13px; }

.follow-up-preview { margin-top: 16px; padding: 14px; background: #f6f4ff; border: 1px solid #dfd9f7; border-radius: 10px; overflow-wrap: anywhere; }
.follow-up-preview h4 { margin: 0; font-size: 15px; }
.follow-up-preview p { margin: 5px 0; }
.follow-up-preview ul { margin: 8px 0; padding-inline-start: 20px; }
.follow-up-preview li + li { margin-top: 4px; }
