:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --bg-color: #F3F4F6;
  --panel-bg: #FFFFFF;
  --text-main: #111827;
  --text-muted: #6B7280;
  --border-color: #E5E7EB;
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 260px;
}

body {
  font-family: 'Inter', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-weight: 600;
  color: #111827;
  margin-top: 0;
}

/* Auth View */
.panel-login {
  max-width: 400px;
  margin: 100px auto;
  background: var(--panel-bg);
  padding: 40px;
  border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(0,0,0,0.05);
  text-align: center;
}

.panel-login h1 { font-size: 24px; margin-bottom: 8px; }
.panel-login .muted { margin-bottom: 24px; }
.panel-login label { display: block; text-align: left; margin-bottom: 6px; font-size: 14px; font-weight: 500; }
.panel-login input { width: 100%; box-sizing: border-box; margin-bottom: 16px; }
.panel-login button { width: 100%; }

/* Form Elements */
input, textarea, select {
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #FFF;
  color: var(--text-main);
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

button {
  background: var(--primary);
  color: #FFF;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:hover { background: var(--primary-hover); }
button.btn-outline {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
button.btn-outline:hover { background: #F9FAFB; }

/* Dashboard Layout */
.dashboard-layout {
  display: flex;
  height: calc(100vh - 65px);
  overflow: hidden;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-bg);
  height: 65px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--panel-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.nav-sidebar {
  list-style: none;
  padding: 20px 12px;
  margin: 0;
  flex: 1;
}

.nav-item {
  padding: 10px 16px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 15px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
}

.nav-item:hover {
  background: #F3F4F6;
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
  font-weight: 600;
}

/* Main Content */
.main-content {
  flex-grow: 1;
  min-width: 0;
  background: var(--bg-color);
  overflow-y: auto;
  padding: 32px;
}

.tab-pane {
  max-width: 1200px;
  margin: 0 auto;
}

.tab-pane.hidden {
  display: none !important;
}

/* Cards */
.card {
  background: var(--panel-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
}

.card h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.card p.muted {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
  margin-top: 0;
}

/* Grids & Layout Utilities */
.grid.two {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Messages */
.msg { font-size: 13px; min-height: 20px; margin-top: 8px; color: #10B981; }
.msg.error { color: #EF4444; }

/* Lists & Tables */
.list { list-style: none; padding: 0; margin: 0; }

.list li {
  padding: 12px 16px;
  background: #FFF;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 14px;
  border: 1px solid var(--border-color);
}

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

.data-table th, .data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

.data-table th {
  font-weight: 600;
  color: var(--text-muted);
  background: #F9FAFB;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.05em;
}

.data-table tr:hover td {
  background: #F9FAFB;
}

.title-cell {
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Modal */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(17, 24, 39, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden { display: none !important; }

.modal-content {
  background: var(--panel-bg);
  border-radius: var(--radius);
  width: 100%;
  max-width: 1200px;
  height: 90vh; /* Make modal tall by default */
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #FFF;
}

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

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

/* Product Form Specifics */
.prop-group {
  background: #F9FAFB;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
}
.prop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 14px;
}
.value-item {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.value-item .image-preview {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border-color);
}

.variant-item {
  margin-bottom: 12px;
  padding: 12px;
  background: #fff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}
.variant-header {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.variant-specs {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}
.spec-badge {
  background: #e2e8f0;
  padding: 2px 8px;
  border-radius: 12px;
  color: #475569;
}
.variant-fields {
  display: flex;
  gap: 12px;
  align-items: center;
}
.variant-fields input {
  padding: 6px 8px;
  font-size: 13px;
  margin: 0;
  width: 100px;
}

.action-bar {
  display: flex;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  margin: 12px 0;
}

.image-tile {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px;
  background: #FFF;
}

.image-tile img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}

.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 920px) {
  .dashboard-layout { flex-direction: column; height: auto; }
  .toolbar { flex-wrap: wrap; height: auto; padding: 16px; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); }
  .nav-sidebar { display: flex; overflow-x: auto; padding: 12px; gap: 8px; }
  .nav-item { margin-bottom: 0; white-space: nowrap; }
  .grid.two { grid-template-columns: 1fr; }
  .main-content { padding: 16px; }
}

/* Utilities for word wrapping */
.break-words, .small {
  word-break: break-word;
  overflow-wrap: anywhere; word-break: break-all;
}

.product-head h3,
.card h3 {
  word-break: break-word;
  overflow-wrap: anywhere; word-break: break-all;
}

.small {
  font-size: 13px !important;
  color: var(--text-muted) !important;
}

.product-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.product-head > div:first-child {
  flex: 1;
  min-width: 0; /* Important to prevent flex child from expanding parent */
}

.image-tile {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.image-tile .row {
  margin-top: auto;
}
.image-tile input {
  max-width: 100%;
}

.image-tile input {
  font-size: 11px;
  padding: 4px;
  margin-top: 8px;
  width: 100%;
  box-sizing: border-box;
}

.image-tile .row button {
  padding: 4px 6px;
  font-size: 11px;
  flex: 1;
}

.image-tile img, .image-tile video {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #f3f4f6;
}
.images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 16px;
  margin: 12px 0;
}
