:root {
  --primary: #1f6b52;
  --primary-dark: #15503d;
  --primary-light: #e8f5ef;
  --background: #f4f8f6;
  --surface: #ffffff;
  --surface-soft: #f8fbf9;
  --border: #d8e5de;
  --text: #1d2d27;
  --text-muted: #63736c;
  --success: #17653d;
  --success-light: #e9f8ef;
  --error: #95332f;
  --error-light: #fceceb;
  --white: #ffffff;
  --shadow: 0 18px 50px rgba(23, 65, 48, 0.11);
  --shadow-soft: 0 8px 24px rgba(23, 65, 48, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: linear-gradient(135deg, #edf7f2 0%, var(--background) 48%, #f9fbfa 100%);
  font-family: Arial, Helvetica, sans-serif;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  padding: 32px 20px;
  place-items: center;
}

.auth-card,
.dashboard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(470px, 100%);
  padding: 40px;
}

.auth-brand {
  display: inline-flex;
  width: 64px;
  height: 64px;
  margin-bottom: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
}

.auth-brand img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.auth-brand:focus-visible {
  outline: 3px solid rgba(31, 107, 82, 0.35);
  outline-offset: 4px;
}

.dashboard-page {
  min-height: 100vh;
  padding: 44px 24px;
}

.dashboard-card {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 40px;
}

.dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--border);
}

.dashboard-intro {
  max-width: 680px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  color: var(--primary);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand::before {
  width: 13px;
  height: 13px;
  content: "";
  background: var(--primary);
  border-radius: 4px;
  box-shadow: 8px -8px 0 -2px #9dceb9;
}

.dashboard-eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2 {
  letter-spacing: -0.03em;
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 4vw, 2.55rem);
  line-height: 1.15;
}

h2 {
  margin: 0 0 8px;
  color: var(--primary-dark);
  font-size: 1.35rem;
  line-height: 1.25;
}

p {
  color: var(--text-muted);
  line-height: 1.6;
}

.dashboard-description {
  max-width: 560px;
  margin: 0;
}

.dashboard-top-actions {
  flex: 0 0 auto;
}

.form-group {
  margin: 0;
}

label {
  display: block;
  margin-bottom: 7px;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 13px;
  color: var(--text);
  background-color: var(--white);
  border: 1px solid var(--border);
  border-radius: 9px;
  font: inherit;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

textarea {
  min-height: 112px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #8a9892;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 4px rgba(31, 107, 82, 0.14);
}

button {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  color: var(--white);
  background-color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 9px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

button:hover {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.message {
  display: none;
  margin: 0;
  padding: 13px 15px;
  border-radius: 9px;
  font-size: 0.92rem;
  line-height: 1.45;
}

.message.success {
  display: block;
  color: var(--success);
  background-color: var(--success-light);
  border: 1px solid #c7ead4;
}

.message.error {
  display: block;
  color: var(--error);
  background-color: var(--error-light);
  border: 1px solid #f3c9c7;
}

.secondary-button {
  width: auto;
  min-height: 42px;
  padding: 0.6rem 1rem;
  color: var(--primary);
  background: var(--surface);
  border-color: var(--border);
}

.secondary-button:hover {
  color: var(--white);
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.product-form-section,
.product-list-section {
  border: 1px solid var(--border);
  border-radius: 16px;
}

.product-form-section {
  margin-top: 32px;
  padding: 30px;
  background: var(--surface-soft);
}

.section-heading {
  margin-bottom: 24px;
}

.section-heading p {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px 18px;
}

.form-group-wide {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}

.form-actions #saveProductButton {
  flex: 1;
}

.form-actions .secondary-button[hidden] {
  display: none;
}

.dashboard-actions {
  margin-top: 28px;
  text-align: center;
}

.dashboard-actions a {
  color: var(--primary);
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
}

.dashboard-actions a:hover {
  text-decoration: underline;
}

.product-list-section {
  margin-top: 28px;
  padding: 30px;
  background: var(--surface);
}

.product-list-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.product-count {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 11px;
  color: var(--primary);
  background: var(--primary-light);
  border: 1px solid #cfe8db;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.loading-message,
.empty-products-message {
  padding: 28px 22px;
  color: var(--text-muted);
  background: var(--surface-soft);
  border: 1px dashed #bfd2c8;
  border-radius: 12px;
  text-align: center;
}

.products-table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  -webkit-overflow-scrolling: touch;
}

.products-table {
  width: 100%;
  min-width: 2300px;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.82rem;
}

.products-table th,
.products-table td {
  padding: 13px 14px;
  border-bottom: 1px solid #e5eee9;
  vertical-align: top;
}

.products-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--text);
  background: #edf5f0;
  font-size: 0.73rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.products-table td {
  color: var(--text-muted);
}

.products-table tbody tr {
  transition: background-color 140ms ease;
}

.products-table tbody tr:hover {
  background: #fbfdfc;
}

.products-table tr:last-child td {
  border-bottom: 0;
}

.table-action-cell {
  white-space: nowrap;
}

.edit-product-button,
.delete-product-button {
  width: auto;
  min-height: 36px;
  padding: 0.45rem 0.72rem;
  font-size: 0.78rem;
}

.delete-product-button {
  margin-left: 8px;
  color: var(--error);
  background: var(--error-light);
  border-color: #f3c9c7;
}

.delete-product-button:hover {
  color: var(--white);
  background: var(--error);
  border-color: var(--error);
}

@media (max-width: 850px) {
  .dashboard-card {
    padding: 32px;
  }

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

@media (max-width: 620px) {
  .auth-page,
  .dashboard-page {
    padding: 20px 14px;
  }

  .auth-card,
  .dashboard-card {
    padding: 24px 18px;
    border-radius: 16px;
  }

  .dashboard-header {
    flex-direction: column;
    gap: 20px;
    padding-bottom: 24px;
  }

  .brand {
    margin-bottom: 22px;
  }

  .dashboard-top-actions,
  .dashboard-top-actions .secondary-button {
    width: 100%;
  }

  .product-form-section,
  .product-list-section {
    padding: 22px 18px;
    border-radius: 14px;
  }

  .product-form-section {
    margin-top: 24px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .form-group-wide {
    grid-column: auto;
  }

  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .form-actions .secondary-button {
    width: 100%;
  }

  .product-list-heading {
    flex-direction: column;
  }

  .products-table-container {
    margin: 0 -2px;
  }
}
