:root {
  --bg: #f5f7f4;
  --panel: #ffffff;
  --ink: #1e2528;
  --muted: #66727a;
  --line: #d9e0dc;
  --green: #176b55;
  --green-dark: #0f4c3e;
  --amber: #b45f06;
  --red: #b3261e;
  --blue: #235d8f;
  --shadow: 0 14px 34px rgba(31, 45, 39, .10);
}

* { box-sizing: border-box; }
html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
  overflow-x: clip;
}
button, input, select, textarea { font: inherit; touch-action: manipulation; }
button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 14px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(16, 45, 40, .10);
}
button:active { transform: translateY(1px); }
button:hover { border-color: #98aaa1; }
.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
.primary:hover { background: var(--green-dark); }
.ghost { background: #fff; }
.ghost.attention { border-color: var(--amber); color: var(--amber); background: #fff6ea; font-weight: 700; }
.ghost.attention::before { content: "● "; font-size: 10px; vertical-align: middle; }
.danger { color: var(--red); border-color: #e4b8b4; }
.icon-btn { width: 42px; padding: 0; font-size: 24px; line-height: 1; }

.app-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: #102d28;
  color: #fff;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.mark {
  width: 48px; height: 48px; border-radius: 8px;
  background: #f4d35e; color: #102d28;
  display: grid; place-items: center; font-weight: 900; font-size: 24px;
}
.brand h1 { margin: 0; font-size: 18px; }
.brand p { margin: 4px 0 0; color: #c2d2cb; font-size: 13px; }
.nav { display: grid; gap: 8px; }
.nav button {
  width: 100%; justify-content: flex-start; text-align: left;
  background: transparent; color: #e8f2ee; border-color: transparent;
}
.nav button.active, .nav button:hover { background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.10); }
.status-box {
  margin-top: auto; display: grid; gap: 8px; padding: 14px;
  background: rgba(255,255,255,.08); border-radius: 8px;
}
.status-box span { font-weight: 700; }
.status-box small { color: #c2d2cb; }

/* ハンバーガーメニュー（モバイルのみ表示） */
.menu-toggle {
  display: none;
  width: 46px;
  min-height: 46px;
  font-size: 22px;
  line-height: 1;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border-color: rgba(255, 255, 255, .18);
}

/* バックアップ警告バナー */
.backup-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 12px 18px;
  background: #fff6ea;
  border-bottom: 1px solid #f0d9b5;
  color: #7a4a06;
  font-size: 14px;
  line-height: 1.5;
}
.backup-notice[hidden] { display: none; }
.backup-notice-actions { display: flex; gap: 8px; flex-shrink: 0; }
.backup-notice-actions button { min-height: 38px; }

main { min-width: 0; }
.topbar {
  height: 88px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.78);
  position: sticky;
  top: 0;
  z-index: 4;
  backdrop-filter: blur(10px);
}
.topbar p { margin: 0 0 4px; color: var(--muted); font-size: 13px; }
.topbar h2 { margin: 0; font-size: 25px; }
.top-actions { display: flex; gap: 10px; }
.view { padding: 24px 26px 40px; }

.grid { display: grid; gap: 16px; }
.dashboard { grid-template-columns: repeat(4, minmax(160px, 1fr)); }
.card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.card { padding: 18px; min-height: 112px; }
.card b { display: block; font-size: 30px; margin-top: 8px; }
.card span { color: var(--muted); }
.panel { padding: 18px; margin-bottom: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h3 { margin: 0; font-size: 18px; }
.result-count, .auto-save-note { color: var(--muted); font-size: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.home-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
}
.home-actions button { width: 100%; min-width: 0; height: 56px; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 14px; }
.editor-actions button { flex: 1 1 auto; min-width: 130px; min-height: 48px; font-weight: 700; }
.group-title { margin: 16px 0 8px; font-size: 14px; color: var(--muted); }
.btn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.btn-grid button { width: 100%; min-height: 48px; white-space: nowrap; }
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: #edf2ef;
  border-radius: 8px;
}
.segmented button {
  min-height: 34px;
  border-color: transparent;
  background: transparent;
  padding: 0 10px;
}
.segmented button.active {
  background: #fff;
  color: var(--green-dark);
  border-color: var(--line);
  font-weight: 700;
}
.document-filter-bar {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}
.period-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}
.period-filter label { flex: 0 1 170px; }

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 13px; font-weight: 700; }
td.num, th.num { text-align: right; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.subtext {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 0 9px; border-radius: 999px; background: #e9f3ef; color: var(--green-dark); font-size: 12px; font-weight: 700; }
.warn { background: #fff1dd; color: var(--amber); }
.paid { background: #e8f1fb; color: var(--blue); }
.partial { background: #fff8d7; color: #806300; }
.canceled { background: #f0f0f0; color: #777; }

.form-grid { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 12px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; position: relative; }
.label-text { display: inline-flex; align-items: center; gap: 6px; }
.help {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #e8efec;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  cursor: help;
  position: relative;
  appearance: none;
  -webkit-appearance: none;
}
.help::after {
  display: none;
  content: attr(aria-label);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(calc(-50% + var(--help-shift-x, 0px)));
  width: min(260px, calc(100vw - 24px));
  padding: 8px 10px;
  border-radius: 8px;
  background: #102d28;
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,.20);
}
.help.help-open::after { display: block; opacity: 1; }
@media (hover: hover) {
  .help:hover::after { display: block; opacity: 1; }
}
label > .help { position: absolute; top: 0; right: 0; }
.label-text .help { position: relative; top: auto; right: auto; }
.check-label {
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}
.check-label input { width: auto; min-height: auto; }
input, select, textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 42px;
  padding: 8px 10px;
  /* iOSはフォント16px未満の入力欄にフォーカスすると画面を自動拡大するため16px固定 */
  font-size: 16px;
  line-height: 1.3;
}
input:disabled, select:disabled, textarea:disabled {
  background: #edf0ee;
  color: #7a8580;
  border-color: #d5dbd7;
  cursor: not-allowed;
}
/* iOSのネイティブ日付・数値入力は既定の見た目だと枠より右へはみ出すため正規化する */
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="number"] {
  -webkit-appearance: none;
  appearance: none;
}
textarea { min-height: 96px; resize: vertical; }
.span-2 { grid-column: span 2; }
.span-4 { grid-column: 1 / -1; }
.form-action { display: flex; align-items: end; }
.form-action button { width: 100%; }
.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
}
.info-line {
  margin: 14px 0 0;
  padding: 10px 12px;
  background: #eef6f2;
  border: 1px solid #cfe2d8;
  border-radius: 8px;
  color: var(--green-dark);
}
.table-scroll { overflow-x: auto; }
.line-editor { table-layout: fixed; min-width: 1120px; }
.line-editor input, .line-editor select { min-width: 0; }
.major-category-cell { background: #f8faf9; }
.construction-disabled .major-category-cell { background: #eef1ef; }
.construction-hint { margin-top: 8px; }
.construction-warning {
  background: #fff6ea;
  border-color: #f0d9b5;
  color: #7a4a06;
}
.row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; min-width: 260px; }
.totals { width: min(420px, 100%); margin-left: auto; display: grid; gap: 8px; }
.totals div { display: flex; justify-content: space-between; }
.totals strong { font-size: 22px; }
.license-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.license-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
}
.license-summary span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.license-summary b { word-break: break-word; }

#printDialog {
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(0,0,0,.28);
}
#printDialog[open] {
  display: flex;
  flex-direction: column;
}
#printDialog::backdrop { background: rgba(0,0,0,.38); }
#receiptItemDialog {
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
}
.dialog-head, .dialog-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  z-index: 2;
}
.dialog-head { top: 0; }
.dialog-actions {
  bottom: 0;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
  gap: 10px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}
