:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --text: #17202a;
  --muted: #6b7280;
  --line: #d9e0e7;
  --primary: #176b87;
  --primary-dark: #0f5268;
  --success: #16805a;
  --warning: #a15c07;
  --danger: #b42318;
  --shadow: 0 12px 30px rgba(23, 32, 42, 0.08);
}

* {
  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;
  line-height: 1.5;
}

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

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

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

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

label {
  display: grid;
  gap: 8px;
  color: #344054;
  font-weight: 600;
}

code {
  background: var(--surface-2);
  border-radius: 6px;
  padding: 2px 5px;
}

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

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

th {
  color: #475467;
  font-size: 12px;
  text-transform: uppercase;
}

.shell {
  min-height: 100vh;
  display: flex;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  font-size: 16px;
}

.brand.standalone {
  margin-bottom: 22px;
}

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

.nav {
  display: grid;
  gap: 8px;
  margin-top: 28px;
}

.nav a {
  border-radius: 8px;
  color: #344054;
  padding: 10px 12px;
}

.nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.sidebar-footer {
  margin-top: auto;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 34px;
}

.auth-content {
  width: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(880px, 100%);
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 42px;
  align-items: center;
}

.auth-panel h1,
.page-header h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
}

.form-card,
.panel,
.table-card,
.published-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.form-card,
.panel,
.published-panel {
  padding: 22px;
}

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

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.muted,
small {
  color: var(--muted);
  font-weight: 500;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #344054;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

.button:hover {
  border-color: #b9c5d2;
}

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

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

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

.button.danger {
  color: var(--danger);
}

.button.ghost {
  width: 100%;
}

.button.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.button-row,
.row-actions,
.copy-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

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

.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
}

.stat span {
  display: block;
  font-size: 30px;
  font-weight: 800;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 12px;
}

.section-title h2,
.panel h2 {
  margin: 0;
  font-size: 18px;
}

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

.table-card.embedded {
  box-shadow: none;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: #475467;
  padding: 4px 8px;
  margin: 2px;
  font-size: 12px;
  font-weight: 700;
}

.badge.success {
  background: #e4f5ee;
  color: var(--success);
}

.badge.warning {
  background: #fff3df;
  color: var(--warning);
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 18px;
}

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

.form-actions {
  display: flex;
  gap: 10px;
  grid-column: 1 / -1;
}

.form-actions.vertical {
  display: grid;
  margin-top: 20px;
}

.check-grid,
.module-list {
  display: grid;
  gap: 10px;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
}

.check input {
  width: auto;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
}

.editor-main,
.editor-side {
  min-width: 0;
}

.editor-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 16px 0;
}

.editor-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  min-height: 560px;
}

.editor-split textarea {
  min-height: 560px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.preview {
  min-height: 560px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
}

.module-item {
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

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

.notice.warning {
  background: #fff3df;
  color: var(--warning);
  border: 1px solid #f7d8a7;
}

.flash-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.flash {
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  color: #344054;
}

.flash.success {
  background: #e4f5ee;
  color: var(--success);
}

.flash.danger {
  background: #fee4e2;
  color: var(--danger);
}

.flash.warning {
  background: #fff3df;
  color: var(--warning);
}

.published-panel {
  max-width: 760px;
  margin: 60px auto;
  display: grid;
  gap: 16px;
}

.success-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 10px;
  background: #e4f5ee;
  color: var(--success);
  font-weight: 900;
}

.copy-row input {
  flex: 1;
  min-width: 240px;
}

.markdown-body {
  line-height: 1.75;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  line-height: 1.25;
}

.markdown-body table {
  margin: 18px 0;
  border: 1px solid var(--line);
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--line);
}

.public-body {
  background: #fff;
}

.public-page {
  width: min(860px, calc(100% - 32px));
  margin: 0 auto;
  padding: 38px 0 80px;
}

.public-header {
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 22px;
  margin-bottom: 24px;
}

.public-header h1 {
  margin: 0;
  font-size: 32px;
}

.app-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
}

@media (max-width: 980px) {
  .shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 16px;
  }

  .nav {
    display: flex;
    margin-top: 0;
  }

  .sidebar-footer {
    margin-left: auto;
    margin-top: 0;
  }

  .stats-grid,
  .two-column,
  .form-grid,
  .editor-layout,
  .editor-split,
  .auth-panel {
    grid-template-columns: 1fr;
  }

  .field-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .content {
    padding: 20px;
  }

  .page-header {
    display: grid;
  }

  .sidebar {
    display: grid;
  }

  .nav {
    flex-wrap: wrap;
  }
}
