/* Modern Friendly CIBC-Inspired Design System (Cute & Clean Twist) */

:root {
  /* Color Palette - Warm Whites, Soft Reds & Sunny Gold */
  --bg-primary: #fdfafb;
  --surface-white: #ffffff;
  
  --cibc-red: #d11232;
  --cibc-red-hover: #eb2547;
  --cibc-red-light: #fdf1f3;
  --cibc-red-muted: #e89da9;
  
  --cibc-gold: #e59f10;
  --cibc-gold-hover: #fcae14;
  --cibc-gold-light: #fdf7e7;
  
  --text-dark: #2b1f21;
  --text-muted: #7d6e71;
  --border-color: #f7ebed;
  
  /* Fonts */
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'Space Mono', monospace;
  
  /* Soft Rounded Surfaces */
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-pill: 30px;
  
  /* Modern Cute Shadows */
  --shadow-sm: 0 2px 8px rgba(209, 18, 50, 0.03);
  --shadow-md: 0 12px 24px rgba(209, 18, 50, 0.04), 0 2px 4px rgba(0, 0, 0, 0.01);
  --shadow-lg: 0 20px 40px rgba(209, 18, 50, 0.06), 0 1px 3px rgba(0, 0, 0, 0.01);
}

/* Base Setup */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-dark);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.monospaced {
  font-family: var(--font-mono);
  font-weight: 700;
}

/* Authentication Screen (PIN only) */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 10% 20%, #fdf5f6 0%, var(--bg-primary) 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

.login-card {
  background-color: var(--surface-white);
  border: 2px solid var(--border-color);
  padding: 40px 35px;
  max-width: 380px;
  width: 100%;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
  transform: translateY(0);
  animation: bounceIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.ledger-brand-mark {
  width: 70px;
  height: 70px;
  background-color: var(--cibc-red);
  color: var(--surface-white);
  font-family: var(--font-sans);
  font-size: 2.2rem;
  font-weight: 800;
  border-radius: 22px;
  line-height: 70px;
  margin: 0 auto 20px auto;
  box-shadow: 0 8px 20px rgba(209, 18, 50, 0.25);
  border: 3px solid var(--cibc-gold-light);
  transform: rotate(-5deg);
  transition: transform 0.3s ease;
}

.login-card:hover .ledger-brand-mark {
  transform: rotate(5deg) scale(1.05);
}

.login-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--text-dark);
  letter-spacing: -0.5px;
}

.login-header .subtitle {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 30px;
}

.pin-container {
  margin-bottom: 25px;
}

.pin-container input {
  width: 100%;
  padding: 16px;
  font-size: 2rem;
  text-align: center;
  border: 2px solid var(--border-color);
  background-color: var(--bg-primary);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  letter-spacing: 10px;
  color: var(--text-dark);
  transition: all 0.2s ease;
}

.pin-container input:focus {
  outline: none;
  border-color: var(--cibc-red);
  background-color: var(--surface-white);
  box-shadow: 0 0 0 4px rgba(209, 18, 50, 0.08);
}

#login-button {
  width: 100%;
  padding: 16px;
  background-color: var(--cibc-red);
  color: var(--surface-white);
  border: none;
  font-size: 1rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 5px 15px rgba(209, 18, 50, 0.15);
  transition: all 0.2s ease;
}

#login-button:hover {
  background-color: var(--cibc-red-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(209, 18, 50, 0.2);
}

#login-button:active {
  transform: translateY(1px);
}

.error-text {
  color: var(--cibc-red);
  font-weight: 700;
  font-size: 0.85rem;
  margin-top: 15px;
}

/* Dashboard UI Layout */
.dashboard {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px;
}

@media(max-width: 600px) {
  .dashboard {
    padding: 20px 10px;
  }
}

/* Header style */
.ledger-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.last-update-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
}

.last-update-text span {
  color: var(--cibc-red);
}

.header-left h2 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-dark);
  letter-spacing: -0.5px;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
  cursor: pointer;
  background: var(--surface-white);
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background-color: var(--cibc-red-light);
  color: var(--cibc-red);
  border-color: var(--cibc-red-muted);
}

/* Cute Summary Grid */
.summary-section {
  margin-bottom: 30px;
}

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

@media (max-width: 600px) {
  .summary-grid {
    gap: 12px;
  }
}

.summary-card {
  background-color: var(--surface-white);
  border: 2px solid var(--border-color);
  padding: 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease;
}

.summary-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.summary-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 4px;
  width: 100%;
}

