:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --ink: #17212b;
  --muted: #697586;
  --line: #d8dee8;
  --blue: #1769e0;
  --green: #14875a;
  --red: #c23434;
  --amber: #b86b00;
  --shadow: 0 18px 50px rgba(18, 32, 50, .14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(23, 105, 224, .14), transparent 36%),
    linear-gradient(315deg, rgba(20, 135, 90, .12), transparent 42%),
    var(--bg);
}

.login-card {
  width: min(440px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin-bottom: 12px;
}

.login-card p {
  color: var(--muted);
  line-height: 1.5;
}

.login-card form,
.login-card label {
  display: grid;
  gap: 10px;
}

.login-card form {
  margin-top: 22px;
}

.login-card .back-link {
  display: inline-block;
  margin-top: 16px;
  color: var(--blue);
  font-weight: 700;
}

.login-card label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.login-card input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
}

.login-error {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid #f1b9b9;
  border-radius: 8px;
  background: #fff1f1;
  color: var(--red);
  font-weight: 700;
}

.app-shell {
  padding: 20px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1;
}

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

.operation-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.nav-menu {
  position: relative;
}

.nav-menu > summary {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.nav-menu > summary::-webkit-details-marker {
  display: none;
}

.nav-menu > summary::after {
  content: "▾";
  font-size: 10px;
  transition: transform .15s ease;
}

.nav-menu[open] > summary {
  filter: brightness(.94);
}

.nav-menu[open] > summary::after {
  transform: rotate(180deg);
}

.nav-dropdown {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 30;
  display: grid;
  width: 250px;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 7px;
  box-shadow: var(--shadow);
}

.nav-dropdown a {
  border-radius: 8px;
  color: var(--ink);
  padding: 9px 10px;
  text-decoration: none;
}

.nav-dropdown a:hover,
.nav-dropdown a:focus {
  background: var(--surface-soft);
  outline: none;
}

.nav-dropdown strong,
.nav-dropdown span {
  display: block;
}

.nav-dropdown strong {
  font-size: 13px;
}

.nav-dropdown span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.logout-form {
  margin: 0;
}

.search {
  display: grid;
  gap: 5px;
  min-width: 310px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.search input,
.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

.search input:focus,
.field input:focus,
.field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, .15);
}

.workflow-guide {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 14px;
  padding: 14px;
}

.lead-alert-banner {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  padding: 14px 16px;
  color: #5b3500;
  text-decoration: none;
  background: #fff5d8;
  border: 1px solid #efc85f;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(184, 107, 0, .14);
}

.lead-alert-banner[hidden] {
  display: none;
}

.lead-alert-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #fff;
  background: var(--amber);
  border-radius: 50%;
  font-size: 24px;
  font-weight: 900;
}

.lead-alert-copy,
.lead-alert-copy strong,
.lead-alert-copy span {
  display: block;
}

.lead-alert-copy small {
  color: #8a5704;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.lead-alert-copy strong {
  margin-top: 3px;
  font-size: 17px;
}

.lead-alert-copy span {
  margin-top: 3px;
  color: #765323;
  font-size: 13px;
}

