:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e3e6ea;
  --border-strong: #cfd4da;
  --text: #1f2733;
  --muted: #697586;
  --faint: #98a2b3;
  --accent: #3b4a6b;
  --accent-hover: #2f3c57;
  --accent-soft: #eceff5;
  --ok-bg: #e7f4ec; --ok-text: #1e7a44;
  --warn-bg: #fdf0e3; --warn-text: #9a5b12;
  --err-bg: #fcebea; --err-text: #a83232;
  --neutral-bg: #edf0f3; --neutral-text: #697586;
  --radius: 8px; --radius-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.55; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--err-text); font-size: 13px; margin: 6px 0 0; }
.empty { color: var(--muted); padding: 14px 4px; }

.app-bar { display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 20px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.app-bar .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
.app-bar .brand .dot { width: 26px; height: 26px; border-radius: var(--radius);
  background: var(--accent-soft); color: var(--accent); display: flex;
  align-items: center; justify-content: center; font-weight: 700; }
.app-bar .ctx { color: var(--muted); font-size: 14px; }
.app-bar a { color: var(--muted); text-decoration: none; font-size: 14px; }
.app-bar a:hover { color: var(--text); }

.container { max-width: 900px; margin: 0 auto; padding: 24px 20px; }

.card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 14px; font-size: 16px; font-weight: 600; }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
input, select { width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--surface); color: var(--text);
  font-size: 14px; font-family: inherit; }
input[type="checkbox"] { width: auto; height: auto; }
input:focus, select:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft); }

button { height: 38px; padding: 0 16px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--surface); color: var(--text);
  font-size: 14px; font-family: inherit; cursor: pointer; }
button:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

.badge { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 20px;
  background: var(--neutral-bg); color: var(--neutral-text); }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-err { background: var(--err-bg); color: var(--err-text); }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; color: var(--muted); font-weight: 600;
  padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab { padding: 10px 14px; font-size: 14px; color: var(--muted); cursor: pointer;
  border: none; border-bottom: 2px solid transparent; background: none; border-radius: 0; height: auto; }
.tab:hover { background: none; color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.pane { display: none; }
.pane.active { display: block; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.metric { background: var(--surface-2); border-radius: var(--radius); padding: 14px; }
.metric .k { font-size: 12px; color: var(--muted); }
.metric .v { font-size: 22px; font-weight: 600; margin-top: 4px; }

.login-wrap { min-height: calc(100vh - 56px); display: flex; align-items: center;
  justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { font-size: 18px; font-weight: 600; margin: 0 0 16px; text-align: center; }
.login-card button { width: 100%; margin-top: 14px; }

.chat { display: flex; flex-direction: column; height: calc(100vh - 56px); max-width: 800px; margin: 0 auto; }
.messages { flex: 1; overflow-y: auto; padding: 20px; }
.msg { padding: 9px 13px; margin: 7px 0; border-radius: var(--radius-lg);
  max-width: 78%; white-space: pre-wrap; font-size: 14.5px; }
.msg.user { background: var(--accent); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.msg.assistant { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.pending { color: var(--muted); }
.msg img { max-width: 100%; display: block; margin-top: 8px; border-radius: var(--radius); }
.composer { display: flex; gap: 8px; padding: 14px 20px; background: var(--surface); border-top: 1px solid var(--border); }
.composer input { flex: 1; }

.row-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.result { font-size: 13px; color: var(--muted); }
a.link { color: var(--accent); text-decoration: none; }
a.link:hover { text-decoration: underline; }
