:root {
  --navy:  #1F2A44;
  --gold:  #B08D57;
  --cream: #F6F2E9;
  --light: #FBF9F4;
  --dark:  #2B2B2B;
  --grey:  #6B6B6B;
  --line:  #E3DCCB;
  --red:   #B23A2E;
  --amber: #C9892B;
  --green: #2E7D52;
  --serif: "Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;
  --r: 10px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--light);
  color: var(--dark);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

/* ── Top bar ─────────────────────────────────────────────── */
.topbar {
  background: var(--navy);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar .logo { font-family: var(--serif); font-size: 17px; font-weight: 700; }
.topbar .sub  { font-size: 9px; letter-spacing: 4px; color: var(--gold); text-transform: uppercase; display: block; }
.topbar .back { color: var(--gold); font-size: 22px; text-decoration: none; line-height: 1; }
.goldbar { height: 3px; background: var(--gold); }

/* ── Cards / containers ──────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--r);
  border: 1px solid var(--line);
  padding: 18px;
  margin-bottom: 14px;
}
.card-sm { padding: 12px 16px; }
.section { padding: 16px; }

/* ── Typography ──────────────────────────────────────────── */
h1,h2,h3 { margin: 0 0 8px; font-family: var(--serif); color: var(--navy); }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--grey); }
.muted { color: var(--grey); font-size: 13px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: var(--r);
  border: 2px solid var(--navy);
  background: var(--navy);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:active { opacity: .8; }
.btn.ghost  { background: #fff; color: var(--navy); }
.btn.gold   { background: var(--gold); border-color: var(--gold); color: #3a2c08; }
.btn.red    { background: var(--red); border-color: var(--red); }
.btn.full   { width: 100%; }
.btn.sm     { font-size: 13px; padding: 8px 14px; }

/* ── Form controls ───────────────────────────────────────── */
.field       { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--grey); text-transform: uppercase; letter-spacing: .5px; }
input[type=text], input[type=number], input[type=password], select, textarea {
  font-size: 16px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--dark);
  width: 100%;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
textarea { min-height: 70px; resize: vertical; }

/* ── Badges ──────────────────────────────────────────────── */
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.b-imp { background: #F7E4E1; color: var(--red); }
.b-rec { background: #F7ECD9; color: var(--amber); }
.b-opc { background: #ECEAE3; color: var(--grey); }
.b-due { background: #E8EAF0; color: var(--navy); }
.b-sw  { background: #FEF4E3; color: #7A5A1E; }
.b-ok  { background: #E3F4EC; color: var(--green); }
.b-rot { background: #F7ECD9; color: var(--amber); }
.b-per { background: #F7E4E1; color: var(--red); }

/* ── Estado selector ─────────────────────────────────────── */
.estado-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.estado-btn {
  padding: 10px 4px;
  border-radius: 8px;
  border: 2px solid var(--line);
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  color: var(--grey);
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.estado-btn.on-bueno   { border-color: var(--green); background: #E3F4EC; color: var(--green); }
.estado-btn.on-roto    { border-color: var(--amber); background: #FEF4E3; color: var(--amber); }
.estado-btn.on-perdido { border-color: var(--red);   background: #FDE9E7; color: var(--red);   }

/* ── Item row ─────────────────────────────────────────────── */
.item-row {
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}
.item-row:last-child { border-bottom: none; }
.item-name { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.item-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }

/* ── Category header ─────────────────────────────────────── */
.cat-header {
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .3px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 8px 8px 0 0;
  margin-top: 16px;
}
.cat-header .cat-count { font-size: 11px; color: #C3CBDB; font-weight: 400; }

/* ── Lists ───────────────────────────────────────────────── */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  gap: 10px;
}
.list-item:last-child { border-bottom: none; }
.list-item .main { font-size: 15px; font-weight: 600; }
.list-item .sub  { font-size: 12px; color: var(--grey); margin-top: 2px; }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--line); background: #fff; overflow-x: auto; }
.tab-btn {
  flex: 1;
  min-width: 80px;
  padding: 13px 6px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  background: none;
  color: var(--grey);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn.active { color: var(--navy); border-bottom-color: var(--gold); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Modal ───────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 20px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform .2s;
}
.overlay.show .modal { transform: translateY(0); }
.modal-title { font-family: var(--serif); font-size: 18px; color: var(--navy); margin-bottom: 16px; }

/* ── Metrics strip ───────────────────────────────────────── */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 10px; padding: 14px 16px; }
.metric { background: var(--cream); border-radius: 8px; padding: 10px 12px; }
.metric .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--grey); }
.metric .val { font-size: 22px; font-weight: 700; color: var(--navy); margin-top: 2px; }
.metric.red .val { color: var(--red); }
.metric.green .val { color: var(--green); }
.metric.amber .val { color: var(--amber); }

/* ── Toast ───────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff;
  padding: 12px 22px; border-radius: 999px;
  font-size: 14px; font-weight: 600;
  z-index: 200; opacity: 0; transition: opacity .3s;
  pointer-events: none; white-space: nowrap;
}
#toast.show { opacity: 1; }

/* ── Utilities ───────────────────────────────────────────── */
.mt8  { margin-top: 8px; }
.mt16 { margin-top: 16px; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.hidden { display: none !important; }
.center { text-align: center; }
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 30px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Photo upload ────────────────────────────────────────── */
.photo-zone {
  border: 2px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  color: var(--grey);
  font-size: 13px;
  cursor: pointer;
  margin-top: 8px;
}
.photo-zone input { display: none; }
.photos-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.photos-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; }

/* ── Summary table ───────────────────────────────────────── */
.sum-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sum-table th { font-size: 10px; text-transform: uppercase; color: var(--grey); text-align: left; padding: 6px 4px; border-bottom: 1.5px solid var(--gold); }
.sum-table td { padding: 7px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.sum-table tr.grp td { background: var(--navy); color: #fff; font-weight: 700; padding: 6px 8px; border: none; font-size: 12px; }
.sum-table tr.total td { font-weight: 700; background: var(--cream); }

@media (min-width: 640px) {
  .topbar { padding: 18px 32px; }
  .section { padding: 20px 32px; }
  .metrics { padding: 16px 32px; }
  .tabs .tab-btn { font-size: 14px; }
}
