@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #ED2533;
  --primary-dark: #c71f2a;
  --primary-light: #ff3d4d;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --dark: #1f2937;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 12px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.header .subtitle {
  font-size: 0.875rem;
  opacity: 0.9;
  font-weight: 500;
}

.header .nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.header .nav-links a {
  color: white;
  text-decoration: none;
  font-weight: 500;
  opacity: 0.9;
  transition: opacity 0.2s;
  font-size: 0.9375rem;
}

.header .nav-links a:hover {
  opacity: 1;
}

/* Container */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.container.wide {
  max-width: 1200px;
}

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}

.card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-700);
  margin: 1.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--gray-100);
}

/* Login */
.login-wrapper {
  min-height: calc(100vh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  background: white;
  border-radius: var(--radius);
  padding: 3rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--gray-200);
}

.login-card h2 {
  font-size: 1.875rem;
  color: var(--gray-900);
  margin-bottom: 2rem;
  text-align: center;
  font-weight: 700;
}

.store-select {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.store-btn {
  padding: 1.25rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  background: white;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s;
  text-align: left;
}

.store-btn:hover {
  border-color: var(--primary);
  background: var(--gray-50);
}

.store-btn.selected {
  border-color: var(--primary);
  background: rgba(237, 37, 51, 0.05);
  color: var(--primary);
}

.store-btn .addr {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--gray-600);
  display: block;
  margin-top: 0.25rem;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.5rem;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: all 0.2s;
  background: white;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(237, 37, 51, 0.1);
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.pin-input {
  font-size: 2rem !important;
  text-align: center;
  letter-spacing: 0.5rem;
  padding: 1.25rem !important;
  font-weight: 700;
}

/* Expenses */
.expense-row {
  display: grid;
  grid-template-columns: 2fr 1fr 2fr 40px;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  align-items: center;
}

.expense-row input[type="text"]:nth-of-type(1) {
  /* Название */
}

.expense-row input[type="number"] {
  /* Сумма */
}

.expense-row input[type="text"]:nth-of-type(2) {
  /* Комментарий */
}

.remove-exp {
  width: 40px;
  height: 44px;
  flex-shrink: 0;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remove-exp:hover {
  background: #dc2626;
}

.add-expense {
  width: 100%;
  padding: 0.875rem;
  background: var(--gray-100);
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 0.5rem;
}

.add-expense:hover {
  background: var(--gray-200);
  border-color: var(--gray-400);
}

/* Total */
.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
  color: white;
  border-radius: var(--radius);
  margin: 2rem 0;
  font-size: 1.25rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
}

.total-row .amount {
  font-size: 1.75rem;
  font-weight: 800;
}

/* Buttons */
.btn {
  padding: 1rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-red {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  box-shadow: var(--shadow-lg);
  width: 100%;
}

.btn-red:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-xl);
}

.btn-red:active {
  transform: translateY(0);
}

/* Date Navigation */
.date-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--gray-100);
  border-radius: var(--radius);
}

.date-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: white;
  border-radius: 50%;
  text-decoration: none;
  font-size: 1.5rem;
  color: var(--gray-700);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
  font-weight: 600;
}

.date-nav a:hover {
  box-shadow: var(--shadow);
  background: var(--gray-50);
}

.date-nav .current-date {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--gray-900);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

table thead {
  background: var(--gray-100);
}

table th {
  padding: 0.875rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--gray-700);
  border-bottom: 2px solid var(--gray-200);
}

table td {
  padding: 1rem;
  border-bottom: 1px solid var(--gray-200);
}

table tr:last-child td {
  border-bottom: none;
}

table tr:hover {
  background: var(--gray-50);
}

/* Flash Messages */
.flash {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  font-weight: 500;
}

.flash.error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.flash.success {
  background: #f0fdf4;
  color: var(--success);
  border: 1px solid #bbf7d0;
}

/* Week Table */
.week-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9375rem;
}

.week-table thead {
  background: var(--gray-100);
}

.week-table th {
  padding: 0.875rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--gray-700);
  border-bottom: 2px solid var(--gray-200);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.week-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}

.week-table tbody tr:hover {
  background: var(--gray-50);
}

.week-table .total-row {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  font-weight: 700;
  font-size: 1rem;
}

.week-table .total-row td {
  padding: 1.125rem 1rem;
  border-top: 3px solid var(--success);
  border-bottom: none;
  color: #15803d !important;
}

/* Expenses Table */
.expenses-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.9375rem;
}

.expenses-table thead {
  background: var(--gray-100);
}

.expenses-table th {
  padding: 0.75rem 0.875rem;
  text-align: left;
  font-weight: 600;
  color: var(--gray-700);
  border-bottom: 2px solid var(--gray-200);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.expenses-table td {
  padding: 0.875rem;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}

.expenses-table tbody tr:hover {
  background: var(--gray-50);
}

.expenses-table tbody tr:last-child td {
  border-bottom: none;
}

.expenses-table .total-row {
  background: var(--gray-100);
  font-weight: 700;
}

.expenses-table .total-row td {
  padding: 1rem 0.875rem;
  border-top: 2px solid var(--gray-300);
  color: #374151 !important;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .header {
    padding: 1rem;
  }
  
  .header h1 {
    font-size: 1.25rem;
  }
  
  .header .nav-links {
    gap: 1rem;
    font-size: 0.875rem;
  }
  
  .container {
    padding: 1.5rem 1rem;
  }
  
  .card {
    padding: 1.5rem;
  }
  
  .login-card {
    padding: 2rem 1.5rem;
  }
  
  .form-group input {
    font-size: 16px; /* Предотвращает zoom на iOS */
  }
  
  .expense-row {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    gap: 0.5rem;
  }
  
  .expense-row input[type="text"],
  .expense-row input[type="number"] {
    width: 100%;
  }
  
  .remove-exp {
    grid-column: 1;
    width: 100%;
  }
  
  /* Таблицы на мобильных */
  .week-table,
  .expenses-table {
    font-size: 0.875rem;
  }
  
  .week-table th,
  .week-table td,
  .expenses-table th,
  .expenses-table td {
    padding: 0.75rem 0.5rem;
  }
}
