/* ========== FONTS ========== */
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* ========== RESET & BASE ========== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #1A1714;
  --bg-warm: #211E19;
  --primary: #D4783A;
  --primary-glow: rgba(212, 120, 58, 0.25);
  --secondary: #A89279;
  --accent: #C8B560;
  --success: #6B9B5E;
  --danger: #C74B3B;
  --cream: #F2E8D5;
  --card: #2A2520;
  --card-border: rgba(168, 146, 121, 0.15);
  --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  --card-shadow-lg: 0 6px 24px rgba(0, 0, 0, 0.4);
  --text: #E8DCC8;
  --text-muted: #8C7E6A;
  --radius: 10px;
  --radius-sm: 6px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-h: 64px;
  --tabbar-h: 72px;
}

html {
  height: 100%;
  background: var(--bg);
  overflow: hidden;
}

body {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  -webkit-user-select: none;
  user-select: none;
  position: fixed;
  width: 100%;
}

input, textarea, select, button {
  font-family: inherit;
  font-size: 16px;
}

/* ========== HEADER ========== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: var(--bg);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-header h1 {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 32px;
  font-weight: 400;
  color: var(--cream);
  letter-spacing: 4px;
  text-transform: uppercase;
}

/* ========== TAB CONTENT ========== */
.tab-content {
  position: fixed;
  top: calc(var(--header-h) + var(--safe-top));
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  left: 0;
  right: 0;
  overflow: hidden;
}

.tab-pane {
  display: none;
  height: 100%;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.tab-pane.active {
  display: block;
}

.tab-scroll {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 16px 16px 80px;
}

/* ========== BOTTOM TAB BAR ========== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-warm);
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 0 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
  touch-action: manipulation;
  min-height: 44px;
}

.tab-btn.active {
  color: var(--primary);
}

.tab-icon {
  font-size: 22px;
  line-height: 1;
}

.tab-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

/* ========== SECTION TITLE ========== */
.section-title {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--secondary);
  margin: 24px 0 12px;
}

.section-title:first-child {
  margin-top: 4px;
}

/* ========== CARDS & STATS ========== */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.card-grid.two-col {
  grid-template-columns: 1fr 1fr;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card.wide {
  grid-column: 1 / -1;
}

.stat-card.accent {
  background: var(--primary);
  border-color: transparent;
}

.stat-card.accent .stat-label {
  color: rgba(242, 232, 213, 0.7);
}

.stat-card.accent .stat-value {
  color: var(--cream);
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

.stat-value {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 32px;
  font-weight: 400;
  color: var(--cream);
  line-height: 1;
  letter-spacing: 1px;
}

.stat-value.price {
  color: var(--accent);
}

.stat-value.expense {
  color: var(--danger);
}

/* ========== SEARCH BAR ========== */
.search-bar {
  margin-bottom: 14px;
}

.search-bar input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 0 16px;
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

.search-bar input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* ========== FILTER TABS ========== */
.filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.filter-btn {
  padding: 7px 16px;
  border-radius: 4px;
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  touch-action: manipulation;
  min-height: 34px;
}

.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--cream);
}

/* ========== INVENTORY LIST ========== */
.inventory-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inv-item {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  transition: transform 0.2s, opacity 0.3s;
  touch-action: manipulation;
  cursor: pointer;
  position: relative;
}

.inv-item.sold {
  opacity: 0.5;
}

.inv-item-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: #332E27;
  flex-shrink: 0;
}

.inv-item-thumb-placeholder {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: #332E27;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.inv-item-info {
  flex: 1;
  min-width: 0;
}

.inv-item-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inv-item-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.inv-item-price {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 20px;
  font-weight: 400;
  color: var(--accent);
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.inv-item-sold-info {
  text-align: right;
}

.inv-item-sold-price {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 20px;
  font-weight: 400;
  color: var(--success);
  letter-spacing: 0.5px;
}

.inv-item-sold-date {
  font-size: 11px;
  color: var(--text-muted);
}

.inv-item-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--success);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ========== QUICK SALE GRID ========== */
.quicksale-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.qs-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, opacity 0.4s;
  touch-action: manipulation;
  -webkit-user-select: none;
}

.qs-card:active {
  transform: scale(0.96);
  border-color: var(--primary);
}

.qs-card.selling {
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.4s ease;
}

.qs-card-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #332E27;
  display: block;
}

