/* === Google Fonts === */
@import url('https://fonts.googleapis.com/css2?family=Ubuntu:wght@400;500;700&family=Ubuntu+Mono&display=swap');

/* === Design tokens === */
:root {
  --cg-blue:        #0070AD;
  --cg-blue-bright: #12ABDB;
  --cg-ink:         #241238;
  --cg-text:        #1F2933;
  --cg-muted:       #64748B;
  --cg-bg:          #FFFFFF;
  --cg-bg-soft:     #F5F8FA;
  --cg-border:      #D8E4EA;
  --cg-shadow:      0 4px 20px rgba(0, 112, 173, 0.09);
  --radius-card:    16px;
  --radius-btn:     999px;
  --radius-input:   10px;
}

[data-theme="dark"] {
  --cg-bg:       #101827;
  --cg-bg-soft:  #162033;
  --cg-text:     #F8FAFC;
  --cg-muted:    #B8C2CC;
  --cg-border:   #2A3A4D;
  --cg-shadow:   0 4px 20px rgba(0, 0, 0, 0.35);
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* === Base === */
body {
  font-family: "Ubuntu", Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--cg-text);
  background: var(--cg-bg-soft);
}

/* === Header === */
header {
  background: var(--cg-ink);
  padding: 0 2rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  position: sticky;
  top: 0;
  z-index: 100;
}
header nav {
  display: flex;
  align-items: center;
  height: 56px;
  gap: 0.6rem;
}
.brand-logo { height: 28px; flex-shrink: 0; display: block; }
.brand-divider {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,0.25);
  margin: 0 1.25rem;
  flex-shrink: 0;
}
.brand-name {
  color: rgba(255,255,255,0.85);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}
