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

:root {
  --gold: #B8956A;
  --gold-light: #D4AF87;
  --gold-pale: #F5ECD7;
  --dark: #1A1610;
  --mid: #3D3529;
  --muted: #8A7E6E;
  --border: #E2D5C0;
  --bg: #FDFAF5;
  --bg2: #F7F1E6;
  --white: #FFFFFF;
  --sold-bg: #F0EDE8;
  --green: #4A7C3F;
  --green-bg: #EBF4E9;
  --red: #8B2E2E;
  --red-bg: #FAEAEA;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--dark);
  min-height: 100vh;
}

/* Header */
header {
  background: var(--dark);
  padding: 20px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 26px;
  font-weight: 500;
  color: var(--gold-light);
  letter-spacing: 0.04em;
}

.logo span { color: var(--white); }

.export-btn {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold-light);
  padding: 8px 20px;
  border-radius: 3px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.2s;
}

.export-btn:hover { background: var(--gold); color: var(--dark); }

/* Stats bar */
.stats-bar {
  background: var(--dark);
  border-top: 1px solid #2E2820;
  padding: 0 40px;
  display: flex;
}

.stat {
  padding: 14px 32px 14px 0;
  margin-right: 32px;
  border-right: 1px solid #2E2820;
}

.stat:last-child { border-right: none; }

.stat-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}

.stat-val {
  font-family: 'Cormorant Garamond', serif;
  font-size: 28px;
  color: var(--gold-light);
  line-height: 1;
}

/* Main */
main {
  padding: 32px 40px;
  max-width: 1400px;
  margin: 0 auto;
}

/* Add form */
.add-form {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px 28px;
  margin-bottom: 28px;
}

.form-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--mid);
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: 2.5fr 1fr 1fr 1.5fr auto;
  gap: 12px;
  align-items: end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.form-group input,
.form-group select {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 9px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--dark);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus { border-color: var(--gold); }

.img-upload-label {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px dashed var(--border);
  border-radius: 4px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  transition: all 0.2s;
  height: 40px;
}

.img-upload-label:hover { border-color: var(--gold); color: var(--gold); }

.img-upload-label.has-img {
  border-color: var(--gold);
  color: var(--mid);
  border-style: solid;
}

.img-preview-thumb {
  width: 24px;
  height: 24px;
  border-radius: 3px;
  object-fit: cover;
  display: none;
}

.hidden-file { display: none; }

.btn-add {
  background: var(--dark);
  color: var(--gold-light);
  border: none;
  border-radius: 4px;
  padding: 0 22px;
  height: 40px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-add:hover { background: var(--mid); }
.btn-add:disabled { opacity: 0.5; cursor: not-allowed; }

/* Filters */
.filter-row {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-row input,
.filter-row select {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--dark);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s;
}

.filter-row input { flex: 1; min-width: 180px; }

.filter-row input:focus,
.filter-row select:focus { border-color: var(--gold); }

/* Items grid */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.item-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s, transform 0.2s;
}

.item-card:hover {
  box-shadow: 0 6px 24px rgba(184,149,106,0.12);
  transform: translateY(-2px);
}

.item-card.sold-card { opacity: 0.6; }
.item-card.removed-card { opacity: 0.5; filter: grayscale(0.5); }

.item-img-wrap {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

.item-img-wrap img { width: 100%; height: 100%; object-fit: cover; }

.item-img-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--border);
}

.item-img-placeholder svg { width: 36px; height: 36px; }
.item-img-placeholder span { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }

.item-img-overlay {
  position: absolute;
  inset: 0;
  background: rgba(26,22,16,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.item-img-wrap:hover .item-img-overlay { opacity: 1; }

.overlay-text {
  color: var(--gold-light);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.item-body {
  padding: 14px 16px 10px;
  flex: 1;
}

.item-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.item-meta {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.item-price {
  font-size: 16px;
  font-weight: 500;
  color: var(--gold);
  margin-top: 6px;
}

.item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 14px;
  gap: 6px;
  border-top: 1px solid var(--bg2);
}

/* Badges */
.badge {
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 99px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-active { background: var(--green-bg); color: var(--green); }
.badge-sold { background: var(--sold-bg); color: var(--muted); }
.badge-removed { background: var(--red-bg); color: var(--red); }

/* Buttons */
.action-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
}

.action-btn:hover {
  background: var(--bg2);
  color: var(--dark);
  border-color: var(--muted);
}

.action-btn.danger:hover {
  background: var(--red-bg);
  color: var(--red);
  border-color: #E09090;
}

.action-btn.sell:hover {
  background: var(--green-bg);
  color: var(--green);
  border-color: #90C088;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
  font-size: 14px;
  grid-column: 1 / -1;
  border: 1px dashed var(--border);
  border-radius: 6px;
}

.empty-state svg {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  display: block;
  opacity: 0.4;
}

/* Info icon tooltip */
.info-icon {
  display: inline-flex;
  align-items: center;
  cursor: help;
  color: var(--muted);
  transition: color 0.15s;
}

.info-icon:hover {
  color: var(--gold);
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,22,16,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px 32px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  animation: fadeIn 0.2s ease;
}

.modal-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 14px;
  color: var(--mid);
  margin-bottom: 16px;
  line-height: 1.4;
}

.modal-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--dark);
  background: var(--bg);
  outline: none;
  margin-bottom: 20px;
  transition: border-color 0.2s;
}

