:root {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-alt: #edf3f2;
  --text: #162426;
  --muted: #5a6d70;
  --primary: #007782;
  --primary-dark: #005b63;
  --accent: #e09f3e;
  --danger: #c43c35;
  --success: #1f8a5b;
  --border: #dce5e4;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(10, 34, 38, 0.06);
  --nav-h: 66px;
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}

.hidden { display: none !important; }

/* Layout */
.login-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.brand-logo { width: 52px; height: 52px; border-radius: 12px; }
.brand-header h1 { margin: 0; font-size: 1.35rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-left { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; }
.topbar-icon { width: 28px; height: 28px; border-radius: 6px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.lang-select {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 6px 8px;
  font-weight: 600;
  color: var(--text);
}

.icon-btn {
  min-width: 42px;
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 1.2rem;
  cursor: pointer;
}

.secondary-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.chip-nav {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.chip-danger { color: var(--danger); border-color: #f3c6c3; background: #fff4f3; }

.content {
  max-width: 780px;
  margin: 0 auto;
  padding: 14px 14px calc(var(--nav-h) + 28px);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 1.3rem; line-height: 1; }

/* Cards & Components */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.card h2, .card h3 { margin: 0 0 10px; font-size: 1.05rem; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.88rem; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

.field textarea { min-height: 110px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-danger { background: #fff0ef; border-color: #f0beb9; color: var(--danger); }
.btn-lg { min-height: 52px; font-size: 1.02rem; width: 100%; }
.btn-sm { min-height: 36px; padding: 6px 10px; font-size: 0.84rem; }

.muted { color: var(--muted); font-size: 0.88rem; margin: 0; }
.error-text { color: var(--danger); font-size: 0.9rem; margin: 0; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--surface-alt);
  color: var(--text);
}

.badge-primary { background: #dff4f6; color: #005b63; }
.badge-warn { background: #fff3d6; color: #8c5a00; }
.badge-success { background: #ddf6ea; color: #116641; }
.badge-danger { background: #fde6e4; color: #a3251f; }

/* Photo Upload & Previews */
.photo-drop {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.photo-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 92px;
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  background: #f0fafb;
  color: var(--primary-dark);
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  padding: 10px;
}

.photo-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
}

.photo-thumb {
  width: 82px;
  height: 82px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* KPI Tiles */
.kpi {
  background: var(--surface-alt);
  border-radius: 12px;
  padding: 12px;
}

.kpi-val { font-size: 1.35rem; font-weight: 800; color: var(--primary-dark); }
.kpi-label { font-size: 0.78rem; color: var(--muted); font-weight: 600; }

/* Item cards */
.item-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.item-meta { flex: 1; min-width: 0; }
.item-title {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 700;
  word-break: break-word;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill { height: 100%; background: var(--primary); }

details.drawer {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-alt);
  padding: 10px 12px;
}

details.drawer > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
}

details.drawer > summary::-webkit-details-marker { display: none; }
details.drawer > summary::after {
  content: "▾";
  font-size: 0.9rem;
  color: var(--muted);
}
details.drawer[open] > summary::after { content: "▴"; }
details.drawer[open] > summary { margin-bottom: 10px; }

.toast {
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: #162426;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

@media (max-width: 480px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
