:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1c2430;
  --muted: #687383;
  --line: #dfe4ea;
  --primary: #226c5f;
  --primary-dark: #194f47;
  --warn: #a65f00;
  --error: #b42318;
  --ok: #12715b;
  --shadow: 0 10px 25px rgba(28, 36, 48, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button,
.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  cursor: pointer;
}

button:hover {
  border-color: #b7c0cb;
}

.button {
  background: #fff;
}

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

.primary:hover {
  background: var(--primary-dark);
}

.wide {
  width: 100%;
}

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid var(--line);
  padding: 18px;
  background: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.brand-mark {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

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

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

.nav a,
.logout button {
  display: block;
  width: 100%;
  border-radius: 6px;
  padding: 10px 12px;
  text-align: left;
  color: var(--muted);
}

.nav a:hover,
.logout button:hover {
  color: var(--text);
  background: #eef3f2;
}

.sidebar-note {
  display: grid;
  gap: 4px;
  border: 1px solid #d7e6e1;
  border-radius: 8px;
  margin-top: 18px;
  padding: 12px;
  background: #f4faf7;
}

.sidebar-note span {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-note strong {
  font-size: 13px;
}

.logout {
  margin-top: auto;
}

.logout button {
  border: 0;
  background: transparent;
}

.main {
  min-width: 0;
  padding: 28px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-subtitle {
  max-width: 680px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
}

h3 {
  margin-bottom: 8px;
  font-size: 14px;
}

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

.metrics article,
.panel,
.item,
.login-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metrics article {
  padding: 16px;
}

.metrics small {
  display: block;
  margin-bottom: 8px;
}

.metrics span {
  display: block;
  font-size: 28px;
  font-weight: 800;
}

.metrics small,
.row span,
.item footer,
.summary {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.panel-head.stacked {
  display: grid;
  gap: 6px;
}

.panel-head.stacked p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.panel-head a {
  color: var(--primary);
  font-size: 14px;
}

.list {
  display: grid;
}

.row {
  display: grid;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
}

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

.row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.message {
  border: 1px solid #bdd7ce;
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ok);
  background: #eff9f5;
}

.message.error {
  border-color: #f3b8b3;
  color: var(--error);
  background: #fff2f0;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
}

.inline-form {
  display: flex;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--text);
  background: #fff;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

td a {
  color: var(--primary);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.pill,
.score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  color: var(--primary);
  background: #e6f3ef;
  font-size: 12px;
  font-weight: 700;
}

.pill.warn {
  color: var(--warn);
  background: #fff3df;
}

.score {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  padding: 0;
  color: #fff;
  background: var(--primary);
}

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

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

.topic-list,
.draft-list {
  display: grid;
  gap: 14px;
}

.item {
  padding: 16px;
}

.item header,
.item footer {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.item header > div {
  display: flex;
  min-width: 0;
  gap: 12px;
  align-items: center;
}

.item p {
  margin: 12px 0;
  line-height: 1.65;
}

.draft-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
}

pre {
  overflow: auto;
  max-height: 420px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 0;
  padding: 12px;
  white-space: pre-wrap;
  line-height: 1.6;
  background: #f9fafb;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.form-stack {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.form-stack label,
.form-stack div {
  display: grid;
  gap: 6px;
}

.form-stack span,
.form-stack label {
  color: var(--muted);
  font-size: 14px;
}

.compact-list {
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  color: var(--muted);
  font-size: 13px;
}

.empty {
  margin: 0;
  padding: 18px;
  color: var(--muted);
}

.empty-state {
  display: grid;
  gap: 7px;
  padding: 18px;
  color: var(--muted);
}

.empty-state strong {
  color: var(--text);
}

.empty-state a {
  width: fit-content;
  color: var(--primary);
  font-weight: 700;
}

.empty-state.compact {
  min-height: 108px;
}

.setup-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 2fr);
  gap: 18px;
  border: 1px solid #cfe0da;
  border-radius: 8px;
  margin-bottom: 16px;
  padding: 18px;
  background: #f7fbf9;
  box-shadow: var(--shadow);
}

.setup-panel h2 {
  margin-bottom: 8px;
  font-size: 22px;
}

.setup-panel p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.setup-steps a {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fff;
}

.setup-steps a:hover {
  border-color: #b9cbc4;
}

.setup-steps span {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.setup-steps small {
  color: var(--muted);
  line-height: 1.45;
}

.setup-steps .done {
  border-color: #b7ded2;
  background: #eef8f4;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: #eef2f4;
}

.login-panel {
  width: min(420px, 100%);
}

.login-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.login-brand h1 {
  font-size: 22px;
}

.login-brand p {
  margin: 2px 0 0;
  color: var(--muted);
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metrics,
  .two,
  .settings-grid,
  .setup-panel,
  .draft-grid {
    grid-template-columns: 1fr;
  }

  .setup-steps {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 18px;
  }
}

@media (max-width: 640px) {
  .page-head,
  .item header,
  .item footer,
  .inline-form,
  .head-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actions {
    justify-content: flex-start;
  }

  .table-panel {
    overflow-x: auto;
  }
}
