:root {
  --bg: #f4f6f8;
  --card: #fff;
  --ink: #17202a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #159a76;
  --nav: #172235;
  --danger: #c0392b;
  --warn: #b7791f;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif; }
a { color: #087a5f; text-decoration: none; }
button, .button { border: 1px solid #cfd6dc; border-radius: 6px; background: #fff; color: var(--ink); padding: 9px 15px; cursor: pointer; font: inherit; }
.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.topbar { min-height: 60px; background: var(--nav); display: flex; align-items: center; justify-content: space-between; padding: 12px 28px; color: #fff; }
.brand { color: #fff; font-size: 18px; font-weight: 700; white-space: nowrap; }
.topbar nav { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.topbar nav a, .link-button { color: #dbe4ed; }
.topbar nav a { padding: 5px 1px; border-bottom: 2px solid transparent; }
.topbar nav a.active { color: #fff; border-bottom-color: #59c4a6; }
.link-button { border: 0; background: transparent; padding: 0; }
.inline { display: inline; }
.container, .public-container { max-width: 1180px; margin: 0 auto; padding: 30px 24px; }
.public-container { max-width: 820px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.page-head h1 { margin: 0 0 4px; font-size: 26px; }
.page-head p, .muted { margin: 0; color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 22px; margin-bottom: 20px; box-shadow: 0 1px 2px rgba(0, 0, 0, .03); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat { display: flex; flex-direction: column; }
.stat strong { font-size: 30px; }
.stat span { color: var(--muted); }
.compact-stats .stat strong { font-size: 22px; }
.status-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.status-grid > div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 10px 0; }
.ok { color: #087a5f; }
.bad, .error-text { color: var(--danger); }
.ok-bg { background: #e3f7ef; color: #087a5f; }
.bad-bg { background: #fee9e7; color: var(--danger); }
.pill { display: inline-block; padding: 3px 8px; border-radius: 20px; background: #eef2f5; font-size: 12px; }
.row-between { display: flex; justify-content: space-between; align-items: start; }
.details { display: grid; grid-template-columns: 160px 1fr; gap: 8px; margin: 20px 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }
.table-wrap { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f8fafb; color: #4b5563; }
.empty { text-align: center; color: var(--muted); padding: 40px; }
.alert { border-radius: 8px; padding: 12px 15px; margin-bottom: 18px; }
.warning { background: #fff4dc; color: #7c5310; }
.error { background: #fee9e7; color: #9f2f24; }
.success { background: #e3f7ef; color: #087a5f; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; color: #4b5563; }
.wide { grid-column: 1 / -1; }
input, textarea, select { width: 100%; border: 1px solid #cfd6dc; border-radius: 6px; padding: 10px 11px; font: inherit; background: #fff; }
textarea { resize: vertical; }
.danger-zone { display: flex; gap: 10px; }
.chat { padding: 24px; }
.bubble-row { display: flex; margin: 10px 0; }
.bubble-row.outbound { justify-content: flex-end; }
.bubble { max-width: 76%; border-radius: 10px; background: #f0f2f4; padding: 10px 14px; }
.outbound .bubble { background: #dff6ed; }
.bubble small, .bubble em { color: var(--muted); font-size: 11px; }
.bubble p { margin: 5px 0; white-space: pre-wrap; }
.login-body { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #172235, #24566a); }
.login-card { width: min(390px, 90vw); background: #fff; padding: 34px; border-radius: 12px; display: flex; flex-direction: column; gap: 16px; }
.login-card h1 { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 6px; }
.two-column { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; }
.help-list { padding-left: 22px; }
.help-list li { margin: 8px 0; }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0; }
.result-grid > div { display: flex; flex-direction: column; background: #f8fafb; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.result-grid span { color: var(--muted); }
.result-grid b { font-size: 20px; }
.preview-chat { background: #f8fafb; border-radius: 8px; margin-top: 15px; }
.history-row, .failure-row { gap: 18px; border-top: 1px solid var(--line); padding: 12px 0; }
.failure-row { display: grid; grid-template-columns: 260px 1fr; }
.job-error { max-width: 340px; white-space: normal; word-break: break-word; }
.status-failed { background: #fee9e7; color: var(--danger); }
.status-completed { background: #e3f7ef; color: #087a5f; }
.status-pending, .status-running { background: #fff4dc; color: #7c5310; }
.security-form { max-width: 620px; display: flex; flex-direction: column; gap: 16px; }
.security-form label { display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 760px) {
  .topbar { height: auto; padding: 13px 16px 8px; align-items: flex-start; flex-direction: column; gap: 7px; }
  .topbar nav { width: 100%; gap: 15px; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; padding-bottom: 3px; }
  .topbar nav a, .topbar nav form { flex: 0 0 auto; white-space: nowrap; }
  .stats, .status-grid, .form-grid, .two-column, .result-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .page-head { align-items: flex-start; gap: 12px; }
  .details { grid-template-columns: 1fr; }
  .bubble { max-width: 90%; }
  .failure-row { grid-template-columns: 1fr; }
}
