:root {
  --bg: #f3f5f2;
  --card: #ffffff;
  --ink: #15322b;
  --muted: #5f6d67;
  --line: #dde4df;
  --brand: #125b50;
  --brand-soft: #e8f3f1;
  --danger: #b9382f;
  --danger-soft: #fdebea;
  --warn: #b56a00;
  --warn-soft: #fff3dd;
  --neutral: #5b6575;
  --neutral-soft: #eff2f7;
  --vacant: #f5f7fa;
  --shadow: 0 12px 32px rgba(12, 32, 26, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

/* 確保 hidden 屬性不被 display 規則覆蓋 */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  background: linear-gradient(180deg, #e5f1ee 0%, var(--bg) 220px);
  color: var(--ink);
}

body.picker-open {
  overflow: hidden;
}

.app-header {
  padding: 24px 16px 20px;
}

.header-inner {
  max-width: 760px;
  margin: 0 auto;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 700;
}

.app-header h1 {
  margin: 0;
  font-size: 30px;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.profile-card {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.profile-card img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--brand-soft);
}

.profile-name {
  font-weight: 700;
}

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

.app-shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

.login-shell {
  min-height: calc(100vh - 140px);
  display: flex;
  align-items: center;
}

.login-card {
  width: 100%;
  display: grid;
  gap: 16px;
}

.login-profile-card {
  margin-top: 0;
  background: #f8fbfa;
  border: 1px solid var(--line);
  box-shadow: none;
}

.login-profile-card .profile-name::before {
  content: "目前登入：";
  color: var(--muted);
  font-weight: 500;
  margin-right: 4px;
}

.login-access-panel {
  display: grid;
  gap: 12px;
}

.access-card {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #f8fbfa;
}

.access-card--allowed {
  background: #eef8f4;
  border-color: #c9e3d7;
}

.access-card--pending {
  background: #fff8ea;
  border-color: #f0d39d;
}

.access-card__eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.access-card__title {
  margin: 6px 0 0;
  font-size: 18px;
  font-weight: 700;
}

.access-card__hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.access-card .info-list {
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.8);
}

.access-request-form {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fcfdfc;
}

.request-field-grid {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

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

.text-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.text-input:focus,
.note-input:focus {
  outline: 2px solid rgba(18, 91, 80, 0.18);
  outline-offset: 0;
  border-color: var(--brand);
}

.access-request-form .ghost-button {
  width: 100%;
}

.login-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

.login-card h2 {
  margin: 0;
  font-size: 28px;
}

.login-feature-list {
  display: grid;
  gap: 10px;
}

.login-feature-item {
  padding: 12px 14px;
  border-radius: 14px;
  background: #f8fbfa;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.card {
  margin-bottom: 16px;
  padding: 18px;
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0;
  font-size: 22px;
}

.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.status-card {
  display: grid;
  gap: 14px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.status-label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-value {
  margin-top: 6px;
  font-size: 20px;
  font-weight: 700;
}

.inline-message {
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
}

.inline-message.info {
  background: var(--brand-soft);
  color: var(--brand);
}

.inline-message.success {
  background: #e6f6ef;
  color: #1e7b53;
}

.inline-message.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.loading {
  padding: 12px 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.inspection-form {
  display: grid;
  gap: 18px;
}

.target-group {
  display: grid;
  gap: 12px;
}

.group-title {
  margin: 0;
  font-size: 18px;
}

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

.target-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: #fcfdfc;
}

.target-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.target-name {
  font-size: 18px;
  font-weight: 700;
}

.target-type {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--brand-soft);
  color: var(--brand);
}

.target-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.info-list {
  margin-top: 10px;
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #f6faf8;
  border: 1px solid var(--line);
}

.info-row {
  display: flex;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.info-label {
  min-width: 56px;
  color: var(--muted);
}

.info-value {
  color: var(--ink);
  word-break: break-word;
}

.info-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.score-item-wrap {
  margin-top: 14px;
}

.native-select-hidden {
  display: none;
}

.score-select {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

.score-select:focus {
  outline: 2px solid rgba(18, 91, 80, 0.18);
  outline-offset: 0;
  border-color: var(--brand);
}

.picker-trigger {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  text-align: left;
}

.picker-trigger::after {
  content: "▾";
  color: var(--muted);
  flex-shrink: 0;
}

.picker-trigger:focus,
.picker-trigger:focus-visible {
  outline: 2px solid rgba(18, 91, 80, 0.18);
  outline-offset: 0;
  border-color: var(--brand);
}

.picker-trigger.is-placeholder {
  color: var(--muted);
}

.picker-trigger:disabled {
  background: #f7faf8;
  color: #94a59f;
  cursor: not-allowed;
}

.picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 240;
  background: rgba(12, 32, 26, 0.48);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-top: 32px;
}

.picker-sheet {
  width: min(760px, 100%);
  max-height: min(72vh, 560px);
  background: #fff;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -12px 32px rgba(12, 32, 26, 0.18);
  padding: 18px 16px calc(16px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.picker-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.picker-sheet-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.picker-sheet-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #eff4f1;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}

.picker-option-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.picker-option-group {
  display: grid;
  gap: 8px;
}

.picker-option-group-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.picker-option {
  width: 100%;
  min-height: 50px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  text-align: left;
}

.picker-option:focus,
.picker-option:focus-visible {
  outline: 2px solid rgba(18, 91, 80, 0.18);
  outline-offset: 0;
  border-color: var(--brand);
}

.picker-option.is-selected {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}

.picker-option-check {
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.picker-empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.note-wrap {
  margin-top: 12px;
}

.note-input {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  font: inherit;
}

.sticky-action {
  position: sticky;
  bottom: 16px;
  margin-top: 16px;
}

.primary-button,
.ghost-button {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 700;
}

.primary-button {
  width: 100%;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 24px rgba(18, 91, 80, 0.22);
}

.primary-button:disabled {
  background: #93b8b1;
  box-shadow: none;
}

.ghost-button {
  background: var(--neutral-soft);
  color: var(--neutral);
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-day {
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.history-toggle {
  width: 100%;
  border: 0;
  padding: 14px 16px;
  background: #fff;
  text-align: left;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-toggle::after {
  content: "▼";
  font-size: 10px;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.history-day.is-open .history-toggle::after {
  transform: rotate(180deg);
}

.history-items {
  display: none;
  gap: 0;
  border-top: 1px solid var(--line);
}

.history-day.is-open .history-items {
  display: grid;
}

.history-item {
  padding: 12px 16px;
  display: grid;
  gap: 4px;
}

.history-item + .history-item {
  border-top: 1px solid var(--line);
}

.history-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-name {
  font-weight: 700;
}

.history-status {
  font-size: 13px;
  font-weight: 700;
}

.history-status.normal {
  color: var(--brand);
}

.history-status.issue {
  color: var(--warn);
}

.history-status.plus {
  color: var(--brand);
}

.history-status.minus {
  color: var(--danger);
}

.history-status.note {
  color: var(--neutral);
}

.history-status.closed,
.history-status.vacant {
  color: var(--neutral);
}

.history-note,
.history-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.empty-state {
  padding: 16px 0;
  color: var(--muted);
  font-size: 14px;
}

/* ── Stall map: view tabs ── */
.stall-view-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.stall-tab {
  appearance: none;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 6px 16px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.stall-tab.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* ── Stall map: floor plan ── */
.stall-floor-plan {
  background: #f4f1eb;
  border: 3px solid #8a8278;
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 10px;
  max-width: 780px;
  margin-inline: auto;
}

.stall-north-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #5f6b7a;
  background: #fff;
  border: 1px solid #d4dbe5;
  border-radius: 999px;
  padding: 4px 10px;
  margin-bottom: 8px;
}

.stall-grid {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 16px minmax(0, 1fr) 14px minmax(0, 1fr) 16px minmax(0, 1fr) 52px;
  grid-template-rows: 44px 90px 90px 90px 90px 44px;
  gap: 6px;
}

/* ── Stall map: landmarks ── */
.stall-lm {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #999;
  background: #efefef;
  border: 1.5px dashed #ccc;
  text-align: center;
  line-height: 1.3;
}

.stall-lm-icon {
  font-size: 1rem;
  line-height: 1;
}

.stall-lm-elevator {
  font-size: 0.75rem;
  color: #666;
  background: #e4e4e4;
  flex-direction: column;
  gap: 4px;
}

.stall-lm-side {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 0.68rem;
  padding: 6px 0;
}

.stall-lm-top,
.stall-lm-bottom,
.stall-lm-stairs {
  font-size: 0.72rem;
}

.stall-lm-xhn {
  font-size: 0.72rem;
  padding: 0 12px;
}

/* ── Stall map: horizontal wall ── */
.stall-wall-h {
  grid-column: 1 / 7;
  background: #8a8278;
  border-radius: 3px;
}

/* ── Stall map: stall cells ── */
.stall-cell {
  border-radius: 10px;
  padding: 8px 6px;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  border: 2.5px dashed var(--line);
  background: #f9faf9;
  overflow: hidden;
  position: relative;
}

.stall-cell:active {
  transform: scale(0.96);
}

.stall-cell--selected {
  box-shadow: 0 0 0 3px var(--brand);
  transform: translateY(-2px);
}

/* Status colors on map cells */
.stall-cell--normal {
  border-style: solid;
  border-color: var(--brand);
  background: #e6f6ef;
}

.stall-cell--issue {
  border-style: solid;
  border-color: #cf6a00;
  background: #fff3dd;
}

.stall-cell--plus {
  border-style: solid;
  border-color: var(--brand);
  background: #e6f6ef;
}

.stall-cell--minus {
  border-style: solid;
  border-color: var(--danger);
  background: var(--danger-soft);
}

.stall-cell--note {
  border-style: solid;
  border-color: var(--neutral);
  background: var(--neutral-soft);
}

.stall-cell--vacant {
  border-style: solid;
  border-color: #7d8aa2;
  background: #f0f2f6;
}

.stall-cell--closed {
  border-style: solid;
  border-color: var(--neutral);
  background: #e8eaed;
}

.stall-cell-no {
  font-size: 1.1rem;
  font-weight: 700;
  color: #333;
  line-height: 1.2;
}

.stall-cell-name {
  font-size: 0.75rem;
  color: #555;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
  max-height: 2.6em;
  word-break: break-all;
}

.stall-cell-status-dot {
  position: absolute;
  top: 4px;
  right: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.stall-cell--normal .stall-cell-status-dot { background: var(--brand); }
.stall-cell--issue .stall-cell-status-dot { background: #cf6a00; }
.stall-cell--plus .stall-cell-status-dot { background: var(--brand); }
.stall-cell--minus .stall-cell-status-dot { background: var(--danger); }
.stall-cell--note .stall-cell-status-dot { background: var(--neutral); }
.stall-cell--vacant .stall-cell-status-dot { background: #7d8aa2; }
.stall-cell--closed .stall-cell-status-dot { background: var(--neutral); }

.stall-map-disclaimer {
  text-align: center;
  font-size: 0.72rem;
  color: #aaa;
  margin: -2px 0 8px;
  letter-spacing: 0.02em;
}

/* ── Stall map: detail panel ── */
.stall-detail-panel {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
  animation: stall-detail-in 0.2s ease;
}

@keyframes stall-detail-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stall-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.stall-detail-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--brand);
}

.stall-detail-meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.stall-detail-panel .info-list {
  margin-top: 0;
  margin-bottom: 12px;
  background: #fff;
}

.stall-detail-close {
  appearance: none;
  border: none;
  background: var(--neutral-soft);
  color: var(--neutral);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Stall map: status legend (below map) ── */
.stall-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 4px 0 8px;
  font-size: 0.72rem;
  color: #666;
}

.stall-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stall-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Responsive ── */
@media (min-width: 768px) {
  .stall-grid {
    grid-template-columns: 50px minmax(0, 1fr) 18px minmax(0, 1fr) 16px minmax(0, 1fr) 18px minmax(0, 1fr) 60px;
    grid-template-rows: 52px 100px 100px 100px 100px 52px;
    gap: 8px;
  }
  .stall-cell-no { font-size: 1.3rem; }
  .stall-cell-name { font-size: 0.85rem; }
}

@media (max-width: 560px) {
  .app-header h1 {
    font-size: 26px;
  }

  .login-card h2 {
    font-size: 24px;
  }

  .card {
    padding: 16px;
    border-radius: 18px;
  }
}

@media (max-width: 600px) {
  .stall-grid {
    grid-template-rows: 44px 92px 92px 92px 92px 44px;
  }
  .stall-cell { padding: 4px 3px; gap: 2px; }
  .stall-cell-no { font-size: 0.7rem; line-height: 1.1; }
  .stall-cell-name {
    font-size: 0.65rem;
    line-height: 1.15;
    -webkit-line-clamp: 3;
    max-height: 3.45em;
  }
}

@media (max-width: 400px) {
  .stall-floor-plan { padding: 6px; }
  .stall-grid {
    grid-template-columns: 32px minmax(0, 1fr) 10px minmax(0, 1fr) 9px minmax(0, 1fr) 10px minmax(0, 1fr) 40px;
    grid-template-rows: 38px 92px 92px 92px 92px 38px;
    gap: 5px;
  }
  .stall-lm { font-size: 0.65rem; }
  .stall-lm-side { font-size: 0.56rem; }
  .stall-north-indicator { padding: 3px 8px; margin-bottom: 6px; }
  .stall-cell { padding: 4px 3px; gap: 2px; }
  .stall-cell-no { font-size: 0.7rem; line-height: 1.1; }
  .stall-cell-name { font-size: 0.65rem; line-height: 1.15; -webkit-line-clamp: 3; max-height: 3.45em; }
}
