* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #0f7b5a;
  --primary-light: #2aa87a;
  --primary-dark: #0a3d2e;
  --primary-glow: rgba(15,123,90,0.3);
  --surface: #f6f9f8;
  --surface-card: #ffffff;
  --text-primary: #1a2e2a;
  --text-secondary: #4a6a62;
  --text-muted: #7a9a92;
  --danger: #c62828;
  --warning: #e65100;
  --success: #2e7d32;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --font-display: 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --font-stat: 'Poppins', sans-serif;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.5;
  overflow: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background: linear-gradient(135deg, #e8f5f0 0%, #d4ece4 20%, #c5e3d9 40%, #dce8e8 60%, #edf3f0 80%, #e8f5f0 100%);
  background-size: 400% 400%;
  animation: honeycombDrift 20s ease-in-out infinite alternate;
  opacity: 0.6;
  pointer-events: none;
}

@keyframes honeycombDrift {
  0% { background-position: 0% 0%; }
  25% { background-position: 50% 100%; }
  50% { background-position: 100% 50%; }
  75% { background-position: 0% 100%; }
  100% { background-position: 100% 0%; }
}

#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 10px; }

.app-header {
  flex-shrink: 0;
  padding: 14px 18px 6px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  z-index: 10;
}
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--primary-dark);
}
.app-header .brand .logo-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}
.app-header .brand .badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.5rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}
.app-header .header-actions {
  display: flex;
  gap: 2px;
}
.app-header .header-actions button {
  background: none;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  transition: var(--transition);
}
.app-header .header-actions button:active {
  transform: scale(0.92);
  background: rgba(0,0,0,0.04);
}
.app-header .header-actions button .material-symbols-rounded {
  font-size: 24px;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 16px 100px 16px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.view {
  display: none;
  animation: viewIn 0.35s ease forwards;
}
.view.active { display: block; }

@keyframes viewIn {
  0% { opacity: 0; transform: translateY(18px); }
  100% { opacity: 1; transform: translateY(0); }
}

.bottom-nav {
  flex-shrink: 0;
  display: flex;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(0,0,0,0.04);
  padding: 4px 0 env(safe-area-inset-bottom,8px) 0;
  z-index: 20;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.04);
}
.bottom-nav button {
  flex: 1;
  background: none;
  border: none;
  padding: 6px 0 4px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0px;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-body);
}
.bottom-nav button .material-symbols-rounded {
  font-size: 26px;
  transition: var(--transition);
}
.bottom-nav button span:last-child {
  font-size: 0.55rem;
  letter-spacing: 0.01em;
}
.bottom-nav button.active {
  color: var(--primary);
}
.bottom-nav button.active .material-symbols-rounded {
  font-variation-settings: 'FILL' 1;
}
.bottom-nav button .nav-indicator {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--primary);
  opacity: 0;
  transition: var(--transition);
}
.bottom-nav button.active .nav-indicator {
  opacity: 1;
}

