:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #e8eef6;
  background: #0c1118;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #0c1118; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { padding: 24px 18px; border-right: 1px solid #222d3b; background: #101720; }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 30px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: #2787e7; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 13px; letter-spacing: .04em; }
.brand small { color: #8090a6; margin-top: 3px; }
nav { display: grid; gap: 6px; }
.nav-item { width: 100%; border: 0; text-align: left; background: transparent; padding: 10px 12px; border-radius: 8px; color: #a9b5c6; text-decoration: none; display: flex; justify-content: space-between; gap: 10px; }
.nav-item.active { background: #172332; color: #fff; }
.nav-item.disabled { opacity: .5; cursor: default; }
.nav-item small { color: #6f879f; }
.main { padding: 30px clamp(20px, 4vw, 54px); overflow: hidden; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: end; }
.eyebrow { margin: 0 0 8px; color: #5ea8f3; font-size: 11px; letter-spacing: .12em; font-weight: 700; }
h1 { margin: 0; font-size: 30px; }
.subtitle { margin: 8px 0 0; color: #8b9bb0; max-width: 760px; }
#refresh-button, .campaign-controls button, #campaign-create, #action-create, .form-panel button, .dm-shell button, .workbench button, .provision-details button { border: 1px solid #315170; background: #172b3f; color: #d9ebff; border-radius: 8px; padding: 9px 14px; }
button:disabled { cursor: not-allowed; opacity: .42; }
button:not(:disabled) { transition: border-color .16s ease, background-color .16s ease, transform .16s ease; }
button:not(:disabled):hover { border-color: #5a9bd8; background: #1b3751; }
button:not(:disabled):active { transform: translateY(1px); }
.danger { border-color: #68353d !important; background: #381c22 !important; color: #ffc3ca !important; }
.global-context { margin-top: 24px; max-width: 760px; display: grid; grid-template-columns: minmax(260px, 1fr) minmax(280px, 1fr); gap: 12px; }
.workspace-control small { color: #61758e; font-weight: 400; }
.status-line { min-height: 22px; margin-top: 8px; color: #82a2c1; font-size: 12px; }
.status-line.error { color: #ff9aa7; }
.toolbar { margin-top: 20px; display: flex; justify-content: space-between; gap: 20px; align-items: end; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { border: 1px solid #263547; background: #111a24; color: #91a1b7; border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.tab.active { color: #fff; border-color: #3d81c3; background: #16314c; }
.workspace-control, .picker-row label, .composer-grid label, .form-stack label, .form-grid-two label { display: grid; gap: 5px; color: #7e90a8; font-size: 11px; }
input, select, textarea { background: #0d141c; color: #dbe6f3; border: 1px solid #29394c; padding: 9px 10px; border-radius: 8px; min-width: 0; }
textarea { resize: vertical; min-height: 90px; line-height: 1.45; }
.workspace-control input { width: 100%; }
.panel { margin-top: 18px; border: 1px solid #202c3a; border-radius: 12px; overflow: hidden; background: #101720; }
.compact-panel { padding: 14px 16px; }
.panel-head { padding: 16px 18px; display: flex; justify-content: space-between; border-bottom: 1px solid #202c3a; }
.panel-head strong { margin-right: 10px; }
.panel-head span, .panel-head p { color: #76879d; font-size: 12px; }
.panel-head p { margin: 0; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 18px; border-bottom: 1px solid #1c2734; text-align: left; font-size: 13px; vertical-align: top; }
th { color: #78899f; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.muted { color: #7d8da1; }
.pill { display: inline-block; border: 1px solid #315170; border-radius: 999px; padding: 3px 8px; color: #9dc9f4; font-size: 11px; }
.empty { text-align: center; color: #6f8096; padding: 40px 20px; }
.hidden { display: none !important; }
.app-view:not(.hidden) { animation: view-in .2s ease both; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.picker-row { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto; align-items: end; gap: 12px; }
.summary-grid { margin-top: 18px; display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 10px; }
.metric-card { background: #101720; border: 1px solid #202c3a; border-radius: 11px; padding: 14px; }
.metric-card span { display: block; color: #72849a; font-size: 11px; margin-bottom: 6px; }
.metric-card strong { font-size: 21px; }
.campaign-controls { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.button-group { display: flex; gap: 8px; flex-wrap: wrap; }
.campaign-controls .danger { border-color: #68353d; background: #381c22; color: #ffc3ca; }
#campaign-status { color: #8294aa; font-size: 12px; }
.composer-grid { padding: 16px 18px; display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.composer-grid .wide { grid-column: span 2; }
.action-composer { overflow: visible; }
.campaign-toolbar { margin-top: 18px; }
.queue-filter-panel { overflow: visible; }
.queue-filter-grid { display: grid; grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(150px, 1fr)) auto; gap: 10px; align-items: end; }
.queue-filter-grid label { display: grid; gap: 5px; color: #7e90a8; font-size: 11px; }
.queue-filter-actions { align-items: center; padding-bottom: 1px; }
.attempt-filter-grid { padding: 14px 18px; grid-template-columns: repeat(3, minmax(180px, 1fr)) auto; }
#action-attempts-panel .output { margin: 0 18px 18px; max-height: 420px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tiny { border: 1px solid #315170; background: #172b3f; color: #d9ebff; border-radius: 6px; padding: 5px 7px; font-size: 11px; }
.tiny.ghost { background: transparent; color: #8fb6db; }
td small { display: block; margin-top: 4px; color: #71849a; }

.ops-grid { margin-top: 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-panel { overflow: visible; }
.form-stack { padding: 16px 18px; display: grid; gap: 12px; }
.form-grid-two { padding: 16px 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-actions { padding: 0 18px 16px; }
.wide-panel { max-width: 1160px; }
.output { margin: 0; border: 1px solid #223144; background: #0b1219; color: #91a6bd; border-radius: 8px; padding: 12px; min-height: 88px; max-height: 260px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: 11px/1.45 "SFMono-Regular", Consolas, monospace; }
.output.tall { max-height: 480px; min-height: 180px; }

.dm-shell { margin-top: 18px; min-height: 650px; display: grid; grid-template-columns: minmax(230px,  .8fr) minmax(360px, 1.6fr) minmax(250px, .9fr); gap: 12px; }
.dm-shell .panel { margin-top: 0; min-width: 0; }
.dm-list, .dm-thread, .dm-detail { display: flex; flex-direction: column; }
.dm-filter { padding: 12px; display: grid; grid-template-columns: 1fr auto; gap: 8px; border-bottom: 1px solid #202c3a; }
.conversation-list { overflow: auto; flex: 1; }
.conversation-row { width: 100%; padding: 12px 14px; border: 0; border-bottom: 1px solid #1c2734; border-radius: 0; background: transparent; color: #dbe6f3; display: flex; justify-content: space-between; gap: 10px; text-align: left; }
.conversation-row:hover, .conversation-row.active { background: #162332; }
.conversation-row span { min-width: 0; }
.conversation-row strong, .conversation-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-row small { margin-top: 4px; color: #71849a; font-size: 10px; }
.conversation-meta { text-align: right; max-width: 105px; }
.conversation-meta b { display: inline-grid; min-width: 20px; min-height: 20px; place-items: center; border-radius: 999px; background: #245d8e; font-size: 10px; }
.message-list { flex: 1; min-height: 430px; max-height: 600px; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.message { max-width: 80%; border: 1px solid #243549; background: #111b26; border-radius: 12px; padding: 10px 12px; align-self: flex-start; }
.message.outbound { align-self: flex-end; background: #17304a; border-color: #315170; }
.message.system { align-self: center; opacity: .8; }
.message p { margin: 5px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.message small { color: #708299; font-size: 9px; }
.synthetic-badge { display: inline-block; margin-top: 7px; color: #e8bb73; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.reply-box { padding: 12px; border-top: 1px solid #202c3a; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.reply-box textarea { min-height: 70px; }
.dm-detail .output { margin: 14px; }
.detail-form { padding-top: 0; }

.setup-details { margin-top: 13px; border-top: 1px solid #202c3a; padding-top: 12px; }
.setup-details summary, .provision-details summary { cursor: pointer; color: #9dc9f4; font-size: 12px; font-weight: 650; }
.embedded-form { padding: 14px 0 2px; }
.full { grid-column: 1 / -1; }
.code-tall { min-height: 190px; }
.workbench { margin-top: 18px; border-top: 1px solid #263547; border-bottom: 1px solid #263547; background: #101720; }
.two-pane, .intelligence-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, .85fr); }
.workbench-main { min-width: 0; border-right: 1px solid #202c3a; }
.workbench-inspector { min-width: 0; padding-bottom: 18px; }
.section-heading { min-height: 68px; padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid #202c3a; }
.section-heading strong, .section-heading span { display: block; }
.section-heading strong { font-size: 14px; }
.section-heading span { margin-top: 4px; color: #76879d; font-size: 11px; }
.section-heading .safety-flag { margin: 0; flex: none; color: #80ccb6; border: 1px solid #285b50; border-radius: 999px; padding: 5px 9px; }
.workbench-inspector > .output { margin: 16px 18px 0; }
.workbench-inspector > .form-stack { padding-top: 0; }
.import-form, .outreach-form { padding-bottom: 8px; }
.inline-context { display: flex; gap: 8px; align-items: center; }
.inline-context input { width: min(260px, 30vw); }
.review-inspector { padding: 0 18px 18px; }
.review-inspector .section-heading { margin: 0 -18px 15px; }
.review-inspector label { display: grid; gap: 5px; margin-top: 10px; color: #7e90a8; font-size: 11px; }
.review-inspector textarea { min-height: 125px; }
.review-inspector .button-group { margin-top: 12px; }
.review-inspector > .output { margin: 14px 0 0; }
.provision-details { padding: 16px 18px; overflow: visible; }
.provision-details > .form-grid-two { padding-left: 0; padding-right: 0; }
.provision-details > .form-actions { padding-left: 0; }
.progress-track { height: 3px; margin: 17px 18px 0; overflow: hidden; background: #1f2b39; }
.progress-track span { display: block; width: 0; height: 100%; background: #36a7dd; transition: width .3s ease; }
.compact-heading { min-height: 48px; margin-top: 14px; }
.compact-list { max-height: 310px; overflow: auto; }
.compact-row { width: 100%; display: flex; justify-content: space-between; gap: 12px; border: 0 !important; border-bottom: 1px solid #1c2734 !important; border-radius: 0 !important; background: transparent !important; text-align: left; }
.compact-row span, .compact-row strong, .compact-row small { display: block; min-width: 0; }
.compact-row small { margin-top: 4px; color: #71849a; overflow: hidden; text-overflow: ellipsis; }
.compact-meta { text-align: right; }
.compact-meta b { color: #9dc9f4; font-size: 10px; }

@media (max-width: 1180px) {
  .queue-filter-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .dm-shell { grid-template-columns: 260px 1fr; }
  .dm-detail { grid-column: 1 / -1; }
  .ops-grid { grid-template-columns: 1fr; }
  .two-pane, .intelligence-layout { grid-template-columns: 1fr; }
  .workbench-main { border-right: 0; border-bottom: 1px solid #202c3a; }
}
@media (max-width: 1000px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .composer-grid, .form-grid-two { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
}
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid #222d3b; padding: 16px; }
  .brand { margin-bottom: 14px; }
  nav { display: flex; overflow-x: auto; }
  .nav-item { width: auto; white-space: nowrap; }
  .main { padding: 22px 16px; }
  .topbar, .toolbar, .campaign-controls { align-items: stretch; flex-direction: column; }
  .panel-head { gap: 12px; flex-direction: column; }
  .global-context { grid-template-columns: 1fr; }
  .picker-row, .composer-grid, .form-grid-two { grid-template-columns: 1fr; }
  .queue-filter-grid, .attempt-filter-grid { grid-template-columns: 1fr; }
  .composer-grid .wide { grid-column: auto; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .dm-shell { grid-template-columns: 1fr; min-height: 0; }
  .dm-detail { grid-column: auto; }
  .message-list { min-height: 360px; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .section-heading .safety-flag { align-self: flex-start; }
  .inline-context { align-items: stretch; flex-direction: column; }
  .inline-context input { width: 100%; }
}
