@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;600&family=Source+Sans+3:wght@400;500;600;700&display=swap');

:root {
  --bg: #edf1f3;
  --bg-2: #f8fafb;
  --card: #ffffff;
  --line: #d6dce1;
  --ink: #2d363e;
  --muted: #5f6b75;
  --navy: #003764;
  --navy-deep: #022b4c;
  --sky: #00a9f7;
  --sky-soft: #d8f2ff;
  --danger: #bf2e2e;
  --warn: #c98200;
  --ok: #1a8f53;
  --shadow: 0 14px 34px rgba(0, 27, 48, 0.1);
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Source Sans 3', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-user-select: none;
  user-select: none;
}

/* Header */
.header {
  background: linear-gradient(160deg, rgba(0,169,247,0.22), transparent 48%),
    linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  border-bottom: 4px solid var(--sky);
  box-shadow: 0 10px 20px rgba(0,28,49,0.28);
  padding: 1rem;
  text-align: center;
  color: #f4fbff;
}
.header h1 {
  font-family: 'Oswald', sans-serif;
  font-size: 1.4rem;
  letter-spacing: 1px;
  font-weight: 600;
}
.header .subtitle {
  font-size: 0.8rem;
  opacity: 0.7;
  margin-top: 0.2rem;
}

/* Screens */
.screen { display: none; padding: 1rem; max-width: 600px; margin: 0 auto; }
.screen.active { display: block; }

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.card h2 {
  font-family: 'Oswald', sans-serif;
  font-size: 1rem;
  color: var(--navy);
  margin-bottom: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Form */
.form-group { margin-bottom: 0.8rem; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.7rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 1rem;
  font-family: 'Source Sans 3', sans-serif;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 2px rgba(0,169,247,0.2);
}
.form-group input::placeholder { color: var(--muted); opacity: 0.5; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  font-family: 'Source Sans 3', sans-serif;
  transition: opacity 0.2s, transform 0.1s;
}
.btn:active { opacity: 0.85; transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(180deg, var(--sky) 0%, #0090d4 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(0,169,247,0.3);
}
.btn-outline {
  background: transparent;
  border: 2px solid var(--sky);
  color: var(--sky);
}
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--ok); color: white; }
.btn-small { padding: 0.5rem 0.8rem; font-size: 0.85rem; width: auto; }

/* Items table */
.items-list { margin: 0.5rem 0; }
.item-row {
  display: grid;
  grid-template-columns: 50px 70px 1fr 40px;
  gap: 0.4rem;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}
.item-row input, .item-row select { font-size: 0.85rem; padding: 0.5rem; }
.item-remove {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 1.2rem;
  cursor: pointer;
}

/* Photo/Signature areas */
.capture-area {
  background: var(--bg-2);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  position: relative;
}
.capture-area.has-content {
  border-style: solid;
  border-color: var(--ok);
  padding: 0.5rem;
}
.capture-area img,
.capture-area canvas {
  max-width: 100%;
  max-height: 200px;
  border-radius: 6px;
}
.capture-icon { font-size: 2rem; opacity: 0.4; }
.capture-label { font-size: 0.85rem; color: var(--muted); }

/* Signature pad */
.signature-pad {
  background: white;
  border-radius: 6px;
  border: 1px solid var(--line);
  touch-action: none;
  width: 100%;
  height: 150px;
}

/* Summary */
.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--line);
}
.summary-row .label { color: var(--muted); }
.summary-total {
  font-family: 'Oswald', sans-serif;
  font-size: 1.3rem;
  color: var(--navy);
  font-weight: 600;
  text-align: right;
  padding: 0.8rem 0;
}

/* List view */
.purchase-list-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin-bottom: 0.6rem;
  border-left: 4px solid var(--sky);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.purchase-list-item .info { font-size: 0.9rem; }
.purchase-list-item .info .name { font-weight: 600; color: var(--ink); }
.purchase-list-item .info .meta { color: var(--muted); font-size: 0.8rem; }
.purchase-list-item .amount {
  font-family: 'Oswald', sans-serif;
  color: var(--navy);
  font-weight: 600;
  font-size: 1.1rem;
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-borrador { background: var(--bg); color: var(--muted); }
.badge-firmada { background: rgba(26,143,83,0.12); color: var(--ok); }
.badge-archivada { background: var(--sky-soft); color: var(--navy); }

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  border-top: 3px solid var(--sky);
  display: flex;
  justify-content: space-around;
  padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom));
  z-index: 100;
}
.nav-item {
  text-align: center;
  color: rgba(255,255,255,0.5);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0.3rem 0.8rem;
  border: none;
  background: none;
  font-family: 'Source Sans 3', sans-serif;
}
.nav-item.active { color: white; }
.nav-icon { font-size: 1.3rem; display: block; }

/* Toast */
.toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ok);
  color: white;
  padding: 0.7rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 999;
  display: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.toast.error { background: var(--danger); }
.toast.show { display: block; animation: fadeInOut 3s ease; }
@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* Legal text */
.legal-text {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
}
.empty-state .icon { font-size: 3rem; opacity: 0.3; margin-bottom: 0.5rem; }

/* Spacing for bottom nav */
.screen { padding-bottom: 80px; }