.brand-name:hover { color: #fff; }
.nav-spacer { flex: 1; }
.theme-toggle {
  background: none;
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.8);
  border-radius: var(--radius-btn);
  padding: 5px 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
  flex-shrink: 0;
}
.theme-toggle:hover { background: rgba(255,255,255,0.1); color: #fff; border-color: rgba(255,255,255,0.5); }

/* === Main & footer === */
main { max-width: 1280px; margin: 0 auto; padding: 2rem 1.5rem; }
footer {
  text-align: center;
  padding: 1.25rem;
  color: var(--cg-muted);
  font-size: 12px;
  border-top: 1px solid var(--cg-border);
  margin-top: 2rem;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-btn);
  border: 1.5px solid transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--cg-blue);
  color: #fff;
  border-color: var(--cg-blue);
}
.btn-primary:hover { background: #005e92; border-color: #005e92; box-shadow: 0 2px 8px rgba(0,112,173,0.3); }
.btn-secondary {
  background: var(--cg-bg);
  color: var(--cg-blue);
  border-color: var(--cg-border);
}
.btn-secondary:hover { background: var(--cg-bg-soft); border-color: var(--cg-blue); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Page header === */
.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.page-header h1 { flex: 1; font-size: 20px; font-weight: 700; color: var(--cg-text); }

/* === Alerts === */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 1rem; font-size: 13px; }
.alert-error  { background: #fff0f0; border: 1px solid #ffcccc; color: #cc0000; }
.alert-ok     { background: #f0fff4; border: 1px solid #b2f0c9; color: #007700; }
.alert-warn   { background: #fffbe6; border: 1px solid #ffe580; color: #7a5900; }

/* === Status pills === */
.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-btn);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.status-idle      { background: #e8e8e8;  color: #555;    }
.status-running   { background: #e0f4ff;  color: #0055aa; }
.status-succeeded { background: #e0ffe4;  color: #007700; }
.status-failed    { background: #ffe0e0;  color: #cc0000; }

/* === Cards === */
.card {
  background: var(--cg-bg);
  border: 1px solid var(--cg-border);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  box-shadow: var(--cg-shadow);
  margin-bottom: 1.25rem;
}
.card h2 {
  font-size: 11px;
  font-weight: 700;
  color: var(--cg-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--cg-blue-bright);
  display: inline-block;
}
.card textarea {
  width: 100%;
  border: 1.5px solid var(--cg-border);
  border-radius: var(--radius-input);
  font-family: "Ubuntu Mono", "Courier New", monospace;
  font-size: 12.5px;
  padding: 10px 12px;
  resize: vertical;
  margin-bottom: 0.75rem;
  color: var(--cg-text);
  background: var(--cg-bg-soft);
  line-height: 1.65;
  transition: border-color 0.15s, background 0.15s;
  display: block;
}
.card textarea:focus { outline: none; border-color: var(--cg-blue); background: var(--cg-bg); }

/* === Jobs table === */
.jobs-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--cg-bg);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--cg-shadow);
  border: 1px solid var(--cg-border);
}
.jobs-table th {
  background: var(--cg-bg-soft);
  font-size: 11px;
  color: var(--cg-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 18px;
  text-align: left;
  border-bottom: 1px solid var(--cg-border);
}
.jobs-table td { padding: 14px 18px; border-bottom: 1px solid var(--cg-border); font-size: 14px; }
.jobs-table tbody tr:last-child td { border-bottom: none; }

/* Click-to-sort column headers (jobs + admin tables). */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--cg-blue); }
th.sortable.num { text-align: right; }
th.sortable .sort-ind { font-size: 0.85em; opacity: 0.35; margin-left: 2px; }
th.sortable.sorted { color: var(--cg-blue); }
th.sortable.sorted .sort-ind { opacity: 1; }
.jobs-table tbody tr:hover { background: var(--cg-bg-soft); transition: background 0.1s; }
.jobs-table a { color: var(--cg-blue); text-decoration: none; font-weight: 500; }
.jobs-table a:hover { text-decoration: underline; }

.empty-state { text-align: center; padding: 4rem 2rem; color: var(--cg-muted); }
.empty-state p { margin-bottom: 1.5rem; font-size: 15px; }

/* === Jobs filter (page header dropdown) === */
.jobs-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 13px;
  color: var(--cg-muted);
}
.jobs-filter-label { font-weight: 500; }
.jobs-filter-select {
  font-family: inherit;
  font-size: 13px;
  padding: 5px 10px;
  border: 1px solid var(--cg-border);
  border-radius: var(--radius-btn);
  background: var(--cg-bg);
  color: var(--cg-text);
  cursor: pointer;
}
.jobs-filter-select:hover { border-color: var(--cg-blue); }
.jobs-filter-select:focus { outline: none; border-color: var(--cg-blue); }

/* === Per-row actions cell === */
/* The <td> stays a normal table cell so the table layout can size the column.
   The flex container lives inside, which keeps the action items aligned at the
   right edge regardless of how many items the row has. */
.jobs-actions-cell { text-align: right; width: 1%; white-space: nowrap; }
.jobs-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: flex-end;
}
.btn-archive {
  font-family: inherit;
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--cg-border);
  border-radius: var(--radius-btn);
  background: var(--cg-bg);
  color: var(--cg-muted);
  cursor: pointer;
}
.btn-archive:hover { border-color: var(--cg-blue); color: var(--cg-blue); }
.btn-archive:disabled { opacity: 0.5; cursor: wait; }

/* === Job-row tags (jobs list) === */
.job-tags { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: var(--radius-btn);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  border: 1px solid transparent;
  white-space: nowrap;
}
.tag-diagram-rich-picture {
  background: #fff1e6;
  color: #b04a00;
  border-color: #f5cda1;
}
.tag-diagram-value-stream {
  background: #e6f1ff;
  color: #0055aa;
  border-color: #a8c8ec;
}
[data-theme="dark"] .tag-diagram-rich-picture {
  background: rgba(224, 120, 0, 0.18); color: #f5b769; border-color: rgba(224, 120, 0, 0.4);
}
[data-theme="dark"] .tag-diagram-value-stream {
  background: rgba(18, 171, 219, 0.18); color: var(--cg-blue-bright); border-color: rgba(18, 171, 219, 0.4);
}
.tag-start {
  background: var(--cg-bg-soft);
  color: var(--cg-text);
  border-color: var(--cg-border);
}
.tag-image {
  background: transparent;
  color: var(--cg-muted);
  border-color: var(--cg-border);
  font-family: "Ubuntu Mono", "Courier New", monospace;
  text-transform: none;
  font-weight: 500;
}

