:root {
  --bg: #EEF0E2;
  --surface: #FCFDF8;
  --surface-soft: #F5F7ED;
  --sidebar: #F7F8F0;
  --olive: #5E7442;
  --olive-dark: #41532B;
  --olive-ink: #2B371C;
  --sage: #99AA84;
  --sage-soft: #E6ECDD;
  --border: #D6DDCC;
  --border-soft: #E5EADC;
  --muted: #6B735E;
  --danger: #B94437;
  --danger-bg: #FBECE9;
  --danger-border: #ECC9C2;
  --warn: #8F6518;
  --warn-bg: #FAF2DE;
  --warn-border: #EAD7AE;
  --success: #3B5928;
  --success-bg: #E5F0DC;
  --success-border: #C5DAB5;
  --shadow-card: 0 1px 2px rgba(65, 83, 43, 0.04), 0 10px 24px -16px rgba(65, 83, 43, 0.14);
  --shadow-btn: 0 1px 2px rgba(65, 83, 43, 0.25), 0 6px 14px -6px rgba(65, 83, 43, 0.42);
  --radius: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(at 0% 0%, rgba(153, 170, 132, 0.2) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(94, 116, 66, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--olive-ink);
  font-family: 'Plus Jakarta Sans', 'IBM Plex Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

button, input, select {
  font-family: inherit;
}

/* Portfolio Top Ribbon */
.demo-ribbon {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--olive-dark);
  color: #F4F6EE;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

.demo-ribbon-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.demo-pulse {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #B9E18E;
  box-shadow: 0 0 0 3px rgba(185, 225, 142, 0.28);
  flex-shrink: 0;
}

.demo-ribbon-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.demo-ribbon-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ribbon-btn {
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #F8F9F2;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease;
}

.ribbon-btn:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* App Shell Layout */
.shell {
  display: flex;
  min-height: calc(100vh - 36px);
}

.sidebar {
  display: none;
  width: 256px;
  flex-shrink: 0;
  background: rgba(247, 248, 240, 0.94);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  flex-direction: column;
  position: sticky;
  top: 36px;
  height: calc(100vh - 36px);
}

@media (min-width: 860px) {
  .sidebar {
    display: flex;
  }
  .mobile-topbar,
  .mobile-bottom-nav {
    display: none !important;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 16px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--olive), var(--olive-dark));
  color: #F8F9F2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  box-shadow: var(--shadow-btn);
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--olive-ink);
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
}

.branch-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(238, 240, 226, 0.78);
  border: 1px solid var(--border);
  margin-bottom: 18px;
}

.branch-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--olive);
  box-shadow: 0 0 0 4px rgba(153, 170, 132, 0.35);
  margin-left: auto;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #848E74;
  padding: 0 12px 8px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 11px 13px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  color: #556147;
  cursor: pointer;
  text-align: left;
  position: relative;
  transition: all 150ms ease;
}

.nav-btn:hover {
  background: #EAEFE1;
  color: var(--olive-ink);
}

.nav-btn.active {
  background: var(--sage-soft);
  color: var(--olive-ink);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(94, 116, 66, 0.2);
}

.nav-btn.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 20px;
  border-radius: 0 4px 4px 0;
  background: var(--olive);
}

.nav-badge {
  margin-left: auto;
  background: var(--olive-dark);
  color: #F8F9F2;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}

.sidebar-cta {
  margin-top: 12px;
  width: 100%;
  border: 1px solid #C8D4B8;
  background: linear-gradient(135deg, #E6ECDD, #EEF0E2);
  color: var(--olive-dark);
  padding: 11px 12px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 150ms ease;
}

.sidebar-cta:hover {
  border-color: var(--olive);
  transform: translateY(-1px);
}

/* Mobile Header & Bottom Nav */
.mobile-topbar {
  position: sticky;
  top: 36px;
  z-index: 30;
  background: rgba(246, 247, 238, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 35;
  background: rgba(252, 253, 248, 0.96);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -6px 20px -10px rgba(43, 55, 28, 0.14);
}

.bottom-tab {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: 12px;
  color: #778268;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
}

.bottom-tab.active {
  color: var(--olive-dark);
  background: var(--sage-soft);
  font-weight: 700;
}

.bottom-badge {
  position: absolute;
  top: 3px;
  right: calc(50% - 18px);
  background: var(--danger);
  color: white;
  font-size: 9px;
  font-weight: 700;
  min-width: 15px;
  height: 15px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* Main Content */
.main {
  flex: 1;
  min-width: 0;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 16px 96px;
  animation: fadeSlide 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 860px) {
  .main {
    padding: 28px 32px 48px;
  }
}

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

/* Cards & Typography */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.page-eyebrow {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 2px;
}

.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--olive-ink);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 7px;
}

.title-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--olive);
  display: inline-block;
  margin-top: 6px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 18px;
}

.card + .card {
  margin-top: 16px;
}

