:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #475569;
  --border: #cbd5e1;
  --navy: #0f294a;
  --cobalt: #1d4ed8;
  --ok: #047857;
  --warn: #b45309;
  --danger: #b91c1c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.site-header {
  background: linear-gradient(135deg, #0b1e38 0%, #153b6e 100%);
  color: #f8fafc;
  padding: 28px 0;
  border-bottom: 3px solid #0284c7;
}
.header-inner { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.brand-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: rgba(56, 189, 248, 0.18);
  color: #bae6fd;
  border: 1px solid rgba(56, 189, 248, 0.45);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.site-header h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: -0.02em; }
.subtitle { margin: 0; max-width: 680px; color: #cbd5e1; font-size: 15px; }
.header-links { display: flex; gap: 12px; flex-wrap: wrap; }
.header-links a {
  color: #e0f2fe;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.header-links a:hover { background: rgba(255, 255, 255, 0.18); }

main { padding: 24px 0 48px; display: flex; flex-direction: column; gap: 22px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.card h2 { margin: 0 0 6px; font-size: 21px; color: var(--navy); }
.muted { margin: 0; color: var(--muted); font-size: 14px; }
.pill {
  font-size: 12px;
  font-weight: 700;
  color: #0369a1;
  background: #e0f2fe;
  border: 1px solid #bae6fd;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  align-items: end;
}
.grid-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--navy); }
.grid-form input, .grid-form select {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}
.btn-primary {
  background: var(--navy);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: var(--cobalt); }
.field-error { color: var(--danger); font-size: 13px; font-weight: 600; margin: 10px 0 0; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; margin-top: 18px; }
.subcard {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.subcard h3 { margin: 0 0 10px; font-size: 15px; color: var(--navy); }
.output-body { font-size: 13.5px; color: var(--ink); }
.status-tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; margin-bottom: 8px; }
.status-clear { background: #dcfce7; color: #166534; }
.status-ext { background: #fef3c7; color: #92400e; }
.reroute-item { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; }
.reroute-item:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.stamp-vault { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.stamp-card {
  background: #f0f9ff;
  border: 1px solid #7dd3fc;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13.5px;
}
.stamp-card code { font-size: 12px; word-break: break-all; background: #e0f2fe; padding: 2px 5px; border-radius: 4px; }
.facts-list { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.site-footer { padding: 0 20px 32px; color: var(--muted); font-size: 13px; }
.site-footer a { color: var(--cobalt); }
.panel { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; max-width: 560px; margin: 20px auto; }
.confirmation { background: #f0fdf4; border: 1px solid #86efac; border-radius: 12px; padding: 18px 20px; max-width: 560px; margin: 20px auto; }
.write-form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.write-form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; }
.write-form input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.write-actions { display: flex; gap: 10px; margin-top: 8px; }
.btn-secondary { background: transparent; color: var(--navy); border: 1px solid var(--border); border-radius: 8px; padding: 9px 14px; font-size: 14px; font-weight: 600; cursor: pointer; }

/* Assistant layout & official runtime styling */
.assistant { margin-top: 4px; }
#agent-app {
  --ns-font: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --ns-bg: #ffffff;
  --ns-fg: #0f172a;
  --ns-primary: #0f294a;
  --ns-accent: #1d4ed8;
  --ns-border: #cbd5e1;
  --ns-panelbg: #ffffff;
  --ns-msgbg: #f1f5f9;
  --ns-muted: #475569;
}
.assistant-panels { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 16px; margin-top: 16px; }
#agent-app.ns-composed-app [data-ns-slot="chat"] { height: 640px; }
#agent-app .ns-chat { background: var(--ns-bg); }
#agent-app input[type="checkbox"], #agent-app input[type="radio"] { width: auto; }
#agent-app .ns-header { flex-wrap: wrap; }
#agent-app .ns-settings-body label { margin: 4px 0; font-weight: 400; }
#agent-app .ns-w-label { font-family: inherit; }
#agent-app .ns-widget label { margin: 0; }
#agent-app .ns-w-radio label, #agent-app .ns-w-multi label, #agent-app .ns-w-toggle { font-weight: 400; }
#agent-app .ns-w-toggle { font-size: 13px; }
#agent-app button { margin: 0; }
#agent-app .ns-w-choice { color: var(--ns-fg); }
#agent-app .ns-devtoggle:not(.on):hover, #agent-app .ns-modal-close:hover { background: transparent; }
#agent-app .ns-w-choice:disabled:hover { background: #fafbfc; }
#agent-app .ns-consent { background: #fffbeb; }
#agent-app .ns-msgs:has(.ns-consent-actions) > .ns-turn-status { display: none; }
#agent-app .ns-msg { overflow-wrap: break-word; }
#agent-app .ns-consent-actions { flex-wrap: wrap; }
#agent-app .ns-consent-actions button { white-space: nowrap; }

body > dialog h2 { margin: 0 0 12px; font: 700 1.25em system-ui, sans-serif; }
body > dialog button { margin-right: 8px; }
.assistant-review { max-width: 640px; width: 85%; max-height: 85vh; overflow: auto; border: 1px solid #888; border-radius: 12px; padding: 24px; font: 16px system-ui, sans-serif; }
.assistant-review dl { display: grid; grid-template-columns: fit-content(40%) 1fr; gap: 4px 16px; margin: 12px 0; }
.assistant-review dt { font-weight: 600; }
.assistant-review dd { margin: 0; overflow-wrap: anywhere; }
.assistant-review details { margin: 12px 0; }
.assistant-review pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.assistant-review .assistant-decline { background: transparent; color: inherit; border: 1px solid currentColor; }

@media (max-width: 760px) {
  .assistant-panels { grid-template-columns: 1fr; }
  .assistant-review dl { grid-template-columns: 1fr; gap: 0; }
  .assistant-review dd { margin-bottom: 8px; }
}
