﻿* {
  box-sizing: border-box;
}

:root {
  --navy: #0b1739;
  --navy-light: #142653;
  --blue: #2457f5;
  --green: #16a36a;
  --red: #e55757;
  --gold: #e9a923;
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #17213b;
  --muted: #69738a;
  --border: #e4e9f2;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(36,87,245,.10), transparent 28rem),
    var(--bg);
  color: var(--text);
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  height: 78px;
  padding: 0 6%;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--navy);
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  color: white;
  font-size: 21px;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(36,87,245,.22);
}

.brand strong {
  font-size: 20px;
  letter-spacing: -.5px;
}

.brand small {
  margin-left: 4px;
  color: var(--blue);
  font-weight: 800;
}

.language {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: white;
  color: var(--navy);
  outline: none;
}

.app {
  width: min(1100px, 90%);
  margin: 0 auto;
  padding: 64px 0 50px;
}

.welcome {
  max-width: 760px;
  margin-bottom: 38px;
}

.eyebrow,
.section-label {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.4px;
}

.welcome h1 {
  margin: 10px 0 12px;
  max-width: 700px;
  color: var(--navy);
  font-size: clamp(36px, 5vw, 58px);
  line-height: 1.04;
  letter-spacing: -2px;
}

.welcome p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.65;
}

.status {
  width: fit-content;
  margin-top: 20px;
  padding: 9px 13px;
  border: 1px solid #d9eee5;
  border-radius: 999px;
  background: #effaf5;
  color: #277052;
  font-size: 13px;
  font-weight: 650;
}

