:root {
  --bg: #0f1a14;
  --surface: #1a2820;
  --surface-2: #243429;
  --border: #2f4438;
  --text: #e8efe9;
  --muted: #8aa493;
  --accent: #6dd49a;
  --accent-dim: #3e8b62;
  --warn: #f0b96c;
  --danger: #e87b6d;
  --done: #4a7c5f;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --radius: 12px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
}

.rig-pill {
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  max-width: 50%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tabs */
.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 55px;
  top: calc(55px + env(safe-area-inset-top));
  z-index: 9;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1 0 auto;
  min-width: 90px;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-family: inherit;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Content */
main {
  flex: 1;
  padding: 16px;
  padding-bottom: 80px;
}

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty h2 {
  color: var(--text);
  margin: 0 0 8px;
  font-size: 18px;
}

.empty p {
  margin: 0 0 16px;
  font-size: 14px;
}

/* Phase header */
.phase {
  margin-bottom: 24px;
}

.phase-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.phase-num {
  width: 24px;
  height: 24px;
  background: var(--accent-dim);
  color: var(--text);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.phase.done .phase-num {
  background: var(--done);
}

.phase-title {
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.phase.active .phase-title {
  color: var(--accent);
}

.phase.locked {
  opacity: 0.4;
  pointer-events: none;
}

/* Checklist items */
.item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 12px;
  margin-bottom: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  user-select: none;
}

.item:active {
  transform: scale(0.99);
}

.item.checked {
  background: var(--surface-2);
  border-color: var(--done);
}

.item.checked .item-label {
  text-decoration: line-through;
  color: var(--muted);
}

.checkbox {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.15s;
}

.item.checked .checkbox {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox svg {
  width: 16px;
  height: 16px;
  stroke: var(--bg);
  stroke-width: 3;
  fill: none;
  opacity: 0;
}

.item.checked .checkbox svg {
  opacity: 1;
}

.item-body {
  flex: 1;
  min-width: 0;
}

.item-label {
  font-size: 15px;
  font-weight: 500;
  margin: 0;
}

.item-hint {
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 0;
  line-height: 1.4;
}

.item-critical {
  display: inline-block;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Progress */
.progress-bar {
  height: 4px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

/* Buttons */
.btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:active { transform: scale(0.98); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

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

.btn-full { width: 100%; justify-content: center; }

/* Floating action */
.fab {
  position: fixed;
  right: 16px;
  bottom: 24px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  border: none;
  font-size: 28px;
  font-weight: 300;
  cursor: pointer;
  box-shadow: var(--shadow);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Section header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-header h2 {
  font-size: 18px;
  margin: 0;
}

.section-header .count {
  font-size: 13px;
  color: var(--muted);
}

/* Locker item */
.locker-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
}

.locker-item .name {
  flex: 1;
  font-size: 15px;
}

.locker-item .qty {
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 99px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  font-size: 18px;
  display: flex;
  align-items: center;
}

.icon-btn:hover { color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); }

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

.field label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.field input,
.field select,
.field textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  width: 100%;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

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

@media (min-width: 600px) {
  .modal-bg { align-items: center; }
}

.modal {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 20px;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

@media (min-width: 600px) {
  .modal { border-radius: 16px; }
}

.modal h3 {
  margin: 0 0 16px;
  font-size: 18px;
}

/* Rig card */
.rig-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
}

.rig-card.active {
  border-color: var(--accent);
  background: var(--surface-2);
}

.rig-card .rig-name {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 4px;
}

.rig-card .rig-meta {
  font-size: 13px;
  color: var(--muted);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 99px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Completion celebration */
.celebrate {
  text-align: center;
  padding: 32px 20px;
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  border: 1px solid var(--done);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.celebrate h2 {
  margin: 0 0 8px;
  font-size: 22px;
  color: var(--accent);
}

.celebrate p {
  margin: 0 0 16px;
  color: var(--muted);
}

/* Drag affordance */
.modal::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  margin: -8px auto 16px;
}

@media (min-width: 600px) {
  .modal::before { display: none; }
}

/* Quantity stepper */
.qty-stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  border-radius: 99px;
  padding: 2px;
}

.qty-stepper button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-stepper span {
  min-width: 24px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
}

/* Add-from-locker hint */
.hint-box {
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

/* Customize steps modal */
.customize-phase {
  margin-top: 16px;
  margin-bottom: 6px;
}

.customize-phase-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.customize-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}

.customize-row:active { background: var(--surface-2); }

.customize-row.disabled {
  opacity: 0.45;
}

.customize-label {
  font-size: 14px;
  flex: 1;
}

.custom-cb {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 2px solid var(--border);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.custom-cb.on {
  background: var(--accent);
  border-color: var(--accent);
}

.custom-cb svg {
  width: 14px;
  height: 14px;
  stroke: var(--bg);
  stroke-width: 3;
  fill: none;
  opacity: 0;
}

.custom-cb.on svg {
  opacity: 1;
}

.modal-hint {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 8px;
}

/* Trip cards */
.trip-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.trip-card.active {
  border-color: var(--accent);
  background: var(--surface-2);
}

.trip-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.trip-name {
  font-size: 15px;
  font-weight: 600;
}

/* ---------- Rig picker (Add Rig modal) ---------- */
.picker-results {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 6px;
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}

.picker-row {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.picker-row:last-child { border-bottom: none; }

.picker-row:active,
.picker-row:hover {
  background: var(--surface-2);
}

.picker-row-main {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.picker-row-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.picker-hint {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
}

.picker-selected {
  border: 1px solid var(--accent);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-top: 8px;
}

.picker-selected-main {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.picker-selected-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