.hero-card {
  background: linear-gradient(135deg, #41532B 0%, #5E7442 100%);
  color: #F8F9F2;
  border: none;
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 12px 28px -14px rgba(43, 55, 28, 0.5);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.hero-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 4px;
}

.hero-desc {
  font-size: 13px;
  opacity: 0.9;
  margin: 0;
  max-width: 560px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Grids */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

@media (min-width: 960px) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  box-shadow: var(--shadow-card);
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.kpi-val {
  font-size: 22px;
  font-weight: 800;
  margin-top: 8px;
  color: var(--olive-ink);
  letter-spacing: -0.02em;
}

.kpi-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 900px) {
  .grid-2 {
    grid-template-columns: 1.5fr 1fr;
  }
}

.grid-equal-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 640px) {
  .grid-equal-2 {
    grid-template-columns: 1fr 1fr;
  }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 150ms ease;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(180deg, #5E7442, #4C6034);
  color: #F8F9F2;
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #526738, #41532B);
}

.btn-cream {
  background: #F8F9F2;
  color: var(--olive-dark);
}

.btn-cream:hover {
  background: #FFFFFF;
}

.btn-ghost-light {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.25);
  color: #F8F9F2;
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border);
  color: var(--olive-dark);
}

.btn-outline:hover {
  background: var(--surface-soft);
  border-color: var(--sage);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 10px;
}

.btn-danger-ghost {
  background: transparent;
  color: var(--muted);
  padding: 6px 8px;
}

.btn-danger-ghost:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Badges & Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-sage {
  background: var(--sage-soft);
  color: var(--olive-dark);
  border: 1px solid #CFD9C0;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn-border);
}

.badge-outline {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* Inputs */
.input, .select {
  width: 100%;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--olive-ink);
  padding: 0 12px;
  font-size: 14px;
  transition: border-color 150ms, box-shadow 150ms;
}

.input:focus, .select:focus {
  outline: none;
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(94, 116, 66, 0.16);
}

.label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--olive-dark);
  margin-bottom: 5px;
}

/* Filter Pills Row */
.pills-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.pills-row::-webkit-scrollbar {
  display: none;
}

.pill-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 140ms ease;
}

.pill-btn.active {
  background: var(--olive-dark);
  color: #F8F9F2;
  border-color: var(--olive-dark);
}

/* Segmented Control */
.segmented {
  display: inline-flex;
  background: #E6ECDD;
  border: 1px solid #CFD9C0;
  padding: 4px;
  border-radius: 13px;
  gap: 4px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: #5A654C;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 140ms ease;
}

.seg-btn.active {
  background: var(--surface);
  color: var(--olive-ink);
  box-shadow: 0 1px 3px rgba(43, 55, 28, 0.12);
}

/* Alert items */
.alert-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  margin-bottom: 10px;
}

.alert-item.price {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.alert-item.stock {
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.alert-item.read {
  opacity: 0.55;
  background: var(--surface-soft);
  border-color: var(--border-soft);
}

/* Stock Progress Bar */
.stock-bar-track {
  position: relative;
  height: 7px;
  background: #E5EADC;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}

.stock-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 260ms ease;
}

/* Item Cards for Mobile-first Lists */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.row-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  transition: border-color 150ms ease, transform 150ms ease;
}

.row-card:hover {
  border-color: var(--sage);
}

/* Bar Chart */
.chart-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 190px;
  padding: 14px 8px 4px;
  border-bottom: 1px solid var(--border-soft);
  overflow-x: auto;
}

.chart-day {
  flex: 1;
  min-width: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 145px;
  width: 100%;
  justify-content: center;
}

.bar {
  width: 15px;
  border-radius: 6px 6px 2px 2px;
  transition: height 350ms cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  cursor: pointer;
}

.bar-rev {
  background: linear-gradient(180deg, #5E7442, #41532B);
}

.bar-exp {
  background: linear-gradient(180deg, #D07A5B, #B9553B);
}

.chart-label {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
}

/* Modal / Bottom Sheet */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(38, 49, 25, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn 160ms ease;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 20px;
  }
}

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

.modal-box {
  background: var(--surface);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 22px 22px 0 0;
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px -12px rgba(38, 49, 25, 0.35);
  animation: sheetUp 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 640px) {
  .modal-box {
    border-radius: 22px;
  }
}

@keyframes sheetUp {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  position: sticky;
  top: 0;
  background: rgba(252, 253, 248, 0.96);
  backdrop-filter: blur(8px);
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 5;
}

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

.modal-footer {
  position: sticky;
  bottom: 0;
  background: rgba(252, 253, 248, 0.96);
  backdrop-filter: blur(8px);
  padding: 14px 20px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* AI Receipt Scanner Mock Visual */
.receipt-mock {
  position: relative;
  background: #FFFDF7;
  border: 1px dashed #BFC9AF;
  border-radius: 16px;
  padding: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #3E4636;
  overflow: hidden;
}

.scan-laser {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #5E7442, #99AA84, #5E7442, transparent);
  box-shadow: 0 0 14px 3px rgba(94, 116, 66, 0.55);
  animation: laserMove 1.1s ease-in-out infinite;
}

@keyframes laserMove {
  0% { top: 8%; }
  50% { top: 90%; }
  100% { top: 8%; }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 78px;
  right: 16px;
  left: 16px;
  z-index: 80;
  background: var(--olive-ink);
  color: #F8F9F2;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 14px 30px -8px rgba(38, 49, 25, 0.45);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: sheetUp 200ms ease;
}

@media (min-width: 640px) {
  .toast {
    left: auto;
    bottom: 24px;
    right: 24px;
    max-width: 400px;
  }
}

/* Utility */
.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 15px;
  margin-bottom: 12px;
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--sage-soft);
  color: var(--olive-dark);
  font-weight: 700;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.range-olive {
  width: 100%;
  accent-color: var(--olive);
  cursor: pointer;
}

.table-scroll {
  overflow-x: auto;
}

table.clean-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.clean-table th {
  text-align: left;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}

table.clean-table td {
  padding: 11px 10px;
  border-bottom: 1px solid #EEF1E6;
}

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