.status-dot {
  width: 8px;
  height: 8px;
  margin-right: 7px;
  display: inline-block;
  border-radius: 50%;
  background: var(--green);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.action-card {
  min-height: 116px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(16,35,70,.06);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.action-card:hover {
  transform: translateY(-3px);
  border-color: #cfd9f5;
  box-shadow: 0 16px 35px rgba(16,35,70,.11);
}

.icon {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  font-size: 24px;
  font-weight: 800;
}

.income .icon {
  background: #eaf9f2;
  color: var(--green);
}

.expense .icon {
  background: #fff0f0;
  color: var(--red);
}

.receipt .icon {
  background: #fff7df;
  color: #b77a00;
}

.records .icon {
  background: #edf2ff;
  color: var(--blue);
}

.action-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
}

.action-text strong {
  color: var(--navy);
  font-size: 17px;
}

.action-text small {
  color: var(--muted);
  font-size: 13px;
}

.arrow {
  color: #9ba5ba;
  font-size: 22px;
}

.summary-card {
  margin-top: 22px;
  padding: 28px;
  background: var(--navy);
  color: white;
  border-radius: 24px;
  box-shadow: 0 18px 45px rgba(11,23,57,.17);
}

.summary-card .section-label {
  color: #8eabff;
}

.summary-card h2 {
  margin: 6px 0 24px;
  font-size: 25px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.summary-grid div {
  padding: 18px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 15px;
  background: rgba(255,255,255,.07);
}

.summary-grid small {
  display: block;
  margin-bottom: 8px;
  color: #b9c4dd;
}

.summary-grid strong {
  font-size: 24px;
}

.empty-message {
  margin: 20px 0 0;
  color: #b9c4dd;
  font-size: 13px;
}

.prepare-card {
  margin-top: 22px;
  padding: 27px;
  display: flex;
  align-items: center;
  gap: 20px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 8px 30px rgba(16,35,70,.06);
}

.prepare-icon {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: #eaf9f2;
  color: var(--green);
  font-size: 27px;
  font-weight: 900;
}

.prepare-copy {
  flex: 1;
}

.prepare-copy h2 {
  margin: 5px 0 6px;
  color: var(--navy);
}

.prepare-copy p {
  max-width: 600px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.prepare-button {
  padding: 13px 19px;
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: white;
  font-weight: 750;
  box-shadow: 0 8px 18px rgba(36,87,245,.20);
}

.disclaimer {
  margin: 22px auto 0;
  max-width: 760px;
  color: #7b8498;
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
}

footer {
  padding: 27px 6%;
  display: flex;
  justify-content: center;
  gap: 10px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

footer strong {
  color: var(--navy);
}

@media (max-width: 700px) {
  .topbar {
    height: 68px;
    padding: 0 5%;
  }

  .brand strong {
    font-size: 18px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .language {
    max-width: 112px;
  }

  .app {
    width: 92%;
    padding-top: 38px;
  }

  .welcome h1 {
    font-size: 38px;
    letter-spacing: -1.4px;
  }

  .welcome p {
    font-size: 16px;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .action-card {
    min-height: 98px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .prepare-card {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .prepare-copy {
    width: calc(100% - 80px);
  }

  .prepare-button {
    width: 100%;
  }

  footer {
    flex-direction: column;
    align-items: center;
  }
}

/* ===== Record Modal ===== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  padding: 24px;
  display: grid;
  place-items: center;
  background: rgba(6, 14, 35, .66);
  backdrop-filter: blur(7px);
}

.modal-backdrop[hidden] {
  display: none;
}

body.modal-open {
  overflow: hidden;
}

.record-modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 30px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: 0 28px 80px rgba(4, 12, 35, .28);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 25px;
}

.modal-header h2 {
  margin: 6px 0 6px;
  color: var(--navy);
  font-size: 28px;
}

.modal-header p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.close-modal {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border: 0;
  border-radius: 12px;
  background: #f1f4f9;
  color: var(--navy);
  font-size: 25px;
  line-height: 1;
}

.record-modal form {
  display: grid;
  gap: 18px;
}

.record-modal label {
  display: grid;
  gap: 8px;
  color: var(--navy);
  font-size: 14px;
  font-weight: 700;
}

.record-modal input,
.record-modal textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid #d9e0eb;
  border-radius: 12px;
  background: #fbfcfe;
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.record-modal textarea {
  resize: vertical;
}

.record-modal input:focus,
.record-modal textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(36,87,245,.10);
  background: white;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.form-hint {
  padding: 12px 14px;
  border-radius: 12px;
  background: #f0f5ff;
  color: #53627d;
  font-size: 13px;
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 5px;
}

.secondary-button,
.save-button {
  padding: 13px 19px;
  border-radius: 12px;
  font-weight: 750;
}

.secondary-button {
  border: 1px solid var(--border);
  background: white;
  color: var(--navy);
}

.save-button {
  border: 0;
  background: linear-gradient(135deg, var(--blue), #1741c9);
  color: white;
  box-shadow: 0 9px 20px rgba(36,87,245,.22);
}

.save-button:hover {
  transform: translateY(-1px);
}

@media (max-width: 600px) {
  .modal-backdrop {
    padding: 12px;
    align-items: end;
  }

  .record-modal {
    max-height: 92vh;
    padding: 23px 19px;
    border-radius: 24px 24px 18px 18px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

/* ===== My Records ===== */

.records-modal {
  width: min(760px, 100%);
}

.records-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.records-summary > div {
  padding: 18px;
  border: 1px solid #e2e8f2;
  border-radius: 16px;
  background: #f8faff;
}

.records-summary small {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.records-summary strong {
  color: var(--navy);
  font-size: 25px;
}

.records-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 12px;
}

.records-toolbar strong {
  color: var(--navy);
}

.records-toolbar span {
  color: var(--muted);
  font-size: 12px;
}

.records-list {
  display: grid;
  gap: 10px;
}

.record-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: white;
  transition: transform .15s ease, box-shadow .15s ease;
}

.record-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(16,35,70,.07);
}

.record-type-icon {
  width: 43px;
  height: 43px;
  flex: 0 0 43px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #eaf9f2;
  color: var(--green);
  font-size: 18px;
  font-weight: 850;
}

.record-details {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.record-details strong {
  overflow: hidden;
  color: var(--navy);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-details span,
.record-details small {
  color: var(--muted);
  font-size: 12px;
}

.record-amount {
  flex: 0 0 auto;
  font-size: 17px;
  font-weight: 800;
}

.income-amount {
  color: var(--green);
}

.records-empty {
  padding: 35px 20px;
  border: 1px dashed #d8dfeb;
  border-radius: 16px;
  background: #fafbfd;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

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

  .records-summary strong {
    font-size: 20px;
  }

  .record-item {
    align-items: flex-start;
  }

  .record-amount {
    font-size: 15px;
  }
}

.record-actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
}

.delete-record {
  border: 0;
  background: transparent;
  color: var(--red);
  padding: 4px 6px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.delete-record:hover {
  background: #fff0f0;
}

.delete-record:disabled {
  opacity: .55;
  cursor: not-allowed;
}

[hidden] {
  display: none !important;
}

/* ===== Record action buttons ===== */

.record-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.edit-record,
.edit-expense,
.delete-record,
.delete-expense {
  appearance: none;
  border: 0;
  border-radius: 7px;
  padding: 5px 9px;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}

.edit-record,
.edit-expense {
  color: #3156d3;
  background: #eef3ff;
}

.edit-record:hover,
.edit-expense:hover {
  background: #dfe8ff;
}

.delete-record,
.delete-expense {
  color: #d92d20;
  background: #fff1f0;
}

.delete-record:hover,
.delete-expense:hover {
  background: #ffe2df;
}

.edit-record:disabled,
.edit-expense:disabled,
.delete-record:disabled,
.delete-expense:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ===== My Records summary polish ===== */

.records-summary-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.records-summary-three > div {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.records-summary-three strong {
  display: block;
  margin-bottom: 5px;
}

.records-summary-three span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

@media (max-width: 700px) {
  .records-summary-three {
    grid-template-columns: 1fr;
  }
}


/* Receipt upload controls */
.receipt-box {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid #dfe5ec;
  border-radius: 12px;
  background: #f8fafc;
}

.receipt-box > strong {
  display: block;
  margin-bottom: 6px;
}

.receipt-box > p {
  margin: 0 0 14px;
  color: #667085;
  font-size: 14px;
  line-height: 1.5;
}

.receipt-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.receipt-upload {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #ffffff;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.receipt-upload:hover {
  background: #f1f5f9;
}

.receipt-upload input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

#receiptStatus {
  display: block;
  margin-top: 4px;
  color: #475467;
  font-size: 13px;
  overflow-wrap: anywhere;
}

/* ===== Authentication ===== */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-name {
  max-width: 180px;
  overflow: hidden;
  color: var(--navy);
  font-size: 13px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-button {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  color: var(--navy);
  font-weight: 700;
}

.auth-shell {
  width: min(520px, 90%);
  min-height: calc(100vh - 160px);
  margin: 0 auto;
  padding: 64px 0;
  display: grid;
  place-items: center;
}

.auth-card {
  width: 100%;
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: white;
  box-shadow: 0 18px 55px rgba(16,35,70,.10);
}

.auth-card h1 {
  margin: 9px 0 10px;
  color: var(--navy);
  font-size: clamp(30px, 5vw, 42px);
  letter-spacing: -1.3px;
}

.auth-card > p {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.55;
}

.auth-tabs {
  margin-bottom: 22px;
  padding: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border-radius: 13px;
  background: #f1f4f9;
}

.auth-tab {
  padding: 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}

.auth-tab.active {
  background: white;
  color: var(--navy);
  box-shadow: 0 3px 12px rgba(16,35,70,.08);
}

.auth-form {
  display: grid;
  gap: 17px;
}

.auth-form label {
  display: grid;
  gap: 8px;
  color: var(--navy);
  font-size: 14px;
  font-weight: 700;
}

.auth-form input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid #d9e0eb;
  border-radius: 12px;
  background: #fbfcfe;
  color: var(--text);
  font: inherit;
  outline: none;
}

.auth-form input:focus {
  border-color: var(--blue);
  background: white;
  box-shadow: 0 0 0 4px rgba(36,87,245,.10);
}

.auth-submit {
  margin-top: 3px;
  padding: 14px 18px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue), #1741c9);
  color: white;
  font-weight: 800;
  box-shadow: 0 9px 20px rgba(36,87,245,.20);
}

.auth-submit:disabled,
.logout-button:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.auth-error {
  padding: 11px 13px;
  border: 1px solid #f3cccc;
  border-radius: 11px;
  background: #fff3f3;
  color: #a93434;
  font-size: 13px;
  line-height: 1.45;
}

.auth-hint {
  margin-top: -7px;
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 700px) {
  .topbar-actions {
    gap: 7px;
  }

  .user-name {
    display: none;
  }

  .logout-button {
    padding: 8px 9px;
    font-size: 12px;
  }

  .auth-shell {
    width: 92%;
    min-height: calc(100vh - 140px);
    padding: 35px 0;
  }

  .auth-card {
    padding: 25px 20px;
  }
}
