:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #eef3f8;
  --line: #dce4ec;
  --text: #1f2933;
  --muted: #687684;
  --brand: #246b63;
  --brand-strong: #174d47;
  --accent: #b45f3d;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(31, 41, 51, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(36, 107, 99, 0.08), transparent 260px),
    var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.05;
}

h2 {
  font-size: 20px;
}

.toolbar {
  display: flex;
  gap: 10px;
}

.file-input {
  display: none;
}

.icon-button,
.small-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  font-size: 23px;
  line-height: 1;
}

.small-button {
  width: 40px;
  height: 40px;
  border-radius: 7px;
  color: var(--brand);
  font-size: 22px;
  font-weight: 700;
}

.small-button.danger {
  color: var(--danger);
}

.icon-button:hover,
.small-button:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
}

.icon-button.danger {
  color: var(--danger);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric,
.entry-panel,
.filter-panel,
.list-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

.entry-panel,
.filter-panel,
.list-panel {
  padding: 18px;
  margin-top: 16px;
}

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

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 40px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  padding: 0 11px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(36, 107, 99, 0.12);
}

.select-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px 40px;
  gap: 8px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.primary-button {
  min-width: 128px;
  height: 42px;
  border: 0;
  border-radius: 7px;
  background: var(--brand);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--brand-strong);
}

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

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

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

.date-range {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 220px));
  gap: 14px;
}

.search-box {
  width: min(360px, 100%);
}

.table-wrap {
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  background: var(--surface);
}

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

th {
  background: var(--surface-soft);
  color: #40505e;
  font-size: 13px;
  white-space: nowrap;
}

td {
  font-size: 14px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.quantity-cell {
  font-weight: 800;
  color: var(--accent);
}

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

.text-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--brand);
  cursor: pointer;
  padding: 6px 10px;
}

.text-button.delete {
  color: var(--danger);
}

.empty-state {
  display: none;
  padding: 32px;
  background: #fff;
  color: var(--muted);
  text-align: center;
}

.empty-state.is-visible {
  display: block;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 22px, 1180px);
    padding-top: 18px;
  }

  .topbar,
  .filter-head,
  .list-head {
    align-items: stretch;
    flex-direction: column;
  }

  .date-range {
    grid-template-columns: 1fr;
  }

  .toolbar {
    justify-content: flex-end;
  }

  .metrics,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .entry-panel,
  .list-panel {
    padding: 14px;
  }

  .form-actions {
    justify-content: stretch;
  }

  .primary-button {
    width: 100%;
  }
}
