* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #14151b; color: #e8e8ec;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font-family: inherit; font-size: 1rem; }

/* ── Passcode gate ─────────────────────────────────────────────────────── */
#gate-screen {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
#gate-form { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 260px; }
#gate-input {
  background: #1e1f27; border: 1px solid #2f3140; color: #e8e8ec;
  padding: 14px 16px; border-radius: 10px; text-align: center; letter-spacing: 2px;
}
#gate-form button[type="submit"] {
  background: #4f8ef7; color: #fff; border: none; border-radius: 10px;
  padding: 12px; font-weight: 600; cursor: pointer;
}
#gate-msg { text-align: center; min-height: 1.2em; color: #f75f5f; font-size: 0.85rem; }

/* ── App shell ─────────────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; }
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid #26272f; background: #1a1b22;
  flex-shrink: 0;
}
#tabs { display: flex; gap: 6px; overflow-x: auto; }
.tab-btn {
  background: none; border: none; color: #9a9ba8; padding: 8px 12px;
  border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.tab-btn.active { background: #2a2c38; color: #fff; }
#logout-btn {
  background: none; border: 1px solid #33354280; color: #9a9ba8;
  padding: 6px 10px; border-radius: 8px; cursor: pointer; flex-shrink: 0;
}
#queue-note {
  margin: 0 14px; margin-top: 10px; padding: 8px 12px; border-radius: 8px;
  background: rgba(245, 200, 66, 0.1); border: 1px solid rgba(245, 200, 66, 0.35);
  color: #f5c842; font-size: 0.8rem; flex-shrink: 0;
}
#panels { flex: 1; overflow-y: auto; padding: 14px; padding-bottom: 40px; }
.panel { display: none; }
.panel.active { display: block; }

/* ── Bills ─────────────────────────────────────────────────────────────── */
.summary-card {
  background: #1e1f27; border: 1px solid #2a2c38; border-radius: 12px;
  padding: 14px 16px; margin-bottom: 14px;
}
.summary-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 0.9rem; }
.summary-total { border-top: 1px solid #2a2c38; margin-top: 6px; padding-top: 8px; font-size: 1rem; }
.add-btn {
  display: block; width: 100%; background: #4f8ef7; color: #fff; border: none;
  border-radius: 10px; padding: 12px; font-weight: 600; cursor: pointer; margin-bottom: 14px;
}
.empty-msg { color: #6f7080; text-align: center; padding: 30px 0; }
.bill-card {
  background: #1e1f27; border: 1px solid #2a2c38; border-left: 4px solid #4f8ef7;
  border-radius: 10px; padding: 12px 14px; margin-bottom: 10px;
}
.bill-card.paid { opacity: 0.5; }
.bill-head { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 8px; }
.bill-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.bill-meta label { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: #9a9ba8; }
.due-day-input { width: 56px; background: #14151b; border: 1px solid #2a2c38; color: #e8e8ec; border-radius: 6px; padding: 4px 6px; }
.priority-select, .status-toggle-btn {
  background: #14151b; border: 1px solid #2a2c38; color: #e8e8ec;
  border-radius: 6px; padding: 5px 8px; cursor: pointer;
}
.bill-notes { font-size: 0.85rem; color: #b8b9c4; margin-bottom: 8px; white-space: pre-wrap; }
.bill-photo { max-width: 100%; border-radius: 8px; margin-bottom: 8px; display: block; }
.bill-actions { display: flex; gap: 8px; }
.edit-btn, .delete-btn {
  background: none; border: 1px solid #33354280; color: #9a9ba8;
  border-radius: 6px; padding: 5px 10px; cursor: pointer; font-size: 0.85rem;
}
.delete-btn { color: #f75f5f; border-color: #f75f5f40; }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal { background: #1a1b22; border-radius: 14px; width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid #2a2c38; }
.modal-close { background: none; border: none; color: #9a9ba8; font-size: 1.2rem; cursor: pointer; }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.form-label { font-size: 0.8rem; color: #9a9ba8; margin-top: 8px; }
.modal-body input, .modal-body select, .modal-body textarea {
  background: #14151b; border: 1px solid #2a2c38; color: #e8e8ec;
  border-radius: 8px; padding: 10px; width: 100%;
}
#f-photo-preview { max-width: 100%; border-radius: 8px; margin-top: 8px; display: none; }
.form-msg { min-height: 1.2em; font-size: 0.85rem; color: #f75f5f; margin-top: 6px; }

/* ── Notepad ───────────────────────────────────────────────────────────── */
.notepad-bar { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.notepad-bar button {
  background: #1e1f27; border: 1px solid #2a2c38; color: #e8e8ec;
  border-radius: 8px; padding: 8px 12px; cursor: pointer; flex: 1;
}
#note-page-indicator { flex: 2; text-align: center; align-self: center; color: #9a9ba8; font-size: 0.85rem; }
#note-text {
  width: 100%; min-height: 55vh; background: #1e1f27; border: 1px solid #2a2c38;
  color: #e8e8ec; border-radius: 10px; padding: 14px; resize: vertical;
}

/* ── Calculator ────────────────────────────────────────────────────────── */
.calc { max-width: 340px; margin: 0 auto; }
#calc-display {
  background: #1e1f27; border: 1px solid #2a2c38; border-radius: 10px;
  padding: 20px 16px; text-align: right; font-size: 2rem; margin-bottom: 12px;
  overflow-x: auto; white-space: nowrap;
}
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.calc-grid button {
  background: #1e1f27; border: 1px solid #2a2c38; color: #e8e8ec;
  border-radius: 10px; padding: 18px 0; font-size: 1.1rem; cursor: pointer;
}
.calc-grid button.op { background: #4f8ef7; color: #fff; }
.calc-grid button.wide { grid-column: span 2; }

/* ── Toast ─────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #2a2c38; color: #fff; padding: 10px 16px; border-radius: 8px;
  opacity: 0; transition: all 0.2s; pointer-events: none; font-size: 0.85rem; z-index: 200;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 480px) {
  .bill-meta { gap: 6px; }
  #calc-display { font-size: 1.6rem; }
}
