:root {
  --bg: #f4f7f2;
  --panel: #ffffff;
  --text: #203125;
  --muted: #5b6f61;
  --border: #d7e3d9;
  --brand: #2d8e5e;
  --brand-soft: #e5f3eb;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Avenir Next", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(180deg, #eff5f0, var(--bg));
  color: var(--text);
}

code {
  background: #ecf5ef;
  border: 1px solid #d6e6da;
  border-radius: 6px;
  padding: 0 0.35em;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(5px);
  padding: 14px 18px;
}

.brandBlock {
  display: grid;
  gap: 4px;
}

.brandHome {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brandMark {
  border-radius: 9px;
  border: 1px solid #d6e6da;
  background: #f3faf6;
}

.topLinks {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.topLinks a {
  color: var(--muted);
  text-decoration: none;
}

.topLinks a:hover {
  color: var(--text);
  text-decoration: underline;
}

.title { font-size: 21px; font-weight: 780; }
.subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 8px 22px rgba(33, 52, 39, 0.07);
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.row-space { justify-content: space-between; }

.pill {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f7fbf8;
  color: var(--muted);
  font-size: 12px;
}

.btn {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  color: var(--text);
  padding: 8px 12px;
  font-weight: 620;
  cursor: pointer;
}

.btn:hover { border-color: #b8d1bf; }
.btn:disabled { opacity: 0.58; cursor: not-allowed; }

.btn-primary {
  border-color: #92c3a8;
  background: linear-gradient(135deg, var(--brand-soft), #f0fbf5);
}

.btn-ghost { background: #f7fbf8; }

.form {
  display: grid;
  gap: 10px;
}

.form-inline {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form label {
  display: grid;
  gap: 5px;
}

input, select, textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  font: inherit;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: #82ba9a;
  box-shadow: 0 0 0 3px rgba(45, 142, 94, 0.14);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.kpi {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #fbfefc;
}

.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { margin-top: 6px; font-size: 22px; font-weight: 760; }

.muted { color: var(--muted); }
.small { font-size: 12px; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th, td {
  border-bottom: 1px solid #edf3ee;
  padding: 9px 10px;
  text-align: left;
  font-size: 13px;
}

th {
  background: #f7fbf8;
  color: #4d6657;
  font-weight: 700;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.tag {
  display: inline-flex;
  border: 1px solid #d3e4da;
  background: #edf6f0;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
}

.ai-thread {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.ai-row {
  display: flex;
}

.ai-row.assistant {
  justify-content: flex-start;
}

.ai-row.user {
  justify-content: flex-end;
}

.ai-bubble {
  max-width: min(100%, 780px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 11px;
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 14px;
}

.ai-row.assistant .ai-bubble {
  background: #f4faf6;
}

.ai-row.user .ai-bubble {
  background: #e9f5ee;
}

@media (max-width: 980px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
}
