* { box-sizing: border-box; }

body {
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: #f4f5f7;
  color: #1f2430;
  margin: 0;
  padding: 1.5rem 1rem 3rem;
}

.page {
  max-width: 1000px;
  margin: 0 auto;
}

h1 {
  margin-bottom: 0.1rem;
}

.subtitle {
  margin-top: 0;
  color: #666;
}

.hint {
  color: #777;
  font-size: 0.85rem;
  margin: -0.25rem 0 0.75rem;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

#auth-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.google-btn {
  display: inline-block;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 4px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  text-decoration: none;
  font-weight: 500;
}

.google-btn:hover {
  background: #f8f9fa;
}

#auth-profile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

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

@media (max-width: 700px) {
  .grid { grid-template-columns: 1fr; }
  body { padding: 1rem 0.75rem 3rem; }
  .app-header { align-items: center; }
  .card { padding: 1rem; }
}

.card {
  background: #fff;
  border: 1px solid #e2e4e9;
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

/* --- Trip summary --- */
.summary-card {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
}

.summary-stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 90px;
}

.summary-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #2c2f6b;
}

.summary-label {
  font-size: 0.78rem;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.breakdown-summary .summary-value { font-size: 1.6rem; }

/* --- Pills / lists --- */
.pill-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem 0;
}

.pill-list li {
  background: #eef1ff;
  border: 1px solid #ccd3ff;
  border-radius: 999px;
  padding: 0.25rem 0.4rem 0.25rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.participant-link {
  background: none;
  border: none;
  color: #2c2f6b;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.participant-link:hover {
  text-decoration: underline;
}

.remove-btn {
  border: none;
  background: transparent;
  color: #a33;
  cursor: pointer;
  font-weight: bold;
  padding: 0.1rem 0.35rem;
  line-height: 1;
  border-radius: 50%;
}

.remove-btn:hover {
  background: #fde3e3;
}

/* --- Forms --- */
.inline-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.inline-form input {
  flex: 1;
  min-width: 160px;
}

.inline-form select {
  width: auto;
}

form label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: #444;
}

form input,
form select {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
}

form input:focus,
form select:focus {
  outline: 2px solid #4a5cff33;
  border-color: #4a5cff;
}

.field-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 480px) {
  .field-row { grid-template-columns: 1fr; }
}

.field-error {
  display: block;
  color: #cf222e;
  font-size: 0.8rem;
  min-height: 1.1em;
  margin-top: 0.2rem;
}

fieldset {
  border: 1px solid #ddd;
  border-radius: 6px;
  margin: 0 0 0.75rem 0;
}

legend {
  font-size: 0.9rem;
  color: #444;
  padding: 0 0.3rem;
}

.split-toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.link-btn {
  background: none;
  border: none;
  color: #4a5cff;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
}

.checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.checkbox-list label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
}

.checkbox-list input {
  width: auto;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* --- Buttons --- */
button {
  background: #4a5cff;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s ease;
}

button:hover {
  background: #3a4ae0;
}

button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.btn-secondary {
  background: #eceef5;
  color: #333;
}

.btn-secondary:hover {
  background: #dde0ec;
}

button.danger {
  background: #cf222e;
}

button.danger:hover {
  background: #a5121c;
}

/* --- Tables --- */
.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

th, td {
  text-align: left;
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid #eee;
  font-size: 0.88rem;
  white-space: nowrap;
}

td:nth-child(2) {
  white-space: normal;
}

.amount-main {
  font-weight: 600;
}

.amount-sub {
  font-size: 0.75rem;
  color: #888;
  cursor: help;
}

.action-cell {
  white-space: nowrap;
}

.empty-msg {
  color: #888;
  font-size: 0.9rem;
}

/* --- Expense toolbar (sort/filter) --- */
.expense-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #eee;
}

.toolbar-field {
  display: flex;
  flex-direction: column;
  font-size: 0.78rem;
  color: #666;
  gap: 0.2rem;
}

.toolbar-field select {
  margin-top: 0;
  padding: 0.35rem 0.4rem;
  font-size: 0.85rem;
  min-width: 130px;
}