/* === Form card === */
.form-card {
  background: var(--cg-bg);
  border: 1px solid var(--cg-border);
  border-radius: var(--radius-card);
  padding: 2rem;
  box-shadow: var(--cg-shadow);
  max-width: 520px;
}
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 13px; color: var(--cg-text); }
.form-group input,
.form-group select {
  width: 100%;
  padding: 9px 14px;
  border: 1.5px solid var(--cg-border);
  border-radius: var(--radius-input);
  font-family: inherit;
  font-size: 14px;
  color: var(--cg-text);
  background: var(--cg-bg-soft);
  transition: border-color 0.15s, background 0.15s;
}
.form-group input:focus,
.form-group select:focus { outline: none; border-color: var(--cg-blue); background: var(--cg-bg); }

/* === Job detail layout === */
.job-layout { display: grid; grid-template-columns: 3fr 2fr; gap: 1.5rem; align-items: start; }
@media (max-width: 960px) { .job-layout { grid-template-columns: 1fr; } }

/* === Job header strip (unified title + actions + status) === */
.job-header-strip { padding: 0; overflow: hidden; margin-bottom: 1.25rem; }
.job-header-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.25rem;
  border-bottom: 1px solid var(--cg-border);
}
.job-title {
  flex: 1;
  font-size: 18px;
  font-weight: 700;
  color: var(--cg-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.job-back-btn { font-size: 12px; padding: 0.3rem 0.8rem; flex-shrink: 0; }
.job-rename-btn {
  font-family: inherit;
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--cg-border);
  border-radius: var(--radius-btn);
  background: var(--cg-bg);
  color: var(--cg-muted);
  cursor: pointer;
  flex-shrink: 0;
}
.job-rename-btn:hover { border-color: var(--cg-blue); color: var(--cg-blue); }
.job-header-status {
  padding: 0.5rem 1.25rem;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* === Run controls === */
.run-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.validate-result { font-size: 12px; white-space: pre-wrap; flex: 1; }

/* === Progress bar === */
#progress-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}
#progress-bar-wrap {
  background: var(--cg-bg-soft);
  border-radius: var(--radius-btn);
  height: 8px;
  overflow: hidden;
  flex: 1;
  min-width: 80px;
}
#progress-bar {
  background: linear-gradient(90deg, var(--cg-blue), var(--cg-blue-bright));
  height: 100%;
  border-radius: var(--radius-btn);
  width: 0%;
  transition: width 0.4s ease;
}
.progress-stage-pill {
  background: #e0f4ff;
  color: #0055aa;
  border: 1px solid #b3dcf5;
  border-radius: var(--radius-btn);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}
[data-theme="dark"] .progress-stage-pill {
  background: rgba(18,171,219,0.15);
  color: var(--cg-blue-bright);
  border-color: rgba(18,171,219,0.3);
}

/* === Run status badge === */
.run-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 4px 12px;
  border-radius: var(--radius-btn);
  font-size: 12px;
  font-weight: 700;
  transition: opacity 1s ease;
}
.run-status-succeeded { background: #e0ffe4; color: #007700; border: 1px solid #b2f0c9; }
.run-status-failed    { background: #ffe0e0; color: #cc0000; border: 1px solid #ffcccc; }
.run-status-dismiss {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  color: inherit;
  opacity: 0.5;
  padding: 0 2px;
  font-family: inherit;
}
.run-status-dismiss:hover { opacity: 1; }

/* === Output image card (top of right column) === */
.output-card { padding: 0.4rem; }
.output-full-img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
  cursor: pointer;
  transition: opacity 0.15s;
}
.output-full-img:hover { opacity: 0.88; }

/* === Input card top row (heading left, save button right) === */
.input-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.input-card-top h2 { margin-bottom: 0; }
.input-save-area { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.dirty-msg { font-size: 12px; color: #b06000; font-weight: 600; }
.btn-unsaved { background: #e07800 !important; border-color: #e07800 !important; }
.btn-unsaved:hover { background: #c06400 !important; border-color: #c06400 !important; }

/* === Run log === */
.run-log {
  font-size: 11px;
  font-family: "Ubuntu Mono", "Courier New", monospace;
  white-space: pre-wrap;
  background: #101827;
  color: #cdd9e5;
  padding: 1rem;
  border-radius: 10px;
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.6;
}

/* === Image upload === */
.upload-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-top: 0.75rem; }
.upload-form select,
.upload-form input[type="file"] {
  font-family: inherit;
  font-size: 12px;
  padding: 5px 8px;
  border: 1.5px solid var(--cg-border);
  border-radius: var(--radius-input);
  background: var(--cg-bg-soft);
  color: var(--cg-text);
}
.image-role-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--cg-border);
  font-size: 13px;
}
.image-role-item:last-child { border-bottom: none; }

/* === Template axes (two-segment selector) === */
.template-axes { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.75rem; }
.axis-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.axis-label {
  font-size: 12px;
  color: var(--cg-muted);
  white-space: nowrap;
  min-width: 100px;
  font-weight: 500;
}
.segmented {
  display: inline-flex;
  border: 1px solid var(--cg-border);
  border-radius: var(--radius-btn);
  overflow: hidden;
  background: var(--cg-bg-soft);
}
.segmented button {
  padding: 5px 14px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--cg-text);
  cursor: pointer;
  border-right: 1px solid var(--cg-border);
  transition: background 0.15s, color 0.15s;
}
.segmented button:last-child { border-right: none; }
.segmented button.active {
  background: var(--cg-blue);
  color: #fff;
}
.segmented button:not(.active):hover {
  background: var(--cg-bg);
}
.apply-tpl-btn {
  font-size: 12px;
  padding: 0.4rem 0.9rem;
  margin-left: auto;
}
.boilerplate-warning {
  margin-top: 0.5rem;
  font-size: 12px;
  color: #b06000;
  font-weight: 500;
}
[data-theme="dark"] .boilerplate-warning { color: #f5b769; }

/* === Image slot help tooltip === */
.slot-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cg-bg-soft);
  color: var(--cg-muted);
  cursor: help;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--cg-border);
}
.slot-help:hover {
  background: var(--cg-blue);
  color: #fff;
  border-color: var(--cg-blue);
}

