:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f8f8f8;
  --accent: #333333;
  --accent-dark: #000000;
  --accent-light: #666666;
  --success: #888888;
  --danger: #888888;
  --muted: #999999;
  --border: #cccccc;
  --radius: 24px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 40px 100px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 60px 120px rgba(0, 0, 0, 0.2), 0 0 2px rgba(0, 0, 0, 0.6);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUpStagger {
  0% { opacity: 0; transform: translateY(15px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(0, 0, 0, 0); }
}

@keyframes shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: 'Segoe UI', 'Trebuchet MS', Arial, sans-serif;
  background: radial-gradient(circle at top, #f8f8f8 0%, #e0e0e0 55%, #ffffff 100%);
  color: #000000;
}

button, input, select {
  font: inherit;
}

a { color: inherit; text-decoration: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 16px;
  padding: 18px 28px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  width: 100%;
  font-size: 1.05rem;
  letter-spacing: 0.5px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2), 0 0 1px rgba(0, 0, 0, 0.5);
  animation: slideUpStagger 0.6s ease 0.35s both;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.6s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-4px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3), 0 0 20px rgba(0, 0, 0, 0.15);
}

.btn:hover:not(:disabled)::before {
  left: 100%;
}

.btn:active:not(:disabled) {
  transform: translateY(-2px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-loader {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-small {
  padding: 8px 12px;
  font-size: 0.9rem;
  background: #ffffff;
  color: #666666;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.btn-small:hover {
  background: #f8f8f8;
}

.btn-secondary {
  background: #f4f4f5;
  color: #1f2937;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

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

.sheet-actions {
  justify-content: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}

.sheet-summary {
  gap: 20px;
  margin-bottom: 24px;
}

.sheet-summary h3 {
  margin-bottom: 8px;
}

.sheet-table-wrapper {
  overflow-x: auto;
}

.spreadsheet-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.spreadsheet-table th,
.spreadsheet-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  text-align: left;
  font-size: 0.95rem;
}

.spreadsheet-table thead th {
  background: #f8fafc;
  color: #111827;
  font-weight: 700;
}

.spreadsheet-table tr.positive {
  background: #ecfdf5;
  color: #0f5132;
}

.spreadsheet-table tr.negative {
  background: #fef2f2;
  color: #991b1b;
}

.spreadsheet-table tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.03);
}

.sheet-goals {
  display: grid;
  gap: 14px;
}

.goal-pill {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #f8fafc;
}

.goal-pill span {
  color: #475569;
}

.goal-pill.green {
  background: #ecfdf5;
  border-color: rgba(16, 185, 129, 0.25);
}

.goal-pill.warning {
  background: #fef3c7;
  border-color: rgba(234, 179, 8, 0.25);
}

.goal-pill.neutral {
  background: #eef2ff;
  border-color: rgba(59, 130, 246, 0.2);
}

.link-button {
  background: transparent;
  color: var(--accent);
  border: none;
  padding: 4px 8px;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  transition: color 0.3s ease;
}

.link-button::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.link-button:hover {
  color: var(--accent-dark);
}

.link-button:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: 
    radial-gradient(circle at 10% 40%, rgba(0, 0, 0, 0.3) 0%, transparent 40%),
    radial-gradient(circle at 90% 60%, rgba(0, 0, 0, 0.25) 0%, transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(0, 0, 0, 0.15) 0%, transparent 50%),
    linear-gradient(135deg, #f8f8f8 0%, #e0e0e0 50%, #ffffff 100%);
  background-attachment: fixed;
  animation: fadeIn 0.8s ease;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
  background-size: 50px 50px;
  animation: float 20s ease-in-out infinite;
  z-index: -1;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(30px, 30px); }
}

.login-shell {
  width: min(420px, calc(100% - 32px));
}

.login-card {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 32px;
  padding: 56px 44px;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  z-index: 10;
}

.login-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 30% 30%, rgba(59, 130, 246, 0.05) 0%, transparent 50%);
  pointer-events: none;
}

.brand {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--accent-dark);
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: slideUpStagger 0.6s ease 0.1s both;
}