.greeting-card {
  padding: 20px 0 8px 0;
}
.greeting-card .greeting-line1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--text-primary);
  line-height: 1.2;
}
.greeting-card .greeting-line1 .highlight {
  color: var(--primary);
}
.greeting-card .greeting-line2 {
  font-weight: 400;
  font-size: 0.95rem;
  color: var(--primary);
  font-style: italic;
  margin-top: 2px;
  opacity: 0.85;
  animation: textPulse 4s ease-in-out infinite;
}
@keyframes textPulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}
.greeting-card .greeting-line3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}
.greeting-card .greeting-line3 .mode-badge span {
  background: rgba(15,123,90,0.1);
  padding: 2px 10px;
  border-radius: 20px;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.6rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0 16px 0;
}
.stat-card {
  background: var(--surface-card);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,0.02);
  transition: var(--transition);
  cursor: default;
  position: relative;
  overflow: hidden;
}
.stat-card:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-icon {
  font-size: 20px;
  color: var(--primary);
  opacity: 0.5;
  margin-bottom: 4px;
}
.stat-card .stat-value {
  font-family: var(--font-stat);
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--text-primary);
  line-height: 1.1;
}
.stat-card .stat-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.stat-card .stat-bg-glow {
  position: absolute;
  right: -20px;
  bottom: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15,123,90,0.06), transparent 70%);
  pointer-events: none;
}
.stat-card.critical .stat-value { color: var(--danger); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.good .stat-value { color: var(--primary); }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0 10px 0;
}
.section-header h3 {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
}
.section-header .see-all {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 20px;
  transition: var(--transition);
}
.section-header .see-all:active {
  background: rgba(15,123,90,0.08);
  transform: scale(0.94);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0 16px 0;
}
.quick-action {
  background: var(--surface-card);
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 6px 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-body);
  position: relative;
  overflow: hidden;
}
.quick-action:active { transform: scale(0.95); }
.quick-action .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(15,123,90,0.15);
  transform: scale(0);
  animation: rippleAnim 0.6s ease-out forwards;
  pointer-events: none;
}
@keyframes rippleAnim {
  to { transform: scale(4); opacity: 0; }
}
.quick-action .material-symbols-rounded {
  font-size: 32px;
  color: var(--primary);
}
.quick-action span:last-child {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 6px 0 10px 0;
}
.item-row {
  background: var(--surface-card);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(0,0,0,0.02);
  transition: var(--transition);
  cursor: pointer;
}
.item-row:active {
  transform: scale(0.98);
  border-color: var(--primary-light);
}
.item-row .item-emoji {
  font-size: 28px;
  width: 40px;
  text-align: center;
  flex-shrink: 0;
}
.item-row .item-info {
  flex: 1;
  min-width: 0;
}
.item-row .item-info .item-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-row .item-info .item-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.item-row .item-info .item-meta .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
}
.item-row .item-info .item-meta .dot.green { background: var(--success); }
.item-row .item-info .item-meta .dot.orange { background: var(--warning); }
.item-row .item-info .item-meta .dot.red { background: var(--danger); }
.item-row .item-stock {
  text-align: right;
  flex-shrink: 0;
}
.item-row .item-stock .stock-num {
  font-weight: 800;
  font-size: 1rem;
  color: var(--text-primary);
}
.item-row .item-stock .stock-unit {
  font-size: 0.6rem;
  color: var(--text-muted);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-card);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,0.04);
  transition: var(--transition);
  margin: 8px 0 12px 0;
}
.search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 0;
  font-size: 0.9rem;
  font-family: var(--font-body);
  outline: none;
  color: var(--text-primary);
}
.search-bar input::placeholder {
  color: var(--text-muted);
}
.search-bar button {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  transition: var(--transition);
}
.search-bar button:active {
  transform: scale(0.9);
  color: var(--primary);
}

.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chips .chip {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid rgba(0,0,0,0.06);
  background: var(--surface-card);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-body);
}
.filter-chips .chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px var(--primary-glow);
}
.filter-chips .chip:active { transform: scale(0.94); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state .material-symbols-rounded {
  font-size: 56px;
  opacity: 0.3;
}
.empty-state h4 {
  margin-top: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}
.empty-state p {
  font-size: 0.85rem;
  margin-top: 4px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.25s ease;
}
.modal-overlay.open { display: flex; }
@keyframes fadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}
.modal-sheet {
  background: var(--surface-card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  max-width: 480px;
  width: 100%;
  max-height: 92vh;
  padding: 16px 20px 30px 20px;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
  overflow-y: auto;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
}
.modal-overlay.open .modal-sheet {
  transform: translateY(0);
}
.modal-sheet .modal-handle {
  width: 40px;
  height: 4px;
  border-radius: 4px;
  background: rgba(0,0,0,0.12);
  margin: 0 auto 16px auto;
}
.modal-sheet h2 {
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 12px;
  padding-right: 32px;
}
.modal-sheet .modal-close {
  position: sticky;
  top: 0;
  float: right;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  transition: var(--transition);
}
.modal-sheet .modal-close:active {
  transform: scale(0.9);
  color: var(--text-primary);
}
.modal-sheet label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
  margin-top: 12px;
  margin-bottom: 4px;
}
.modal-sheet input,
.modal-sheet select,
.modal-sheet textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0,0,0,0.08);
  font-family: var(--font-body);
  font-size: 0.9rem;
  background: var(--surface);
  transition: var(--transition);
  outline: none;
}
.modal-sheet input:focus,
.modal-sheet select:focus,
.modal-sheet textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.modal-sheet textarea {
  resize: vertical;
  min-height: 60px;
}
.modal-sheet .btn-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.modal-sheet .btn-row button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-body);
}
.modal-sheet .btn-row .btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}
.modal-sheet .btn-row .btn-primary:active { transform: scale(0.96); }
.modal-sheet .btn-row .btn-secondary {
  background: rgba(0,0,0,0.04);
  color: var(--text-secondary);
}
.modal-sheet .btn-row .btn-secondary:active { transform: scale(0.96); }
.modal-sheet .btn-row .btn-danger {
  background: var(--danger);
  color: #fff;
}
.modal-sheet .btn-row .btn-danger:active { transform: scale(0.96); }

