:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-strong: #eef3f1;
  --text: #1f2933;
  --muted: #66727f;
  --line: #d9e0e3;
  --primary: #256f61;
  --primary-strong: #17564a;
  --accent: #8a5a1f;
  --danger: #a83f39;
  --review: #fff5d9;
  --shadow: 0 8px 24px rgba(31, 41, 51, 0.08);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  width: min(1500px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
  font-weight: 750;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
  font-weight: 700;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
}

.topbar-actions,
.actions-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.upload-band,
.table-section,
.status-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.upload-band {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(260px, 0.55fr);
  gap: 18px;
  padding: 18px;
}

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 160px;
  padding: 24px;
  border: 2px dashed #98aaa5;
  border-radius: 8px;
  background: var(--surface-strong);
  text-align: center;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.drop-zone.drag-over {
  border-color: var(--primary);
  background: #e1eee9;
}

.drop-zone strong {
  display: block;
  font-size: 20px;
}

.drop-zone span {
  color: var(--muted);
}

.drop-zone input {
  display: none;
}

.actions-panel {
  align-content: center;
  justify-content: flex-start;
}

.button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.button {
  min-height: 40px;
  padding: 9px 14px;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  border-color: #aab6ba;
}

.button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

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

.button.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.button.secondary {
  background: #eaf0ee;
}

.button.danger {
  color: #ffffff;
  background: var(--danger);
  border-color: var(--danger);
}

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  font-size: 20px;
}

.status-block {
  display: none;
  margin-top: 16px;
  padding: 12px 14px;
  color: var(--muted);
}

.status-block.active {
  display: block;
}

.status-block.error {
  color: var(--danger);
  border-color: rgba(168, 63, 57, 0.35);
}

.status-block.success {
  color: var(--primary-strong);
  border-color: rgba(37, 111, 97, 0.35);
}

.status-list {
  margin: 8px 0 0;
  padding-left: 18px;
}

.table-section {
  margin-top: 18px;
  overflow: hidden;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table-wrap.compact {
  max-width: 760px;
}

table {
  width: 100%;
  min-width: 1380px;
  border-collapse: collapse;
  font-size: 14px;
}

#summaryTable {
  min-width: 560px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f9f9;
  color: #3b4650;
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

tr.needs-review {
  background: var(--review);
}

td.readonly {
  color: var(--muted);
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

input,
select {
  width: 100%;
  min-width: 96px;
  border: 1px solid #c8d1d4;
  border-radius: 5px;
  padding: 7px 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

input[type="checkbox"] {
  min-width: 18px;
  width: 18px;
  height: 18px;
}

.number-cell {
  min-width: 110px;
}

.expense-type-cell {
  min-width: 300px;
}

.expense-type-cell select {
  min-width: 290px;
}

.description-cell {
  min-width: 260px;
}

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

.save-button,
.delete-button {
  min-width: 88px;
}

.empty-row {
  color: var(--muted);
  text-align: center;
}

.totals-block {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #f8fbfa;
}

.totals-title {
  color: var(--muted);
  font-weight: 750;
}

.total-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid rgba(37, 111, 97, 0.22);
  border-radius: 6px;
  background: #eaf3ef;
  color: var(--primary-strong);
  font-weight: 750;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100vw - 20px, 1500px);
    padding-top: 10px;
  }

  .topbar,
  .upload-band {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .button {
    width: 100%;
  }
}
