:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-muted: #f8faf9;
  --ink: #15211d;
  --muted: #60706a;
  --brand: #087466;
  --brand-strong: #04564c;
  --brand-accent: #23a35a;
  --accent: #a8c84c;
  --danger: #a12a2a;
  --danger-soft: #fff4f2;
  --line: #d9e1de;
  --line-strong: #c6d1cd;
  --shadow: 0 12px 28px rgba(18, 38, 32, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
}

body {
  font-family: "Outfit", "Segoe UI", sans-serif;
  line-height: 1.45;
}

.layout {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 28px 20px 56px;
  display: grid;
  gap: 16px;
}

.hero,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding: 22px;
  border-top: 4px solid var(--brand);
}

.kicker {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
}

h1,
h2,
h3 {
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: clamp(2rem, 4vw, 2.8rem);
  margin-top: 4px;
}

.brand-word {
  color: var(--ink);
}

.brand-accent-d {
  color: var(--brand-accent);
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1.05rem;
}

.subhead {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 58ch;
}

.auth-actions,
.panel-actions,
.privacy-actions,
.history-card-actions,
.result-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.auth-actions {
  justify-content: flex-end;
  min-width: 180px;
}

.panel {
  padding: 18px;
}

.panel-chat {
  border-top: 3px solid var(--brand);
}

.panel-history,
.panel-analytics {
  border-top: 3px solid #7e9950;
}

.panel-account {
  border-top: 3px solid var(--danger);
  background: var(--danger-soft);
}

.panel-disclaimer {
  background: #f9fbfc;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-head p,
.panel-note {
  margin: 6px 0 0;
  color: var(--muted);
}

.panel-note {
  font-size: 13px;
}

.chat-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.field-label {
  font-weight: 700;
  font-size: 14px;
}

textarea {
  width: 100%;
  min-height: 132px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  padding: 12px;
  font: inherit;
  color: var(--ink);
  resize: vertical;
}

textarea:focus-visible,
.btn:focus-visible,
input:focus-visible {
  outline: 2px solid #7ac7bb;
  outline-offset: 2px;
}

.form-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.example-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.btn {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  font: 700 14px/1 "Outfit", sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.btn:hover:not(:disabled) {
  box-shadow: 0 6px 16px rgba(18, 38, 32, 0.1);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-strong);
}

.btn-ghost {
  background: #f4f7f6;
  color: #243b34;
  border-color: var(--line);
}

.btn-example {
  min-height: 34px;
  padding: 8px 10px;
  background: #eef7f1;
  color: #1c5130;
  border-color: #cde4d3;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger-ghost {
  background: #fffafa;
  color: var(--danger);
  border-color: #e8c9c4;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge-muted {
  background: #edf2ef;
  color: #40534a;
}

.badge-active {
  background: #e7f3d0;
  color: #3e5f1f;
}

.result {
  margin-top: 14px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
  border-radius: 8px;
  padding: 14px;
}

.result h3 {
  margin-bottom: 10px;
}

.result p {
  margin: 10px 0 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}

.status-neutral {
  background: #edf4f1;
  color: #2e5449;
}

.status-danger {
  background: #fde8e4;
  color: var(--danger);
}

.emergency-action {
  border-left: 4px solid var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 800;
  padding: 10px 12px;
  border-radius: 8px;
}

.result ul {
  margin: 6px 0 0 20px;
  padding: 0;
}

.payload-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.payload-grid span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 13px;
}

.payload-grid strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 12px;
}

.analytics-grid,
.analytics-breakdown {
  display: grid;
  gap: 12px;
}

.analytics-grid {
  margin-top: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.analytics-breakdown {
  margin-top: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-card,
.breakdown-card,
.history-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
}

.metric-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.metric-value {
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  font-size: 1.8rem;
}

.breakdown-list,
.history-list {
  list-style: none;
  padding: 0;
}

.breakdown-list {
  margin: 12px 0 0;
  display: grid;
  gap: 8px;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e7ece9;
}

.breakdown-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.history-list {
  margin: 14px 0 0;
  display: grid;
  gap: 10px;
}

.history-card p {
  margin: 8px 0 0;
}

.history-card p:first-child {
  margin-top: 0;
}

.history-card strong {
  display: inline-block;
  margin-right: 8px;
}

.history-card-actions {
  margin-top: 12px;
}

.error,
.success {
  margin-top: 10px;
  font-weight: 700;
}

.error {
  color: var(--danger);
}

.success {
  color: #1f6b3a;
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

@media (max-width: 840px) {
  .layout {
    padding: 20px 14px 44px;
  }

  .hero,
  .panel-head,
  .form-row {
    flex-direction: column;
  }

  .hero,
  .panel {
    padding: 16px;
  }

  .auth-actions,
  .panel-actions,
  .privacy-actions,
  .history-card-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .panel-actions .btn {
    flex: 0 0 auto;
  }

  .form-row,
  .form-row .btn {
    width: 100%;
  }

  .analytics-grid,
  .analytics-breakdown,
  .payload-grid {
    grid-template-columns: 1fr;
  }
}
