:root {
  --bg: #0f1614;
  --surface: #1a2421;
  --surface-2: #243330;
  --text: #e8ede9;
  --muted: #8aa39a;
  --accent: #2e8b57;
  --accent-hover: #3aa86a;
  --error: #e07a7a;
  --warn: #d9a85a;
  --radius: 12px;
  --max-w: 560px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  min-height: 100vh;
}

.screen {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 16px;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}
.hidden { display: none !important; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

h1, h2, h3 { margin: 0 0 12px; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--error); }
.warn { color: var(--warn); background: rgba(217,168,90,0.1); padding: 10px; border-radius: 8px; }

input, select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid #2f4540;
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); }

label {
  display: block;
  margin-bottom: 14px;
  font-size: 0.9rem;
  color: var(--muted);
}
label input, label select, label textarea { margin-top: 6px; }

.row { display: flex; gap: 12px; }
.row .grow { flex: 1; }

button {
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  background: var(--surface-2);
  color: var(--text);
}
button.primary, .primary {
  background: var(--accent);
  color: white;
  font-weight: 600;
}
button.primary:hover, .primary:hover { background: var(--accent-hover); }
button.link, .link {
  background: transparent;
  color: var(--accent-hover);
  padding: 4px 8px;
  font-size: 0.95rem;
  text-decoration: underline;
  cursor: pointer;
  display: inline-block;
}

.big-button {
  display: block;
  width: 100%;
  padding: 18px;
  text-align: center;
  font-size: 1.1rem;
  margin-bottom: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px 14px;
  font-size: 0.95rem;
}

.drop-zone {
  border: 2px dashed #3d5550;
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}
.drop-zone.drag-over {
  background: rgba(46,139,87,0.12);
  border-color: var(--accent);
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(217,168,90,0.08);
  border: 1px solid rgba(217,168,90,0.3);
  border-radius: 8px;
  padding: 12px;
}
.checkbox-row input[type=checkbox] {
  width: 22px;
  height: 22px;
  margin: 2px 0 0 0;
  flex-shrink: 0;
}
.checkbox-row small { font-size: 0.85rem; }

.badge {
  display: inline-block;
  background: var(--warn);
  color: #1a1a1a;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-left: 6px;
}

.manage-list { list-style: none; padding: 0; margin: 0; }
.manage-list li {
  padding: 12px 0;
  border-bottom: 1px solid #2f4540;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.manage-list li:last-child { border-bottom: none; }
.manage-list .meta { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }
.manage-list .amt { font-weight: 700; color: var(--text); }
.manage-list .delete-btn {
  flex-shrink: 0;
  background: transparent;
  color: var(--error);
  border: 1px solid rgba(224,122,122,0.4);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 1rem;
  cursor: pointer;
}
.manage-list .delete-btn:hover { background: rgba(224,122,122,0.15); }
.manage-list .delete-btn:disabled { opacity: 0.4; cursor: wait; }

.reimb-list { list-style: none; padding: 0; margin: 0; }
.reimb-list li {
  padding: 14px;
  background: var(--surface-2);
  border-radius: 8px;
  margin-bottom: 10px;
}
.reimb-list .who {
  font-weight: 700;
  color: var(--warn);
  margin-bottom: 4px;
}
.reimb-list .amount {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}
.reimb-list .meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 6px 0;
}
.reimb-list .mark-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  background: var(--accent);
  color: white;
  font-weight: 600;
}

.stat-big {
  font-size: 2rem;
  font-weight: 700;
  margin: 4px 0;
}
.stat-sub { font-size: 0.9rem; color: var(--muted); }
.stat-up { color: var(--error); }
.stat-down { color: var(--accent-hover); }

.bar-row {
  display: grid;
  grid-template-columns: 70px 1fr 90px;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.88rem;
}
.bar-row.current .bar-fill { background: var(--accent); }
.bar-track {
  background: var(--surface-2);
  height: 22px;
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  background: #3d5550;
  height: 100%;
  border-radius: 4px;
  min-width: 2px;
  transition: width 0.4s ease;
}
.bar-amt { text-align: right; color: var(--muted); }

.kv-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #2f4540;
  font-size: 0.92rem;
}
.kv-row:last-child { border-bottom: none; }
.kv-row .pct { color: var(--muted); font-size: 0.85rem; margin-left: 8px; }

.recent { list-style: none; padding: 0; margin: 0; }
.recent li {
  padding: 8px 0;
  border-bottom: 1px solid #2f4540;
  font-size: 0.92rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.recent li:last-child { border-bottom: none; }
.recent .row-text { flex: 1; min-width: 0; }
.recent .delete-btn {
  flex-shrink: 0;
  background: transparent;
  color: var(--error);
  border: 1px solid rgba(224,122,122,0.4);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}
.recent .delete-btn:hover { background: rgba(224,122,122,0.15); }
.recent .delete-btn:disabled { opacity: 0.4; cursor: wait; }

#preview-wrap img, #preview-wrap embed {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 12px;
  background: black;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #2f4540;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