/* --- Settlements --- */
.settlement-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.settlement-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f0fff4;
  border: 1px solid #cdeed7;
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.settlement-from,
.settlement-to {
  font-weight: 600;
}

.settlement-arrow {
  color: #1a7f37;
}

.settlement-amount {
  margin-left: auto;
  font-weight: 700;
  color: #1a7f37;
}

.net-positive { color: #1a7f37; font-weight: 600; }
.net-negative { color: #cf222e; font-weight: 600; }
.net-zero { color: #666; }

.delete-link {
  color: #a33;
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: underline;
}

.edit-link {
  color: #4a5cff;
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: underline;
}

.trip-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.trip-controls select {
  flex: 1;
  min-width: 160px;
  padding: 0.5rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
}

/* --- Breakdown ("page") view --- */
.back-link {
  display: inline-block;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

/* --- Toast --- */
.toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(-1rem);
  background: #1f2430;
  color: #fff;
  padding: 0.6rem 1.1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.toast.error {
  background: #cf222e;
}

/* --- Join screen / join-by-code --- */
#join-screen {
  text-align: center;
  max-width: 480px;
  margin: 2rem auto;
}

#join-code-preview {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: #f7f8fc;
  border: 1px solid #e2e4e9;
  border-radius: 6px;
}

#join-code-preview p {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
}

.field-error-block {
  color: #cf222e;
}

/* --- Trip dates --- */
.dates-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.dates-form label {
  flex: 1;
  min-width: 140px;
  margin-bottom: 0;
}

.dates-form .form-actions {
  margin-top: 0;
  flex-basis: 100%;
}

/* --- Split methods --- */
.split-rows label {
  align-items: center;
}

.split-value-input {
  width: 80px !important;
  margin: 0 !important;
  padding: 0.25rem 0.4rem !important;
  font-size: 0.85rem !important;
}

.split-preview {
  margin-top: 0.6rem;
}

.split-preview-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
  color: #444;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
}

.split-preview-list li {
  background: #f7f8fc;
  border: 1px solid #e2e4e9;
  border-radius: 4px;
  padding: 0.2rem 0.55rem;
}

/* --- Per-currency balances/settlements --- */
.currency-bucket {
  margin-bottom: 1.25rem;
}

.currency-bucket:last-child {
  margin-bottom: 0;
}

.currency-bucket h3 {
  font-size: 0.95rem;
  margin: 0 0 0.4rem;
  color: #2c2f6b;
}

/* --- Notes --- */
.note-form textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
}

.note-form input {
  margin-bottom: 0.6rem;
}

.note-card {
  border: 1px solid #e2e4e9;
  border-radius: 6px;
  padding: 0.75rem 0.9rem;
  margin-top: 0.75rem;
}

.note-card h3 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
}

.note-content {
  margin: 0 0 0.4rem;
  white-space: pre-wrap;
  font-size: 0.9rem;
}

.note-meta {
  font-size: 0.78rem;
  color: #888;
  margin-bottom: 0.3rem;
}

.note-actions {
  font-size: 0.85rem;
}

/* --- Modal (share/invite) --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 30, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 200;
}

.modal {
  background: #fff;
  border-radius: 10px;
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: transparent;
  color: #666;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.modal-close:hover {
  background: #eee;
}

.modal h2 {
  margin-top: 0;
  padding-right: 1.5rem;
  font-size: 1.1rem;
}

.share-qr {
  display: block;
  width: 100%;
  max-width: 260px;
  height: auto;
  margin: 0.5rem auto 1.25rem;
  border: 1px solid #e2e4e9;
  border-radius: 8px;
  padding: 0.5rem;
  background: #fff;
}

.share-field {
  margin-bottom: 1rem;
}

.share-field label {
  display: block;
  font-size: 0.85rem;
  color: #444;
  margin-bottom: 0.25rem;
}

.copy-row {
  display: flex;
  gap: 0.5rem;
}

.copy-row input {
  flex: 1;
  font-family: monospace;
  font-size: 0.85rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #f7f8fc;
}

.share-owner-actions {
  display: flex;
  gap: 1rem;
  margin: 0.5rem 0 1rem;
}

@media (max-width: 480px) {
  .modal { padding: 1.25rem; }
  .dates-form { flex-direction: column; }
  .dates-form label { width: 100%; }
}

/* ===========================================================================
   Landing page (logged-out state)
   =========================================================================== */

