:root {
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --hover: #FAFAFB;
  --ink: #0A0A0A;
  --ink2: #5A5A5A;
  --meta: #8A8A8A;
  --primary: #7A4A20;
  --primary-h: #5A3618;
  --accent: #C8965A;
  --t50: #FBF7F1;
  --t100: #F4E9D4;
  --t200: #E5C99F;
  --b1: #ECEDEF;
  --b2: #D8DBDF;
  --danger: #DC2626;
  --sh1: 0 1px 2px rgba(0,0,0,.04);
  --sh2: 0 3px 8px rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.03);
  --sh3: 0 8px 24px rgba(0,0,0,.08);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color-scheme: light;
  overflow: hidden;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
}

button {
  cursor: pointer;
  user-select: none;
}

button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* App container */
.app-container {
  display: flex;
  width: 100%;
  height: 100dvh;
  height: 100vh;
  justify-content: center;
  align-items: center;
  background: #EAECEF;
}

/* Phone Frame */
.phone {
  width: 100%;
  max-width: 420px;
  height: 100%;
  max-height: 880px;
  background: var(--bg);
  border: 1px solid var(--b2);
  border-radius: 34px;
  box-shadow: var(--sh3);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

@media (max-width: 600px) {
  .app-container {
    background: var(--bg);
  }
  .phone {
    max-width: 100%;
    max-height: 100%;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
}

/* Top Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 8px;
  background: var(--card);
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
  z-index: 10;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F0D9B0, #A06E37);
  position: relative;
  overflow: hidden;
  flex: none;
}

.brand-logo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(315deg, #5A3618, #1A0A02);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-install {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--t50);
  color: var(--primary-h);
  font-size: 11px;
  font-weight: 700;
}

.btn-lang {
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--b2);
  background: var(--card);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink2);
}

/* Screens */
.scr {
  display: none;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  flex: 1;
}

.scr.on {
  display: flex;
}

/* Header */
.hd {
  padding: 14px 18px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.hd h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.hd h1 small {
  display: block;
  font-size: 12px;
  color: var(--ink2);
  font-weight: 400;
  letter-spacing: 0;
  margin-top: 2px;
}

.back {
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.link {
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
}

/* Scrollable Body */
.body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overscroll-behavior-y: contain;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--b1);
  border-radius: 16px;
  box-shadow: var(--sh1);
  overflow: hidden;
}

.card .sec {
  padding: 12px 14px;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--meta);
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-top: 1px solid var(--b1);
  min-height: 48px;
  text-align: left;
  width: 100%;
}

.row:first-child, .sec + .row {
  border-top: 0;
}

.card > .row:first-of-type {
  border-top: 0;
}

.row b {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}

.row small {
  display: block;
  font-size: 12px;
  color: var(--ink2);
}

.row .chev {
  color: var(--meta);
  font-size: 16px;
}

.row.clk {
  cursor: pointer;
  transition: background 120ms ease;
}

.row.clk:hover, .row.clk:active {
  background: var(--hover);
}

/* Tags & Badges */
.tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 8px;
  white-space: nowrap;
}

.tag-draft { background: #ECEDEF; color: #5A5A5A; }
.tag-sent { background: #DCE6F5; color: #2D4FBC; }
.tag-synced { background: #C9E5D3; color: #1E5A35; }
.tag-off { background: #FBEAC2; color: #8A5A1C; }
.tag-crit { background: #E8C4C4; color: #6B1820; }
.tag-an { background: #E5DFC9; color: #7A4A20; }

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  margin-right: 6px;
  vertical-align: 1px;
}

/* Buttons */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 20px;
  border-radius: 9999px;
  border: 1.5px solid var(--primary);
  background: var(--card);
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  transition: all 120ms ease;
  width: 100%;
}

.btn:hover, .btn:active {
  background: var(--primary);
  color: #fff;
}

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

.btn.solid:hover, .btn.solid:active {
  background: var(--primary-h);
}

.btn.ghost {
  border-color: var(--b2);
  color: var(--ink2);
}

.btn.ghost:hover, .btn.ghost:active {
  background: var(--hover);
  color: var(--ink);
}

.footer {
  padding: 10px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg);
  flex-shrink: 0;
}

/* Bottom Tabs */
.tabs {
  display: flex;
  border-top: 1px solid var(--b1);
  background: var(--card);
  padding: 8px 0 12px;
  flex-shrink: 0;
}

.tabs button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--meta);
  min-height: 44px;
  justify-content: center;
  position: relative;
}

.tabs button.on {
  color: var(--primary);
}

.tabs svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tabs .badge {
  position: absolute;
  margin-left: 22px;
  margin-top: -12px;
  background: var(--primary);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 999px;
}

/* Segmented Control */
.seg {
  display: flex;
  border: 1px solid var(--b2);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card);
}

