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

:root {
  --primary: #1a1a1a;
  --secondary: #404040;
  --accent: #0080ff;
  --success: #00a651;
  --danger: #e74c3c;
  --warning: #f39c12;
  --bg: #ffffff;
  --surface: #f5f5f5;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #666666;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

button:hover {
  background: var(--secondary);
  transform: translateY(-1px);
}

button.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

button.danger {
  background: var(--danger);
}

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

input, textarea, select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border 0.2s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 128, 255, 0.1);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  padding: 0;
}

.container {
  max-width: 1024px;
  margin: 0 auto;
  padding: 16px;
}

.header {
  background: var(--primary);
  color: white;
  padding: 16px 0;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 auto;
  padding: 16px;
  max-width: 1024px;
}

.header h1 {
  font-size: 24px;
  font-weight: 600;
}

.nav-links {
  display: flex;
  gap: 16px;
  list-style: none;
}

.nav-links a {
  color: white;
  text-decoration: none;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 4px;
  transition: background 0.2s;
}

.nav-links a:hover {
  background: var(--secondary);
  text-decoration: none;
}

.nav-links a.active {
  background: var(--accent);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.form-group label {
  font-weight: 500;
  font-size: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row.full {
  grid-template-columns: 1fr;
}

.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.card h2 {
  font-size: 18px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card h3 {
  font-size: 14px;
  margin-top: 16px;
  margin-bottom: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.metric {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.metric:last-child {
  border-bottom: none;
}

.metric-label {
  color: var(--text-muted);
}

.metric-value {
  font-weight: 600;
  color: var(--text);
}

.metric-value.positive {
  color: var(--success);
}

.metric-value.negative {
  color: var(--danger);
}

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

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

.receipt-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 12px;
  align-items: flex-start;
}

.receipt-thumbnail {
  width: 60px;
  height: 60px;
  background: var(--surface);
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.receipt-info {
  flex: 1;
  font-size: 13px;
}

.receipt-amount {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.receipt-date {
  color: var(--text-muted);
  font-size: 12px;
}

.receipt-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.receipt-actions button {
  padding: 6px 10px;
  font-size: 12px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 14px;
}

.table th {
  background: var(--surface);
  padding: 12px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}

.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.table tr:hover {
  background: var(--surface);
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.tabs button {
  padding: 12px 16px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  font-weight: 500;
}

.tabs button:hover {
  color: var(--text);
  background: transparent;
  transform: none;
}

.tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
}

.alert.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.alert.info {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

.loader {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.upload-area {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 16px;
}

.upload-area:hover {
  border-color: var(--accent);
  background: rgba(0, 128, 255, 0.05);
}

.upload-area.dragover {
  border-color: var(--accent);
  background: rgba(0, 128, 255, 0.1);
}

.upload-area p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 8px;
}

.field-set {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.field-set.full {
  grid-template-columns: 1fr;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-weight: 500;
  font-size: 13px;
}

.field input, .field select, .field textarea {
  width: 100%;
}

.chart-container {
  position: relative;
  height: 300px;
  margin: 20px 0;
}

.button-group {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.button-group.full {
  flex-direction: column;
}

.button-group.full button {
  width: 100%;
}

/* Dashboard header with CTA */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.dashboard-header h2 {
  flex: 1;
  min-width: 150px;
  margin: 0;
}

.btn-add-receipt {
  background: #ff6b35;
  color: white;
  padding: 12px 20px;
  border-radius: 6px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-add-receipt:hover {
  background: #ff5520;
  transform: translateY(-2px);
}

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

/* Mobile file upload button */
.btn-file-upload {
  width: 100%;
  padding: 40px 20px;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn-file-upload:active {
  background: rgba(0, 128, 255, 0.1);
  transform: scale(0.98);
}

/* File preview */
.preview-container {
  margin: 12px 0;
  border-radius: 6px;
  overflow: hidden;
}

.file-preview-img {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: 6px;
}

/* Amount input with prefix */
.amount-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.amount-prefix {
  position: absolute;
  left: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
}

.amount-input-group input {
  padding-left: 32px;
  width: 100%;
}

/* Bottom navigation for mobile */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: white;
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
  z-index: 999;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  border-radius: 0;
  padding: 8px 4px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  transition: all 0.2s;
}

.bottom-nav-item:active {
  background: rgba(0, 128, 255, 0.05);
  color: var(--accent);
}

.bottom-nav-item.bottom-nav-center {
  flex: 1.2;
  background: var(--accent);
  color: white;
  border-radius: 50% 50% 0 0;
  margin-bottom: 8px;
  box-shadow: 0 -2px 8px rgba(0, 128, 255, 0.3);
}

.bottom-nav-item.bottom-nav-center:active {
  background: #0066cc;
  box-shadow: 0 -2px 12px rgba(0, 128, 255, 0.4);
}

.nav-icon {
  font-size: 20px;
  display: block;
}

.nav-label {
  display: block;
}

/* More menu */
.menu-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-item {
  display: block;
  width: 100%;
  padding: 12px 16px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 4px;
}

.menu-item:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Container adjustments for mobile */
.container-mobile {
  padding-bottom: 80px;
}

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

  .nav-links {
    display: none;
  }

  .header h1 {
    font-size: 20px;
  }

  .metric {
    font-size: 13px;
  }

  .card {
    padding: 16px;
  }

  .quick-add {
    display: none !important;
  }

  .bottom-nav {
    display: flex !important;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-header h2 {
    margin-bottom: 8px;
  }

  .btn-add-receipt {
    width: 100%;
    padding: 16px;
    font-size: 16px;
  }

  .modal-content {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 12px 12px 0 0;
    margin-top: auto;
  }
}

/* Login page */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

.login-box {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 340px;
}

.login-box h1 {
  text-align: center;
  margin-bottom: 32px;
  font-size: 28px;
}

.login-box .form-group {
  margin-bottom: 20px;
}

.login-box button {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
}

/* Dashboard cards for entities */
.entity-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.entity-card h2 {
  font-size: 16px;
  margin-bottom: 16px;
  color: var(--primary);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 8px;
}

.entity-card .metric {
  padding: 8px 0;
  border-bottom: 1px solid var(--surface);
}

.entity-card .metric:last-child {
  border-bottom: none;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-fill {
  height: 100%;
  background: var(--success);
  transition: width 0.3s;
}

.progress-fill.warning {
  background: var(--warning);
}

.progress-fill.danger {
  background: var(--danger);
}

.quick-add {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 128, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 50;
}

.quick-add:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 128, 255, 0.4);
}

@media (max-width: 768px) {
  .quick-add {
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
  }
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 8px;
  padding: 24px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.modal-close:hover {
  color: var(--text);
}
