:root {
  color-scheme: light;
  --bg: #f7faf8;
  --surface: #ffffff;
  --surface-2: #eef5f0;
  --ink: #18231d;
  --muted: #65746b;
  --line: #d9e3dd;
  --green: #0f5132;
  --green-2: #187044;
  --yellow: #f6c945;
  --red: #c94444;
  --blue: #2463a6;
  --shadow: 0 18px 55px rgba(24, 35, 29, 0.12);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  min-height: 100dvh;
  overflow-x: hidden;
}

.mobile-frame {
  width: min(100%, 480px);
  max-width: 100%;
  min-height: 100dvh;
  margin: 0 auto;
  overflow-x: clip;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 0 1px rgba(15, 81, 50, 0.05);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(247, 250, 248, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand > div:last-child {
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--green);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.1;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-2);
  box-shadow: 0 0 0 3px rgba(24, 112, 68, 0.12);
}

.dot.pending {
  background: var(--yellow);
  box-shadow: 0 0 0 3px rgba(246, 201, 69, 0.18);
}

.dot.danger {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(201, 68, 68, 0.16);
}

.content {
  padding: 16px 16px calc(86px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

.view-title {
  margin: 0 0 6px;
  font-size: 24px;
  line-height: 1.12;
  font-weight: 850;
  letter-spacing: 0;
}

.view-copy {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.view-copy,
.row-title,
.row-subtitle,
.panel-note {
  overflow-wrap: anywhere;
}

.stack {
  display: grid;
  gap: 12px;
}

.panel,
.list-row,
.field,
.camera-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel {
  position: relative;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(24, 35, 29, 0.05);
}

.check-pipa-card {
  overflow: hidden;
  transition: background 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}

.check-pipa-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--red);
}

.check-pipa-card.checked {
  border-color: rgba(15, 81, 50, 0.28);
  background: #eef5f0;
  opacity: 0.86;
}

.check-pipa-card.checked::before {
  background: var(--green);
}

.panel-header,
.row-main,
.row-meta,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
}

.panel-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.area-lock-card {
  border-color: rgba(15, 81, 50, 0.24);
  background: #f3faf6;
}

.area-label {
  margin: 5px 0 0;
  color: var(--green);
  font-size: 22px;
  line-height: 1.1;
  font-weight: 900;
}

.round-card {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 81, 50, 0.18);
  border-radius: var(--radius);
  background: #f3faf6;
}

.round-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.form-error {
  padding: 10px 12px;
  border: 1px solid #f0caca;
  border-radius: var(--radius);
  background: #fff5f5;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.login-card {
  margin-top: 12px;
  padding: 18px;
}

.field {
  display: grid;
  gap: 7px;
  padding: 10px 12px;
}

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

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}

.field input:disabled {
  color: var(--muted);
  opacity: 0.55;
  cursor: not-allowed;
}

.kiosk-select-field.checked {
  border-color: rgba(15, 81, 50, 0.38);
  background: #eef5f0;
}

.kiosk-select-field.checked label,
.kiosk-select-field.checked select {
  color: var(--green);
}

.field textarea {
  min-height: 78px;
  resize: vertical;
  line-height: 1.35;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.grid-2 > * {
  min-width: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--green);
  color: #fff;
}

.btn-secondary {
  background: #e7f0eb;
  color: var(--green);
}

.btn-danger {
  background: #f8e9e9;
  color: var(--red);
}

.panel form,
form.panel {
  min-width: 0;
}

.btn-full {
  width: 100%;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.kpi {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.kpi strong {
  display: block;
  font-size: 21px;
  line-height: 1;
}

.kpi span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.list {
  display: grid;
  gap: 10px;
}

.toggle-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.toggle-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--green);
  flex: 0 0 auto;
}

.toggle-row strong,
.toggle-row small {
  display: block;
}

.toggle-row strong {
  font-size: 14px;
}

.toggle-row small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.list-row {
  width: 100%;
  min-height: 76px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.sortable-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: stretch;
}

.sortable-row.dragging {
  opacity: 0.62;
}

.sortable-row.drag-over {
  border-color: rgba(15, 81, 50, 0.58);
  box-shadow: inset 0 0 0 2px rgba(15, 81, 50, 0.18);
}

.list-row.checked {
  border-color: rgba(15, 81, 50, 0.32);
  background: #eef5f0;
}

.row-content {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.drag-handle,
.sort-btn {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef5f0;
  color: var(--green);
  font-size: 18px;
  font-weight: 900;
}

.drag-handle {
  touch-action: none;
  cursor: grab;
}

.sort-actions {
  display: grid;
  gap: 6px;
}

.sort-btn {
  min-height: 0;
  font-size: 15px;
}

.sort-btn:disabled {
  color: var(--muted);
  opacity: 0.35;
}

.row-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
  font-weight: 850;
}

.row-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.segment {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.segment.active {
  background: var(--green);
  color: #fff;
}

.camera-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.camera-card {
  min-height: 132px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.camera-card input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.camera-pick-zone {
  display: block;
  min-height: 108px;
  cursor: pointer;
}

.camera-label {
  display: grid;
  gap: 8px;
  height: 100%;
  align-content: center;
  justify-items: center;
  color: var(--green);
  text-align: center;
  font-size: 13px;
  font-weight: 850;
}

.photo-save-btn {
  width: 100%;
  min-height: 38px;
  font-size: 12px;
}

.camera-preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-2);
}

.filename {
  width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
}

.photo-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef5f0;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
}

.photo-chip-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.photo-download {
  min-height: 32px;
  padding: 0 10px;
  font-size: 11px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100%, 480px);
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  transform: translateX(-50%);
  backdrop-filter: blur(14px);
}

.nav-item {
  display: grid;
  gap: 3px;
  place-items: center;
  min-height: 54px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.nav-item.active {
  background: #e7f0eb;
  color: var(--green);
}

.empty {
  padding: 24px 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  font-size: 14px;
  line-height: 1.4;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(78px + env(safe-area-inset-bottom));
  z-index: 50;
  width: min(430px, calc(100% - 24px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 750;
  transform: translateX(-50%);
}

.hidden {
  display: none !important;
}

@media (min-width: 900px) {
  body {
    background: #dfe8e2;
  }

  .mobile-frame {
    min-height: calc(100dvh - 32px);
    margin: 16px auto;
    border-radius: 18px;
    overflow: clip;
  }
}

@media (max-width: 360px) {
  .grid-2,
  .camera-grid,
  .kpi-strip {
    grid-template-columns: 1fr;
  }
}
