:root {
  --blue: #0F034E;
  --blue-light: #ede9f8;
  --blue-mid: #2a1878;
  --gold: #9C7E0F;
  --gold-light: #f9f4e3;
  --red: #dc2626;
  --green: #16a34a;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-400: #94a3b8;
  --gray-700: #334155;
  --gray-900: #0f172a;
  font-family: system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.5;
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 0.4rem 4rem;
}

header {
  padding: 1.5rem 0 1rem;
  border-bottom: 3px solid var(--blue);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-left { display: flex; flex-direction: column; }

header h1 { margin: 0; font-size: 1.5rem; color: var(--blue); }

.header-logo {
  height: 52px;
  width: auto;
  flex-shrink: 0;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--gray-400);
  font-size: 0.9rem;
}

.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-400);
}

.auto-label {
  font-size: 0.75rem;
  font-weight: normal;
  text-transform: none;
  letter-spacing: 0;
  color: var(--gray-400);
}

.field-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.75rem;
}

.field-row label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--gray-700);
}

.req { color: var(--red); }

input[type="text"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--gray-50);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

/* Entry rows (employee, contractor, etc.) */
.entry-card {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: var(--gray-50);
  position: relative;
}

.entry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
}

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

.entry-grid .full-width { grid-column: 1 / -1; }

.entry-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.2rem;
  display: block;
}

.btn-remove {
  position: absolute;
  top: 0.6rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0;
  line-height: 1;
}

.btn-remove:hover { color: var(--red); }

.btn-copy {
  position: absolute;
  top: 0.6rem;
  right: 2rem;
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 1.0rem;
  padding: 0;
  line-height: 1;
}

.btn-copy:hover { color: var(--blue); }

.btn-add {
  background: none;
  border: 1px dashed var(--gray-400);
  border-radius: 6px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  color: var(--blue);
  cursor: pointer;
  width: 100%;
  margin-top: 0.25rem;
}

.btn-add:hover { background: var(--blue-light); }

.submit-row {
  text-align: center;
  margin-top: 1.5rem;
}

.btn-submit {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 2.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-submit:hover { background: var(--blue-mid); }
.btn-submit:disabled { opacity: 0.6; cursor: default; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 1.75rem;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-box h2 { margin: 0 0 1rem; }

.summary-section { margin-bottom: 1rem; }
.summary-section h3 { font-size: 0.85rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--gray-400); margin: 0 0 0.4rem; }

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid var(--gray-100);
}

.validation-modal-title {
  margin: 0 0 1rem;
  color: var(--red);
}

.validation-error-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.5rem;
}

.validation-error-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.4rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--gray-900);
}

.validation-error-list li::before {
  content: '!';
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  background: var(--red);
  color: #fff;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.1rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  justify-content: flex-end;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 0.6rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover { background: var(--blue-mid); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
  border-radius: 7px;
  padding: 0.6rem 1.5rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn-secondary:hover { background: var(--gray-200); }

/* Result screen */
.result-card {
  text-align: center;
  padding: 3rem 2rem;
  margin-top: 2rem;
}

.result-icon { font-size: 3rem; margin-bottom: 0.5rem; }

#result-actions { margin-top: 1.5rem; display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

.btn-download {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
  border-radius: 7px;
  padding: 0.55rem 1.25rem;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn-download:hover { background: var(--gray-200); }

/* Numbered location display in Ticket Details */
.loc-display-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.35rem 0;
}

.loc-badge {
  background: var(--blue-light);
  color: var(--blue);
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  font-size: 0.82rem;
  font-weight: 500;
}

/* Sheet location cell overlay */
.loc-num-disp {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 0.3rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray-700);
  pointer-events: none;
  background: transparent;
}

.error-msg {
  color: var(--red);
  font-size: 0.8rem;
  margin-top: 0.25rem;
  display: none;
}

input.invalid, select.invalid { border-color: var(--red); }

.confirm-fields {
  border-top: 1px solid var(--gray-200);
  margin-top: 1rem;
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Section header with inline toggle */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-header h2 { margin: 0; }

/* Card / Sheet toggle */
.view-toggle {
  display: flex;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  overflow: hidden;
}

.toggle-btn {
  background: none;
  border: none;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-400);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.toggle-btn + .toggle-btn {
  border-left: 1px solid var(--gray-200);
}

.toggle-btn.active {
  background: var(--blue);
  color: #fff;
}

/* Spreadsheet */
.sheet-scroll {
  overflow-x: auto;
  margin-bottom: 0.5rem;
  border: 1px solid #adb5bd;
  border-radius: 4px;
}

.emp-sheet {
  border-collapse: collapse;
  width: 100%;
  min-width: 620px;
  font-size: 0.82rem;
  table-layout: fixed;
}

.emp-sheet thead th {
  background: #e9ecef;
  border: 1px solid #adb5bd;
  padding: 0.3rem 0.4rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gray-700);
  white-space: nowrap;
  overflow: hidden;
}

.emp-sheet th.col-loc       { width: 60px; }
.emp-sheet th.col-actions   { width: 52px; }
.emp-sheet th.col-name      { width: 160px; }
.emp-sheet th.col-pos       { width: 120px; }
.emp-sheet th.col-crew      { width: 58px; }
.emp-sheet th.col-dtype     { width: 90px; }
.emp-sheet th.col-pd        { width: 66px; }
.emp-sheet th.col-hrs       { width: 72px; }
.emp-sheet th.col-day-rate  { width: 72px; }
.emp-sheet th.col-notes     { width: auto; }
.emp-sheet th.col-notes-sm  { width: auto; }

.emp-sheet tbody tr:nth-child(even) { background: #f8f9fa; }
.emp-sheet tbody tr:hover { background: #eef4ff; }

.sheet-cell {
  border: 1px solid #ced4da;
  padding: 0;
  vertical-align: middle;
}

.sheet-actions-cell {
  border: 1px solid #ced4da;
  padding: 0.15rem;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

.sheet-input {
  width: 100%;
  height: 28px;
  padding: 0.15rem 0.3rem;
  border: none;
  border-radius: 0;
  background: transparent;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
}

.sheet-input:focus {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
  background: #fff;
}

select.sheet-input {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 0.2rem;
  cursor: pointer;
}

.sheet-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.15rem 0.25rem;
  color: var(--gray-400);
  line-height: 1;
  border-radius: 3px;
}

.sheet-btn:hover { color: var(--gray-900); background: var(--gray-200); }
.sheet-btn-del:hover { color: var(--red); background: #fee2e2; }

.error-instructions {
  text-align: left;
  margin: 0.75rem 0 1rem;
  padding-left: 1.5rem;
  color: var(--gray-700);
  line-height: 1.7;
}

.error-instructions a {
  color: var(--blue);
  text-decoration: underline;
}