.toast-container {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  max-width: 420px;
  width: 90%;
  pointer-events: none;
}
.toast {
  background: rgba(26,46,42,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateY(80px);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), opacity 0.3s ease;
  pointer-events: auto;
  border: 1px solid rgba(255,255,255,0.06);
  position: relative;
}
.toast.show {
  transform: translateY(0);
  opacity: 1;
}
.toast .toast-icon { font-size: 24px; }
.toast .toast-msg {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
}
.toast .toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--primary-light);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  width: 100%;
  animation: toastShrink 3s linear forwards;
}
@keyframes toastShrink {
  0% { width: 100%; }
  100% { width: 0%; }
}

.chart-box {
  background: var(--surface-card);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  margin: 10px 0;
  border: 1px solid rgba(0,0,0,0.02);
}
.chart-box .chart-title {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--text-secondary);
}
.chart-container {
  width: 100%;
  height: 260px;
}
.chart-container.tall { height: 300px; }

.cover-insight {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: #fff;
  margin: 8px 0 12px 0;
  font-weight: 500;
  font-size: 0.85rem;
  animation: insightPulse 4s ease-in-out infinite alternate;
}
@keyframes insightPulse {
  0% { opacity: 0.85; transform: scale(0.99); }
  100% { opacity: 1; transform: scale(1); }
}

.settings-group { margin-bottom: 20px; }
.settings-group .sg-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.settings-item {
  background: var(--surface-card);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(0,0,0,0.02);
  margin-bottom: 4px;
  cursor: pointer;
  transition: var(--transition);
}
.settings-item:active {
  transform: scale(0.98);
  background: rgba(0,0,0,0.02);
}
.settings-item .si-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.settings-item .si-left .material-symbols-rounded {
  font-size: 22px;
  color: var(--text-muted);
}
.settings-item .si-left .si-text {
  font-size: 0.85rem;
  font-weight: 500;
}
.settings-item .si-left .si-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
}
.settings-item .si-right {
  color: var(--text-muted);
  font-size: 20px;
}

.hidden { display: none !important; }
.mt-8 { margin-top: 8px; }
.mb-8 { margin-bottom: 8px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }

@media (min-width: 481px) {
  #app {
    border-radius: 20px;
    margin-top: 12px;
    margin-bottom: 12px;
    height: calc(100% - 24px);
    max-height: 900px;
  }
  .toast-container { bottom: 100px; }
}

@media (max-width: 400px) {
  .greeting-card .greeting-line1 { font-size: 1.2rem; }
  .stat-card .stat-value { font-size: 1.3rem; }
  .quick-action .material-symbols-rounded { font-size: 26px; }
  .bottom-nav button .material-symbols-rounded { font-size: 22px; }
  .bottom-nav button span:last-child { font-size: 0.5rem; }
}