:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d8dde6;
  --text: #17202f;
  --muted: #667085;
  --accent: #2857a4;
  --warn: #8a5a00;
  --bad: #9b2c2c;
}

* {
  box-sizing: border-box;
}

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

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

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

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

.session {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 12px;
  cursor: pointer;
}

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

button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.65;
}

.nav {
  display: flex;
  gap: 4px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
  overflow-x: auto;
}

.nav a {
  border-radius: 6px;
  color: var(--muted);
  padding: 8px 10px;
  text-decoration: none;
  white-space: nowrap;
}

.nav a.active {
  background: #eaf0fa;
  color: var(--accent);
}

.layout {
  display: grid;
  gap: 16px;
  padding: 20px;
}

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

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

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

.metric .value {
  margin-top: 8px;
  font-size: 20px;
  font-weight: 650;
}

.review {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--accent);
  background: #eef4ff;
  font-weight: 650;
}

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

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

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

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

.error {
  color: var(--bad);
  min-height: 20px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-panel {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 22px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr auto;
  gap: 12px;
  align-items: end;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  font: inherit;
}

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

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

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.field-block {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.field-block .label {
  color: var(--muted);
  font-size: 12px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.template-preview {
  min-height: 360px;
  margin-top: 12px;
  white-space: pre-wrap;
  line-height: 1.55;
}

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

  .inline-form {
    grid-template-columns: 1fr;
  }
}
