:root {
  --ink: #17212b;
  --muted: #697586;
  --line: #d9e0e8;
  --soft: #f4f7fa;
  --panel: #ffffff;
  --blue: #1f6f8b;
  --green: #1f7a5a;
  --red: #b42318;
  --shadow: 0 18px 45px rgba(25, 38, 54, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, "Noto Sans Thai", sans-serif;
  color: var(--ink);
  background: #edf2f6;
}

button,
input,
textarea {
  font: inherit;
}

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

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.15;
}

.total-box {
  min-width: 180px;
  padding: 14px 16px;
  background: var(--ink);
  color: white;
  border-radius: 8px;
  text-align: right;
}

.total-box span {
  display: block;
  color: #c6d1dc;
  font-size: 13px;
}

.total-box strong {
  display: block;
  font-size: 26px;
}

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

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

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

.upload-zone {
  position: relative;
  min-height: 118px;
  border: 2px dashed #a9b8c8;
  border-radius: 8px;
  background: var(--soft);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
}

.upload-zone.dragging {
  border-color: var(--blue);
  background: #e6f4f8;
}

.upload-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-copy strong {
  display: block;
  font-size: 18px;
}

.upload-copy span,
small,
.ocr-status,
.list-head p,
.expense-card p {
  color: var(--muted);
  font-size: 13px;
}

.preview {
  width: 100%;
  max-height: 250px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

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

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

label span {
  font-size: 14px;
}

input,
textarea {
  width: 100%;
  border: 1px solid #bcc8d4;
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: white;
}

textarea {
  resize: vertical;
}

.ocr-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.ocr-details summary {
  cursor: pointer;
  font-weight: 700;
}

.ocr-details textarea {
  margin-top: 10px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 800;
}

.primary {
  color: white;
  background: var(--green);
}

.secondary {
  color: var(--ink);
  background: #e7edf3;
}

.list-panel {
  min-height: 520px;
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.list-head h2 {
  margin-bottom: 3px;
  font-size: 22px;
}

.list-head p {
  margin-bottom: 0;
}

.list-head input {
  max-width: 260px;
}

.expense-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.expense-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.expense-card time {
  display: block;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 4px;
}

.expense-card h3 {
  margin-bottom: 4px;
  font-size: 17px;
  line-height: 1.35;
}

.expense-card p {
  margin-bottom: 0;
}

.card-side {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.card-side strong {
  font-size: 20px;
}

.card-side button {
  padding: 7px 9px;
  margin-left: 4px;
  background: #e8eef5;
}

.card-side button[data-delete] {
  color: var(--red);
}

.empty {
  padding: 34px 12px;
  color: var(--muted);
  text-align: center;
}

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

  .topbar,
  .workspace,
  .list-head,
  .expense-card {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    align-items: stretch;
  }

  .total-box {
    text-align: left;
  }

  .workspace {
    display: grid;
  }

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

  .list-head {
    display: grid;
  }

  .list-head input {
    max-width: none;
  }

  .card-side {
    justify-items: start;
  }
}
