:root {
  --bg: #667eea;
  --bg-light: #f8f9ff;
  --card: #ffffff;
  --accent: #667eea;
  --accent-hover: #5568d3;
  --accent-light: #eef2ff;
  --muted: #6b7280;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --border: #e5e7eb;
  --shadow: 0 4px 15px rgba(102, 126, 234, 0.15);
  --shadow-lg: 0 10px 30px rgba(102, 126, 234, 0.2);
}

* { box-sizing: border-box }

html { scroll-behavior: smooth; }

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

body {
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #5a6fd1 100%);
  background-attachment: fixed;
  color: var(--bg-light);
}
 
.container {
  padding: 20px;
  max-width: 1200px;
  margin: auto;
}

header {
  background: var(--card);
  background-image: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(90, 111, 209, 0.1) 100%), url('res/back.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  padding: 40px 24px;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(102, 126, 234, 0.25);
  margin-bottom: 24px;
  text-align: center;
}

header h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  background: var(--bg);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
h2 {
  text-align: center;
  margin-bottom: 15px;
  font-weight: 600;
}

header p {
  margin: 8px 0 0;
  color: white;
  font-size: 15px;
}

main {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.card {
  background: var(--card);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
  margin: 20px 0;
  color: #1f2937;
  border-left: 5px solid #667eea;
}

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

.card h2 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
}

.card h3 {
  margin: 16px 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card {
  animation: fadeUp 0.7s ease;
}

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

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

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

.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.row.small {
  font-size: 14px;
}

input[type=text],
input[type=number],
input[type=search],
input[type=file],
#member-name,
#expense-desc,
#expense-amount,
input, select {
  width: 100%;
  padding: 12px 15px;
  margin: 10px 0;
  border-radius: 12px;
  border: 2px solid #e0e0e0;
  outline: none;
  font-size: 15px;
  color: #1f2937;
  background: #ffffff;
  transition: all 0.3s ease;
}

input[type=text]:hover,
input[type=number]:hover,
input[type=search]:hover,
#member-name:hover,
#expense-desc:hover,
#expense-amount:hover,
select:hover {
  border-color: #667eea;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

input[type=text]:focus,
input[type=number]:focus,
input[type=search]:focus,
#member-name:focus,
#expense-desc:focus,
#expense-amount:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

button {
  background: linear-gradient(135deg, #43e97b, #38f9d7);
  color: #000;
  border: none;
  padding: 12px 16px;
  width: 100%;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(67, 233, 123, 0.3);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(67, 233, 123, 0.4);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  max-height: 280px;
  overflow-y: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
}

.list li:hover {
  background-color: #f0f4ff;
  border-left: 3px solid #667eea;
  padding-left: 18px;
}

.member-name {
  font-weight: 600;
  color: #1f2937;
}

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

.split-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
  background: #f0f4ff;
  padding: 12px;
  border-radius: 8px;
}

.split-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: stretch;
  margin-bottom: 10px;
}

.split-row div:first-child {
  font-weight: 500;
  color: #374151;
}

.split-row input {
  flex: 1;
  min-width: 120px;
}

.summary {
  display: grid;
  gap: 10px;
}

.balance {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f0f4ff;
  border-left: 4px solid var(--accent);
  transition: transform 0.2s ease;
  color: #1f2937;
}

.balance:hover {
  transform: translateX(4px);
}

.badge {
  background: #667eea;
  color: white;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
}

.delete {
  background: transparent;
  border: 1px solid var(--danger);
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.delete:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger-hover);
  color: var(--danger-hover);
}

.file-btn {
  background: var(--accent-light);
  border: 1px solid var(--accent);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-block;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  transition: all 0.2s ease;
}

.file-btn:hover {
  border-color: var(--accent-hover);
  background: var(--accent);
  color: white;
}

.file-btn input {
  display: none;
}

footer {
  margin-top: 26px;
  padding: 14px;
  text-align: center;
  background: rgb(228, 244, 230);
  color: #757dc2;
  font-size: 14px;
  border-radius: 7px;
  box-shadow: var(--shadow);
  font-weight: 500;
}

@media (max-width: 600px) {
  .card {
    margin: 15px;
  }
}

main > .card:nth-child(4n+1) {
  background: #5b80bc;;
}

main > .card:nth-child(4n+2) {
  background: #5b80bc;
}

main > .card:nth-child(4n+2) {
  background: #5b80bc;
}

main > .card:nth-child(4n+3) {
  background: #5b80bc;
}

main > .card:nth-child(4n+4) {
  background: #5b80bc;
}

.back-to-top {
  display: none;
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: transparent;
  color: white;
  border: none;
  padding: 6px 9px;
  border-radius: 50px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  z-index: 999;
}

.back-to-top.show {
  display: block;
  animation: fadeUp 0.3s ease;
}

.back-to-top:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

.quick-add {
  flex: 1;
  background: linear-gradient(135deg, #667eea, #5a6fd1) !important;
  color: white !important;
  font-size: 13px !important;
  padding: 8px 10px !important;
  font-weight: 600 !important;
}

.quick-add:hover {
  transform: translateY(-1px) !important;
}

.tip-btn {
  flex: 1;
  background: linear-gradient(135deg, #43e97b, #38f9d7) !important;
  color: #000 !important;
  font-size: 12px !important;
  padding: 8px 10px !important;
  font-weight: 600 !important;
}

.tip-btn:hover {
  transform: translateY(-1px) !important;
}

#tax-input {
  flex: 1 !important;
  max-width: 100px !important;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.stat-card {
  background: #f0f4ff;
  padding: 12px;
  border-radius: 8px;
  border-left: 4px solid #667eea;
  text-align: center;
}

.stat-label {
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: #1f2937;
  margin-top: 4px;
}

.edit-btn {
  background: #667eea !important;
  color: white !important;
  border: none !important;
  padding: 4px 8px !important;
  font-size: 12px !important;
  border-radius: 4px !important;
}