.login-card h1 {
  font-size: 2rem;
  font-weight: 900;
  margin: 0 0 8px;
  color: #0f172a;
  letter-spacing: -0.5px;
  animation: slideUpStagger 0.6s ease 0.15s both;
}

.error-message {
  min-height: 28px;
  margin-bottom: 28px;
  font-weight: 700;
  padding: 14px 16px;
  border-radius: 14px;
  animation: slideUpStagger 0.6s ease 0.05s both;
  backdrop-filter: blur(10px);
}

.error-message:not(:empty) {
  background: rgba(220, 38, 38, 0.1);
  border-left: 4px solid var(--danger);
  border-right: 1px solid rgba(220, 38, 38, 0.2);
}

.input-group {
  position: relative;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  animation: slideUpStagger 0.6s ease both;
}

.input-group:nth-child(1) { animation-delay: 0.2s; }
.input-group:nth-child(2) { animation-delay: 0.25s; }
.input-group:nth-child(4) { animation-delay: 0.3s; }

.input-icon {
  position: absolute;
  left: 16px;
  width: 20px;
  height: 20px;
  color: var(--accent);
  pointer-events: none;
  z-index: 2;
  transition: color 0.3s ease, transform 0.3s ease;
  flex-shrink: 0;
}

.validation-icon {
  position: absolute;
  right: 16px;
  width: 18px;
  height: 18px;
  font-size: 1.1rem;
  z-index: 3;
  animation: slideUp 0.3s ease;
}

.login-card input,
.login-card select {
  width: 100%;
  padding: 16px 16px 16px 48px;
  border-radius: 16px;
  border: 2px solid rgba(148, 163, 184, 0.15);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(248, 250, 252, 0.8) 100%);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 1rem;
  font-weight: 500;
}

.login-card input::placeholder {
  color: rgba(100, 116, 139, 0.45);
  font-weight: 500;
}

.login-card input:focus,
.login-card select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12), inset 0 2px 6px rgba(37, 99, 235, 0.08);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(240, 249, 255, 0.95) 100%);
  transform: translateY(-2px);
}

.toggle-password {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 6px 8px;
  transition: all 0.2s ease;
  z-index: 3;
  color: var(--accent);
  opacity: 0.8;
}

.toggle-password:hover {
  opacity: 1;
  transform: scale(1.2) rotate(10deg);
}

.toggle-password:active {
  transform: scale(1.1) rotate(5deg);
}

.password-strength {
  margin: -14px 0 18px 0;
  animation: slideUpStagger 0.3s ease;
}

.strength-bar {
  height: 5px;
  background: rgba(226, 232, 240, 0.6);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}

.strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.4s ease, background-color 0.4s ease, filter 0.3s ease;
  background: #dc2626;
  filter: drop-shadow(0 0 4px rgba(220, 38, 38, 0.4));
}

