:root {
  --border: #1f1f1f;
  --radius: 0;
  --blue: #3ea1f0;
  --blue-text: #ffffff;
  --red: #e74c3c;
  --red-text: #ffffff;
  --green: #23c1f1;
  --green-text: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa url('assets/dashboard-background.jpg') center / cover no-repeat fixed;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #1f1f1f;
}

/* Customer-facing payment pages: portrait background on phones. fixed attachment is unreliable on mobile browsers. */
@media (max-width: 767px) and (orientation: portrait) {
  body.payment-page {
    min-height: 100dvh;
    background: #0a3a33 url('assets/mobile-background.png') center / cover no-repeat scroll;
  }
}

@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  body.payment-page {
    min-height: 100dvh;
    background: #0a3a33 url('assets/tablet-background.jpg') center / cover no-repeat scroll;
  }
}

/* Payment pages on phones and tablets held in landscape: rotate the page back to portrait.
   payment-page.js sets data-rotate on html from the screen angle: ccw when the device was turned
   counter-clockwise (needs -90deg), cw when turned clockwise (needs +90deg).
   In landscape the viewport height is the device's short side, so the size queries use min-height. */
@media screen and (orientation: landscape) and (max-device-width: 1024px) {
  html[data-rotate] {
    width: 100vh;
    height: 100vw;
    overflow-x: hidden;
    position: absolute;
    transform-origin: left top;
    /* A background on html stops body's background spreading to the unrotated canvas. */
    background: #0a3a33;
  }

  html[data-rotate='ccw'] {
    transform: rotate(-90deg);
    top: 100%;
    left: 0;
  }

  html[data-rotate='cw'] {
    transform: rotate(90deg);
    top: 0;
    left: 100%;
  }

  html[data-rotate] body.payment-page {
    min-height: 100vw;
    background: #0a3a33 url('assets/mobile-background.png') center / cover no-repeat scroll;
  }
}

@media screen and (orientation: landscape) and (max-device-width: 1024px) and (min-height: 768px) {
  html[data-rotate] body.payment-page {
    background-image: url('assets/tablet-background.jpg');
  }
}

.card {
  width: 300px;
  max-width: calc(100vw - 32px);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  background: #fff;
}

h1 {
  text-align: center;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  margin: 0 0 24px;
}

.field {
  display: block;
  margin-bottom: 18px;
}

.field-label {
  display: none;
}

.field input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  text-align: center;
  background: #fff;
  color: #1f1f1f;
}

.field input::placeholder {
  color: #aaa;
}

.field input:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.link-field {
  position: relative;
}

.link-field input {
  text-align: center;
  padding-right: 44px;
  color: #555;
}

.icon-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
}

.icon-btn:hover {
  background: #f0f0f0;
}

.actions {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}

.btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--blue);
  color: var(--blue-text);
}

.btn-primary:hover {
  filter: brightness(0.95);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.error {
  color: #c0392b;
  font-size: 0.85rem;
  text-align: center;
  margin: -8px 0 18px;
}

.success {
  color: #1e8449;
  font-size: 0.85rem;
  text-align: center;
  margin: -8px 0 18px;
}

.status-message {
  text-align: center;
  font-size: 1rem;
  line-height: 1.4;
  margin: 0 0 12px;
}

.status-note {
  text-align: center;
  font-size: 0.85rem;
  line-height: 1.4;
  color: #555;
  margin: 0;
}

.btn-cancel {
  background: var(--red);
  color: var(--red-text);
}

.btn-cancel:hover {
  filter: brightness(0.95);
}

.btn-send {
  background: var(--green);
  color: var(--green-text);
}

.btn-send:hover {
  filter: brightness(0.95);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  width: 420px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.modal-body {
  overflow-y: auto;
  padding-right: 4px;
}

.modal-title {
  text-align: center;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  margin: 0 0 24px;
}

.modal-field {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-field-label {
  flex: 0 0 64px;
  white-space: nowrap;
  font-size: 0.85rem;
  color: #555;
}

.modal-field input {
  flex: 1;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: #fff;
  color: #1f1f1f;
}

.modal-field input::placeholder {
  color: #aaa;
}

.modal-field input:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.remove-row-btn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: #1f1f1f;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remove-row-btn:hover {
  background: #f0f0f0;
}

.add-row-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: 0 auto 18px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: #fff;
  color: #1f1f1f;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.add-row-btn[hidden] {
  display: none;
}

.add-row-btn:hover {
  background: #f0f0f0;
}

.modal-methods {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

.modal-methods .modal-field-label {
  float: left;
  width: 64px;
  padding: 0;
}

.method-option + .method-option {
  margin-left: 8px;
}

.method-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.phone-input {
  flex: 1;
  display: flex;
  align-items: center;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.phone-input:focus-within {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.phone-prefix {
  padding: 0 0 0 14px;
  font-size: 0.9rem;
  line-height: inherit;
  color: #1f1f1f;
  user-select: none;
}

.modal-field .phone-input input {
  border: 0;
  padding-left: 4px;
  /* Inputs don't inherit font settings; match the "0" prefix so both share a baseline. */
  font-family: inherit;
  line-height: inherit;
}

.modal-field .phone-input input:focus {
  outline: none;
}

#emailSection:not([hidden]) + #smsSection:not([hidden]) {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #ddd;
}
