:root {
  --ink: #1e3a5f;
  --paper: #fff;
  --desk: #cfc6b8;
  --navy: #1c2b3a;
  --amber: #fbf6ee;
  --amber-bar: #b46a2e;
  --blue: #e7f0f8;
  --line: #1c1c1c;
  --muted: #7d756b;
  --warn: #6e2e24;
  --ok: #1e4634;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--desk);
  color: #1a1a1a;
  font-family: "Segoe UI", Calibri, Arial, sans-serif;
  font-size: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--navy);
  color: #f4efe6;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand strong {
  display: block;
  font-size: 16px;
  letter-spacing: 0.01em;
}

.brand span {
  display: block;
  font-size: 12px;
  opacity: 0.8;
}

.brand .mark {
  display: block;
  height: 36px;
  width: auto;
  background: #fff;
  padding: 2px 4px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.btn {
  border: 1px solid transparent;
  background: #f4efe6;
  color: var(--navy);
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.btn.primary { background: #e0a33a; }

.btn:hover { filter: brightness(0.97); }

.btn:focus-visible,
.status-tabs button:focus-visible,
.tickbtn:focus-visible,
.ticket-link:focus-visible {
  outline: 2px solid #e0a33a;
  outline-offset: 2px;
}

.banner {
  margin: 0;
  padding: 8px 18px;
  background: #243044;
  color: #f4efe6;
  font-size: 14px;
}

.banner.warn { background: var(--warn); }
.banner.ok { background: var(--ok); }

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 12px 48px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin: 0 0 10px;
  font-size: 13px;
}

.swatch {
  width: 14px;
  height: 14px;
  border: 1px solid #1c1c1c;
  display: inline-block;
  margin-right: 6px;
  vertical-align: -2px;
}

.swatch.entry { background: var(--amber); box-shadow: inset 3px 0 0 var(--amber-bar); }
.swatch.auto { background: var(--blue); }

.sheet {
  background: var(--paper);
  box-shadow: 0 10px 28px rgba(40, 30, 10, 0.18);
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.c-label { width: 20%; }
.c-value { width: 30%; }
.c-mid { width: 18%; }
.c-mid2 { width: 14%; }
.c-end { width: 18%; }

.sheet-table td {
  border: 1px solid var(--line);
  padding: 4px 6px;
  vertical-align: top;
  font-size: 12px;
  line-height: 1.35;
}

.k {
  font-weight: 650;
  font-size: 11px;
}

.logo-cell {
  vertical-align: middle;
  padding: 8px 10px;
}

.sheet-logo {
  display: block;
  width: 140px;
  height: auto;
}

.co-cell {
  text-align: right;
  padding: 8px 10px;
  line-height: 1.35;
}

.co-cell strong { font-size: 15px; }

.val {
  font-weight: 700;
  color: var(--ink);
  font-size: 13px;
}

.val.block {
  display: block;
  margin-top: 3px;
  white-space: pre-line;
}

.val.ghost {
  font-weight: 400;
  color: var(--muted);
  font-style: italic;
}

.addr-label { text-decoration: underline; }

.fixed-address {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.4;
  color: #1a1a1a;
}

#problem { min-height: 64px; font-size: 15px; }

#faultyPartSerial { display: block; margin-top: 2px; }

.when-row {
  display: flex;
  gap: 8px;
}

.when-row label {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  font-size: 11px;
  font-weight: 750;
}

.when-row input[type="date"],
.when-row input[type="time"] {
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  border: 1px solid #1c2b3a;
  background: #fff;
  padding: 6px 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.when-show {
  margin-top: 6px;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}

.when-show.ghost {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.flag { font-size: 15px; }

.auto-cell { background: var(--blue); }

.entry-cell {
  background: var(--amber);
  box-shadow: inset 3px 0 0 var(--amber-bar);
}

.sheet input,
.sheet textarea {
  width: 100%;
  border: 0;
  margin: 0;
  padding: 2px 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  resize: none;
  overflow: hidden;
}

.sheet input:focus,
.sheet textarea:focus { outline: none; }

#trouble { min-height: 68px; font-size: 15px; }

#engineer { font-weight: 600; }

.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border: 1px solid currentColor;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--amber-bar);
  vertical-align: 1px;
}

.ctype {
  display: inline-block;
  border: 1px solid var(--line);
  padding: 0 4px;
  margin: 0 2px 2px 0;
  font-size: 10px;
  line-height: 1.6;
}

.ctype.on {
  background: var(--navy);
  color: white;
  font-weight: 700;
}

.status-tabs {
  display: flex;
  gap: 4px;
}

.status-tabs button {
  flex: 1;
  border: 1px solid var(--navy);
  background: white;
  color: var(--navy);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 2px;
  cursor: pointer;
}

.status-tabs button[aria-selected="true"] {
  background: var(--navy);
  color: white;
}

.rating {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

.tick { text-align: center; vertical-align: middle; width: 42px; }

.tickbtn {
  width: 22px;
  height: 18px;
  border: 1px solid var(--line);
  background: white;
  color: transparent;
  font-weight: 800;
  cursor: pointer;
  line-height: 1;
}

.tickbtn[aria-pressed="true"] { color: var(--ink); }

.sign-cell { min-height: 96px; }

.sign-name {
  display: none;
  margin-top: 8px;
  font-family: "Segoe Script", "Brush Script MT", "Segoe Print", cursive;
  font-size: 26px;
  color: #24344d;
  font-weight: 400;
  line-height: 1.1;
}

.stamp-cell { height: 36px; }

.remark-cell textarea { min-height: 88px; font-weight: 600; }

.foot {
  text-align: center;
  font-size: 11px;
  line-height: 1.4;
  padding: 6px;
}

.suggest {
  position: fixed;
  z-index: 20;
  margin: 0;
  padding: 0;
  list-style: none;
  background: white;
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
  max-height: 220px;
  overflow: auto;
}

.suggest button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid #e4e0d8;
  background: white;
  padding: 7px 8px;
  font: inherit;
  cursor: pointer;
}

.suggest button strong { display: block; }
.suggest button small { display: block; color: #5c564e; font-size: 12px; }

.suggest button.on,
.suggest button:hover { background: #f4f0e6; }

.panel {
  margin-top: 18px;
  background: #f7f4ee;
  border: 1px solid #2a2a2a;
}

.panel summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 750;
  background: #efeae1;
}

.panel-note,
.panel .register-form,
.ticket-list { margin: 0; padding: 10px 12px 14px; }

.panel-note { color: #333; font-size: 13px; }

.register-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}

.register-form label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  font-weight: 650;
}

.register-form label.file-btn {
  flex-direction: row;
  display: inline-flex;
  width: auto;
  font-size: 13px;
  font-weight: 650;
  padding: 8px 12px;
}

.register-form input,
.register-form select,
.register-form textarea {
  font: inherit;
  font-weight: 500;
  padding: 6px 8px;
  border: 1px solid var(--navy);
  background: white;
  color: #1a1a1a;
}

.wide { grid-column: 1 / -1; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.file-btn {
  display: inline-flex;
  align-items: center;
  background: #f4efe6;
  color: var(--navy);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  border: 1px solid transparent;
}

.ticket-list { list-style: none; }

.ticket-list li {
  display: flex;
  gap: 8px;
  align-items: stretch;
  border-top: 1px solid #ddd6ca;
}

.ticket-link {
  flex: 1;
  text-align: left;
  border: 0;
  background: transparent;
  font: inherit;
  min-height: 48px;
  padding: 12px 4px;
  cursor: pointer;
}

.ticket-list li .remove,
.ticket-list li .load {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--navy);
}

@media (max-width: 800px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions .btn { min-height: 44px; }
  .register-form { grid-template-columns: 1fr; }
  .when-row { flex-direction: column; }
  .c-label { width: 34%; }
  .c-value { width: 66%; }
}

@media print {
  body { background: white; }
  .no-print { display: none !important; }
  .wrap { max-width: none; margin: 0; padding: 0; }
  .sheet { box-shadow: none; }
  .auto-cell,
  .entry-cell {
    background: transparent !important;
    box-shadow: none !important;
  }
  .val, .sheet input, .sheet textarea, #trouble, #problem, .fixed-address { color: #1a1a1a; }
  .sheet input, .sheet textarea { font-weight: 600; }
  .sheet-logo {
    display: block !important;
    visibility: visible !important;
    width: 140px !important;
    height: auto !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  #engineer { display: none; }
  .sign-name { display: block; }
  .val.ghost { display: none !important; }
  .sheet input::placeholder,
  .sheet textarea::placeholder { color: transparent; }
  .when-row,
  .when-show.ghost { display: none !important; }
  .when-show {
    display: block;
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
  }
  .status-tabs button { display: none; border: 0; background: transparent; padding: 0; }
  .status-tabs button[aria-selected="true"] {
    display: inline;
    color: #1a1a1a;
    font-size: 14px;
    font-weight: 700;
  }
  .ctype.on {
    background: transparent;
    color: #1a1a1a;
    outline: 1.5px solid #1a1a1a;
  }
  @page { size: A4; margin: 8mm; }
}