/* === Accent stripe on page header === */
.page-header-accent {
  height: 2px;
  background: linear-gradient(90deg, var(--cg-blue), var(--cg-blue-bright));
  border-radius: 2px;
  margin-bottom: 0.75rem;
}

/* === Help pages === */
.help-page {
  max-width: 820px;
  margin: 0 auto;
}
.help-card {
  padding: 2rem 2.25rem;
}
.help-card h1 {
  margin-top: 0;
  font-size: 28px;
  color: var(--cg-text);
}
.help-card h2 {
  font-size: 20px;
  margin-top: 1.75rem;
  color: var(--cg-text);
}
.help-card h3 {
  font-size: 16px;
  margin-top: 1.25rem;
  color: var(--cg-muted);
}
.help-card p,
.help-card ul,
.help-card ol {
  line-height: 1.55;
  color: var(--cg-text);
}
.help-card code {
  background: var(--cg-bg-soft);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: 'Ubuntu Mono', monospace;
  font-size: 0.9em;
}
.help-card a {
  color: var(--cg-blue);
}
table.help-comparison {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}
table.help-comparison th,
table.help-comparison td {
  padding: 8px 12px;
  border: 1px solid var(--cg-border);
  text-align: left;
  font-size: 13px;
}
table.help-comparison th {
  background: var(--cg-bg-soft);
  font-weight: 500;
}

