:root {
  --ink: #17211d;
  --muted: #61706a;
  --line: #dce4dd;
  --paper: #fbfcf8;
  --panel: #ffffff;
  --leaf: #286b45;
  --leaf-dark: #17452e;
  --lime: #d8e85f;
  --tomato: #db5b3d;
  --gold: #f3b63e;
  --sky: #dbeff3;
  --shadow: 0 18px 50px rgba(28, 48, 39, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
  max-width: 100%;
  min-width: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #11251b;
  color: white;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: var(--lime);
  color: #122016;
  font-weight: 900;
  border-radius: 8px;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3,
.panel p,
.hero-band h3,
.hero-band p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p,
.sidebar-card p {
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 8px;
  scrollbar-width: none;
}

.nav-list::-webkit-scrollbar {
  display: none;
}

.nav-item {
  border: 0;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  padding: 12px 14px;
  text-align: left;
  transition: 0.18s ease;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(216, 232, 95, 0.12);
  color: white;
}

.sidebar-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-card strong {
  display: block;
  margin: 6px 0;
  font-size: 34px;
  letter-spacing: 0;
}

.main {
  min-width: 0;
  padding: 24px;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar h2 {
  font-size: 30px;
  letter-spacing: 0;
}

.eyebrow {
  color: var(--leaf);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
}

.search {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search input,
select,
input {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  min-height: 42px;
  padding: 0 12px;
}

.search input {
  width: min(34vw, 340px);
}

.icon-btn,
.primary-btn,
.ghost-btn,
.mini-btn {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  font-weight: 800;
}

.icon-btn {
  width: 42px;
  background: #e9efe9;
  color: var(--leaf-dark);
  font-size: 19px;
}

.primary-btn {
  background: var(--leaf);
  color: white;
  padding: 0 18px;
}

.ghost-btn,
.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e9efe9;
  color: var(--leaf-dark);
  padding: 0 14px;
}

.mini-btn {
  min-height: 32px;
  font-size: 12px;
}

.whatsapp-btn {
  background: #d8f5df;
  color: #126b2f;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.is-hidden {
  display: none !important;
}

.hero-band {
  min-height: 220px;
  border-radius: 8px;
  padding: 28px;
  background:
    linear-gradient(100deg, rgba(17, 37, 27, 0.92), rgba(17, 37, 27, 0.66)),
    radial-gradient(circle at 80% 25%, rgba(243, 182, 62, 0.9), transparent 24%),
    linear-gradient(135deg, #1b5136, #9fbf55 55%, #db5b3d);
  color: white;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 24px;
  align-items: center;
  overflow: hidden;
  margin-bottom: 18px;
}

.hero-band .eyebrow {
  color: var(--lime);
}

.hero-band h3 {
  font-size: clamp(30px, 5vw, 56px);
  line-height: 0.98;
  max-width: 760px;
  margin: 8px 0 14px;
  overflow-wrap: anywhere;
}

.hero-band p:not(.eyebrow) {
  color: rgba(255, 255, 255, 0.84);
  max-width: 620px;
  font-size: 17px;
}

.fruit-visual {
  position: relative;
  height: 170px;
}

.fruit-visual span {
  position: absolute;
  display: block;
  border-radius: 50%;
  box-shadow: inset -16px -18px 26px rgba(0, 0, 0, 0.18), 0 18px 34px rgba(0, 0, 0, 0.22);
}

.fruit-visual span:nth-child(1) {
  width: 110px;
  height: 110px;
  background: #e3442f;
  left: 18px;
  top: 42px;
}

.fruit-visual span:nth-child(2) {
  width: 88px;
  height: 88px;
  background: #f2c245;
  left: 94px;
  top: 24px;
}

.fruit-visual span:nth-child(3) {
  width: 95px;
  height: 95px;
  background: #7eb34a;
  left: 158px;
  top: 62px;
}

.fruit-visual span:nth-child(4) {
  width: 68px;
  height: 68px;
  background: #b34479;
  left: 74px;
  top: 102px;
}

.fruit-visual span:nth-child(5) {
  width: 56px;
  height: 56px;
  background: #f58a3f;
  left: 178px;
  top: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.filter-panel {
  margin-bottom: 18px;
}

.compact-grid {
  grid-template-columns: repeat(2, minmax(180px, 260px));
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  letter-spacing: 0;
}

.dashboard-grid,
.entry-grid,
.report-grid {
  display: grid;
  gap: 16px;
}

.dashboard-grid {
  grid-template-columns: 1.1fr 0.9fr;
}

.entry-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.report-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.report-wide {
  grid-column: 1 / -1;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel h3 {
  font-size: 20px;
  margin-top: 3px;
}

.form-panel {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  min-width: 0;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.sale-preview {
  border: 1px solid #cfe2d2;
  border-radius: 8px;
  background: #f3faf3;
  color: var(--leaf-dark);
  font-size: 13px;
  font-weight: 800;
  padding: 12px;
}

.stack-list {
  display: grid;
  gap: 10px;
}

#receivableList,
#stockList {
  max-height: 430px;
  overflow-y: auto;
  padding-right: 4px;
}

.stack-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  background: #f5f8f3;
  border: 1px solid #e4ebe3;
  border-radius: 8px;
}

.alert-row {
  background: #fff1e8;
  border-color: #f2b899;
}

.alert-soft {
  background: #fff8f2;
}

.stack-item small {
  color: var(--muted);
  display: block;
  margin-top: 3px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  background: var(--sky);
  color: #174856;
}

.tag.commission {
  background: #e7f4cf;
  color: #31580d;
}

.tag.trading {
  background: #ffe5ce;
  color: #833f00;
}

.negative {
  color: #b73824;
  font-weight: 800;
}

.positive {
  color: var(--leaf);
  font-weight: 800;
}

.insight-list {
  margin: 14px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  padding: 12px 16px;
  border-radius: 8px;
  color: white;
  background: var(--leaf-dark);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: 0.2s ease;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    gap: 16px;
  }

  .nav-list {
    grid-template-columns: repeat(6, max-content);
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-item {
    white-space: nowrap;
  }

  .sidebar-card {
    display: none;
  }

  .hero-band,
  .dashboard-grid,
  .entry-grid,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fruit-visual {
    display: none;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 14px;
  }

  .main,
  .sidebar {
    padding: 12px;
  }

  .sidebar {
    padding-bottom: 10px;
    overflow-x: hidden;
  }

  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 14px;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .top-actions .search {
    grid-column: 1 / -1;
  }

  .search input {
    width: 100%;
  }

  .icon-btn {
    width: 100%;
    min-width: 0;
    font-size: 14px;
  }

  .nav-list,
  .metric-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
  }

  .nav-item {
    flex: 0 0 auto;
  }

  .hero-band {
    min-height: auto;
    padding: 16px;
    margin-bottom: 12px;
  }

  .hero-band h3 {
    font-size: 26px;
    line-height: 1.05;
  }

  .hero-band p:not(.eyebrow) {
    font-size: 14px;
  }

  .panel {
    padding: 14px;
  }

  .panel-head {
    flex-direction: column;
    gap: 10px;
  }

  .panel-head select,
  .panel-head button {
    width: 100%;
  }

  .metric {
    padding: 14px;
  }

  .metric strong {
    font-size: 22px;
    overflow-wrap: anywhere;
  }

  table {
    min-width: 680px;
  }

  th,
  td {
    padding: 10px 8px;
  }

  .stack-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .stack-item > strong {
    align-self: flex-end;
  }
}
}