.pdf-status {
  align-self: center;
  color: var(--muted);
  font-size: .86rem;
  margin-right: auto;
}
.dialog-head h3 { margin: 0; }
.print-area {
  flex: 1 1 auto;
  min-height: 0;
  padding: 28px;
  background: #f2f4f3;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.evidence-banner {
  width: 794px;
  margin: 0 auto 12px;
  border: 1px solid #b8c2b8;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fbf8;
  color: #2f4732;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
}
.evidence-banner strong { color: #17351d; }
.sheet {
  width: 794px;
  min-height: 0;
  margin: 0 auto;
  padding: 34px 40px;
  background: #fff;
  color: #111;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  display: block;
}
.sheet + .sheet { margin-top: 22px; }
.sheet-landscape {
  width: 100%;
  max-width: 1123px;
  padding: 32px 40px;
}
.construction-summary-table th:first-child,
.construction-summary-table td:first-child { width: 48px; }
.construction-summary-table th:nth-child(4),
.construction-summary-table td:nth-child(4) { width: 70px; }
.construction-summary-table th:nth-child(5),
.construction-summary-table td:nth-child(5) { width: 55px; }
.construction-summary-table th:last-child,
.construction-summary-table td:last-child { width: 150px; }
.construction-details h1 { margin-bottom: 8px; }
.construction-detail-meta {
  margin-bottom: 16px !important;
  text-align: right;
  color: #444;
}
.construction-group { margin-top: 18px; }
.construction-group h2 {
  margin: 0 0 6px;
  padding: 6px 10px;
  font-size: 15px;
  background: #f0f3f1;
  border-left: 4px solid #3d6658;
}
.construction-subtotal td {
  background: #f5f7f6;
  font-weight: 700;
}
.construction-subtotal td:first-child { text-align: right; }
.sheet-content { min-width: 0; }
.sheet h1 { text-align: center; font-size: 24px; margin: 0 0 14px; }
.sheet p { margin: 6px 0; }
.sheet-meta { display: grid; grid-template-columns: 1fr 260px; gap: 22px; margin-bottom: 12px; }
.issuer-block { display: grid; gap: 14px; }
.subject-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 18px;
  margin: 8px 0 10px;
}
.subject-row > div:first-child { min-width: 0; }
.subject-line { font-weight: 700; }
.subject-line, .document-message {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.document-message { color: #333; }
.sheet-total { font-size: 23px; font-weight: 800; border-bottom: 3px double #333; padding: 8px 0; margin: 12px 0; }
.sheet-total span { display: inline-block; min-width: 140px; }
.payment-due-line { font-weight: 700; margin: -4px 0 10px; }
.sheet table { table-layout: fixed; }
.sheet table th, .sheet table td {
  border: 1px solid #777;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.sheet table th, .sheet table td { padding: 5px; font-size: 11px; line-height: 1.25; }
.sheet .right { text-align: right; }
.tax-summary { width: min(430px, 100%); margin: 10px 0 0 auto; }
.tax-summary { table-layout: auto; }
.bank-box, .remarks-box {
  border: 1px solid #777;
  padding: 10px;
  margin-top: 10px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.remarks-box {
  margin-top: 16px;
}
.bank-box strong, .remarks-box strong { display: inline-block; margin-bottom: 8px; }
.stamp-box {
  width: 96px;
  height: 116px;
  border: 1px solid #bbb;
  color: #bbb;
  display: grid;
  place-items: center;
  margin-left: auto;
  font-size: 13px;
}
.print-frame {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 0;
  height: 0;
  border: 0;
}

@media (max-width: 900px) {
  /* 行を auto 1fr に固定し、本文が短い画面でヘッダ（サイドバー）が伸縮しないようにする */
  .app-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    padding: 10px 14px;
    position: sticky;
    top: 0;
    z-index: 8;
  }
  html.standalone-mode .sidebar {
    padding-top: calc(10px + env(safe-area-inset-top));
  }
  .brand { flex: 1 1 auto; min-width: 0; order: 1; }
  .brand h1 { font-size: 16px; }
  .brand p { display: none; }
  .mark { width: 38px; height: 38px; font-size: 20px; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; order: 2; }

  /* ナビはハンバーガーで開閉する縦リスト。既定は閉じる */
  .nav { display: none; }
  .sidebar.nav-open .nav {
    display: grid;
    order: 3;
    width: 100%;
    min-width: 0;
    gap: 6px;
    margin-top: 4px;
  }
  .nav button { width: 100%; justify-content: flex-start; min-height: 48px; }

  .status-box { display: none; }
  .sidebar.nav-open .status-box {
    display: flex;
    order: 4;
    width: 100%;
    margin-top: 0;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
  }

  /* 画面切替でヘッダ高さがぶれないよう固定。iOSのちらつき源 backdrop-filter は無効化し背景を不透明に */
  .topbar {
    position: static;
    height: auto;
    min-height: 70px;
    align-items: stretch;
    gap: 10px;
    flex-direction: column;
    padding: 12px 16px;
    background: var(--panel);
    backdrop-filter: none;
  }
  .topbar h2 { font-size: 22px; }
  .top-actions { width: 100%; flex-wrap: wrap; }
  /* flex:1 1 0 だとボタン幅が均等に潰れ「バックアップ」が「プ」で折り返すため、内容幅基準にする */
  .top-actions button { flex: 1 1 auto; min-width: 0; white-space: nowrap; }

  .dashboard, .form-grid, .license-summary { grid-template-columns: minmax(0, 1fr); }
  .home-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2, .span-4 { grid-column: auto; }
  .view { padding: 16px 14px 32px; }
  .panel, .form-grid, .form-grid > *, .table-scroll {
    min-width: 0;
    max-width: 100%;
  }
  .check-label { overflow-wrap: anywhere; }
  .row-actions { min-width: 0; }
  .print-area { padding: 12px; }
  .evidence-banner { width: 100%; }
  .sheet {
    width: 100%;
    min-height: auto;
    aspect-ratio: 210 / 297;
    padding: 20px;
    font-size: 10px;
  }
  .sheet-landscape {
    width: 100%;
    aspect-ratio: 297 / 210;
    padding: 18px;
  }
  .sheet-landscape .construction-group h2 { font-size: 10px; padding: 4px 6px; }
  .sheet h1 { font-size: 20px; margin-bottom: 10px; }
  .sheet-meta { grid-template-columns: minmax(0, 1fr) 38%; gap: 10px; margin-bottom: 8px; }
  .issuer-block { gap: 7px; }
  .subject-row { gap: 8px; margin: 6px 0 8px; }
  .sheet-total { font-size: 17px; padding: 6px 0; margin: 8px 0; }
  .sheet-total span { min-width: 100px; }
  .sheet table th, .sheet table td { padding: 3px 2px; font-size: 8px; line-height: 1.15; }
  .tax-summary { margin-top: 6px; }
  .totals { margin-top: 7px; gap: 3px; font-size: 9px; }
  .totals strong { font-size: 14px; }
  .bank-box, .remarks-box { padding: 6px; margin-top: 6px; font-size: 9px; }
  .bank-box strong, .remarks-box strong { margin-bottom: 4px; }
  .stamp-box { width: 58px; height: 70px; font-size: 8px; }

}

@media (display-mode: standalone) and (max-width: 900px) {
  .sidebar {
    padding-top: calc(10px + env(safe-area-inset-top));
  }
  #printDialog {
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    margin: env(safe-area-inset-top) auto env(safe-area-inset-bottom);
  }
  #receiptItemDialog {
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px);
  }
}

@media (max-width: 700px) {
  /* 明細エディタは行ごとのカードに積み替えて入力・確認しやすくする */
  .table-scroll { overflow-x: hidden; }
  .line-editor thead { display: none; }
  .line-editor, .line-editor tbody, .line-editor tr, .line-editor td {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .line-editor tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 12px;
    background: #fff;
  }
  .line-editor td {
    border: 0;
    padding: 6px 0;
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
  }
  .line-editor td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
  }
  .line-editor td.num { text-align: left; }
  .line-editor input, .line-editor select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 46px;
    text-overflow: ellipsis;
  }
  .line-editor td[data-label="金額"] { font-size: 18px; font-weight: 700; }
  .line-editor td[data-label="操作"] { display: block; }
  .line-editor td[data-label="操作"]::before { content: ""; }
  .line-editor td[data-label="操作"] button { width: 100%; min-height: 44px; }

  /* 一覧（帳票・入金・マスタ）も行カードに積み替え、操作ボタンを隠さない */
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; background: #fff; }
  .data-table td { border: 0; padding: 5px 0; display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; align-items: center; }
  .data-table td::before { content: attr(data-label); color: var(--muted); font-size: 13px; font-weight: 700; }
  .data-table td.num { text-align: left; }
  .data-table td.row-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
  .data-table td.row-actions::before { content: none; }
  .data-table td.row-actions button { width: 100%; min-height: 44px; min-width: 0; }
}

