:root {
  --bg: #000000;
  --card: #0b0b0b;
  --text: #ffffff;
  --muted: #cfcfcf;
  --primary: #fed421;
  --button-text: #000000;
  --success: #16a34a;
  --danger: #dc2626;
  --border: rgba(255,255,255,0.06);
  --input-bg: #111315;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.customer-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.access-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.access-main {
  width: 100%;
  max-width: 420px;
}

.access-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem;
}

.access-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.3rem;
}

.access-card p {
  margin: 0 0 1rem;
  color: var(--muted);
}

.access-card .access-error {
  margin: 0.75rem 0;
  color: #ff5959;
  font-size: 0.9rem;
  font-weight: 600;
}

body.customer-page main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

body.customer-page .form-section {
  max-width: 750px;
  width: 100%;
}

header {
  padding: 2rem 1.5rem;
  background: linear-gradient(135deg, #000 0%, #fed421 100%);
  color: var(--text);
}

header h1 {
  margin: 0 0 0.5rem;
}

header p {
  margin: 0 0 1rem;
  max-width: 40rem;
}

header nav {
  margin-top: 1rem;
}

header nav a {
  color: white;
  text-decoration: underline;
  font-weight: 600;
}

main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
}

/* Tab switching */
.view-tabs {
  display: flex;
  gap: 0.5rem;
  order: -1;
  margin-bottom: -1.5rem;
  margin-top: 1.5rem;
}

.tab-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem 0.5rem 0 0;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(255, 212, 33, 0.05);
}

.tab-btn.active {
  color: var(--text);
  background: rgba(255, 212, 33, 0.15);
  border-color: var(--primary);
  border-bottom-color: var(--card);
}

.form-section,
.list-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem;
}

.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-header-row h2 {
  margin: 0;
}

.sort-control {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-weight: 600;
  color: var(--muted);
}

.sort-control select {
  width: auto;
  margin-top: 0;
  padding: 0.5rem 0.65rem;
  border-radius: 0.55rem;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
}

#activeSection,
#completedSection,
#archiveSection {
  margin-left: -0.5rem;
  padding-left: 0.9rem;
}

/* Service details specific styles to match provided design */
.service-details {
  padding: 1.25rem 1.5rem;
}

.service-details h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  color: var(--text);
}

.field {
  margin-bottom: 1rem;
}

.field-label {
  display: block;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.select-wrapper {
  position: relative;
}

.custom-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 0.9rem 1rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  background: var(--input-bg);
  font: inherit;
  cursor: pointer;
  color: var(--text);
}

.select-wrapper::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #ffffff;
  pointer-events: none;
}

.large-text {
  min-height: 120px;
  resize: vertical;
  padding: 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: var(--input-bg);
}

.rich-text-editor {
  border-radius: 0.75rem;
  overflow: hidden;
  border: none !important;
  background: var(--input-bg);
  box-shadow: none !important;
}

.rich-text-editor .ql-toolbar.ql-snow {
  border: none !important;
  border-top: none !important;
  border-right: none !important;
  border-bottom: none !important;
  border-left: none !important;
  outline: none !important;
  background: #0f1113;
  box-shadow: none !important;
}

.rich-text-editor .ql-container.ql-snow {
  border: none !important;
  min-height: 140px;
  color: var(--text);
  font-family: inherit;
  box-shadow: none !important;
}

.rich-text-editor .ql-editor {
  min-height: 140px;
}

.rich-text-editor .ql-container.ql-snow:focus,
.rich-text-editor .ql-container.ql-snow.ql-focused,
.rich-text-editor .ql-editor:focus {
  outline: none !important;
  box-shadow: none !important;
}

.rich-text-editor .ql-snow .ql-stroke {
  stroke: #d1d5db;
}

.rich-text-editor .ql-snow .ql-fill {
  fill: #d1d5db;
}

.rich-text-editor .ql-snow .ql-picker {
  color: #d1d5db;
}

.address-fields {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 0.75rem;
}

.address-field {
  display: flex;
  flex-direction: column;
}

.address-field input {
  margin-top: 0;
}

.address-autocomplete-wrapper {
  position: relative;
}

.address-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 0.75rem 0.75rem;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
}

.address-dropdown-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  transition: background 0.2s;
}

.address-dropdown-item:hover {
  background: rgba(255, 212, 33, 0.1);
}

.address-dropdown-item:last-child {
  border-bottom: none;
}

.image-drop {
  border: 1px dashed var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  min-height: 68px;
}

.image-placeholder svg { display:block; }

