:root {
  color-scheme: light;
  --brand-red: rgb(224, 60, 49);
  --brand-yellow: rgb(242, 169, 0);
  --brand-blue: rgb(0, 146, 188);
  --brand-green: rgb(206, 220, 0);
  --brand-offwhite: rgb(247, 247, 245);
  --bg: var(--brand-offwhite);
  --panel: #ffffff;
  --ink: #262626;
  --muted: #666665;
  --line: #deded8;
  --accent: var(--brand-blue);
  --accent-dark: #006f91;
  --primary: var(--brand-red);
  --primary-dark: #b92f27;
  --warning: #805800;
  --soft: #f0f6f7;
  --success-soft: #f5f8d4;
  --shadow: 0 14px 38px rgba(38, 38, 38, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Roboto, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.app-shell {
  width: min(1440px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  border-top: 6px solid var(--primary);
  padding: 18px 0 22px;
}

.brand-lockup {
  display: grid;
  gap: 10px;
}

.brand-logo {
  width: min(282px, 72vw);
  height: auto;
  color: var(--ink);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand-red);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.85rem, 3vw, 3.1rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.05rem;
}

h3 {
  margin: 0;
  font-size: 1rem;
}

.status-pill {
  min-width: 138px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  padding: 9px 14px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ghost-link {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--accent-dark);
  padding: 9px 14px;
  font-weight: 800;
  text-decoration: none;
}

.ghost-link:hover {
  background: var(--soft);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 18px;
  align-items: start;
}

.form-panel,
.output-panel {
  display: grid;
  gap: 16px;
}

.section,
.result-box,
.spot-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.section:first-of-type {
  border-top: 4px solid var(--brand-blue);
}

.output-panel .result-box:first-child {
  border-top: 4px solid var(--brand-yellow);
}

.section,
.result-box {
  padding: 18px;
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
}

.section-heading h2 {
  color: var(--ink);
}

.section-heading.inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.system-field-row {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #34443f;
  font-size: 0.88rem;
  font-weight: 700;
}

.section > label + label,
.spot-card > label {
  margin-top: 14px;
}

.textarea-block {
  margin-top: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d4d4cf;
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 146, 188, 0.16);
}

.system-field {
  color: #4d4d4b;
}

.system-field input {
  border-color: #d9d9d2;
  background: #f4f4f1;
  color: #4d4d4b;
  font-weight: 700;
}

.system-field input:focus {
  border-color: #d9d9d2;
  box-shadow: none;
}

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

.spot-card {
  padding: 14px;
  box-shadow: none;
}

.spot-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.primary-button,
.ghost-button,
.icon-button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
  padding: 12px 16px;
}

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

.primary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ghost-button,
.icon-button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--accent-dark);
  padding: 10px 12px;
}

.ghost-button:hover,
.icon-button:hover {
  background: var(--soft);
}

.icon-button {
  color: var(--primary);
  padding: 7px 10px;
}

.full {
  width: 100%;
}

.review-send {
  margin-top: 10px;
}

.danger-action {
  border-color: rgba(224, 60, 49, 0.34);
  color: var(--primary-dark);
}

.processing-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(245, 247, 246, 0.72);
  backdrop-filter: blur(3px);
  padding: 24px;
}

.processing-panel {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(320px, calc(100vw - 48px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  padding: 22px;
  color: var(--ink);
  text-align: center;
}

.processing-panel strong {
  font-size: 1rem;
}

.processing-panel span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.processing-spinner {
  width: 38px;
  height: 38px;
  border: 4px solid #e8e8e2;
  border-top-color: var(--brand-blue);
  border-right-color: var(--brand-yellow);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(13, 22, 19, 0.48);
  padding: 24px;
}

.modal-panel {
  width: min(1180px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.bulk-table-wrap {
  overflow-x: auto;
}

.bulk-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}

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

.bulk-table th {
  color: var(--accent-dark);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.bulk-table input,
.bulk-table textarea {
  min-width: 150px;
}

.bulk-table textarea {
  min-height: 42px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

pre {
  min-height: 340px;
  max-height: 520px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfc;
  padding: 12px;
  color: #27332f;
  line-height: 1.45;
}

.draft-heading {
  margin-bottom: 10px;
}

.draft-editor {
  min-height: 420px;
  max-height: 620px;
  resize: vertical;
  background: #fbfcfc;
  color: #27332f;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.sync-status {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--muted);
  margin-bottom: 10px;
  padding: 9px 10px;
  font-size: 0.86rem;
  font-weight: 800;
}

.sync-status.success {
  border-color: rgba(206, 220, 0, 0.55);
  background: var(--success-soft);
  color: #526000;
}

.sync-status.warning {
  border-color: rgba(242, 169, 0, 0.5);
  background: #fff8e6;
  color: var(--warning);
}

.saved-search {
  margin-bottom: 10px;
}

.saved-list {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

.saved-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px;
  background: #fbfbf9;
}

.saved-item strong {
  display: block;
  margin-bottom: 3px;
}

.saved-item span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
}

.saved-item a {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.saved-item a:hover {
  text-decoration: underline;
}

.saved-item .load-packet {
  display: inline-block;
  margin-top: 8px;
  margin-left: 8px;
  padding: 7px 9px;
}

@media (max-width: 1050px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .output-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 24px, 1440px);
    padding-top: 14px;
  }

  .topbar,
  .section-heading.inline,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  h1 {
    font-size: 2.2rem;
  }
}