#landing-page {
  display: flex;
  flex-direction: column;
  gap: 3rem;
  padding-top: 1rem;
}

.section-title {
  font-size: 1.5rem;
  text-align: center;
  margin: 0 0 0.4rem;
}

.section-subtitle {
  text-align: center;
  color: #666;
  margin: 0 0 1.5rem;
}

/* --- Hero --- */
.hero {
  text-align: center;
  padding: 2rem 1rem 2.5rem;
  background: linear-gradient(180deg, #eef1ff 0%, #f4f5f7 100%);
  border-radius: 14px;
}

.hero-logo {
  max-width: 260px;
  width: 70%;
  height: auto;
  margin: 0 auto 1.5rem;
  display: block;
}

.hero-title {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  max-width: 640px;
  margin: 0 auto 0.75rem;
  line-height: 1.25;
}

.hero-subtitle {
  max-width: 560px;
  margin: 0 auto 1.75rem;
  color: #444;
  font-size: 1.05rem;
  line-height: 1.5;
}

.hero-ctas {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.hero-cta-primary {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.hero-cta-secondary {
  color: #4a5cff;
  text-decoration: underline;
  font-size: 0.95rem;
}

/* --- Preview mock --- */
.preview-section {
  padding: 0 0.25rem;
}

.preview-card {
  max-width: 700px;
  margin: 0 auto;
  position: relative;
}

.preview-badge {
  position: absolute;
  top: -0.6rem;
  right: 1rem;
  background: #2c2f6b;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}

.preview-header h3 {
  margin: 0 0 0.15rem;
  font-size: 1.2rem;
}

.preview-stats {
  gap: 1.25rem;
  margin: 1rem 0;
  padding: 0.75rem 0;
  border-top: 1px solid #eee;
  border-bottom: 1px solid #eee;
}

.preview-pills {
  margin-bottom: 1rem;
}

.preview-pills li {
  pointer-events: none;
}

.preview-table {
  margin-bottom: 1rem;
}

.preview-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.preview-columns .settlement-item {
  margin-bottom: 0;
}

.preview-label {
  font-size: 0.78rem;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0 0 0.4rem;
}

@media (max-width: 600px) {
  .preview-columns { grid-template-columns: 1fr; }
}

/* --- Features --- */
.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

@media (max-width: 800px) {
  .features-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 550px) {
  .features-grid { grid-template-columns: 1fr; }
}

.feature {
  background: #fff;
  border: 1px solid #e2e4e9;
  border-radius: 10px;
  padding: 1.25rem;
}

.feature-icon {
  font-size: 1.6rem;
  display: block;
  margin-bottom: 0.5rem;
}

.feature h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.feature p {
  margin: 0;
  font-size: 0.88rem;
  color: #555;
  line-height: 1.45;
}

/* --- How it works --- */
.steps-section {
  text-align: center;
}

.steps-list {
  list-style: none;
  padding: 0;
  margin: 0 auto 1.75rem;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  text-align: left;
}

.steps-list li {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #4a5cff;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
}

.steps-list h3 {
  margin: 0 0 0.2rem;
  font-size: 1rem;
}

.steps-list p {
  margin: 0;
  font-size: 0.88rem;
  color: #555;
}

/* --- Footer --- */
.app-footer {
  text-align: center;
  padding: 1.5rem 0 0.5rem;
  border-top: 1px solid #e2e4e9;
  color: #777;
  font-size: 0.85rem;
}

.app-footer a {
  color: #4a5cff;
}

@media (max-width: 500px) {
  .hero { padding: 1.75rem 1rem 2rem; border-radius: 10px; }
  #landing-page { gap: 2.25rem; }
}
