:root {
  --orange: #E8711A;
  --orange-dark: #C55E10;
  --dark: #1C2128;
  --surface: #FFFFFF;
  --bg: #F0F2F5;
  --text: #24292F;
  --text-muted: #636E7B;
  --border: #D0D7DE;
  --success: #2DA44E;
  --danger: #CF222E;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,.12);
  --shadow-md: 0 4px 16px rgba(0,0,0,.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.5;
}

/* ── App Header ── */
.app-header {
  background: var(--dark);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.app-header .logo { font-weight: 700; font-size: 1.1rem; letter-spacing: .5px; }
.app-header .logo span { color: var(--orange); }
.app-header .spacer { flex: 1; }
.app-header .user-info { font-size: .85rem; color: rgba(255,255,255,.8); text-align: right; }
.app-header .user-name { font-weight: 600; color: #fff; display: block; }
.header-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,.8);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  font-size: .85rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.header-btn:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .1s, opacity .15s;
  min-height: 48px;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #c0c8d4; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a81a23; }
.btn-success { background: var(--success); color: #fff; }
.btn-ghost { background: transparent; color: var(--orange); border: 2px solid var(--orange); }
.btn-ghost:hover { background: var(--orange); color: #fff; }
.btn-sm { padding: 6px 12px; min-height: 36px; font-size: .9rem; }
.btn-full { width: 100%; }
.btn-google {
  background: #fff;
  color: #3c4043;
  border: 2px solid var(--border);
  font-size: 1rem;
  padding: 12px 20px;
}
.btn-google:hover { background: #f8f9fa; }
.btn-google svg { width: 20px; height: 20px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card h2 { font-size: 1.15rem; font-weight: 700; }
.card h3 { font-size: 1rem; font-weight: 600; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: .9rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
  -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--orange);
}
.form-textarea { min-height: 100px; resize: vertical; }

/* ── Checkbox Grid ── */
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  user-select: none;
}
.check-item:hover { border-color: var(--orange); background: #fef6f0; }
.check-item input[type=checkbox], .check-item input[type=radio] {
  width: 20px;
  height: 20px;
  accent-color: var(--orange);
  cursor: pointer;
  flex-shrink: 0;
}
.check-item.checked { border-color: var(--orange); background: #fef6f0; }

/* ── Radio Row ── */
.radio-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}
.radio-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.radio-item:hover { border-color: var(--orange); }
.radio-item input { width: 20px; height: 20px; accent-color: var(--orange); flex-shrink: 0; }
.radio-item.selected { border-color: var(--orange); background: #fef6f0; font-weight: 600; }

/* ── Multi-Select ── */
.ms-container {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .15s;
}
.ms-container:focus-within { border-color: var(--orange); }
.ms-search-wrap { padding: 8px; border-bottom: 1px solid var(--border); background: #fafbfc; }
.ms-search {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: .95rem;
}
.ms-search:focus { outline: none; border-color: var(--orange); }
.ms-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  min-height: 42px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
}
.ms-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--orange);
  color: #fff;
  border-radius: 20px;
  padding: 4px 10px;
  font-size: .85rem;
  font-weight: 600;
}
.ms-tag button {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
  opacity: .8;
}
.ms-tag button:hover { opacity: 1; }
.ms-options {
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
}
.ms-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .95rem;
  transition: background .1s;
}
.ms-option:hover { background: #f0f2f5; }
.ms-option input { width: 18px; height: 18px; accent-color: var(--orange); flex-shrink: 0; }

/* ── Equipment Grid ── */
.equip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.equip-item {
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color .15s;
}
.equip-item.active { border-color: var(--orange); }
.equip-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  cursor: pointer;
  background: #fafbfc;
}
.equip-header input { width: 20px; height: 20px; accent-color: var(--orange); flex-shrink: 0; }
.equip-name { font-size: .9rem; font-weight: 600; }
.equip-qty {
  display: none;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: #fef6f0;
}
.equip-item.active .equip-qty { display: block; }
.equip-qty input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: .95rem;
}
.equip-qty label { font-size: .8rem; color: var(--text-muted); display: block; margin-bottom: 4px; }

/* ── Materials ── */
.mat-search-bar {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 8px 0 12px;
  z-index: 10;
}
.mat-category { margin-bottom: 16px; }
.mat-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--dark);
  color: #fff;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-weight: 600;
  font-size: .95rem;
  user-select: none;
}
.mat-cat-header .count {
  background: rgba(255,255,255,.2);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: .8rem;
}
.mat-cat-body { border: 2px solid var(--dark); border-top: none; border-radius: 0 0 8px 8px; }
.mat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.mat-item:last-child { border-bottom: none; }
.mat-item:hover { background: #f8f9fa; }
.mat-item input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--orange); flex-shrink: 0; }
.mat-name { flex: 1; font-size: .92rem; }
.mat-price { font-size: .85rem; color: var(--text-muted); white-space: nowrap; }
.mat-qty {
  display: none;
  align-items: center;
  gap: 6px;
  margin-left: 30px;
  margin-bottom: 6px;
  padding: 0 14px 10px;
  background: #fef6f0;
}
.mat-qty.show { display: flex; }
.mat-qty input {
  width: 90px;
  border: 2px solid var(--orange);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: .95rem;
  font-weight: 600;
}
.mat-qty label { font-size: .85rem; color: var(--text-muted); }
.mat-hidden { display: none; }

