:root {
  --bg: #f6f3ed;
  --panel: #fff;
  --line: #d9dee7;
  --text: #17191f;
  --muted: #65707f;
  --accent: #186c5c;
  --accent-dark: #115247;
  --bad: #aa3b31;
  --ok: #17663a;
  --soft: #eef1f4;
}

* { box-sizing: border-box; }

html { font-size: 14px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

header {
  min-height: 70px;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

header span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
  margin-top: 2px;
}

nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 800;
}

main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 64px;
}

.panel,
.stats div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.hidden {
  display: none !important;
}

h1,
h2,
p {
  margin-top: 0;
  letter-spacing: 0;
}

h1,
h2 {
  margin-bottom: 16px;
}

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

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

.login-panel {
  max-width: 980px;
}

label {
  color: var(--muted);
  font-size: 0.92rem;
}

input,
select,
textarea {
  display: block;
  width: 100%;
  min-height: 40px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input[type="checkbox"] {
  display: inline-grid;
  width: 18px;
  min-height: 18px;
  margin: 0;
}

.checkbox-label {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 750;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 9px 14px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button.ghost {
  background: #263142;
}

.status {
  min-height: 22px;
  margin-top: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.status.ok {
  color: var(--ok);
}

.status.bad {
  color: var(--bad);
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.stats span {
  color: var(--muted);
  font-size: 0.92rem;
}

.stats strong {
  display: block;
  margin-top: 6px;
  font-size: 2rem;
}

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

.user-row {
  display: grid;
  grid-template-columns: 80px 1fr 120px 1.5fr;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fbfcfd;
}

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

.templates-panel {
  margin-top: 16px;
}

.template-workspace {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}

.template-list {
  display: grid;
  gap: 8px;
}

.template-row {
  width: 100%;
  min-height: 72px;
  padding: 10px;
  display: grid;
  gap: 2px;
  justify-items: start;
  text-align: left;
  background: #fbfcfd;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.template-row:hover,
.template-row.selected {
  background: var(--soft);
}

.template-row span,
.template-row small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.template-form {
  display: grid;
  gap: 12px;
}

.template-form.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.prompts-grid {
  align-items: stretch;
}

@media (max-width: 900px) {
  header,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar,
  .stats,
  .user-row,
  .template-workspace,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