/* === Preprocessing prompts panel (revision v2 §5.2) === */
.preprocessing-panel {
  padding: 0;
  overflow: hidden;
}
.preprocessing-panel[open] {
  padding-bottom: 1rem;
}
.preprocessing-summary {
  list-style: none;
  cursor: pointer;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  user-select: none;
}
.preprocessing-summary::-webkit-details-marker { display: none; }
.preprocessing-summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.55rem;
  color: var(--cg-muted);
  transition: transform 0.15s;
}
.preprocessing-panel[open] .preprocessing-summary::before { transform: rotate(90deg); }
.preprocessing-summary-title {
  font-weight: 700;
  color: var(--cg-text);
  font-size: 15px;
}
.preprocessing-summary-hint {
  color: var(--cg-muted);
  font-size: 12px;
  font-weight: 500;
}
.preprocessing-blurb {
  padding: 0 1.25rem;
  margin: 0 0 0.75rem;
  font-size: 13px;
  color: var(--cg-muted);
}
.preprocessing-tabs {
  margin: 0 1.25rem 0.75rem;
}
.preprocessing-body {
  padding: 0 1.25rem;
}
.preprocessing-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.preprocessing-copy-btn { font-size: 12px; padding: 0.4rem 1rem; }
.preprocessing-copy-status {
  font-size: 12px;
  color: var(--cg-muted);
  transition: color 0.15s;
}
.preprocessing-copy-status.success { color: var(--cg-blue); font-weight: 500; }
#preprocessing-text {
  width: 100%;
  font-family: "Ubuntu Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  padding: 0.75rem;
  border: 1.5px solid var(--cg-border);
  border-radius: var(--radius-input);
  background: var(--cg-bg-soft);
  color: var(--cg-text);
  resize: vertical;
}
.preprocessing-error {
  margin-top: 0.5rem;
  font-size: 12px;
  color: #b00020;
}
[data-theme="dark"] .preprocessing-error { color: #ff7986; }

/* === How-to-use dialog (jobs page) === */
.how-to-btn { margin-right: 0.5rem; }

.how-to-dialog {
  width: min(880px, 92vw);
  max-height: 88vh;
  padding: 0;
  border: none;
  border-radius: var(--radius-card);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  background: var(--cg-bg);
  color: var(--cg-text);
}
.how-to-dialog::backdrop {
  background: rgba(15, 25, 45, 0.55);
  backdrop-filter: blur(2px);
}
.how-to-inner {
  padding: 1.25rem 1.75rem 1.75rem;
  overflow-y: auto;
  max-height: 88vh;
}
.how-to-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--cg-border);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  position: sticky;
  top: 0;
  background: var(--cg-bg);
  z-index: 1;
}
.how-to-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--cg-ink);
  margin: 0;
}
[data-theme="dark"] .how-to-header h2 { color: var(--cg-text); }
.how-to-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  color: var(--cg-muted);
  padding: 0 6px;
  border-radius: 6px;
}
.how-to-close:hover { background: var(--cg-bg-soft); color: var(--cg-text); }

.how-to-lede {
  font-size: 15px;
  line-height: 1.55;
  color: var(--cg-text);
  background: var(--cg-bg-soft);
  border-left: 3px solid var(--cg-blue-bright);
  padding: 0.75rem 1rem;
  border-radius: 0 var(--radius-input) var(--radius-input) 0;
  margin-bottom: 1.5rem;
}

.how-to-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--cg-blue);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 1.5rem 0 0.75rem;
}

/* --- Diagram cards (rich picture vs value stream) --- */
.how-to-diagram-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.how-to-diagram-card {
  background: var(--cg-bg-soft);
  border: 1px solid var(--cg-border);
  border-radius: var(--radius-card);
  padding: 1rem 1.25rem;
}
.how-to-diagram-card h4 {
  font-size: 16px;
  font-weight: 700;
  margin: 0.75rem 0 0.25rem;
  color: var(--cg-text);
}
.how-to-purpose {
  font-size: 13px;
  font-weight: 500;
  color: var(--cg-blue);
  margin-bottom: 0.5rem;
}
.how-to-detail {
  font-size: 13px;
  line-height: 1.5;
  color: var(--cg-muted);
  margin-bottom: 0.5rem;
}
.how-to-deeper {
  font-size: 12px;
  font-weight: 500;
  color: var(--cg-blue);
  text-decoration: none;
}
.how-to-deeper:hover { text-decoration: underline; }

/* CSS-only visual hint for rich picture: four overlapping coloured zones. */
.how-to-icon-rich {
  position: relative;
  height: 56px;
  width: 100%;
}
.how-to-icon-rich .zone {
  position: absolute;
  border-radius: 12px;
  opacity: 0.85;
}
.how-to-icon-rich .z1 { left: 4%;  top: 4px;   width: 36%; height: 32px; background: var(--cg-blue-bright); }
.how-to-icon-rich .z2 { left: 28%; top: 18px;  width: 38%; height: 32px; background: var(--cg-blue); }
.how-to-icon-rich .z3 { left: 56%; top: 4px;   width: 30%; height: 28px; background: #f5b769; }
.how-to-icon-rich .z4 { left: 64%; top: 22px;  width: 28%; height: 28px; background: #8a6cdc; }

/* CSS-only visual hint for value stream: panels and arrows in a row. */
.how-to-icon-vs {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 56px;
  padding: 0 4%;
}
.how-to-icon-vs .panel {
  flex: 1;
  height: 36px;
  background: var(--cg-blue);
  border-radius: 6px;
  opacity: 0.9;
}
.how-to-icon-vs .arrow {
  width: 14px;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 10px solid var(--cg-blue-bright);
}

/* --- Step ribbon (5 numbered steps) --- */
.how-to-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.6rem;
}
.how-to-steps li {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.7rem 0.9rem;
  background: var(--cg-bg-soft);
  border-radius: var(--radius-input);
  border: 1px solid var(--cg-border);
}
.how-to-steps strong {
  display: block;
  font-size: 14px;
  color: var(--cg-text);
  margin-bottom: 2px;
}
.how-to-steps p {
  font-size: 13px;
  color: var(--cg-muted);
  line-height: 1.5;
  margin: 0;
}
.how-to-steps em {
  font-style: normal;
  font-weight: 500;
  color: var(--cg-blue);
  background: rgba(0, 112, 173, 0.08);
  padding: 0 4px;
  border-radius: 3px;
}
.step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--cg-blue);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

