:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --panel: #ffffff;
  --panel-soft: #edf3ef;
  --ink: #17211c;
  --muted: #66736d;
  --line: #dce5df;
  --accent: #256d5a;
  --accent-strong: #154f40;
  --accent-soft: #e2f2eb;
  --warn: #b36b00;
  --shadow: 0 18px 50px rgba(28, 48, 39, 0.13);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(37, 109, 90, 0.08), transparent 260px),
    var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px;
}

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

.topbar h1,
.panel-header h2 {
  font-size: 28px;
  letter-spacing: 0;
  line-height: 1.1;
  margin: 2px 0 0;
}

.top-actions,
.scan-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

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

.workspace {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  align-items: start;
}

.capture-panel,
.ledger-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.capture-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.ledger-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.panel-header,
.toolbar {
  align-items: end;
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.status-pill {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 10px;
  white-space: nowrap;
}

.status-pill.busy {
  background: #fff6e6;
  color: var(--warn);
}

.status-pill.ready {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.drop-zone {
  align-items: center;
  background: var(--panel-soft);
  border: 1px dashed #9fb7ac;
  border-radius: var(--radius);
  color: var(--accent-strong);
  display: flex;
  font-weight: 800;
  gap: 10px;
  justify-content: center;
  min-height: 60px;
  position: relative;
}

.drop-zone.dragging {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.drop-zone input {
  inset: 0;
  opacity: 0;
  position: absolute;
}

.drop-icon {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: inline-flex;
  height: 32px;
  justify-content: center;
  width: 32px;
}

.preview-frame {
  align-items: center;
  background:
    linear-gradient(45deg, rgba(220, 229, 223, 0.65) 25%, transparent 25%) 0 0 / 18px 18px,
    linear-gradient(45deg, transparent 75%, rgba(220, 229, 223, 0.65) 75%) 0 0 / 18px 18px,
    #fbfcfb;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  min-height: 300px;
  overflow: hidden;
  position: relative;
}

.preview-frame img {
  display: block;
  height: 100%;
  max-height: 460px;
  object-fit: contain;
  width: 100%;
}

.preview-placeholder {
  color: #99a69f;
  font-size: 28px;
  font-weight: 900;
  margin: auto;
}

.field-block,
.expense-form label,
.toolbar label {
  display: grid;
  gap: 7px;
}

.field-block span,
.expense-form span,
.toolbar span,
.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  min-height: 42px;
  outline: none;
  padding: 10px 11px;
  width: 100%;
}

textarea {
  line-height: 1.55;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 109, 90, 0.13);
}

.expense-form {
  display: grid;
  gap: 13px;
}

.field-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.primary-button,
.secondary-button,
.icon-button,
.danger-button {
  align-items: center;
  border-radius: 7px;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

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

.secondary-button {
  background: var(--panel-soft);
  color: var(--accent-strong);
}

.secondary-button:hover {
  background: var(--accent-soft);
}

.icon-button {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--accent-strong);
  font-size: 22px;
  height: 42px;
  padding: 0;
  width: 42px;
}

.danger-button {
  background: #fff0eb;
  color: #a33a1b;
  min-height: 34px;
  padding: 7px 9px;
}

.full-width {
  width: 100%;
}

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

.metric {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 8px;
  min-height: 92px;
  padding: 14px;
}

.metric strong {
  font-size: 26px;
  line-height: 1;
}

.toolbar {
  align-items: end;
  flex-wrap: wrap;
}

.toolbar label {
  min-width: 180px;
}

.search-box {
  flex: 1 1 240px;
}

.table-shell {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 420px;
  overflow: auto;
  position: relative;
}

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

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

th {
  background: #f8faf8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  position: sticky;
  top: 0;
  z-index: 1;
}

td {
  font-size: 14px;
}

tbody tr:hover {
  background: #fbfcfb;
}

.numeric {
  text-align: right;
}

.action-cell {
  text-align: right;
  width: 76px;
}

.empty-state {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
  inset: 74px 0 0;
  justify-content: center;
  pointer-events: none;
  position: absolute;
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

.empty-state.hidden {
  display: none;
}

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

  .capture-panel,
  .ledger-panel {
    box-shadow: 0 12px 34px rgba(28, 48, 39, 0.11);
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .panel-header {
    align-items: start;
    flex-direction: column;
  }

  .top-actions,
  .scan-actions {
    width: 100%;
  }

  .top-actions .primary-button,
  .scan-actions button {
    flex: 1;
  }

  .field-row,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 78px;
  }
}