.strength-fill.weak { background: #ef4444; }
.strength-fill.fair { background: #f97316; width: 50%; }
.strength-fill.good { background: #eab308; width: 80%; filter: drop-shadow(0 0 4px rgba(234, 179, 8, 0.4)); }
.strength-fill.strong { background: #22c55e; width: 100%; filter: drop-shadow(0 0 6px rgba(34, 197, 94, 0.5)); }

.strength-text {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.3px;
}

.login-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 32px;
  font-size: 0.95rem;
  animation: slideUpStagger 0.6s ease 0.4s both;
  color: #475569;
}

.login-footer .link-button {
  font-size: 0.95rem;
}

.login-card .small {
  margin-top: 28px;
  display: block;
  text-align: center;
  animation: slideUpStagger 0.6s ease 0.45s both;
}

.tm-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.tm-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 28px;
  background: linear-gradient(135deg, #0f172a, #111827);
  color: #f8fafc;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}

.tm-brand {
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.tm-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 14px;
  padding: 12px 18px;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease, color .2s ease;
}

.nav-btn:hover,
.nav-btn.active {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  transform: translateY(-1px);
}

.logout-btn {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.12);
  color: #fde047;
}

.tm-main {
  width: min(1200px, 100%);
  margin: 32px auto 40px;
  padding: 0 20px;
  flex: 1;
}

h1, h2 {
  color: #0f172a;
  margin-bottom: 20px;
  font-weight: 800;
}

.grid-3,
.grid-2,
.grid-4 {
  display: grid;
  gap: 20px;
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 26px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.04);
}

.card h3 {
  margin-top: 0;
  margin-bottom: 18px;
  color: #1e293b;
}

.summary-line,
.form-inline,
.form-grid,
.sheet-head,
.sheet-actions {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.summary-line {
  justify-content: space-between;
  margin-bottom: 14px;
  color: #334155;
  font-weight: 600;
}

.sheet-head {
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 24px;
}

.sheet-head h2 {
  margin-bottom: 8px;
}

.sheet-actions {
  justify-content: flex-end;
}

.sheet-actions .file-input {
  min-width: 240px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: #ffffff;
  color: #0f172a;
}

.stat-card {
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: #f8fbff;
  padding: 22px 24px;
  border-radius: 24px;
  text-align: left;
}

.stat-label {
  display: block;
  margin-bottom: 8px;
  color: #475569;
  font-size: 0.95rem;
  font-weight: 600;
}

.stat-card strong {
  font-size: 1.7rem;
  color: #0f172a;
  display: block;
}

.upload-panel {
  padding: 22px 24px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: #ffffff;
}

.sheet-summary {
  gap: 24px;
  margin-bottom: 22px;
}

.sheet-summary h3 {
  margin-bottom: 10px;
}

.sheet-table-wrapper {
  overflow-x: auto;
}

.spreadsheet-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.spreadsheet-table th,
.spreadsheet-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  text-align: left;
  font-size: 0.95rem;
}

.spreadsheet-table thead th {
  background: #f8fafc;
  color: #0f172a;
  font-weight: 700;
}

.spreadsheet-table tr.positive {
  background: #ecfdf5;
  color: #0f5132;
}

.spreadsheet-table tr.negative {
  background: #fef2f2;
  color: #991b1b;
}

.spreadsheet-table tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.03);
}

.sheet-goals {
  display: grid;
  gap: 14px;
}

.goal-pill {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #f8fbff;
}

.goal-pill span {
  color: #475569;
}

.goal-pill.green {
  background: #ecfdf5;
  border-color: rgba(16, 185, 129, 0.25);
}

.goal-pill.warning {
  background: #fef3c7;
  border-color: rgba(234, 179, 8, 0.25);
}

.goal-pill.neutral {
  background: #eef2ff;
  border-color: rgba(59, 130, 246, 0.2);
}

.progress {
  background: #e2e8f0;
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
  margin-bottom: 14px;
}

.progress.small {
  height: 10px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(135deg, var(--accent), #22c55e);
  transition: width .3s ease;
}

.form-inline input,
.form-inline select,
.form-grid input,
.form-grid select {
  flex: 1;
  min-width: 180px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  background: #ffffff;
}

.form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-grid input,
.form-grid select,
.form-grid button {
  width: 100%;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  background: #f8fbff;
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.empty-state {
  color: var(--muted);
  padding: 18px 0;
}

.txn-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.txn-amount {
  font-weight: 700;
}

.txn-amount.positive { color: var(--success); }
.txn-amount.negative { color: var(--danger); }

.goal-card {
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 22px;
  padding: 18px;
  margin-bottom: 16px;
  background: #f8fbff;
}

.goal-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.goal-title {
  margin-bottom: 8px;
  font-weight: 700;
}

.goal-meta,
.goal-stats {
  color: var(--muted);
  font-size: 0.95rem;
}

.report-summary p {
  margin: 10px 0;
}

.muted {
  color: var(--muted);
}

@media (max-width: 960px) {
  .grid-3,
  .grid-2,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .tm-header {
    padding: 20px 18px;
  }
}

@media (max-width: 600px) {
  .login-card {
    padding: 28px 22px;
  }

  .tm-main {
    margin: 20px auto 30px;
    padding: 0 14px;
  }

  .form-inline,
  .summary-line {
    flex-direction: column;
    align-items: stretch;
  }

  .tm-nav {
    width: 100%;
    overflow-x: auto;
  }

  .nav-btn {
    flex: 1 1 auto;
    white-space: nowrap;
  }
}