:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-strong: #f8fafc;
  --text: #111827;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
}

body:not(.splash-active) * {
  transition: none !important;
  animation: none !important;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  white-space: nowrap;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  backdrop-filter: blur(10px);
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.mobile-nav-toggle {
  display: none;
  border: none;
  background: transparent;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: center;
}

.main-nav a {
  padding: 0.7rem 1rem;
  border-radius: 999px;
  color: #334155;
  transition: all 140ms ease;
}

.main-nav a:hover {
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary-dark);
}

.auth-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.85rem 1.2rem;
  cursor: pointer;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface-strong);
  color: var(--text);
  border-color: var(--border);
}

.btn-link {
  background: transparent;
  color: var(--primary);
  border-color: transparent;
}

.user-badge {
  padding: 0.65rem 0.95rem;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

.page-content {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.page-heading {
  margin-bottom: 1.5rem;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(2rem, 2.5vw, 3rem);
  line-height: 1.05;
}

.alert {
  padding: 1rem 1.2rem;
  border-radius: 1rem;
  border: 1px solid transparent;
  margin-bottom: 1.25rem;
}

.alert.success {
  background: #dcfce7;
  border-color: #bbf7d0;
  color: #166534;
}

.alert.error {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

.dashboard-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.dashboard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 1.6rem;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.dashboard-card:hover {
  transform: translateY(-4px);
  border-color: rgba(37, 99, 235, 0.3);
  box-shadow: 0 22px 58px rgba(15, 23, 42, 0.12);
}

.dashboard-card img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  margin-bottom: 1rem;
}

.dashboard-card h3 {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
}

.dashboard-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.06);
  padding: 2rem;
}

.form-panel {
  display: grid;
  gap: 1.2rem;
  max-width: 560px;
}

.form-panel label {
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: block;
}

.form-panel input[type='text'],
.form-panel input[type='email'],
.form-panel input[type='password'],
.form-panel input[type='number'] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.95rem;
  padding: 0.95rem 1rem;
  background: #ffffff;
  color: var(--text);
}

.form-panel textarea,
.form-panel select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.95rem;
  padding: 0.95rem 1rem;
  background: #ffffff;
  color: var(--text);
}

.transaction-page {
  padding: 1rem 0 2.5rem;
}

.transaction-header {
  border-radius: 1.75rem;
  padding: 2rem 2rem 1.8rem;
  color: white;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.14);
  margin-bottom: 1.75rem;
}

.transaction-header h1 {
  margin: 0;
  font-size: clamp(2.1rem, 3vw, 3.4rem);
  line-height: 1.05;
}

.transaction-header p {
  margin: 0.85rem 0 0;
  max-width: 42rem;
  color: rgba(255, 255, 255, 0.94);
}

.transaction-header--red {
  background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
}

.transaction-header--green {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.transaction-header--orange {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.transaction-header--blue {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.transaction-layout {
  display: grid;
  gap: 1.75rem;
  grid-template-columns: minmax(280px, 1fr) minmax(460px, 1.4fr);
}

.operation-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  padding: 1.75rem;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
}

.account-card {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 1.3rem;
  padding: 1.5rem;
}

.account-card__label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.55rem;
}

.account-card__value {
  margin: 0;
  font-size: clamp(1.6rem, 2.1vw, 2.8rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.05;
}

.account-card__meta {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.96rem;
}

.stats-grid {
  display: grid;
  gap: 0.95rem;
  margin-top: 1.4rem;
}

.stat-pill {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
  align-items: center;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem 1rem;
}

.stat-label {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-value {
  font-weight: 700;
  color: var(--text);
  text-align: right;
}

.form-group {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 1.25rem;
}

.form-group label {
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
}

.input,
.select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem 1rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.input--readonly {
  background: var(--surface-strong);
  color: var(--muted);
  cursor: not-allowed;
}

.exchange-rate-row {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr auto;
  align-items: center;
}

.exchange-rate-input {
  width: 100%;
}

.preview-panel {
  background: var(--surface-strong);
  border-left: 4px solid var(--primary);
  border-radius: 1.3rem;
  padding: 1.3rem;
}

.preview-panel h3 {
  margin: 0 0 1rem;
  color: var(--text);
  font-size: 1rem;
}

.preview-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid rgba(226, 232, 240, 0.95);
}

.preview-item:last-child {
  border-bottom: none;
}

.preview-item span:first-child {
  color: var(--muted);
  font-size: 0.95rem;
}

.preview-item span:last-child {
  font-weight: 700;
  color: var(--text);
}

.form-actions {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 0.75rem;
}

.btn-wide {
  width: 100%;
}

.field-note {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

@media (max-width: 900px) {
  .transaction-layout {
    grid-template-columns: 1fr;
  }

  .form-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .transaction-header {
    padding: 1.5rem 1.5rem 1.2rem;
  }

  .transaction-page {
    padding: 0.5rem 0 1.5rem;
  }
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.flash-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, visibility 220ms ease;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.18);
}

.flash-modal.visible {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.flash-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
}

.flash-modal-panel {
  position: relative;
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 2rem;
  padding: 2rem 1.75rem 1.5rem;
  box-shadow: 0 48px 120px rgba(15, 23, 42, 0.24);
  width: min(92vw, 540px);
  z-index: 1;
  text-align: center;
  overflow: hidden;
}

.flash-modal-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  background: linear-gradient(90deg, #2563eb, #06b6d4);
}

.flash-modal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.flash-modal-icon {
  width: 3.2rem;
  height: 3.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 1.4rem;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.14);
}

.flash-modal.success .flash-modal-icon {
  background: #dcfce7;
  color: #166534;
}

.flash-modal.error .flash-modal-icon {
  background: #fee2e2;
  color: #991b1b;
}

.flash-modal-title {
  font-size: 1.35rem;
  margin: 0;
  color: #0f172a;
}

.flash-modal-message {
  margin: 0 0 1.4rem;
  color: #475569;
  line-height: 1.8;
}

.flash-modal-receipt {
  text-align: left;
  margin-bottom: 1rem;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  padding-top: 1rem;
  display: grid;
  gap: 0.7rem 1rem;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 1rem;
  padding: 1rem 1rem 0.75rem;
}

.flash-modal-receipt .receipt-title {
  grid-column: 1 / -1;
  font-weight: 700;
  color: #111827;
  margin-bottom: 0.35rem;
}

.flash-modal-receipt .receipt-label {
  color: #475569;
  font-size: 0.88rem;
}

.flash-modal-receipt .receipt-value {
  color: #0f172a;
  font-weight: 700;
}

.flash-modal-download {
  min-width: 220px;
  margin-bottom: 0.75rem;
  background: #2563eb;
  color: white;
  border: none;
  padding: 0.95rem 1.1rem;
  border-radius: 999px;
  transition: transform 180ms ease, background 180ms ease;
}

.flash-modal-download:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.transaction-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  z-index: 10000;
  transition: opacity 220ms ease, visibility 220ms ease;
}

