:root {
  color-scheme: light;
  --ink: #221f1c;
  --muted: #6f6861;
  --line: #d8d1ca;
  --paper: #fffdf9;
  --surface: #f5f0ea;
  --accent: #8f1f2c;
  --accent-2: #1f6b64;
  --dark: #23201d;
  --white: #ffffff;
  --shadow: 0 18px 60px rgba(38, 30, 24, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #faf7f1 0%, #ece4db 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

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

button,
.link-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app {
  display: grid;
  grid-template-columns: minmax(440px, 1fr) minmax(430px, 560px);
  min-height: 100vh;
}

.workspace {
  padding: 28px;
}

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

.kicker {
  margin: 0 0 4px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 32px;
  line-height: 1.15;
}

.profile-name {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
}

.top-actions,
.mini-actions,
.settings-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.primary,
.dark,
.ghost,
.danger,
.mini-actions button {
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
}

.link-button {
  display: inline-flex;
  align-items: center;
}

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

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

.ghost,
.mini-actions button {
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
}

.danger {
  width: 100%;
  margin-top: 12px;
  color: #9b1c27;
  background: #fff4f4;
  border: 1px solid #f0c9cf;
}

.panels {
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(260px, 0.75fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(216, 209, 202, 0.9);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(38, 30, 24, 0.06);
}

.form-panel {
  padding: 18px;
}

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

#saveStatus {
  color: var(--muted);
  font-size: 13px;
}

.grid {
  display: grid;
  gap: 12px;
}

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

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(31, 107, 100, 0.13);
}

.settings,
.batch {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.settings summary,
.batch summary {
  cursor: pointer;
  font-weight: 800;
}

.settings .grid {
  margin-top: 14px;
}

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

.history-panel {
  padding: 16px;
}

.history-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 218px);
  overflow: auto;
  padding-right: 2px;
}

.history-item {
  display: grid;
  width: 100%;
  gap: 3px;
  padding: 10px;
  color: var(--ink);
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
}

.history-item:hover {
  border-color: var(--accent-2);
}

.history-main {
  font-weight: 800;
}

.history-sub {
  color: var(--muted);
  font-size: 12px;
}

.empty {
  margin: 0;
  color: var(--muted);
}

.preview-shell {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 28px;
  background:
    linear-gradient(rgba(35, 32, 29, 0.64), rgba(35, 32, 29, 0.72)),
    url("assets/bar.jpg") center / cover;
  overflow: auto;
}

.receipt {
  width: min(100%, 500px);
  min-height: 705px;
  padding: 42px;
  background: var(--paper);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.receipt-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 22px;
  border-bottom: 2px solid var(--ink);
}

.receipt-label {
  display: inline-block;
  margin: 0 0 8px;
  padding: 3px 8px;
  color: var(--white);
  background: var(--accent-2);
  border-radius: 5px;
  font-size: 12px;
  font-weight: 800;
}

.receipt-header h2 {
  font-size: 42px;
  letter-spacing: 0;
}

dl {
  min-width: 150px;
  margin: 0;
}

dl div {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

dd {
  margin: 0;
  text-align: right;
}

.recipient {
  margin-top: 28px;
}

.recipient p {
  min-height: 42px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--ink);
  font-size: 23px;
  font-weight: 800;
}

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

.amount-box {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin: 28px 0;
  padding: 18px 20px;
  background: #f7eee9;
  border: 1px solid #e4cbc2;
  border-radius: 8px;
}

.amount-box span {
  color: var(--muted);
  font-weight: 800;
}

.amount-box strong {
  font-size: 34px;
  line-height: 1.1;
}

.receipt-table {
  width: 100%;
  border-collapse: collapse;
}

.receipt-table th,
.receipt-table td {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.receipt-table th {
  width: 92px;
  color: var(--muted);
  text-align: left;
  font-size: 13px;
}

.issuer {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 18px;
  margin-top: 34px;
  padding-top: 20px;
  border-top: 2px solid var(--ink);
}

.issuer-logo {
  width: 138px;
  height: auto;
  align-self: start;
}

.issuer strong {
  display: block;
  margin-bottom: 5px;
  font-size: 18px;
}

.issuer p {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 13px;
}

.issuer .company-name {
  color: var(--ink);
  font-weight: 800;
}

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

  .preview-shell {
    min-height: 780px;
  }
}

@media (max-width: 820px) {
  .workspace,
  .preview-shell {
    padding: 16px;
  }

  .topbar,
  .panels {
    grid-template-columns: 1fr;
    display: grid;
  }

  .two {
    grid-template-columns: 1fr;
  }

  .receipt {
    padding: 26px;
  }

  .receipt-header,
  .amount-box,
  .issuer {
    display: grid;
  }

  .issuer {
    grid-template-columns: 1fr;
  }

  .amount-box strong {
    font-size: 28px;
  }
}

@media print {
  @page {
    size: A4;
    margin: 14mm;
  }

  body {
    background: #fff;
  }

  .workspace {
    display: none;
  }

  .app,
  .preview-shell {
    display: block;
    min-height: auto;
    padding: 0;
    background: #fff;
  }

  .receipt {
    width: 100%;
    min-height: auto;
    padding: 0;
    box-shadow: none;
    border-radius: 0;
  }
}