.lead-alert-action {
  padding: 9px 13px;
  color: #fff;
  background: var(--amber);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.lead-alert-banner.lead-alert-arrived {
  animation: leadAlertArrival 1s ease 3;
}

@keyframes leadAlertArrival {
  0%, 100% { box-shadow: 0 12px 32px rgba(184, 107, 0, .14); }
  50% { box-shadow: 0 0 0 5px rgba(184, 107, 0, .22), 0 16px 38px rgba(184, 107, 0, .24); }
}

.workflow-guide > header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.workflow-guide h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.workflow-guide > header > p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

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

.workflow-grid article {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px 12px;
}

.workflow-title span,
.workflow-title strong {
  display: block;
}

.workflow-title span {
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.workflow-title strong {
  margin-top: 3px;
  font-size: 14px;
}

.workflow-steps {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.workflow-steps a {
  display: inline-flex;
  min-width: 82px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 7px 8px;
  text-decoration: none;
}

.workflow-steps a:hover {
  border-color: var(--blue);
  box-shadow: 0 5px 12px rgba(18, 32, 50, .08);
}

.workflow-steps b {
  display: inline-flex;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 10px;
}

.workflow-steps span {
  font-size: 11px;
  font-weight: 700;
}

.workflow-steps i {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.field.checkbox-field {
  align-content: center;
  grid-template-columns: auto 1fr;
  min-height: 42px;
  margin-top: 18px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.field.checkbox-field input {
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--blue);
}

.field.checkbox-field:has(input:disabled) {
  background: var(--surface-soft);
  color: var(--muted);
  cursor: not-allowed;
}

.ghost-button,
.primary-button,
.danger-button,
.small-button,
.close-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  font-weight: 700;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.primary-button {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.danger-button {
  border-color: rgba(194, 52, 52, .35);
  background: #fff5f5;
  color: var(--red);
}

.small-button {
  padding: 7px 9px;
  font-size: 13px;
}

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

.summary-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px 15px;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.board {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr) minmax(340px, 1.35fr) minmax(280px, 1fr) minmax(260px, 1fr);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.lane {
  min-width: 260px;
  scroll-margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8edf4;
  padding: 10px;
}

.lane:target {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, .14);
}

.lane-wide {
  min-width: 340px;
}

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

.lane h2 {
  margin: 0;
  font-size: 16px;
}

.lane header button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 19px;
  line-height: 1;
}

.cards {
  display: grid;
  gap: 10px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  box-shadow: 0 1px 0 rgba(18, 32, 50, .04);
  text-align: left;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}

.card:hover {
  border-color: #b9c6d8;
  box-shadow: 0 10px 22px rgba(18, 32, 50, .08);
  transform: translateY(-1px);
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.card-title strong {
  font-size: 16px;
}

.meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #edf4ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.pill.green {
  background: #e9f8f0;
  color: var(--green);
}

.pill.red {
  background: #fff0f0;
  color: var(--red);
}

.pill.amber {
  background: #fff7e8;
  color: var(--amber);
}

.slots-preview {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  margin-top: 10px;
}

.slot-dot {
  border-radius: 6px;
  background: #edf1f7;
  color: var(--muted);
  padding: 5px 0;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.slot-dot.filled {
  background: #e9f8f0;
  color: var(--green);
}

.slot-dot.inactive {
  background: #fff0f0;
  color: #d92d20;
}

.small-button.placement-paused {
  border-color: #f2b8b5;
  color: #d92d20;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
}

.drawer.open {
  display: block;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 20, 30, .42);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(560px, 100%);
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
}

.close-button {
  float: right;
  margin-left: 12px;
}

.drawer-title {
  margin: 12px 0 18px;
}

.drawer-title h3 {
  margin: 0 0 8px;
  font-size: 26px;
}

.drawer-section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
}

.drawer-section h4 {
  margin: 0 0 12px;
  font-size: 15px;
}

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

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

.detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.detail span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.detail strong {
  display: block;
  margin-top: 5px;
  word-break: break-word;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

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

.field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

.as-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.qr-admin {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #cfe0f5;
  border-radius: 8px;
  background: #f2f7ff;
}

.qr-admin img {
  width: 116px;
  height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.qr-admin strong,
.qr-admin span {
  display: block;
}

.qr-admin span {
  margin: 6px 0 10px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.hint-box {
  margin-top: 10px;
  border: 1px solid #cfe0f5;
  border-radius: 8px;
  background: #f2f7ff;
  color: #36536f;
  padding: 10px;
  font-size: 13px;
  line-height: 1.35;
}

.warning-box {
  display: grid;
  gap: 5px;
  margin: 0 0 10px;
  border: 1px solid #f0c36d;
  border-radius: 8px;
  background: #fff8e8;
  color: #6c4700;
  padding: 10px;
  font-size: 13px;
  line-height: 1.35;
}

.warning-box strong {
  color: #563700;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.slot-list {
  display: grid;
  gap: 8px;
}

.slot-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface-soft);
}

.slot-row > select {
  width: 100%;
  min-width: 0;
}

.slot-row.slot-conflict {
  border-color: #f0c36d;
  background: #fff8e8;
}

.slot-code {
  font-weight: 700;
}

.slot-actions {
  display: flex;
  grid-column: 2;
  flex-wrap: wrap;
  gap: 6px;
  white-space: normal;
}

.slot-actions .small-button {
  flex: 0 1 auto;
}

.empty-state {
  border: 1px dashed #b9c6d8;
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.thumb {
  width: 100%;
  aspect-ratio: 1024 / 600;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: #dfe6ef;
}

.image-preview {
  clear: both;
}

.empty-thumb {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
  object-fit: initial;
}

@media (max-width: 920px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .operation-nav {
    align-items: stretch;
    justify-content: flex-start;
  }

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

  .search {
    min-width: 0;
  }

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

@media (max-width: 620px) {
  .lead-alert-banner {
    grid-template-columns: 36px minmax(0, 1fr);
    align-items: start;
    padding: 13px;
  }

  .lead-alert-icon {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }

  .lead-alert-action {
    grid-column: 1 / -1;
    text-align: center;
  }

  .workflow-guide > header,
  .workflow-grid article {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .workflow-guide > header {
    flex-direction: column;
  }

  .workflow-steps {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .workflow-steps i {
    display: none;
  }

  .workflow-steps a {
    flex: 1 1 120px;
  }

  .nav-menu {
    flex: 1 1 140px;
  }

  .nav-menu > summary {
    justify-content: space-between;
    width: 100%;
  }

  .nav-dropdown {
    right: auto;
    left: 0;
    width: min(280px, calc(100vw - 28px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .lead-alert-banner.lead-alert-arrived {
    animation: none;
  }
}
