/* General Layout */
body {
  font-family: system-ui, -apple-system, sans-serif;
  background-color: #f8f9fa;
  margin: 0;
  padding: 0;
  color: #212529;
}

header, footer {
  background: #003366;
  color: #fff;
  padding: 1rem 2rem;
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
}

nav a {
  color: #fff;
  text-decoration: none;
  margin-left: 1rem;
  font-weight: bold;
  border-radius: 4px;
  padding: 0.25rem 0.45rem;
}

nav a:hover {
  text-decoration: underline;
}

nav a[aria-current="page"] {
  background: #ffffff;
  color: #003366;
}

nav a[aria-current="page"]:hover {
  text-decoration: none;
}

.module-links {
  margin-top: 0.75rem;
  display: flex;
  gap: 1rem;
  font-weight: 600;
}

.module-links a {
  color: #003366;
  text-decoration: none;
}

.module-links a[aria-current="page"] {
  text-decoration: underline;
}

main {
  padding: 2rem;
}

/* Container */
.container {
  max-width: 960px;
  margin: auto;
  background: #ffffff;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Forms */
form label {
  display: block;
  margin-top: 1rem;
  font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  max-width: 400px;
  padding: 0.5rem;
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

input[type="checkbox"] {
  margin-left: 0.5rem;
}

.filter-options {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid #d0d7de;
  border-radius: 6px;
}

.filter-options label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.filter-options input[type="checkbox"] {
  margin-left: 0;
}

.filter-options label:has(input:disabled) {
  color: #6c757d;
}

button {
  padding: 0.5rem 1rem;
  margin-top: 1rem;
  border: none;
  background-color: #0069d9;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  background-color: #0056b3;
}

.button-secondary {
  background-color: #e9ecef;
  color: #212529;
  border: 1px solid #ced4da;
}

.button-secondary:hover {
  background-color: #dee2e6;
}

.button-danger {
  background-color: #b42318;
}

.button-danger:hover {
  background-color: #8f1d14;
}

textarea {
  max-width: 600px;
  resize: vertical;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.comms-fieldset {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid #d0d7de;
  border-radius: 6px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.5rem 1rem;
  margin-top: 0.5rem;
  width: 100%;
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.checkbox-grid em {
  grid-column: 1 / -1;
}

.checkbox-section {
  margin-top: 1rem;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.editor-toolbar button {
  background-color: #e9ecef;
  color: #212529;
  border: 1px solid #ced4da;
  padding: 0.4rem 0.6rem;
  margin-top: 0;
}

.editor-toolbar button:hover {
  background-color: #dee2e6;
}

.rich-editor {
  border: 1px solid #ced4da;
  border-radius: 4px;
  padding: 0.75rem;
  min-height: 360px;
  background: #fff;
}

.rich-editor-preview {
  overflow: auto;
}

.rich-editor-preview table {
  margin-top: 0;
  font-size: inherit;
}

.rich-editor-preview td {
  border: 0;
}

.rich-editor-preview tr:nth-child(even) {
  background-color: transparent;
}

.compose-fields {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
  max-width: 760px;
}

.compose-fields textarea {
  max-width: 760px;
}

.compose-section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.compose-sections {
  display: grid;
  gap: 1rem;
}

.compose-section {
  padding: 0 0 1.25rem;
}

.compose-section-header {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  gap: 0.75rem;
}

.compose-section-header label {
  margin-top: 0;
}

.template-builder-controls {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.template-builder-controls label {
  margin-top: 0;
}

.template-builder-controls select {
  max-width: 260px;
}

.template-builder-controls input {
  max-width: 220px;
}

.wildcard-palette,
.html-insert-tools,
.composer-wildcards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}

.wildcard-palette button,
.html-insert-tools button,
.composer-wildcards button {
  background-color: #e9ecef;
  color: #212529;
  border: 1px solid #ced4da;
  padding: 0.35rem 0.55rem;
  margin-top: 0;
}

.template-builder-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
  gap: 1rem;
  align-items: start;
}

.template-source {
  width: 100%;
  max-width: none;
  min-height: 360px;
  font-family: Consolas, Monaco, monospace;
  font-size: 0.9rem;
}

.template-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.template-list-item {
  text-align: left;
  background: #fff;
  color: #212529;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 0.8rem;
}

.template-list-item:hover {
  background: #f6f8fa;
}

.template-list-item strong,
.template-list-item span {
  display: block;
}

.template-list-item span {
  margin-top: 0.25rem;
  color: #5b5b5b;
  font-size: 0.85rem;
}

.editor-hint {
  font-size: 0.85rem;
  color: #5b5b5b;
}

.jobs-limit-grid {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.jobs-metric {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.jobs-metric strong {
  display: block;
  font-size: 0.78rem;
  color: #5b5b5b;
  text-transform: uppercase;
}

.jobs-metric span {
  display: block;
  margin-top: 0.25rem;
  font-size: 1rem;
  font-weight: 700;
}

.jobs-toolbar {
  display: flex;
  align-items: end;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.jobs-toolbar label,
.jobs-run-controls label {
  margin-top: 0;
}

.jobs-toolbar select {
  max-width: 180px;
}

.inline-form {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1rem 0;
}

.inline-form label {
  margin-top: 0;
}

.list-column-chooser {
  margin: 0.75rem 0 1rem;
  padding: 0.75rem;
  border: 1px solid #d0d7de;
  border-radius: 6px;
}

.list-column-chooser legend,
.list-interest-editor legend {
  font-weight: 700;
}

.list-interest-editor {
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.45rem 1rem;
  margin: 0;
  padding: 0.75rem;
  border: 1px solid #d0d7de;
  border-radius: 6px;
}

.list-interest-editor label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.list-interest-editor input[type="checkbox"],
.list-column-chooser input[type="checkbox"] {
  margin-left: 0;
}

.compose-list-interest-filter {
  display: block;
  margin: 0.75rem 0;
}

.compose-list-interest-filter .checkbox-grid {
  margin-top: 0.5rem;
}

#queue-status {
  margin: 0 0 0 auto;
  color: #5b5b5b;
}

.job-progress {
  height: 10px;
  background: #e9ecef;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.6rem;
}

.job-progress span {
  display: block;
  height: 100%;
  background: #0069d9;
}

.job-status {
  display: inline-block;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  background: #e9ecef;
  color: #212529;
  font-size: 0.8rem;
  font-weight: 700;
}

.jobs-attempts table {
  margin-top: 0.5rem;
}

.jobs-table tr[data-job-id] {
  cursor: pointer;
}

@media (max-width: 900px) {
  .compose-section-header {
    grid-template-columns: 1fr;
  }

  .template-builder-grid {
    grid-template-columns: 1fr;
  }

  #queue-status {
    width: 100%;
    margin-left: 0;
  }
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.5rem;
  font-size: 0.95rem;
}

th {
  background-color: #003366;
  color: white;
  padding: 0.75rem;
  text-align: left;
}

td {
  padding: 0.5rem;
  border: 1px solid #ccc;
}

tr:nth-child(even) {
  background-color: #f2f2f2;
}

.jobs-table tr.is-selected,
.jobs-table tr.is-selected:nth-child(even) {
  background-color: #dbeafe;
  outline: 2px solid #0069d9;
  outline-offset: -2px;
}

.jobs-table tr.is-selected td,
.jobs-table tr.is-selected:nth-child(even) td {
  background-color: #dbeafe;
}

/* Footer */
footer {
  text-align: center;
  font-size: 0.85rem;
  margin-top: 2rem;
}