.seg button {
  flex: 1;
  padding: 9px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink2);
  min-height: 44px;
  text-align: center;
}

.seg button.on {
  background: var(--t100);
  color: var(--primary-h);
}

/* Input Fields */
.field {
  border: 1px solid var(--b2);
  border-radius: 12px;
  background: var(--card);
  padding: 9px 12px;
}

.field label {
  display: block;
  font-size: 11px;
  color: var(--meta);
  font-weight: 600;
}

.field span, .field input {
  display: block;
  width: 100%;
  font-size: 15px;
  color: var(--ink);
  outline: none;
  border: none;
  background: transparent;
}

/* Search Bar */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--b2);
  border-radius: 12px;
  background: var(--card);
  padding: 10px 12px;
  color: var(--meta);
  font-size: 13px;
}

.search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
}

/* Chips */
.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}

.chip {
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--b2);
  background: var(--card);
  color: var(--ink2);
  min-height: 34px;
}

.chip.on {
  background: var(--t100);
  color: var(--primary-h);
  border-color: transparent;
}

.hint {
  font-size: 12px;
  color: var(--ink2);
  padding: 0 4px;
}

.kv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13.5px;
  gap: 8px;
}

.kv b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.big {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.big small {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink2);
  letter-spacing: 0;
}

.quote {
  background: var(--t50);
  border: 1px solid var(--t100);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13.5px;
  line-height: 1.45;
}

.quote em {
  font-style: normal;
  background: var(--t200);
  border-radius: 4px;
  padding: 0 2px;
}

/* Photos Container */
.photos {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ph {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--t100), var(--t200));
  border: 1px solid var(--t200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--primary-h);
  font-weight: 600;
  position: relative;
  overflow: hidden;
}

.ph img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ph .del-photo {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ph.add {
  background: var(--card);
  border: 1.5px dashed var(--b2);
  color: var(--ink2);
  font-size: 22px;
  cursor: pointer;
}

/* Checkbox Rows */
.chk {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--b1);
  min-height: 48px;
  width: 100%;
  text-align: left;
}

.chk i {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--b2);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
}

.chk.on i {
  background: var(--primary);
  border-color: var(--primary);
}

.chk.on i::after {
  content: "";
  width: 10px;
  height: 6px;
  border: 2px solid #fff;
  border-top: 0;
  border-right: 0;
  transform: rotate(-45deg);
  margin-top: -3px;
}

.chk b {
  font-weight: 600;
  flex: 1;
}

.chk span {
  font-variant-numeric: tabular-nums;
  color: var(--ink2);
}

/* Counters */
.cnt {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cnt button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cnt button:hover, .cnt button:active {
  background: var(--primary);
  color: #fff;
}

.cnt b {
  width: 28px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Map & SVG */
.map {
  position: relative;
  height: 240px;
  border-radius: 16px;
  background: var(--t50);
  border: 1px solid var(--t100);
  overflow: hidden;
}

.map svg {
  width: 100%;
  height: 100%;
}

.map .lbl {
  position: absolute;
  left: 10px;
  top: 8px;
  font-size: 11px;
  color: var(--ink2);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.85);
  padding: 3px 8px;
  border-radius: 999px;
}

/* Verification list */
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-top: 1px solid var(--b1);
  font-size: 13.5px;
}

.check .ok {
  color: #1E5A35;
  font-weight: 700;
}

.check .no {
  color: #8A5A1C;
  font-weight: 700;
}

/* Pieces */
.piece {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px 8px 28px;
  font-size: 13px;
  border-top: 1px solid var(--b1);
}

.piece:first-child {
  border-top: 0;
}

/* Toast */
.toast {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 80px;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: var(--sh3);
  opacity: 0;
  transform: translateY(6px);
  transition: all 160ms;
  pointer-events: none;
  z-index: 100;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.pill-net {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 8px;
}

/* Modals */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  width: 100%;
  max-width: 340px;
  background: var(--card);
  border: 1px solid var(--b2);
  border-radius: 20px;
  box-shadow: var(--sh3);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  font-size: 18px;
  color: var(--meta);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--meta);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-input, .modal-select {
  border: 1px solid var(--b2);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 16px; /* Prevents auto-zoom on iOS */
  background: var(--card);
  color: var(--ink);
  outline: none;
  width: 100%;
}

.modal-input:focus, .modal-select:focus {
  border-color: var(--primary);
}

.modal-select {
  appearance: auto;
}

/* Install Guide Modal (iOS) */
.install-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--b1);
}

.install-step:first-child {
  border-top: none;
}

.install-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--t100);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.install-desc {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.4;
}

.install-desc b {
  color: var(--primary);
}
