:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-light: #f1f5f9;
  --primary: #10b981;
  --primary-hover: #059669;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --radius: 12px;
  --shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

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

body {
  font-family: "Inter", system-ui, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* --- Navbar --- */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  background-color: rgba(255, 255, 255, 0.8);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links a:hover {
  color: var(--text);
  background: var(--surface-light);
}

.nav-links a.active {
  color: var(--primary);
  background: rgba(16, 185, 129, 0.1);
}

/* --- Layout --- */
.container {
  max-width: 1440px;
  margin: 2rem auto;
  padding: 0 2rem;
}

.header-section {
  margin-bottom: 2rem;
}

.header-section h1 {
  font-size: 1.875rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #1e293b;
}

.header-section p {
  color: var(--text-muted);
}

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #334155;
}

/* --- Tables --- */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th {
  text-align: left;
  padding: 1rem;
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

td {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  color: #475569;
  vertical-align: middle;
}

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

tr:hover td {
  background: #fcfcfc;
}

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

label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #475569;
}

input,
select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 8px !important;
  color: var(--text) !important;
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s;
  appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 8.25l-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 1rem center !important;
  background-size: 1.25rem !important;
}

/* --- Table Images --- */
.table-img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-light);
  border: 1px solid var(--border);
}

.table-img-placeholder {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--surface-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

input:focus,
select:focus {
  outline: none !important;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2) !important;
}

/* --- Selected Product Preview --- */
.product-preview {
  display: none;
  background: #f8fafc;
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
  align-items: center;
  gap: 1rem;
}

.product-preview.active {
  display: flex;
  border-style: solid;
  border-color: var(--primary);
  background: white;
}

.product-preview img {
  width: 50px;
  height: 50px;
  border-radius: 6px;
  object-fit: cover;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: white;
  width: 100%;
  max-width: 650px;
  max-height: 85vh;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-light);
  color: var(--text-muted);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1.25rem;
  padding: 0;
  line-height: 1;
}

.close-btn:hover {
  background: var(--danger);
  color: white;
  transform: rotate(90deg);
}

.modal-search-wrapper {
  position: relative;
}

.modal-search-wrapper i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.modal-search-wrapper input {
  padding-left: 2.75rem;
  background: var(--surface-light);
  border-color: transparent;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  min-height: 300px;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.search-result-item:hover {
  background: #f1f5f9;
  border-color: var(--border);
}

.search-result-item img {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: #f1f5f9;
}

.result-info .name {
  font-weight: 600;
  color: var(--text);
  display: block;
}

.result-info .meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.modal-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
  text-align: right;
}

button {
  width: 100%;
  padding: 0.75rem 1.5rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

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

/* --- Badges --- */
.badge {
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  text-align: center;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}
.badge-warning {
  background: #fef3c7;
  color: #92400e;
}
.badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stat-content .label {
  display: block;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.stat-content .value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
}

/* --- Custom Grid --- */
.layout-grid {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 2rem;
}

@media (max-width: 992px) {
  .layout-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Footer --- */
footer {
  margin-top: 4rem;
  padding: 2rem 0;
  text-align: center;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
}
