:root {
  --ink: #17211f;
  --muted: #65716e;
  --line: #dce3e0;
  --paper: #f7f8f7;
  --white: #ffffff;
  --accent: #0f766e;
  --accent-2: #b3261e;
  --warn: #a16207;
  --ok: #15803d;
  --soft: #eef5f2;
  --blue: #1d4ed8;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
body, button, input, select, textarea { letter-spacing: 0; }
button, input, select, textarea {
  font: inherit;
}
button {
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 6px;
  padding: 9px 12px;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, color .16s ease;
}
button:hover { border-color: #aab8b4; }
button.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.hidden { display: none !important; }
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #eef3f1;
}
.login-panel {
  width: min(380px, calc(100vw - 32px));
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  display: grid;
  gap: 14px;
  box-shadow: 0 18px 45px rgba(23, 33, 31, .08);
}
.brand {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0;
}
.login-panel h1 { margin: 0; font-size: 24px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: white;
  min-width: 0;
}
textarea { min-height: 82px; resize: vertical; }
.error { color: var(--accent-2); min-height: 18px; margin: 0; }
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px 1fr;
}
.nav {
  background: #10201e;
  color: white;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.nav-brand {
  font-weight: 800;
  line-height: 1.1;
  padding: 8px 8px 18px;
}
.nav-brand span { color: #8bd6ca; }
.nav button {
  text-align: left;
  color: #e7efed;
  background: transparent;
  border-color: transparent;
  white-space: nowrap;
}
.nav button.active, .nav button:hover {
  background: #1c3733;
  border-color: #294a45;
}
main { min-width: 0; }
.topbar {
  height: 76px;
  border-bottom: 1px solid var(--line);
  background: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 16px;
}
.topbar h2 { margin: 0; font-size: 21px; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 8px; min-width: 360px; }
.top-actions input { flex: 1; }
#content { padding: 16px; }
.grid { display: grid; gap: 14px; }
.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric, .panel, .card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.metric { padding: 14px; min-height: 86px; }
.metric b { display: block; font-size: 27px; line-height: 1; }
.metric span { color: var(--muted); font-size: 13px; }
.metric.danger { border-color: #f4b4ae; background: #fff7f6; }
.metric.warn { border-color: #f2d59b; background: #fffbeb; }
.metric.info { border-color: #b9cef8; background: #f4f7ff; }
.secondary-metrics { margin-top: 10px; }
.quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 0;
}
.two { grid-template-columns: minmax(260px, 360px) minmax(0, 1fr); align-items: start; }
.three { grid-template-columns: 300px minmax(0, 1fr) 300px; align-items: start; }
.panel { padding: 14px; overflow: hidden; }
.panel h3 { margin: 0 0 12px; font-size: 15px; line-height: 1.2; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.panel-head h3 { margin: 0; }
.list { display: grid; gap: 8px; }
.item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: white;
  display: grid;
  gap: 4px;
}
.item:hover { border-color: #9fb2ad; background: #fbfdfc; }
.item.selected { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.item .row, .row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.muted { color: var(--muted); font-size: 12px; }
.preview { font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  background: #e8f3f1;
  color: #075e57;
  font-size: 12px;
}
.badge.warn { background: #fff7ed; color: var(--warn); }
.badge.danger { background: #fef2f2; color: var(--accent-2); }
.status-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: white;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.status-pill.ok { border-color: #aad8bd; color: var(--ok); background: #f0fdf4; }
.status-pill.danger { border-color: #f1b8b2; color: var(--accent-2); background: #fff7f6; }
.ops-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.ops-strip h3 { margin: 2px 0 0; font-size: 22px; line-height: 1.15; }
.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.dashboard-layout {
  grid-template-columns: minmax(300px, 1fr) minmax(260px, 360px);
  margin-top: 14px;
}
.focus-panel { grid-row: span 2; }
.docs-panel { grid-column: 2; }
.workflow-list { display: grid; gap: 9px; }
.workflow-step {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}
.workflow-step > b {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
}
.workflow-step strong { display: block; font-size: 13px; }
.workflow-step span { display: block; color: var(--muted); font-size: 12px; line-height: 1.35; margin-top: 2px; }
.action-item { cursor: pointer; }
.inbox-shell {
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(360px, 1fr) minmax(260px, 320px);
  gap: 14px;
  align-items: start;
}
.conversation-list {
  height: calc(100vh - 108px);
  overflow: auto;
}
.filterbar {
  position: sticky;
  top: 0;
  z-index: 2;
  background: white;
  padding-bottom: 10px;
}
.filterbar button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  font-size: 12px;
}
.filterbar button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: white;
}
.filterbar span {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255,255,255,.2);
  font-size: 11px;
}
.conversation-card { cursor: pointer; }
.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.chat-head h3 { margin: 0 0 4px; font-size: 16px; }
.chat-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chat {
  height: calc(100vh - 130px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
}
.messages {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 6px;
}
.bubble {
  max-width: 78%;
  border: 1px solid var(--line);
  background: #f8faf9;
  border-radius: 8px;
  padding: 9px 11px;
  line-height: 1.38;
}
.bubble.out { align-self: flex-end; background: #e8f3f1; border-color: #b9d8d2; }
.compose { display: grid; gap: 8px; }
.compose-row { display: flex; gap: 8px; }
.compose-row input { flex: 1; }
.quick-replies {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.quick-replies button {
  flex: 0 0 auto;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 7px 9px;
  font-size: 12px;
}
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; border-bottom: 1px solid var(--line); padding: 9px 6px; vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid.compact { gap: 8px; }
.master-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.master-form {
  display: grid;
  gap: 10px;
}
.master-form h3 { margin-bottom: 2px; }
.empty-state {
  border: 1px dashed #b9c6c2;
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
  background: #fbfcfc;
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .nav { flex-direction: row; overflow-x: auto; padding: 10px; }
  .nav-brand { display: none; }
  .topbar { height: auto; align-items: stretch; flex-direction: column; padding: 14px; }
  .top-actions { min-width: 0; width: 100%; }
  .metrics, .two, .three, .form-grid, .dashboard-layout, .inbox-shell, .master-layout { grid-template-columns: 1fr; }
  .ops-strip { align-items: flex-start; flex-direction: column; }
  .docs-panel { grid-column: auto; }
  .conversation-list { height: auto; max-height: 42vh; }
  .chat { height: auto; min-height: 70vh; }
  .bubble { max-width: 92%; }
  .compose-row { flex-direction: column; }
}
