:root {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-2: #eef5f3;
  --text: #17302c;
  --muted: #687b77;
  --primary: #0f766e;
  --primary-2: #115e59;
  --accent: #dff4ef;
  --danger: #b42318;
  --warning: #a15c00;
  --success: #067647;
  --border: #d9e4e1;
  --shadow: 0 10px 30px rgba(22, 46, 42, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { padding-bottom: env(safe-area-inset-bottom); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; max-width: 760px; margin: 0 auto; background: var(--bg); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; padding: 18px 18px 14px; background: rgba(244,247,246,.94); backdrop-filter: blur(14px); border-bottom: 1px solid rgba(217,228,225,.7); }
.eyebrow { color: var(--primary); font-weight: 800; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 3px 0 0; font-size: 24px; line-height: 1.15; }
h2 { margin: 0 0 12px; font-size: 18px; }
h3 { margin: 0; font-size: 16px; }
p { margin: 0; }
.content { padding: 14px 14px 96px; }

.bottom-nav { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: 0; width: min(760px, 100%); display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); backdrop-filter: blur(14px); border-top: 1px solid var(--border); }
.nav-item { position: relative; border: 0; background: transparent; color: var(--muted); border-radius: 14px; padding: 8px 4px; display: grid; place-items: center; gap: 3px; }
.nav-item span { font-size: 19px; }
.nav-item small { font-size: 11px; font-weight: 700; }
.nav-item.active { background: var(--accent); color: var(--primary-2); }
.badge { position: absolute; top: 4px; right: 22%; min-width: 18px; height: 18px; border-radius: 999px; background: var(--danger); color: white; font-size: 10px; display: grid; place-items: center; padding: 0 5px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.card.soft { background: var(--surface-2); box-shadow: none; }
.hero { background: linear-gradient(145deg, #0f766e, #124f4b); color: white; border: 0; }
.hero .muted { color: #d5ebe7; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.stack { display: grid; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 800; }

label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid var(--border); background: white; color: var(--text); border-radius: 12px; padding: 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }
textarea { min-height: 76px; resize: vertical; }

.btn { border: 0; border-radius: 13px; padding: 12px 14px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--primary); color: white; }
.btn.primary:hover { background: var(--primary-2); }
.btn.secondary { background: var(--accent); color: var(--primary-2); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: #fff0ee; color: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { width: 42px; height: 42px; border: 1px solid var(--border); border-radius: 13px; background: white; font-weight: 900; font-size: 18px; color: var(--primary); }

.kpi { background: white; border: 1px solid var(--border); border-radius: 15px; padding: 12px; }
.kpi .value { font-size: 22px; font-weight: 900; margin-top: 4px; }

.item-card { display: grid; grid-template-columns: 78px 1fr; gap: 12px; border: 1px solid var(--border); background: white; border-radius: 16px; padding: 10px; }
.item-photo { width: 78px; height: 78px; object-fit: cover; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.item-photo.placeholder { display: grid; place-items: center; font-size: 26px; color: var(--muted); }
.item-meta { min-width: 0; }
.item-title { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.item-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-code { font-size: 10px; font-weight: 800; color: var(--primary); background: var(--accent); padding: 3px 6px; border-radius: 999px; flex: 0 0 auto; }
.item-actions { display: flex; gap: 7px; margin-top: 9px; flex-wrap: wrap; }

.photo-picker { border: 1px dashed #9cbab5; border-radius: 15px; padding: 14px; text-align: center; background: #f8fbfa; }
.photo-picker input { border: 0; padding: 8px 0 0; }
.preview { margin-top: 10px; border-radius: 14px; max-height: 220px; width: 100%; object-fit: cover; }

.status { display: inline-flex; align-items: center; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status.sent { color: #175cd3; background: #eff8ff; }
.status.partial { color: var(--warning); background: #fff7e8; }
.status.returned { color: var(--success); background: #ecfdf3; }
.status.overdue { color: var(--danger); background: #fff0ee; }
.status.draft { color: var(--muted); background: #f2f4f7; }

.return-row { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: white; }
.return-main { display: grid; grid-template-columns: 70px 1fr auto; gap: 10px; padding: 10px; align-items: center; }
.return-main .item-photo { width: 70px; height: 70px; }
.check-wrap { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--surface-2); }
.check-wrap input { width: 24px; height: 24px; accent-color: var(--primary); }
.return-extra { padding: 0 10px 10px; display: grid; gap: 8px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.compare figure { margin: 0; }
.compare figcaption { font-size: 10px; color: var(--muted); margin: 4px 2px 0; }

.progress { height: 9px; background: #e7eeec; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }

.alert { border-radius: 14px; padding: 11px 12px; font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.alert.warn { background: #fff7e8; color: #7a4500; }
.alert.danger { background: #fff0ee; color: var(--danger); }
.alert.success { background: #ecfdf3; color: var(--success); }

.summary-line { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.summary-line:last-child { border-bottom: 0; }

.bar-list { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr auto; gap: 8px; align-items: center; }
.bar-track { height: 10px; background: #e7eeec; border-radius: 999px; overflow: hidden; }
.bar-track span { display: block; height: 100%; background: var(--primary); border-radius: inherit; min-width: 4px; }

.empty { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty .emoji { font-size: 38px; margin-bottom: 10px; }

.segmented { display: grid; grid-template-columns: repeat(2,1fr); background: var(--surface-2); padding: 4px; border-radius: 14px; margin-bottom: 12px; }
.segmented button { border: 0; border-radius: 10px; padding: 9px; background: transparent; color: var(--muted); font-weight: 800; }
.segmented button.active { background: white; color: var(--text); box-shadow: 0 2px 10px rgba(0,0,0,.05); }

.modal-backdrop { position: fixed; z-index: 60; inset: 0; background: rgba(15, 30, 27, .48); display: grid; align-items: end; padding: 14px; }
.modal { width: min(620px, 100%); max-height: 90vh; overflow: auto; margin: 0 auto; background: white; border-radius: 22px 22px 18px 18px; padding: 16px; box-shadow: 0 18px 60px rgba(0,0,0,.24); }
.modal h2 { margin-bottom: 14px; }

@media (min-width: 700px) {
  .content { padding: 20px 20px 110px; }
  .topbar { padding-left: 22px; padding-right: 22px; }
}

@media (max-width: 430px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 72px 1fr auto; }
}
