/* WrenchMinder — Glovebox Service Ticket Rail */

:root {
  --charcoal: #232a2e;
  --charcoal-deep: #1a2023;
  --charcoal-line: #2f383d;
  --amber: #e08a2e;
  --amber-soft: rgba(224, 138, 46, 0.14);
  --sand: #d8c3a5;
  --sand-dim: rgba(216, 195, 165, 0.55);
  --sand-faint: rgba(216, 195, 165, 0.3);
  --teal: #4a9a90;
  --teal-soft: rgba(74, 154, 144, 0.16);
  --graphite: #6d7a80;
  --danger: #c4574a;
  --ticket: #262f34;
  --radius-ticket: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--charcoal-deep);
  color: var(--sand);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  overscroll-behavior-y: contain;
}

#app { min-height: 100vh; }

/* ---------- layout ---------- */

#panels {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 14px;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: calc(108px + env(safe-area-inset-bottom, 0px));
}

.panel { padding-top: 10px; }
.panel[hidden] { display: none; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- garage: service-sticker header ---------- */

.sticker-header { margin: 8px 0 14px; }

.sticker-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--sand);
  color: var(--charcoal);
  border-radius: 8px;
  padding: 10px 12px;
  border-left: 6px solid var(--amber);
  position: relative;
  overflow: hidden;
}

.sticker-hole {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--charcoal-deep);
  border: 3px solid var(--charcoal);
  flex: 0 0 auto;
}

.sticker-text h1 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sticker-text p {
  margin: 1px 0 0;
  font-size: 11px;
  opacity: 0.75;
}

.sticker-stripe {
  position: absolute;
  right: -6px;
  top: 0;
  bottom: 0;
  width: 22px;
  background: repeating-linear-gradient(
    -45deg,
    var(--amber) 0 6px,
    var(--charcoal) 6px 12px
  );
  opacity: 0.85;
}

/* ---------- counters ---------- */

.counter-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.counter {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ticket);
  border: 1px solid var(--charcoal-line);
  border-radius: 10px;
  padding: 9px 12px;
}

.counter-num {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  min-width: 20px;
}

.counter-word {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sand-dim);
}

/* ---------- rivets ---------- */

.rivet {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--graphite);
  background: transparent;
  flex: 0 0 auto;
}

.rivet.filled { background: currentColor; border-color: currentColor; }
.rivet-amber { color: var(--amber); }
.rivet-teal { color: var(--teal); }
.rivet-graphite { color: var(--graphite); }

/* ---------- add strip ---------- */

.add-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  background: var(--amber);
  color: #241a0d;
  border: none;
  border-radius: var(--radius-ticket);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  margin-bottom: 18px;
}

.add-strip:active { transform: scale(0.985); }

.add-plus {
  width: 14px;
  height: 14px;
  position: relative;
}

.add-plus::before,
.add-plus::after {
  content: '';
  position: absolute;
  background: #241a0d;
}

.add-plus::before {
  left: 50%; top: 0; bottom: 0;
  width: 3px; margin-left: -1.5px;
}

.add-plus::after {
  top: 50%; left: 0; right: 0;
  height: 3px; margin-top: -1.5px;
}

.rail-label {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sand-dim);
  margin: 0 2px 8px;
}

/* ---------- panel headers ---------- */

.panel-header {
  border-bottom: 1px solid var(--charcoal-line);
  padding: 8px 2px 10px;
  margin-bottom: 12px;
}

.panel-header h1 {
  margin: 0;
  font-size: 20px;
  color: #fff;
}

.panel-header p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--sand-dim);
}

/* ---------- tickets ---------- */

.ticket {
  display: flex;
  align-items: stretch;
  background: var(--ticket);
  border: 1px solid var(--charcoal-line);
  border-radius: var(--radius-ticket);
  margin-bottom: 10px;
  overflow: hidden;
}

.ticket-stripe {
  width: 7px;
  flex: 0 0 auto;
}

.stage-due .ticket-stripe { background: var(--amber); }
.stage-wrenching .ticket-stripe { background: var(--teal); }
.stage-done .ticket-stripe { background: var(--graphite); }
.stage-done .ticket { opacity: 0.78; }

.ticket-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px 12px 12px;
  min-height: 56px;
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  text-align: left;
}

.ticket-main:active { background: rgba(255, 255, 255, 0.03); }

.ticket-text { flex: 1; min-width: 0; }

.ticket-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-meta {
  display: block;
  font-size: 12px;
  color: var(--sand-dim);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-word {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  flex: 0 0 auto;
}

.stage-due .stage-word { color: var(--amber); }
.stage-wrenching .stage-word { color: var(--teal); }
.stage-done .stage-word { color: var(--graphite); }

/* focus ticket on Garage */

.focus-ticket { border-width: 1.5px; border-color: rgba(224, 138, 46, 0.4); }

.focus-ticket .ticket-title { font-size: 18px; }
.focus-ticket .ticket-meta { font-size: 13px; margin-top: 4px; }
.focus-ticket .ticket-main { padding: 16px 12px; min-height: 76px; }
.focus-ticket .stage-hint {
  display: block;
  font-size: 11px;
  color: var(--amber);
  margin-top: 6px;
  letter-spacing: 0.04em;
}

/* row actions */

.ticket-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 8px 8px 8px 0;
}