.summary-card:nth-child(1)::before {
  background-color: var(--cibc-red);
}

.summary-card:nth-child(2)::before {
  background-color: var(--cibc-gold);
}

.summary-card:nth-child(3)::before {
  background-color: var(--text-muted);
}

.card-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.card-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-dark);
  line-height: 1.1;
  letter-spacing: -0.5px;
}

#total-spend {
  color: var(--cibc-red);
}

#transaction-count {
  color: var(--cibc-gold);
}

/* Control Panel (Cute and rounded) */
.control-panel {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  background-color: var(--surface-white);
  border: 2px solid var(--border-color);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

#search-input {
  flex: 6;
  width: 100%;
}

#card-filter,
#month-filter {
  flex: 2;
  min-width: 110px;
}

.control-panel input,
.control-panel select {
  padding: 12px 16px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  border: 2px solid var(--border-color);
  background-color: var(--bg-primary);
  border-radius: var(--radius-md);
  outline: none;
  color: var(--text-dark);
  transition: all 0.2s ease;
  width: 100%;
}

.control-panel input:focus,
.control-panel select:focus {
  border-color: var(--cibc-red);
  background-color: var(--surface-white);
  box-shadow: 0 0 0 4px rgba(209, 18, 50, 0.06);
}

/* Ledger Sheet / List Styling */
.ledger-sheet-container {
  margin-bottom: 30px;
}

.ledger-sheet {
  background-color: var(--surface-white);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px;
}

.table-responsive {
  width: 100%;
}

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.ledger-table th {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 14px 16px;
  border-bottom: 2px solid var(--border-color);
  letter-spacing: 0.5px;
}

.ledger-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.95rem;
  font-weight: 600;
}

.ledger-table tr:hover td {
  background-color: var(--bg-primary);
}

/* Column dimensions */
.col-date {
  width: 60px;
  color: var(--text-muted);
  font-weight: 500 !important;
  white-space: nowrap !important;
}

.col-desc {
  font-size: 1rem;
  color: var(--text-dark);
}

.col-card {
  width: 80px;
  text-align: center;
}

.ledger-table th.col-card {
  text-align: center;
}

/* Cute tag for card accounts */
.ledger-table td.col-card {
  font-family: var(--font-sans);
  text-align: center;
}

/* Pill badge styling for Costco card */
.col-card-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  vertical-align: middle;
  background-color: var(--cibc-gold-light);
  color: var(--cibc-gold);
  border: 1px solid rgba(229, 159, 16, 0.15);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.col-amount {
  width: 130px;
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--cibc-red);
  white-space: nowrap !important;
}

/* System Notifications Style */
tr.row-system td.col-desc {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--cibc-red);
  background-color: var(--cibc-red-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  word-break: break-all;
  border: 1px solid rgba(209, 18, 50, 0.08);
}

tr.row-system td.col-amount {
  color: var(--text-muted);
}

/* Month Group Divider (Badge Design) */
tr.month-divider-row:hover td {
  background-color: transparent !important;
}

td.month-divider-cell {
  padding: 30px 0 15px 0 !important;
  text-align: center;
  border-bottom: none !important;
}

.month-divider-badge {
  display: inline-block;
  background-color: var(--cibc-red-light);
  color: var(--cibc-red);
  border: 1px solid rgba(209, 18, 50, 0.15);
  padding: 6px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 1px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px !important;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Footer layout */
.ledger-footer {
  text-align: center;
  padding: 30px 0 10px 0;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.ledger-footer strong {
  color: var(--cibc-red);
}

/* Offline toast card */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--text-dark);
  color: var(--surface-white);
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 2000;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.hidden {
  display: none !important;
  opacity: 0;
}

/* Mobile Table Optimization & Layout Spacing Adjustments */
@media (max-width: 600px) {
  .ledger-sheet {
    padding: 12px !important;
  }
  
  .ledger-table th, 
  .ledger-table td {
    padding: 10px 8px !important;
    font-size: 0.85rem !important;
  }
  
  .col-date {
    width: 50px !important;
    white-space: nowrap !important;
  }
  
  .col-card {
    width: 65px !important;
  }
  
  .col-amount {
    width: 95px !important;
  }
  
  .col-card-badge {
    padding: 2px 6px !important;
    font-size: 0.7rem !important;
  }
  
  #card-filter,
  #month-filter {
    padding: 12px 6px !important;
    font-size: 0.85rem !important;
    min-width: 90px !important;
  }
  
  #search-input {
    padding: 12px 10px !important;
    font-size: 0.85rem !important;
  }
}