/* --- Mode cards (three-mode row) --- */
.how-to-modes-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}
.how-to-mode-card {
  padding: 0.85rem;
  background: var(--cg-bg-soft);
  border: 1px solid var(--cg-border);
  border-radius: var(--radius-input);
  border-top: 3px solid var(--cg-blue-bright);
}
.how-to-mode-card h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--cg-text);
  margin: 0 0 0.25rem;
}
.how-to-mode-card p {
  font-size: 12px;
  color: var(--cg-muted);
  line-height: 1.45;
  margin: 0;
}

/* --- Principles list --- */
.how-to-principles {
  margin: 0;
  padding-left: 1.25rem;
}
.how-to-principles li {
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 0.4rem;
  color: var(--cg-text);
}
.how-to-principles strong { color: var(--cg-ink); }
[data-theme="dark"] .how-to-principles strong { color: var(--cg-text); }

.how-to-footer-links {
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--cg-border);
  font-size: 13px;
  color: var(--cg-muted);
  text-align: center;
}
.how-to-footer-links a { color: var(--cg-blue); text-decoration: underline; }

/* Responsive: collapse to single column on narrow viewports. */
@media (max-width: 640px) {
  .how-to-diagram-row,
  .how-to-modes-row { grid-template-columns: 1fr; }
}

/* === AWS hosted frontend additions === */
/* The `hidden` attribute must always win, even over component display rules
   like `.btn { display: inline-flex }` — otherwise toggled sign-in/out buttons
   and [data-admin-only] items stay visible. */
[hidden] { display: none !important; }

.nav-link {
  color: rgba(255,255,255,0.8);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  padding: 5px 8px;
  border-radius: var(--radius-btn);
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,0.08); }

.login-panel {
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}
.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--cg-blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.login-copy {
  max-width: 680px;
  color: var(--cg-muted);
}