.row-btn {
  min-width: 52px;
  min-height: 34px;
  border: 1px solid var(--charcoal-line);
  border-radius: 8px;
  background: var(--charcoal-deep);
  color: var(--sand);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.row-btn:active { background: var(--charcoal-line); }
.row-btn.confirm { border-color: var(--danger); color: var(--danger); }

/* group headers in Queue */

.group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 2px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.group-head .g-count {
  margin-left: auto;
  color: var(--sand-dim);
  font-weight: 500;
  letter-spacing: 0;
}

.group-due { color: var(--amber); }
.group-wrenching { color: var(--teal); }
.group-done { color: var(--graphite); }

.group-empty {
  margin: 2px 4px 10px;
  font-size: 12.5px;
  color: var(--sand-faint);
}

/* ---------- empty states ---------- */

.empty {
  text-align: center;
  padding: 30px 16px 26px;
  color: var(--sand-dim);
}

.empty-sticker {
  width: 92px;
  height: 62px;
  margin: 0 auto 14px;
  border: 2px dashed var(--sand-faint);
  border-radius: 10px;
  position: relative;
}

.empty-sticker::before {
  /* punched hole */
  content: '';
  position: absolute;
  top: 7px;
  left: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--sand-faint);
}

.empty-sticker::after {
  /* oil drip */
  content: '';
  position: absolute;
  bottom: 8px;
  right: 16px;
  width: 7px;
  height: 14px;
  background: var(--sand-faint);
  border-radius: 4px 4px 7px 7px;
}

.empty p { margin: 0 0 4px; font-size: 15px; color: var(--sand); }
.empty .hint { font-size: 12.5px; color: var(--sand-dim); }

/* ---------- forms ---------- */

.field { margin-bottom: 14px; }

.field label,
.label-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--sand);
  margin-bottom: 6px;
}

.field label em {
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber);
}

.field input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  font-size: 16px; /* prevents iOS zoom */
  color: #fff;
  background: var(--ticket);
  border: 1px solid var(--charcoal-line);
  border-radius: 10px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.field input:focus { border-color: var(--amber); }

.field input[aria-invalid="true"] { border-color: var(--danger); }

.field-error {
  margin: 5px 2px 0;
  font-size: 12px;
  color: var(--danger);
}

.search-field { margin-bottom: 12px; }
.search-field input { border-radius: 24px; }

.stage-picker {
  display: flex;
  gap: 8px;
}

.stage-opt {
  flex: 1;
  min-height: 46px;
  border-radius: 10px;
  border: 1px solid var(--charcoal-line);
  background: var(--ticket);
  color: var(--sand-dim);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.stage-opt[aria-pressed="true"] { color: #fff; }
.stage-opt-due[aria-pressed="true"] { background: var(--amber-soft); border-color: var(--amber); }
.stage-opt-wrenching[aria-pressed="true"] { background: var(--teal-soft); border-color: var(--teal); }
.stage-opt-done[aria-pressed="true"] { background: rgba(109, 122, 128, 0.2); border-color: var(--graphite); }

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.btn-primary {
  min-height: 52px;
  border: none;
  border-radius: var(--radius-ticket);
  background: var(--amber);
  color: #241a0d;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.btn-ghost {
  min-height: 46px;
  border: 1px solid var(--charcoal-line);
  border-radius: var(--radius-ticket);
  background: transparent;
  color: var(--sand);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger {
  min-height: 46px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-ticket);
  background: transparent;
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- about ---------- */

.about-card {
  margin-top: 22px;
  background: var(--ticket);
  border: 1px solid var(--charcoal-line);
  border-left: 6px solid var(--graphite);
  border-radius: var(--radius-ticket);
  padding: 14px;
}

.about-card h2 {
  margin: 0 0 6px;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sand);
}

.about-card p {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--sand-dim);
}

.about-actions {
  display: flex;
  gap: 10px;
}

.about-actions button { flex: 1; font-size: 13px; min-height: 44px; }

/* ---------- bottom tab bar: hex nuts ---------- */

#tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  max-width: 480px;
  margin: 0 auto;
  background: var(--charcoal);
  border-top: 1px solid var(--charcoal-line);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0px));
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-height: 58px;
  padding: 4px 0 2px;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tab-label {
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--sand-dim);
}

.nut {
  width: 26px;
  height: 26px;
  background: #46535a;
  clip-path: polygon(25% 3%, 75% 3%, 98% 50%, 75% 97%, 25% 97%, 2% 50%);
  position: relative;
  transition: transform 0.25s ease, background-color 0.2s ease, filter 0.2s ease;
}

.nut::after {
  content: '';
  position: absolute;
  inset: 28%;
  background: var(--charcoal);
  clip-path: inherit;
}

.tab.active .nut {
  background: var(--amber);
  transform: rotate(90deg);
  filter: drop-shadow(0 3px 5px rgba(224, 138, 46, 0.45));
}

.tab.active .tab-label { color: var(--amber); font-weight: 700; }

/* ---------- toast ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(102px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 30;
  background: var(--sand);
  color: var(--charcoal);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 20px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

#toast[hidden] { display: none; }
