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

:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --panel-soft: #fbfcfe;
  --line: #eceef3;
  --text: #1c2331;
  --muted: #8790a3;
  --accent: #3d5afe;
  --accent-dark: #2f47db;
  --accent-soft: #eef0ff;
  --green: #16a37a;
  --green-soft: #e7f8f1;
  --red: #e2483d;
  --red-soft: #fdeceb;
  --amber: #b26a00;
  --amber-soft: #fff4e0;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 10px 30px -14px rgba(30, 40, 70, 0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
}

header.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--panel);
  color: var(--text);
  padding: calc(16px + env(safe-area-inset-top)) 18px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

header.topbar h1 {
  font-size: 17px;
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.01em;
}

header.topbar .sub {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
}

button.link-btn {
  background: var(--accent-soft);
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
}

main {
  padding: 18px;
}

.card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 16px;
  animation: card-in 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .card, .msg, .tabs button, .btn, #main { animation: none !important; transition: none !important; }
}

.card h2 {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  margin: 14px 0 6px;
}

input, select, textarea {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  font-size: 16px;
  background: var(--panel-soft);
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel);
}

textarea { resize: vertical; min-height: 60px; }

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 15px 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  margin-top: 18px;
  font-family: inherit;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; transform: none; }

.btn-primary { background: var(--accent); color: white; box-shadow: 0 10px 20px -6px rgba(61, 90, 254, 0.45); }
.btn-primary:active { background: var(--accent-dark); }
.btn-secondary { background: var(--accent-soft); color: var(--accent); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-sm { width: auto; padding: 9px 14px; font-size: 13px; margin-top: 0; box-shadow: none; }

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 12px 18px 0;
  background: var(--bg);
}

.tabs button {
  flex: 0 0 auto;
  background: var(--panel);
  color: var(--muted);
  border: 1.5px solid var(--line);
  padding: 9px 15px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  font-family: inherit;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}

.tabs button:active { transform: scale(0.95); }

.tabs button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.gasto-item {
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.gasto-item:last-child { border-bottom: none; }

.gasto-item img.thumb {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--accent-soft);
  flex-shrink: 0;
}

.gasto-info { flex: 1; min-width: 0; }
.gasto-info .top-row { display: flex; justify-content: space-between; gap: 8px; }
.gasto-info .monto { font-weight: 800; font-size: 17px; letter-spacing: -0.01em; }
.gasto-info .obra { font-size: 13px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.gasto-info .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 4px 11px;
  border-radius: 999px;
  font-weight: 700;
  margin-top: 6px;
  margin-right: 4px;
}

.badge.pendiente { background: var(--amber-soft); color: var(--amber); }
.badge.aprobado { background: var(--green-soft); color: var(--green); }
.badge.rechazado { background: var(--red-soft); color: var(--red); }
.badge.anulado { background: #eef0f4; color: var(--muted); text-decoration: line-through; }

.alerta {
  background: var(--red-soft);
  border: none;
  color: #a6332a;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  margin-top: 14px;
}

.msg {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  margin: 12px 0;
  animation: msg-in 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.msg.error { background: var(--red-soft); color: #a6332a; }
.msg.ok { background: var(--green-soft); color: #0e7a58; }

@keyframes msg-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border-radius: 24px;
  padding: 32px 26px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card .logo {
  width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 16px;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}

.login-card .logo img { width: 30px; height: 30px; display: block; }

.login-card h2 { font-weight: 800; font-size: 22px; }

.small-muted { color: var(--muted); font-size: 12.5px; font-weight: 500; }

.bar-row { margin-bottom: 12px; }
.bar-row .label-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; font-weight: 600; }
.bar-track { background: var(--accent-soft); border-radius: 999px; height: 10px; overflow: hidden; }
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.list-clean { list-style: none; margin: 0; padding: 0; }
.list-clean li { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 600; }
.list-clean li:last-child { border-bottom: none; }

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  font-size: 12.5px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 7px 12px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chip input { width: auto; margin: 0; }

.fab-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1.5px dashed #d6dbe6;
  border-radius: var(--radius-sm);
  padding: 20px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  background: var(--panel-soft);
}

.preview-photo {
  width: 100%;
  border-radius: var(--radius-sm);
  margin-top: 12px;
  max-height: 260px;
  object-fit: contain;
  background: #000;
}

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
}
.filters select { width: auto; min-width: 130px; }

.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

.bottom-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.bottom-actions .btn { margin-top: 0; }

@media (min-width: 480px) {
  main { padding: 22px; }
}
