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

:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --danger: #ef4444;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --warning: #f59e0b;
  --success: #10b981;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 80px;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--card);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-title {
  font-size: 18px;
  font-weight: 600;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.2s;
}

.icon-btn:active { background: var(--bg); }

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.search-wrap {
  flex: 1;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus { border-color: var(--primary); }

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 14px;
}

.filter-select {
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--card);
  outline: none;
  max-width: 100px;
}

/* Stats Bar */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-light);
  background: var(--card);
}

.stat-item.alert { color: var(--warning); font-weight: 600; }
.stat-divider { color: var(--border); }

/* Item List */
.item-list {
  padding: 8px;
}

.item-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: transform 0.1s;
}

.item-card:active { transform: scale(0.98); }

.item-icon {
  font-size: 28px;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 10px;
}

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

.item-name {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-meta {
  font-size: 12px;
  color: var(--text-light);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.item-meta .tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.item-meta .tag-expiry-soon {
  color: var(--warning);
  font-weight: 600;
}

.item-meta .tag-expired {
  color: var(--danger);
  font-weight: 600;
}

.item-qty {
  font-size: 13px;
  color: var(--text-light);
  flex-shrink: 0;
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 20px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* FAB */
.fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 28px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

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

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--card);
  width: 100%;
  max-width: 500px;
  border-radius: 16px 16px 0 0;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

.modal-wide { max-width: 600px; }

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@media (min-width: 600px) {
  .modal { border-radius: 16px; }
  .modal-overlay { align-items: center; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}

.modal-header h2 { font-size: 17px; font-weight: 600; }

.modal-body { padding: 16px 20px; }

.modal-footer {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--card);
}

/* Forms */
.form-group { margin-bottom: 14px; }

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 4px;
  font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select,
.form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

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

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* Buttons */
.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn:active { opacity: 0.7; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-primary { background: var(--primary); color: white; flex: 1; }
.btn-secondary { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: white; }

/* Manage */
.manage-section { margin-bottom: 24px; }
.manage-section h3 { font-size: 15px; margin-bottom: 10px; }

.manage-list { margin-bottom: 10px; }

.manage-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 6px;
}

.manage-item-name { flex: 1; font-size: 14px; }
.manage-item-count { font-size: 12px; color: var(--text-light); }
.manage-item-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 2px 6px;
  border-radius: 6px;
}

.manage-add {
  display: flex;
  gap: 6px;
}

.manage-input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; }
.manage-input-icon { width: 50px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; text-align: center; outline: none; }
.manage-input-select { padding: 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; max-width: 120px; outline: none; }

/* Stats Content */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stats-card {
  background: var(--bg);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.stats-card-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stats-card-label { font-size: 13px; color: var(--text-light); margin-top: 4px; }

.stats-section-title { font-size: 15px; font-weight: 600; margin: 16px 0 8px; }

.stats-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  margin-bottom: 8px;
}

.stats-bar-item {
  flex: 1;
  background: var(--primary-light);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  position: relative;
  transition: height 0.3s;
}

.stats-bar-label {
  font-size: 11px;
  color: var(--text-light);
  text-align: center;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-expiring-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #fef3c7;
  border-radius: 8px;
  margin-bottom: 6px;
}

.stats-expiring-item.expired { background: #fee2e2; }

.stats-expiring-name { flex: 1; font-size: 14px; }
.stats-expiring-date { font-size: 12px; color: var(--text-light); }

.loading-text { text-align: center; color: var(--text-light); padding: 20px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 300;
  animation: toastIn 0.3s, toastOut 0.3s 1.5s;
  animation-fill-mode: both;
}

@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toastOut { to { opacity: 0; } }