@media (max-width: 560px) {
  .dashboard { grid-template-columns: 1fr 1fr; }
  .home-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .editor-actions button { min-width: 0; }
  .editor-actions .wide { grid-column: 1 / -1; }
  .topbar h2 { font-size: 21px; }
  .card { min-height: auto; padding: 14px; }
  .card b { font-size: 24px; }
  th, td { padding: 8px 6px; }
  .subtext { max-width: 150px; }
  .period-filter {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .period-filter label { min-width: 0; }
  .period-filter button { grid-column: 1 / -1; }
  #printDialog {
    width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }
  #printDialog .dialog-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
    gap: 8px;
    padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  }
  #printDialog .dialog-actions .pdf-status {
    grid-column: 1 / -1;
    margin: 0;
  }
  #printDialog .dialog-actions button {
    width: 100%;
    min-width: 0;
    white-space: normal;
  }
  .dialog-head { padding-top: max(14px, env(safe-area-inset-top)); }
  .sheet { padding: 14px; }
}

@media (max-width: 560px) {
  html.standalone-mode #printDialog {
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    margin: env(safe-area-inset-top) auto env(safe-area-inset-bottom);
  }
  html.standalone-mode #printDialog .dialog-head {
    padding-top: 14px;
  }
  html.standalone-mode #receiptItemDialog {
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px);
  }
}

@media (display-mode: standalone) and (max-width: 560px) {
  #printDialog {
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    margin: env(safe-area-inset-top) auto env(safe-area-inset-bottom);
  }
  #printDialog .dialog-head {
    padding-top: 14px;
  }
  #receiptItemDialog {
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px);
  }
}