/* ── Step Indicator ── */
.step-bar {
  background: var(--dark);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.step-bar::-webkit-scrollbar { display: none; }
.step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.3);
  color: rgba(255,255,255,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: all .2s;
}
.step-dot.done { background: var(--success); border-color: var(--success); color: #fff; }
.step-dot.active { background: var(--orange); border-color: var(--orange); color: #fff; }
.step-line {
  flex: 1;
  height: 2px;
  background: rgba(255,255,255,.2);
  min-width: 20px;
}
.step-line.done { background: var(--success); }
.step-label {
  display: none;
}
@media (min-width: 480px) {
  .step-label {
    display: block;
    font-size: .65rem;
    color: rgba(255,255,255,.5);
    text-align: center;
    margin-top: 4px;
  }
  .step-dot.active + .step-label { color: var(--orange); }
  .step-dot-wrap { display: flex; flex-direction: column; align-items: center; }
}

/* ── Form Wizard ── */
.form-step { display: none; }
.form-step.active { display: block; }
.step-section {
  padding: 0 0 80px;
  max-width: 700px;
  margin: 0 auto;
}
.step-title {
  padding: 20px 16px 4px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--dark);
}
.step-subtitle {
  padding: 0 16px 16px;
  color: var(--text-muted);
  font-size: .9rem;
}
.step-body { padding: 0 16px; }

.form-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 50;
  box-shadow: 0 -4px 12px rgba(0,0,0,.08);
}
.form-footer .step-counter {
  flex: 1;
  text-align: center;
  font-size: .85rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ── Index / Login ── */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--dark) 0%, #2d3748 100%);
}
.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .company { font-size: 1.5rem; font-weight: 800; color: var(--dark); }
.login-logo .company span { color: var(--orange); }
.login-logo .subtitle { color: var(--text-muted); font-size: .9rem; margin-top: 4px; }
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: .85rem;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.admin-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .85rem;
  cursor: pointer;
  text-decoration: underline;
  display: block;
  margin: 12px auto 0;
}
.admin-form { display: none; }
.admin-form.open { display: block; }
.error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--danger);
  font-size: .9rem;
  margin-bottom: 14px;
  display: none;
}
.error-msg.show { display: block; }

/* ── Cards List ── */
.cards-container { max-width: 700px; margin: 0 auto; padding: 16px; }
.job-card-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
  border-left: 4px solid var(--border);
}
.job-card-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.job-card-item.status-finished { border-left-color: var(--success); }
.job-card-item.status-busy { border-left-color: var(--orange); }
.jc-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.jc-number { font-weight: 700; font-size: 1.05rem; }
.jc-status { font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.jc-status.finished { background: #d4edda; color: #155724; }
.jc-status.busy { background: #fff3cd; color: #856404; }
.jc-location { color: var(--text-muted); font-size: .9rem; }
.jc-date { color: var(--text-muted); font-size: .85rem; margin-top: 6px; }
.jc-meta { display: flex; gap: 16px; margin-top: 8px; font-size: .85rem; color: var(--text-muted); }

/* ── Admin Panel ── */
.admin-layout {
  display: flex;
  min-height: calc(100vh - 56px);
}
.admin-sidebar {
  width: 240px;
  background: var(--dark);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 0;
}
@media (max-width: 768px) {
  .admin-sidebar { display: none; }
  .admin-sidebar.open { display: flex; position: fixed; top: 56px; left: 0; bottom: 0; z-index: 200; width: 240px; }
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  transition: background .1s, color .1s;
  font-size: .95rem;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--orange); color: #fff; }
.admin-main { flex: 1; padding: 20px; overflow-x: hidden; }
.admin-content { display: none; }
.admin-content.active { display: block; }

/* ── Stats Row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}
.stat-value { font-size: 2rem; font-weight: 800; color: var(--orange); }
.stat-label { font-size: .8rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; margin-top: 4px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th {
  background: var(--dark);
  color: #fff;
  padding: 12px 14px;
  text-align: left;
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: .9rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8f9fa; }
tr.clickable { cursor: pointer; }

/* ── Filters ── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.filter-bar .form-input, .filter-bar .form-select { max-width: 200px; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
  overflow-y: auto;
  padding: 20px;
}
.modal-overlay.open { display: flex; align-items: flex-start; justify-content: center; }
.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 720px;
  box-shadow: var(--shadow-md);
  margin: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.2rem; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 4px;
}
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Tabs ── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab {
  padding: 10px 18px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
}
.tab.active { color: var(--orange); border-bottom-color: var(--orange); }

/* ── Badge ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: .78rem;
  font-weight: 700;
}
.badge-finished { background: #d4edda; color: #155724; }
.badge-busy { background: #fff3cd; color: #856404; }

/* ── Photo Grid ── */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin-top: 10px; }
.photo-thumb {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--border);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.photo-thumb .del-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(207,34,46,.85);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: .9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.photo-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s;
  color: var(--text-muted);
  font-size: .9rem;
}
.photo-upload-area:hover { border-color: var(--orange); color: var(--orange); }
.photo-upload-area input[type=file] { display: none; }

/* ── Misc ── */
.section-divider { border: none; border-top: 2px solid var(--border); margin: 24px 0; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  flex-direction: column;
  gap: 12px;
  font-weight: 600;
}
.loading-overlay .spinner { border-color: rgba(232,113,26,.3); border-top-color: var(--orange); }
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--dark);
  color: #fff;
  padding: 12px 20px;
  border-radius: 24px;
  font-weight: 600;
  z-index: 600;
  box-shadow: var(--shadow-md);
  transition: opacity .3s;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }

/* ── Footer branding ── */
.app-footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: .8rem;
}
.app-footer a { color: var(--orange); text-decoration: none; }

@media (max-width: 600px) {
  .check-grid { grid-template-columns: 1fr 1fr; }
  .equip-grid { grid-template-columns: 1fr 1fr; }
  .radio-group { grid-template-columns: 1fr 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .filter-bar .form-input, .filter-bar .form-select { max-width: 100%; width: 100%; }
  .admin-main { padding: 12px; }
}
