:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1b2430;
  --muted: #5b6876;
  --line: #d9e0e8;
  --primary: #0b3d6b;
  --primary-ink: #ffffff;
  --accent: #eef5fc;
  --grand: #0b6b3d;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 20px;
  background: var(--primary); color: var(--primary-ink);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.brand strong { display: block; font-size: 16px; }
.brand .sub { font-size: 12px; opacity: .8; }
.actions { display: flex; gap: 8px; }

button { font-size: 14px; border-radius: 6px; padding: 8px 14px; cursor: pointer; border: 1px solid transparent; }
button.primary { background: #ffc23c; color: #3a2b00; font-weight: 600; }
button.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
button:disabled { opacity: .6; cursor: progress; }

main { max-width: 1080px; margin: 20px auto; padding: 0 16px 60px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 15px; color: var(--primary); border-bottom: 1px solid var(--line); padding-bottom: 8px; }

.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.span { grid-column: 1 / -1; }

label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--ink);
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc2e6; border-color: #9cc2e6; }
input[readonly] { background: var(--accent); color: var(--ink); font-weight: 600; }

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

/* charge accounts */
.ca-row { display: grid; grid-template-columns: repeat(6, 1fr) 1.2fr; gap: 6px; margin-bottom: 6px; align-items: end; }
.ca-row label { font-size: 11px; }

/* day block */
.day { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 14px; overflow: hidden; }
.day-head { background: var(--accent); padding: 8px 12px; font-weight: 600; font-size: 13px; color: var(--primary); display:flex; justify-content: space-between; }
.day-body { padding: 12px; display: grid; gap: 12px; }
.row { display: grid; gap: 10px; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: 1fr 1fr; }
.subhdr { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 4px 0 -4px; }
.meal label small { color: var(--muted); font-weight: 400; }

.totalbox { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--accent); align-self: start; }
.totalrow { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.totalrow.grand { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; font-size: 16px; color: var(--grand); }
.daysub { text-align: right; font-size: 13px; color: var(--grand); font-weight: 600; }

iframe#pdfPreview { width: 100%; height: 720px; border: 1px solid var(--line); border-radius: 6px; }

/* attachments */
#attachInput { font-size: 13px; }
.attach-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.attach-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--accent); font-size: 13px; }
.attach-list .meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.attach-list .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-list .size { color: var(--muted); font-size: 12px; flex: none; }
.attach-list .badge { flex: none; font-size: 11px; padding: 1px 6px; border-radius: 10px; background: #dfe8f1; color: var(--primary); }
.attach-list .rm { flex: none; border: none; background: transparent; color: #b4232a; cursor: pointer; font-size: 16px; padding: 0 4px; }
.attach-list .warn { color: #b4232a; }

/* send for signature */
.send-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
#sendStatus.ok { color: var(--grand); }
#sendStatus.err { color: #b4232a; }

@media (max-width: 760px) {
  .grid-2, .grid-3, .cols-4, .cols-3, .cols-2 { grid-template-columns: 1fr; }
  .ca-row { grid-template-columns: repeat(3, 1fr); }
}