.jobs-panel[hidden],
.login-panel[hidden] {
  display: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.summary-grid > div {
  border: 1px solid var(--cg-border);
  border-radius: var(--radius-input);
  padding: 1rem;
  background: var(--cg-bg-soft);
}
.summary-grid strong,
.summary-grid span { display: block; }
.summary-grid span {
  color: var(--cg-muted);
  font-size: 13px;
}

.admin-user-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(180px, 1fr) 140px auto;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}
.admin-user-form input,
.admin-user-form select {
  margin: 0;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.table-actions button {
  padding: 0.35rem 0.75rem;
}

.status-queued,
.status-validating,
.status-resolving_images,
.status-brief_model,
.status-image_model,
.status-saving_outputs { background: #e0f4ff; color: #0055aa; }
.status-completed { background: #e0ffe4; color: #007700; }
.status-dead_lettered,
.status-cancelled { background: #fffbe6; color: #7a5900; }

@media (max-width: 800px) {
  .login-panel {
    align-items: flex-start;
    flex-direction: column;
  }
  .summary-grid,
  .admin-user-form {
    grid-template-columns: 1fr;
  }
}

/* === Hosted SPA additions === */
.muted { color: var(--cg-muted); font-size: 13px; padding: 0.5rem 0; }
.admin-tabs { display: inline-flex; margin: 1rem 0 1.5rem; flex-wrap: wrap; }
.admin-section { display: block; }
.admin-section[hidden] { display: none !important; }
.admin-section .card { margin-bottom: 1rem; }

/* Branded admin tables */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table thead th {
  text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--cg-muted);
  border-bottom: 2px solid var(--cg-border); background: var(--cg-bg-soft);
}
.admin-table td { padding: 10px 14px; border-bottom: 1px solid var(--cg-border); vertical-align: top; }
.admin-table tbody tr:hover { background: var(--cg-bg-soft); }
.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.admin-table .nowrap { white-space: nowrap; color: var(--cg-muted); }
.log-detail { max-width: 460px; white-space: pre-wrap; word-break: break-word; font-size: 12px; color: var(--cg-muted); }
.log-error { color: var(--cg-danger, #c0392b); }

/* Small buttons + action cells */
.btn-sm { padding: 0.3rem 0.7rem; font-size: 12px; font-weight: 600; }
.table-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.logs-header { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.logs-filter { font-size: 13px; color: var(--cg-muted); }
.logs-filter select { margin-left: 0.4rem; padding: 4px 8px; border: 1.5px solid var(--cg-border); border-radius: var(--radius-input); background: var(--cg-bg-soft); color: var(--cg-text); font-family: inherit; font-size: 13px; }

/* Status / role / access pills */
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
  background: var(--cg-bg-soft); color: var(--cg-text); border: 1px solid var(--cg-border);
}
.pill-admin { background: #eef4ff; color: #1f5fbf; border-color: #cfe0ff; }
.pill-user { background: var(--cg-bg-soft); color: var(--cg-muted); }
.pill-ok { background: #e9f7ef; color: #1e7e44; border-color: #bfe6cd; }
.pill-off { background: #fdecea; color: #c0392b; border-color: #f5c6c0; }
.pill-pending { background: #fff6e5; color: #9a6700; border-color: #ffe3a8; }

/* Branded form fields (admin create-user + new-job) */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 0.35rem; }
.admin-user-form input, .admin-user-form select, .form-card input, .form-card select {
  width: 100%; max-width: 420px; padding: 0.55rem 0.75rem; font-family: inherit; font-size: 14px;
  border: 1.5px solid var(--cg-border); border-radius: var(--radius-input);
  background: var(--cg-bg-soft); color: var(--cg-text);
}
.admin-user-form input:focus, .form-card input:focus { outline: none; border-color: var(--cg-blue); }
.downloads-title { font-size: 13px; font-weight: 500; color: var(--cg-muted); margin: 0.75rem 0 0.4rem; }
.download-list { display: flex; flex-direction: column; gap: 4px; }
.download-row {
  display: block; padding: 6px 10px; border: 1px solid var(--cg-border);
  border-radius: var(--radius-input); color: var(--cg-blue); text-decoration: none;
  font-size: 13px; font-family: var(--font-mono, monospace); background: var(--cg-bg-soft);
}
.download-row:hover { text-decoration: underline; }

/* Admin: filter bar, sub-headings, load-more, danger button */
.admin-filter { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.admin-filter label { font-size: 12px; color: var(--cg-muted); display: inline-flex; align-items: center; gap: 0.35rem; }
.admin-filter input[type="date"] { padding: 4px 8px; border: 1.5px solid var(--cg-border); border-radius: var(--radius-input); background: var(--cg-bg-soft); color: var(--cg-text); font-family: inherit; font-size: 13px; }
.admin-subhead { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--cg-muted); margin: 1.4rem 0 0.6rem; }
.load-more-wrap { display: flex; justify-content: center; margin-top: 1rem; }
.admin-table .total-row td { border-top: 2px solid var(--cg-border); }
.btn-danger { background: #fdecea; color: #c0392b; border: 1px solid #f5c6c0; }
.btn-danger:hover { background: #f9d9d4; }

/* Admin: run drill-down modal */
.run-detail-dialog { border: none; border-radius: var(--radius-card); padding: 0; max-width: 760px; width: calc(100% - 2rem); box-shadow: var(--cg-shadow); background: var(--cg-bg); color: var(--cg-text); }
.run-detail-dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.run-detail-inner { padding: 1.4rem 1.6rem 1.8rem; }
.run-detail-inner details { border: 1px solid var(--cg-border); border-radius: var(--radius-input); margin-bottom: 0.6rem; }
.run-detail-inner summary { cursor: pointer; padding: 8px 12px; font-weight: 600; font-size: 13px; }
.run-artifact { margin: 0; padding: 12px; max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-family: var(--font-mono, monospace); font-size: 12px; background: var(--cg-bg-soft); border-top: 1px solid var(--cg-border); }
.run-detail-image { margin: 0.8rem 0; }
.run-detail-image img { max-width: 100%; border: 1px solid var(--cg-border); border-radius: var(--radius-input); }
.run-detail-downloads { display: flex; gap: 0.5rem; flex-wrap: wrap; }
