:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --bg: #f3f4f6;
  --glass: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(255, 255, 255, 0.4);
  --text: #111827;
  --text-muted: #6b7280;
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 12px;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #eef2ff 0%, #fef2f2 100%);
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  transition: background 0.5s ease;
  display: flex; /* Default centered layout for login/dashboard */
  align-items: center;
  justify-content: center;
}

body.invoice-page {
  display: block;
  background: #f1f5f9;
  padding: 2rem 0;
}

body.auth-page, body.dashboard-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 2.5rem;
  border-radius: 1.5rem;
  border: 1px solid var(--glass-border);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 400px;
  animation: slideIn 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
}

.auth-header img {
  width: 120px;
  height: auto;
  margin-bottom: 1.5rem;
}

.auth-header h1 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  background: linear-gradient(to right, #4f46e5, #ec4899);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1.25rem;
  text-align: left;
}

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

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.6);
  transition: all 0.2s;
  box-sizing: border-box;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
  background: #fff;
}

.btn-primary {
  width: 100%;
  padding: 0.875rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3);
}

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

.error-msg {
  color: #ef4444;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: #fee2e2;
  border-radius: 8px;
  border: 1px solid #fecaca;
  animation: shake 0.5s ease-in-out;
}

/* Dashboard Styles */
.dashboard-container {
  max-width: 1000px;
  width: 100%;
  padding: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  align-items: center;
}

.dashboard-card {
  background: var(--glass);
  backdrop-filter: blur(10px);
  border-radius: 2rem;
  padding: 2.5rem;
  text-align: center;
  border: 1px solid var(--glass-border);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  text-decoration: none;
  color: inherit;
}

.dashboard-card:hover {
  transform: translateY(-10px) scale(1.05);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
  background: #fff;
}

.icon-wrapper {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #818cf8 0%, #4f46e5 100%);
  border-radius: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 2.5rem;
  box-shadow: 0 10px 20px -5px rgba(79, 70, 229, 0.4);
}

.dashboard-card h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

/* Invoice Editor Styles */
.invoice-wrapper {
  background: white;
  width: 100%;
  max-width: 900px;
  min-height: 1000px;
  padding: 50px;
  margin: 2rem auto;
  box-shadow: var(--shadow);
  border-radius: 8px;
  position: relative;
  box-sizing: border-box;
}

.invoice-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 50px;
}

.invoice-header .logo {
  max-width: 180px;
}

.invoice-header .title {
  text-align: right;
}

.invoice-header h1 {
  font-size: 3rem;
  margin: 0;
  color: #1a1a1a;
  text-transform: uppercase;
}

.table-container {
  margin: 40px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background: #f8fafc;
  text-align: left;
  padding: 12px;
  border-bottom: 2px solid #e2e8f0;
  color: #475569;
}

td {
  padding: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.editable {
  border: 1px solid transparent;
  padding: 4px 8px;
  border-radius: 4px;
}

.editable:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.editable:focus {
  background: #fff;
  border-color: var(--primary);
  outline: none;
}

.totals {
  width: 300px;
  margin-left: auto;
}

.total-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
}

.total-row.grand-total {
  border-top: 2px solid #1a1a1a;
  font-weight: 800;
  font-size: 1.25rem;
  margin-top: 10px;
}

.controls {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  gap: 1rem;
  z-index: 100;
}

.btn-floating {
  padding: 1rem 2rem;
  border-radius: 50px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  border: none;
  font-weight: 600;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
  transition: all 0.2s;
}

.btn-print { background: #10b981; color: white; }
.btn-save { background: #3b82f6; color: white; }
.btn-back { background: #6b7280; color: white; }

.btn-floating:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Responsive Design */
@media screen and (max-width: 768px) {
  body {
    padding: 1rem;
    display: block;
  }

  .auth-card {
    padding: 1.5rem;
    margin: 2rem auto;
  }

  .dashboard-container {
    padding: 1rem;
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .dashboard-card {
    padding: 1.5rem;
    flex-direction: row;
    text-align: left;
    gap: 1rem;
  }

  .icon-wrapper {
    width: 60px;
    height: 60px;
    font-size: 1.8rem;
    flex-shrink: 0;
  }

  .dashboard-card h3 {
    font-size: 1.1rem;
  }

  .dashboard-card p {
    display: none;
  }

  .invoice-wrapper {
    padding: 20px;
    margin: 1rem 0;
    min-height: auto;
  }

  .invoice-header {
    flex-direction: column;
    text-align: left;
    gap: 1.5rem;
    margin-bottom: 30px;
  }

  .invoice-header .title {
    text-align: left;
  }

  .invoice-header .logo {
    max-width: 140px; /* Smaller logo for mobile headers */
  }

  .invoice-header h1 {
    font-size: 2rem;
  }

  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 20px 0;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
  }

  table {
    min-width: 600px; /* Allow horizontal scroll for the table */
  }

  .totals {
    width: 100%;
  }

  .controls {
    position: sticky;
    bottom: 0;
    right: 0;
    left: 0;
    background: rgba(243, 244, 246, 0.9);
    backdrop-filter: blur(8px);
    padding: 1rem;
    margin: 0 -1rem;
    justify-content: center;
    flex-wrap: wrap;
    border-top: 1px solid #e2e8f0;
  }

  .btn-floating {
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
  }

  .editable {
    padding: 8px 12px; /* Larger touch target on mobile */
  }

  .logout-btn {
    top: 1rem;
    right: 1rem;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
  }
}

/* Print Only Styles */
@media print {
  body { background: white !important; padding: 0 !important; margin: 0 !important; }
  .controls, .auth-card, .dashboard-container, .logout-btn { display: none !important; }
  .invoice-wrapper {
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}
