:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #202832;
  --muted: #66788a;
  --border: #d8dee6;
  --primary: #235a8f;
  --primary-dark: #1b456d;
  --danger: #a63232;
  --success: #287a4b;
  --warning: #946200;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); }
.topbar nav { display: flex; gap: 18px; align-items: center; }

.container { max-width: 1120px; margin: 28px auto; padding: 0 20px; }
.narrow { max-width: 460px; margin: 64px auto; }
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}
h1 { font-size: 28px; margin: 0; }
h2 { font-size: 18px; margin: 0 0 14px; }
.muted { color: var(--muted); margin: 4px 0 0; }

.panel, .form-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
}
.panel-inner {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafbfc;
  margin: 4px 0 14px;
}
.mail-preview {
  margin: 12px 0 16px;
  padding: 14px;
  min-height: 180px;
  white-space: pre-wrap;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafbfc;
  color: var(--text);
  font: 15px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.mail-template-editor {
  min-height: 220px;
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 29, 38, .45);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(720px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(20, 29, 38, .2);
}
.modal-header { margin-bottom: 12px; }
.template-choice-list { display: grid; gap: 10px; }
.template-choice {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 12px;
  text-align: left;
}
.template-choice strong,
.template-choice span {
  display: block;
}
.template-choice span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}
.logo-preview-block {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
}
.company-logo-preview {
  width: 180px;
  height: 96px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #253844;
  display: flex;
  align-items: center;
  justify-content: center;
}
.company-logo-preview img {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: #44515f; font-size: 13px; background: #fafbfc; }
.actions, .button-row { display: flex; gap: 10px; align-items: center; }

label { display: block; font-weight: 600; margin-bottom: 12px; }
.field-help {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
}
input, select, textarea {
  width: 100%;
  margin-top: 5px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: #ffffff;
}
textarea { resize: vertical; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; margin: 0 12px 0 0; }
.checkbox input { width: auto; margin: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.checkbox-card {
  min-height: 62px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
}

.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.button.primary, button.primary { background: var(--primary); border-color: var(--primary); color: #ffffff; }
.button.primary:hover, button.primary:hover { background: var(--primary-dark); text-decoration: none; }
.button.secondary { color: var(--text); }
.link-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 0;
  min-height: auto;
}
.inline-form { display: inline; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 12px 0; }
.inline-actions label { margin: 0; min-width: 110px; }
.form-actions { display: flex; gap: 10px; margin-top: 10px; }
.full-width { flex-basis: 100%; width: 100%; }

.messages { margin-bottom: 18px; }
.message {
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  background: #ffffff;
}
.message.success { border-color: #b8d8c5; color: var(--success); }
.message.error { border-color: #e5b7b7; color: var(--danger); }
.message.warning { border-color: #efd391; color: var(--warning); }
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef1f4;
  color: #52636c;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.status-pill.success { background: #e6f3ec; color: var(--success); }
.status-pill.error { background: #f8e8e8; color: var(--danger); }
.status-pill.warning, .status-pill.skipped { background: #fff4d9; color: var(--warning); }
.status-pill.started, .status-pill.finished { background: #e8f0f7; color: var(--primary); }
.status-pill.muted { color: var(--muted); }

@media (max-width: 760px) {
  .topbar, .page-header { align-items: flex-start; flex-direction: column; }
  .topbar nav { flex-wrap: wrap; gap: 12px; }
  .grid-3, .grid-2, .logo-preview-block { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
}
