:root { --gold: #a8842a; --field: #ececec; --line: #cfcfcf; --err: #b3261e; }
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #222; background: #f6f4ef; }

.toolbar { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 8px 12px; position: sticky; top: 0; background: #f6f4ef; z-index: 5; }
#status { margin-right: auto; font-size: 14px; color: #555; }
#status.err { color: var(--err); font-weight: 600; }
button { font: inherit; padding: 10px 16px; border: 1px solid var(--gold); background: var(--gold); color: #fff; border-radius: 8px; cursor: pointer; min-height: 44px; }
button.secondary { background: #fff; color: var(--gold); }
button.danger { background: #fff; color: var(--err); border-color: var(--err); }
button.icon { background: transparent; border-color: transparent; color: var(--gold); width: 44px; padding: 0; font-size: 22px; opacity: 0; }
button.icon:focus-visible { opacity: .6; }

.sheet { max-width: 900px; margin: 0 auto 24px; background: #fff; padding: 16px; }
.sheet-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.addr { flex: 1 1 260px; font-size: 14px; min-width: 0; }
.logo { height: 64px; width: auto; margin-left: auto; }
h1 { font-size: 20px; margin: 14px 0 8px; }
.picker { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0 12px; }
.picker strong { min-width: 52px; text-align: center; }
.months { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { background: #fff; color: #222; border: 1px solid var(--line); border-radius: 8px; min-height: 40px; min-width: 40px; padding: 0 10px; font-size: 14px; }
.pill[aria-pressed=true] { background: var(--gold); border-color: var(--gold); color: #fff; }
.pill:disabled { opacity: .35; cursor: default; }
.period { display: none; }
.sign label { display: flex; align-items: center; gap: 8px; font-size: 14px; }

select, input, textarea { font: inherit; border: 1px solid var(--line); background: var(--field); border-radius: 4px; padding: 8px; min-height: 40px; color: #111; }
select:focus, input:focus, textarea:focus { outline: 2px solid var(--gold); background: #fff; }
.bad { border-color: var(--err) !important; background: #fdecea !important; }

.table-wrap { overflow-x: auto; }
table { border-collapse: separate; border-spacing: 0 2px; width: 100%; table-layout: fixed; }
th { text-align: left; font-size: 13px; font-weight: 600; padding: 0 2px 2px; }
td { padding: 0 2px; vertical-align: middle; }
td.day { width: 46px; font-size: 13px; text-align: right; padding-right: 6px; }
th.day { width: 46px; }
td.temp { width: 112px; }
th.temp { width: 112px; }
td.temp .cell { display: flex; align-items: center; gap: 4px; }
td.temp input { width: 100%; text-align: right; }
th.temp { white-space: normal; overflow-wrap: anywhere; hyphens: auto; line-height: 1.15; vertical-align: bottom; }
th.note, td.note { width: 56px; text-align: center; padding: 0; }
.nbtn { width: 44px; height: 40px; min-height: 40px; padding: 0; background: #fff; border: 1px solid var(--line); border-radius: 6px; color: #888; display: inline-flex; align-items: center; justify-content: center; }
.nbtn.has { color: var(--gold); border-color: var(--gold); background: #fbf6e8; }
.lbl-prt { display: none; }
.pnote { display: none; }

.sign { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; }
.sign label:first-child { flex: 1 1 260px; }
.sign label:first-child input { flex: 1; min-width: 0; }
.foot { margin-top: 18px; font-size: 11px; color: #444; }

dialog { width: min(640px, 100vw - 16px); max-height: 92vh; border: 0; border-radius: 12px; padding: 16px; }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { margin: 0 0 8px; font-size: 18px; }
dialog h3 { margin: 18px 0 8px; font-size: 16px; }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 10px; display: grid; gap: 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > input[type=text], .row > input:not([type]) { flex: 1 1 160px; min-width: 0; }
.row input[type=number] { width: 84px; }
.row label { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.row input[type=checkbox] { width: 22px; height: 22px; min-height: 0; }
.msg { font-size: 13px; color: var(--err); min-height: 1em; }
.hint { font-size: 13px; color: #555; margin: 0 0 8px; }

@media (max-width: 760px) { .months { display: grid; grid-template-columns: repeat(6, 1fr); width: 100%; } .months .pill { padding: 0; min-width: 0; } }
@media (max-width: 520px) { .sheet { padding: 10px; } .logo { height: 40px; } td.temp, th.temp { width: 90px; } th.note, td.note { width: 48px; } .nbtn { width: 40px; } th { font-size: 12px; } td.day, th.day { width: 42px; } td.day { font-size: 12px; padding-right: 4px; } td.temp input { padding: 8px 4px; } td.temp .cell { gap: 2px; font-size: 13px; } }

@page { size: A4 portrait; margin: 10mm 12mm; }
@media print {
  body { background: #fff; font-size: 10pt; }
  .noprint { display: none !important; }
  .sheet { max-width: none; margin: 0; padding: 0; }
  .logo { height: 20mm; }
  .addr { font-size: 10pt; }
  h1 { font-size: 14pt; margin: 6mm 0 3mm; }
  select, input, textarea { background: var(--field); border: 0; border-radius: 0; padding: 0 2mm; min-height: 0; height: 5.6mm; font-size: 9pt; }
  select { -webkit-appearance: none; appearance: none; background-image: none; min-width: 40mm; }
  table { border-spacing: 0 .6mm; }
  td.day, th { font-size: 9pt; }
  td.day { width: 11mm; } th.day { width: 11mm; }
  td.temp, th.temp { width: 32mm; } td.temp input { height: 5.6mm; }
  .nbtn, .fill { display: none; }
  th.note, td.note { width: auto; text-align: left; }
  .lbl-scr { display: none; } .lbl-prt { display: inline; }
  .pnote { display: block; background: var(--field); min-height: 5.6mm; padding: 0 2mm; font-size: 9pt; line-height: 5.6mm; white-space: pre-wrap; word-break: break-word; }
  .table-wrap { overflow: visible; }
  .period { display: flex; gap: 6mm; margin-bottom: 3mm; font-size: 9pt; }
  .period span { display: flex; align-items: center; gap: 2mm; }
  .period b { font-weight: 400; display: inline-block; min-width: 40mm; height: 5.6mm; line-height: 5.6mm; padding: 0 2mm; background: var(--field); }
  .sign { margin-top: 6mm; }
  .foot { position: fixed; bottom: 0; left: 0; right: 0; font-size: 8pt; }
}

.full { width: 100%; margin-bottom: 6px; }

.editor-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; align-items: center; }
.editor-bar button { min-height: 40px; min-width: 40px; padding: 4px 10px; }
.editor-bar select { min-height: 40px; }
.editor-bar input[type=color] { width: 44px; min-height: 40px; padding: 2px; }
.editor { border: 1px solid var(--line); border-radius: 4px; padding: 10px; min-height: 80px; background: #fff; }
.editor:focus { outline: 2px solid var(--gold); }

.sigbox { width: 160px; height: 56px; padding: 0; border: 1px dashed var(--line); background: var(--field); color: #666; border-radius: 4px; font-size: 13px; }
.sigbox img { display: block; max-width: 100%; max-height: 100%; margin: auto; }
.pad { display: block; width: 100%; height: auto; aspect-ratio: 560 / 200; background: #fff; border: 1px solid var(--line); border-radius: 6px; touch-action: none; cursor: crosshair; }
.sigview { display: block; max-width: 100%; margin: 8px auto 12px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
@media print { .sign { align-items: center; flex-wrap: nowrap; gap: 4mm; } .sign label:first-child { flex: 1 1 0; } .sigbox { flex: none; } .sigbox { width: 40mm; height: 12mm; border: 0; border-radius: 0; } .sigbox .ph { display: none; } }