.qs-card-placeholder {
  width: 100%;
  aspect-ratio: 1;
  background: #332E27;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}

.qs-card-body {
  padding: 10px;
}

.qs-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qs-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.qs-card-price {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 22px;
  font-weight: 400;
  color: var(--accent);
  margin-top: 4px;
  letter-spacing: 0.5px;
}

/* ========== EXPENSES LIST ========== */
.expenses-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exp-date-group {
  margin-bottom: 4px;
}

.exp-date-header {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-top: 8px;
}

.exp-item {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.exp-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #332E27;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.exp-info {
  flex: 1;
  min-width: 0;
}

.exp-desc {
  font-size: 15px;
  font-weight: 600;
  color: var(--cream);
}

.exp-cat {
  font-size: 12px;
  color: var(--text-muted);
}

.exp-amount {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 20px;
  font-weight: 400;
  color: var(--danger);
  white-space: nowrap;
  letter-spacing: 0.5px;
}

/* ========== REPORTS ========== */
.report-stat {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.report-stat .stat-label {
  font-size: 10px;
}

.report-stat .stat-value {
  font-size: 24px;
}

.chart-container {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 160px;
  min-width: 100%;
}

.chart-bar-wrapper {
  flex: 1;
  min-width: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar {
  width: 100%;
  max-width: 36px;
  background: linear-gradient(180deg, var(--primary) 0%, #A35A2A 100%);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.4s ease;
}

.chart-bar-label {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: center;
  white-space: nowrap;
}

.chart-bar-value {
  font-size: 10px;
  font-weight: 700;
  color: var(--cream);
  margin-bottom: 4px;
}

/* ========== FLOATING ACTION BUTTON ========== */
.fab {
  position: fixed;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 20px);
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--cream);
  border: none;
  font-size: 28px;
  font-weight: 300;
  box-shadow: 0 4px 20px rgba(212, 120, 58, 0.4);
  cursor: pointer;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  touch-action: manipulation;
}

.fab:active {
  transform: scale(0.92);
}

/* ========== MODALS ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s;
}

.modal-overlay.show {
  display: flex;
  opacity: 1;
}

.modal {
  background: var(--bg-warm);
  border-radius: 16px 16px 0 0;
  border-top: 1px solid var(--card-border);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 20px calc(20px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal-overlay.show .modal {
  transform: translateY(0);
}

.modal-sm {
  padding-bottom: calc(24px + var(--safe-bottom));
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 12px;
  position: sticky;
  top: 0;
  background: var(--bg-warm);
  z-index: 1;
}

.modal-header h3 {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 24px;
  font-weight: 400;
  color: var(--cream);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: transparent;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 8px;
}

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

.form-group label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  height: 44px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.form-group textarea {
  height: auto;
  padding: 10px 12px;
  resize: none;
}

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23A89279' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Photo input */
.photo-input {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.photo-preview {
  width: 120px;
  height: 120px;
  border-radius: var(--radius);
  object-fit: cover;
  border: 1px solid var(--card-border);
}

.photo-btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  touch-action: manipulation;
}

/* Buttons */
.btn-primary {
  width: 100%;
  height: 50px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--cream);
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  touch-action: manipulation;
}

.btn-primary:active {
  transform: scale(0.97);
  opacity: 0.9;
}

.btn-sold {
  width: 100%;
  height: 64px;
  border: none;
  border-radius: var(--radius);
  background: var(--success);
  color: var(--cream);
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: 4px;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.15s;
  touch-action: manipulation;
  margin-top: 8px;
}

.btn-sold:active {
  transform: scale(0.96);
}

.btn-secondary {
  height: 44px;
  padding: 0 20px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-danger {
  height: 44px;
  padding: 0 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--danger);
  color: white;
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
}

.modal-body-text {
  padding: 8px 0 20px;
  font-size: 15px;
  color: var(--text);
  line-height: 1.5;
}

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

/* Sale modal */
.sale-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
}

.sale-photo {
  width: 140px;
  height: 140px;
  border-radius: var(--radius);
  object-fit: cover;
  border: 1px solid var(--card-border);
}

.sale-modal-body h4 {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 24px;
  font-weight: 400;
  color: var(--cream);
  text-align: center;
  letter-spacing: 1px;
}

.sale-detail {
  font-size: 14px;
  color: var(--text-muted);
}

.sale-price-input {
  width: 100%;
  height: 56px !important;
  font-family: 'Bebas Neue', Impact, sans-serif !important;
  font-size: 32px !important;
  font-weight: 400 !important;
  text-align: center;
  color: var(--accent) !important;
  border: 1px solid var(--accent) !important;
  border-radius: var(--radius) !important;
  background: var(--card);
  letter-spacing: 2px;
}

/* ========== EMPTY STATE ========== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.empty-state p {
  font-size: 15px;
  color: var(--text-muted);
}

/* ========== TOAST ========== */
.toast {
  position: fixed;
  top: calc(var(--header-h) + var(--safe-top) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--success);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 2px;
  text-transform: uppercase;
  z-index: 300;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ========== UTILITIES ========== */
.inv-item, .qs-card, .tab-btn, .filter-btn, .fab, .btn-primary, .btn-sold {
  -webkit-user-select: none;
  user-select: none;
}

input, textarea {
  -webkit-user-select: text;
  user-select: text;
}