.modal-select:focus { border-color: var(--gold); }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--dark);
  color: var(--gold-light);
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 999;
}

.toast.show { opacity: 1; }

/* Utility */
.hidden { display: none !important; }

/* Tab bar */
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--gold);
  border-radius: 4px;
  overflow: hidden;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 7px 18px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--gold-light);
  background: rgba(184,149,106,0.1);
}

.tab-btn.tab-active {
  background: var(--gold);
  color: var(--dark);
}

/* Analytics panel */
.analytics-loading {
  text-align: center;
  padding: 3rem;
  color: var(--muted);
  font-size: 14px;
}

.analytics-panel-inner {
  animation: fadeIn 0.25s ease;
}

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

/* Analytics cards row */
.analytics-cards-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 28px;
}

.analytics-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px 24px;
  flex: 1 1 140px;
  min-width: 120px;
  text-align: center;
}

.analytics-card-sm {
  flex: 1 1 100px;
  padding: 14px 16px;
}

.analytics-card-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.analytics-card-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 28px;
  color: var(--gold);
  line-height: 1.1;
}

.analytics-card-sm .analytics-card-value {
  font-size: 22px;
}

/* Section title */
.analytics-section-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--mid);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Status bar */
.analytics-bar {
  display: flex;
  height: 32px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg2);
  margin-bottom: 10px;
}

.analytics-bar-segment {
  transition: width 0.4s ease;
  min-width: 4px;
}

.analytics-bar-active {
  background: var(--green);
}

.analytics-bar-sold {
  background: var(--muted);
}

.analytics-bar-removed {
  background: var(--red);
}

.analytics-bar-legend {
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: var(--mid);
  margin-bottom: 28px;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}

.legend-active { background: var(--green); }
.legend-sold { background: var(--muted); }
.legend-removed { background: var(--red); }

/* Category table */
.analytics-table-wrap {
  overflow-x: auto;
  margin-bottom: 28px;
}

.analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.analytics-table th {
  background: var(--bg2);
  color: var(--mid);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.analytics-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--bg2);
  color: var(--dark);
}

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

.analytics-table tr:hover td {
  background: var(--gold-pale);
}

/* Sold price display */
.item-price-sold {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.item-price-original {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: line-through;
  opacity: 0.7;
}

.item-price-sold-value {
  font-size: 16px;
  font-weight: 500;
  color: var(--green);
}

/* Sell modal */
.modal-price-info {
  font-size: 14px;
  color: var(--mid);
  margin-bottom: 16px;
}

.sell-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.sell-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.sell-option:hover {
  border-color: var(--gold);
  background: var(--gold-pale);
}

.sell-option input[type="radio"] {
  accent-color: var(--gold);
  margin: 0;
}

.sell-option-label {
  font-size: 14px;
  color: var(--dark);
}

.sell-discount-group {
  padding: 10px 14px 10px 30px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sell-discount-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.sell-discount-input {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 9px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--dark);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
  max-width: 200px;
}

.sell-discount-input:focus {
  border-color: var(--gold);
}

/* Responsive */
@media (max-width: 700px) {
  header, main { padding: 16px 18px; }
  .stats-bar { padding: 0 18px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .btn-add { grid-column: 1 / -1; width: 100%; justify-content: center; }
  .header-actions { gap: 10px; }
  .tabs { border: none; }
  .tab-btn { padding: 6px 12px; font-size: 12px; }
  .analytics-card { min-width: 100px; padding: 14px 16px; }
  .analytics-card-value { font-size: 22px; }
}