.transaction-modal.visible {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.transaction-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(5px);
}

.transaction-modal-panel {
  position: relative;
  background: linear-gradient(180deg, #f7fbff 0%, #ffffff 100%);
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 2rem;
  padding: 1.75rem 1.75rem 1.5rem;
  box-shadow: 0 52px 130px rgba(15, 23, 42, 0.26);
  width: min(98vw, 980px);
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1;
}

.transaction-modal-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 1.75rem;
  right: 1.75rem;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #06b6d4);
}

.transaction-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  color: #0f172a;
  font-size: 1.35rem;
  cursor: pointer;
  border-radius: 999px;
  width: 2.8rem;
  height: 2.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}

.transaction-modal-close:hover {
  color: #1d4ed8;
}

.transaction-modal-content {
  margin-top: 1.5rem;
}

.transaction-modal-content .transaction-page {
  background: transparent;
}

.transaction-modal-content .transaction-container {
  gap: 1.75rem;
}

.transaction-modal-content .transaction-form-wrapper {
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 1.5rem;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.08);
  padding: 1.5rem;
}

.transaction-modal-content .transaction-form h3,
.transaction-modal-content .transaction-form legend {
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(37, 99, 235, 0.12);
}

.transaction-modal-content .transaction-form label {
  color: #475569;
  font-weight: 600;
}

.transaction-modal-content .transaction-form input,
.transaction-modal-content .transaction-form select,
.transaction-modal-content .transaction-form textarea {
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: none;
  border-radius: 0.95rem;
}

.transaction-modal-content .transaction-form .btn-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  box-shadow: 0 16px 32px rgba(37, 99, 235, 0.18);
}

.transaction-modal-content .transaction-form .btn-primary:hover {
  background: #1d4ed8;
}

.transaction-modal-content .transaction-form .form-actions {
  margin-top: 1.5rem;
}

.account-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  padding: 1.6rem;
}

.account-list {
  display: grid;
  gap: 1rem;
}

.account-list > a {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.2rem;
  padding: 1rem 1.25rem;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.account-list > a:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.3);
}

.account-list span {
  display: block;
  font-weight: 600;
  color: var(--text);
}

.input-inline {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.input-inline input {
  flex: 1 1 220px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 1.25rem;
  overflow: hidden;
}

.table th,
.table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.table th {
  background: var(--surface-strong);
  color: #334155;
}

.site-footer {
  padding: 1.5rem 0 2rem;
  text-align: center;
  color: var(--muted);
  background: var(--surface-strong);
}

@media (max-width: 860px) {
  .header-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    margin: 0.5rem 0;
  }

  .main-nav {
    display: none;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.75rem 0;
    border-top: 1px solid rgba(226, 232, 240, 0.9);
  }

  .main-nav.open {
    display: flex;
  }

  .main-nav a {
    width: 100%;
    padding: 0.85rem 1rem;
    border-radius: 1rem;
    text-align: center;
  }

  .auth-actions {
    justify-content: center;
  }

  .page-content {
    padding: 1.2rem 1rem 1.8rem;
  }

  .btn,
  .btn-primary,
  .btn-secondary,
  .btn-link {
    width: 100%;
  }

  .card-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .input-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .form-panel {
    width: 100%;
  }
}

/* Splash screen styles */
#splash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #ffffff 0%, rgba(245,247,251,0.95) 100%);
  z-index: 9999;
  transition: opacity 360ms ease, visibility 360ms ease;
}
#splash.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-inner { text-align: center; transform: translateY(0); }
.splash-logo { width: 100px; height: 100px; animation: splash-rotate 2.4s ease-in-out infinite; }
.splash-text { margin-top: 0.75rem; font-weight: 700; color: var(--primary-dark); letter-spacing: 0.5px; }

@keyframes splash-rotate {
  0% { transform: rotate(0deg) scale(1); }
  35% { transform: rotate(120deg) scale(1.06); }
  70% { transform: rotate(260deg) scale(1.02); }
  100% { transform: rotate(360deg) scale(1); }
}