.counter {
  float: right;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.actions {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-start;
}

.submit-success {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 0.6rem;
  border: 1px solid rgba(34, 197, 94, 0.55);
  background: rgba(22, 163, 74, 0.2);
  color: #bbf7d0;
  font-weight: 600;
}

/* Thumbnails for uploaded images */
.thumbnails {
  display: flex;
  gap: 0.5rem;
  margin-left: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.thumb {
  width: 64px;
  height: 64px;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  position: relative;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.6);
  color: white;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  z-index: 2;
  touch-action: manipulation;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

@media (max-width: 640px) {
  .thumbnails {
    gap: 0.75rem;
    margin-left: 0;
    margin-top: 0.75rem;
    width: 100%;
  }

  .thumb {
    width: 84px;
    height: 84px;
  }

  .thumb .remove {
    top: 6px;
    right: 6px;
    width: 34px;
    height: 34px;
    font-size: 18px;
  }
}

.image-drop.dragover {
  border-color: #93c5fd;
  background: linear-gradient(180deg, rgba(240,249,255,0.9), rgba(250,250,255,0.9));
}

label {
  display: block;
  margin-bottom: 1rem;
  font-weight: 600;
}

input,
textarea {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--input-bg);
  font: inherit;
  color: var(--text);
}

button {
  background: var(--primary);
  margin-top: 0.5rem;
  border: none;
  color: var(--button-text);
  padding: 0.9rem 1.25rem;
  border-radius: 0.75rem;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  filter: brightness(1.05);
}

.delete-btn {
  background: #dc2626;
  color: white;
}

.delete-btn:hover {
  background: #b91c1c;
  filter: none;
}

.restore-btn {
  background: #16a34a;
  color: white;
}

.restore-btn:hover {
  background: #15803d;
  filter: none;
}

.permanent-delete-btn {
  background: #7f1d1d;
  color: white;
}

.permanent-delete-btn:hover {
  background: #5f1f1f;
  filter: none;
}

.requests-list {
  display: grid;
  gap: 1rem;
}

.request-card {
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem;
  background: var(--card);
  color: var(--text);
}

.request-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.request-created {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  text-align: right;
  margin-top: 0.15rem;
}

.request-name {
  display: block;
  font-size: 1rem;
}

.request-email,
.request-phone,
.request-address {
  display: block;
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

.request-company {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
}

.status-pill {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
  color: #ffffff;
}

.status-pill.status-pending {
  background: rgba(37, 99, 235, 0.62);
  border-color: rgba(147, 197, 253, 0.9);
}

.status-pill.status-invoiced {
  background: rgba(202, 138, 4, 0.72);
  border-color: rgba(253, 224, 71, 0.95);
}

.status-pill.status-completed {
  background: rgba(22, 163, 74, 0.62);
  border-color: rgba(134, 239, 172, 0.9);
}

.request-details {
  margin: 0 0 1rem;
  color: var(--muted);
  line-height: 1.6;
}

.request-map-embed {
  display: none;
  width: 180px;
  height: 180px;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  margin: 0 0 1rem;
  background: #111;
}

.request-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.request-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  background: #111;
  cursor: zoom-in;
}

.image-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  padding: 1rem;
}

.image-preview-modal.open {
  display: flex;
}

.image-preview {
  max-width: min(1100px, 94vw);
  max-height: 90vh;
  width: auto;
  height: auto;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.5);
}

.image-preview-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0;
}

.image-preview-close:hover {
  background: rgba(0, 0, 0, 0.85);
}

.request-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.request-actions button {
  font-size: 0.92rem;
}

/* Card collapsible toggle */
.card-toggle-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--primary);
  padding: 0.35rem 0.85rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.25rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.15s, border-color 0.15s;
}

.card-toggle-btn:hover {
  background: rgba(254, 212, 33, 0.08);
  border-color: var(--primary);
  filter: none;
}

.card-toggle-btn::after {
  content: '▾';
  font-size: 0.8rem;
  transition: transform 0.2s;
  display: inline-block;
}

.card-toggle-btn[aria-expanded="true"]::after {
  transform: rotate(180deg);
}

.card-collapsible {
  margin-top: 0.75rem;
}

.complete-btn,
.invoice-btn {
  flex: 0 1 auto;
  min-width: 0;
  padding: 0.65rem 0.95rem;
  color: #ffffff;
}

.complete-btn {
  background: var(--success);
}

.complete-btn.incomplete-btn {
  background: #2563eb;
  color: #ffffff;
}

.invoice-btn {
  background: #cca712;
  color: #ffffff;
}

.invoice-btn:hover {
  background: #f59e0b;
}

@media (min-width: 768px) {
  main {
    grid-template-columns: 1fr 1.2fr;
  }
}

@media (max-width: 640px) {
  header {
    padding: 1rem 1rem 1.25rem;
  }

  header h1 {
    font-size: 1.3rem;
  }

  header p {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
  }

  main {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .view-tabs {
    margin-top: 0.75rem;
    margin-bottom: -0.75rem;
    gap: 0.35rem;
  }

  .tab-btn {
    flex: 1;
    text-align: center;
    padding: 0.5rem 0.35rem;
    font-size: 0.82rem;
  }

  .form-section,
  .list-section {
    padding: 1rem;
    border-radius: 0.75rem;
  }

  #activeSection,
  #completedSection,
  #archiveSection {
    margin-left: 0;
    padding-left: 1rem;
  }

  .section-header-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .sort-control {
    width: 100%;
  }

  .sort-control select {
    width: 100%;
  }

  .request-header {
    flex-direction: column;
    gap: 0.25rem;
  }

  .request-created {
    text-align: left;
    margin-top: 0;
    font-size: 0.78rem;
  }

  .request-company {
    font-size: 1rem;
  }

  .request-actions {
    flex-direction: column;
  }

  .request-actions button {
    width: 100%;
    text-align: center;
  }

  .card-toggle-btn {
    width: 100%;
    justify-content: center;
    padding: 0.5rem 1rem;
  }

  .address-fields {
    grid-template-columns: 1fr 1fr;
  }

  .actions button {
    width: 100%;
  }
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.65);
}

.modal-content {
  background-color: #fefefe;
  margin: 1% auto;
  padding: 12px;
  border: 1px solid #888;
  width: 98%;
  max-width: 1200px;
  height: 92vh;
  border-radius: 8px;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#invoiceModal iframe {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: none;
}

.close {
  color: #aaa;
  float: none;
  align-self: flex-end;
  font-size: 28px;
  line-height: 1;
  font-weight: bold;
  cursor: pointer;
}

.close:hover,
.close:focus {
  color: black;
  text-decoration: none;
}
