* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:root {
  --bg: #edf0f4;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #1f2933;
  --muted: #6b7280;
  --line: #d9dee7;
  --line-strong: #b9c2d0;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #b42318;
  --success: #0f7a45;
}

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

button,
input,
textarea {
  font: inherit;
}

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

button:hover {
  border-color: var(--accent);
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

button.active,
button[type="submit"] {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

button[type="submit"]:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.25;
}

h2 {
  font-size: 15px;
  line-height: 1.35;
}

label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 650;
  color: #344054;
}

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

input:focus,
textarea:focus {
  outline: 2px solid rgba(37, 99, 235, .2);
  border-color: var(--accent);
}

textarea {
  resize: vertical;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  table-layout: fixed;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid #edf0f5;
  padding: 10px 12px;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  color: #475467;
  font-size: 12px;
  font-weight: 700;
  background: #f8fafc;
}

tbody tr:hover {
  background: #f6f9ff;
}

tbody tr.selected {
  background: #eaf1ff;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
}

.login form {
  width: 380px;
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(31, 41, 51, .08);
}

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

.sidebar {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.brand {
  display: grid;
  gap: 4px;
  padding: 0 6px 18px;
  border-bottom: 1px solid var(--line);
}

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

.brand span,
.section-title span,
.subhead span,
.hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

nav button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border-color: transparent;
  background: transparent;
}

nav button.active {
  background: #eaf1ff;
  color: #174ea6;
  border-color: #c8d8ff;
}

.secondary {
  background: #ffffff;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

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

.topbar p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.statusline {
  min-width: 280px;
  display: grid;
  justify-items: end;
  gap: 4px;
  font-size: 13px;
  line-height: 1.35;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(31, 41, 51, .04);
}

.panel-soft,
.table-panel,
.editor-panel,
.preview-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel-soft);
}

.section-title,
.subhead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

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

.grid.tight {
  gap: 10px;
}

.stack {
  display: grid;
  gap: 14px;
}

.wide {
  grid-column: 1 / -1;
}

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

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check input {
  width: auto;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 12px 0 0;
}

.toolbar input[type="file"] {
  max-width: 320px;
  background: #ffffff;
}

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

.metrics article {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfe;
}

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

.metrics strong {
  font-size: 28px;
  line-height: 1;
}

.template-workbench {
  display: grid;
  grid-template-columns: 330px minmax(420px, 1fr) 420px;
  gap: 16px;
  align-items: start;
}

.template-list,
.preview-panel {
  max-height: calc(100vh - 154px);
  overflow: auto;
}

.template-list table {
  margin-bottom: 18px;
}

.template-list th:nth-child(1),
.template-list td:nth-child(1) {
  width: 46px;
}

.template-list th:nth-child(4),
.template-list td:nth-child(4) {
  width: 82px;
}

.import-box {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.editor-panel {
  background: #ffffff;
}

#template-html {
  min-height: 390px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
}

iframe {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
}

pre {
  min-height: 118px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #ffffff;
  color: #344054;
  font-size: 13px;
}

.preview-panel h2 {
  margin: 16px 0 8px;
}

.link-button {
  min-height: auto;
  max-width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  text-align: left;
  overflow-wrap: anywhere;
}

.link-button:hover {
  text-decoration: underline;
}

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

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

.hint {
  margin: 0;
}
