:root {
  color-scheme: light;
  --bg: #f5f6f2;
  --panel: #ffffff;
  --ink: #1f2520;
  --muted: #687169;
  --line: #d9ded8;
  --accent: #2f6f4e;
  --accent-strong: #25593f;
  --warn: #b44932;
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--accent-strong);
  text-decoration: none;
}

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
}

.topbar nav {
  display: flex;
  gap: 8px;
}

.topbar nav a,
.tabs a,
button,
.primary,
.actions-grid a {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  min-height: 40px;
  padding: 9px 14px;
  place-items: center;
}

button,
.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  cursor: pointer;
}

button:hover,
.primary:hover {
  background: var(--accent-strong);
}

.shell {
  margin: 0 auto;
  max-width: 1180px;
  padding: 28px;
}

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

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 20px;
  margin-bottom: 14px;
}

p {
  color: var(--muted);
  line-height: 1.5;
  margin: 8px 0 0;
}

.login-panel,
.error-box,
.record-form,
.domain-editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.login-panel {
  margin: 80px auto;
  max-width: 420px;
}

.password-panel {
  margin-top: 0;
}

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

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

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

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  min-height: 42px;
  padding: 9px 11px;
  width: 100%;
}

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

.stats,
.actions-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 22px;
}

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

.stats strong {
  display: block;
  font-size: 30px;
}

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

.filters,
.domain-form {
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr auto;
  margin-bottom: 18px;
  padding: 16px;
}

.search-form {
  grid-template-columns: 1.2fr 1.2fr auto;
}

.search-results {
  display: grid;
  gap: 14px;
}

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

.result-item header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.result-item header div {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.result-item header span {
  color: var(--muted);
}

.result-item h2 {
  margin-bottom: 10px;
}

.result-text {
  border-top: 1px solid var(--line);
  line-height: 1.55;
  padding-top: 12px;
}

.result-text p,
.result-text ul,
.result-text ol {
  margin: 0 0 10px;
}

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

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

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

th {
  background: #eef2ed;
  font-size: 13px;
  text-transform: uppercase;
}

.row-actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.inline-form {
  margin: 0;
}

.row-actions a,
.row-actions button {
  background: #ffffff;
  color: var(--accent-strong);
  min-height: 34px;
  padding: 6px 10px;
}

.notice {
  border-radius: 8px;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.notice.success {
  background: #e6f3eb;
  color: #21563a;
}

.notice.error {
  background: #fae8e3;
  color: var(--warn);
}

.record-form {
  display: grid;
  gap: 24px;
}

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

.checkbox-grid label,
.toggle {
  align-items: center;
  color: var(--ink);
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.checkbox-grid input,
.toggle input {
  min-height: auto;
  width: auto;
}

.section-title,
.odg-head,
.form-actions,
.tabs {
  align-items: center;
  display: flex;
  gap: 10px;
}

.section-title {
  justify-content: space-between;
}

.odg-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 14px;
}

.odg-head {
  align-items: end;
}

.odg-picker {
  display: grid;
  flex: 1;
  gap: 8px;
}

.editor-toolbar {
  align-items: center;
  background: #eef2ed;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px;
}

.editor-toolbar button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
  justify-content: center;
  min-height: 32px;
  min-width: 36px;
  padding: 5px 8px;
}

.html-editor {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  line-height: 1.55;
  min-height: 180px;
  outline: none;
  overflow-wrap: anywhere;
  padding: 12px;
}

.html-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 78, 0.14);
}

.html-editor:empty::before {
  color: var(--muted);
  content: attr(placeholder);
}

.html-editor p,
.html-editor ul,
.html-editor ol {
  margin: 0 0 10px;
}

.tabs {
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tabs a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.domain-form {
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
}

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

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

pre {
  background: #1f2520;
  border-radius: 8px;
  color: #ffffff;
  overflow: auto;
  padding: 14px;
}

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

  .shell {
    padding: 18px;
  }

  .cols-3,
  .stats,
  .actions-grid,
  .filters,
  .search-form,
  .domain-form,
  .checkbox-grid {
    grid-template-columns: 1fr;
  }
}
