* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Hiragino Kaku Gothic Pro', 'Meiryo', sans-serif; background: #f0f2f5; font-size: 18px; }

.screen { width: 100%; min-height: 100vh; padding: 16px; }
.hidden { display: none !important; }
.center-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; gap: 16px; }

/* Buttons */
.btn { padding: 13px 24px; font-size: 18px; border: none; border-radius: 6px; cursor: pointer; }
.btn-primary  { background: #1976D2; color: white; }
.btn-success  { background: #388E3C; color: white; }
.btn-warning  { background: #F57C00; color: white; }
.btn-danger   { background: #D32F2F; color: white; }
.btn-secondary{ background: #757575; color: white; }
.btn:active { opacity: 0.8; }

/* Input grid */
.grid-header { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1px; background: #1976D2; color: white; font-weight: bold; padding: 6px; margin-bottom: 1px; font-size: 16px; }
.grid-3col   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1px; background: #ddd; }
.grid-col    { display: flex; flex-direction: column; gap: 1px; background: #ddd; }
.product-cell { background: white; padding: 6px 4px; min-height: 58px; border: 2px solid transparent; }
.product-cell.empty-cell { background: #FFF8E1; }
.product-cell.has-input { border-color: #F57C00; background: #FFF3E0; }
.product-cell.extra-selected { background: #FFF8E1; }
.cell-sym    { font-size: 14px; font-weight: bold; color: #333; text-align: center; min-height: 20px; overflow-wrap: anywhere; }
.cell-fields { display: flex; gap: 4px; justify-content: center; }
.cell-field  { width: 50px; min-height: 30px; text-align: center; border: 1px solid #999; border-radius: 4px; font-size: 18px; padding: 3px; cursor: pointer; background: white; font-weight: bold; }
.cell-field.has-value { background: #FFE0B2; border-color: #F57C00; color: #111; }
.cell-field.disabled { background: #eee; color: #bbb; cursor: default; border-color: #ddd; }
.cell-label  { font-size: 12px; color: #666; text-align: center; }
.cell-select { width: 100%; min-height: 36px; font-size: 15px; margin-bottom: 2px; }
.clear-extra-btn { font-size: 14px; color: #D32F2F; border: 0; background: transparent; cursor: pointer; padding: 2px 6px; }

/* Numpad overlay */
#numpad-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 200; }
.numpad-box { background: white; border-radius: 12px; padding: 20px; min-width: 240px; text-align: center; }
.numpad-title   { font-size: 14px; color: #666; margin-bottom: 8px; }
.numpad-display { font-size: 36px; font-weight: bold; border-bottom: 2px solid #333; padding-bottom: 8px; margin-bottom: 12px; min-height: 52px; }
.numpad-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.numpad-keys button { font-size: 22px; padding: 14px; border: 1px solid #ddd; border-radius: 6px; background: white; cursor: pointer; }
.numpad-keys button:active { background: #e3f2fd; }
.numpad-ok  { width: 100%; padding: 12px; font-size: 18px; background: #388E3C; color: white; border: none; border-radius: 6px; cursor: pointer; margin-top: 4px; }
.numpad-clr { width: 100%; padding: 8px; font-size: 14px; background: #D32F2F; color: white; border: none; border-radius: 6px; cursor: pointer; margin-top: 4px; }

/* Loading overlay */
#loading-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 300; }
.loading-box { background: white; padding: 24px 40px; border-radius: 8px; font-size: 18px; }

/* Inspection */
.inspection-note { padding: 10px 14px; background: #E8F5E9; color: #1B5E20; font-weight: bold; flex-shrink: 0; }
.insp-item { background: white; padding: 14px; margin-bottom: 10px; border-radius: 6px; display: flex; align-items: center; gap: 16px; border-left: 6px solid transparent; flex-wrap: wrap; }
.insp-item.changed { border-left-color: #F57C00; background: #FFF8E1; }
.insp-item.removed { border-left-color: #D32F2F; }
.insp-item input[type=checkbox] { width: 30px; height: 30px; cursor: pointer; }
.insp-item.checked { background: #E8F5E9; }
.insp-sym { font-size: 21px; font-weight: bold; min-width: 90px; }
.insp-vals { font-size: 18px; color: #333; font-weight: bold; }
.insp-before { font-size: 15px; color: #666; }
.insp-extra-badge { font-size: 13px; background: #FF9800; color: white; padding: 3px 7px; border-radius: 4px; }
.insp-remove-badge { font-size: 13px; background: #D32F2F; color: white; padding: 3px 7px; border-radius: 4px; }

/* Admin list */
.record-row { background: white; padding: 14px 16px; margin-bottom: 6px; border-radius: 6px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-size: 18px; }
.record-row:active { background: #e3f2fd; }
.record-status { font-size: 12px; padding: 2px 8px; border-radius: 4px; }
.status-badge { font-size: 15px; padding: 4px 9px; border-radius: 4px; background: #E0E0E0; color: #333; }
.status-sent    { background: #BBDEFB; color: #1565C0; }
.status-revised { background: #C8E6C9; color: #2E7D32; }

.complete-summary { margin-top: 14px; background: white; border-radius: 8px; padding: 14px; min-width: min(420px,100%); box-shadow: 0 1px 4px rgba(0,0,0,0.12); text-align: left; }
.complete-summary-title { font-weight: bold; margin-bottom: 8px; }
.complete-summary-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid #eee; }

.densan-detail-wrap { overflow-y: auto; flex: 1; padding: 14px; }
.detail-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.detail-meta div { background: white; border-radius: 6px; padding: 10px 12px; }
.detail-meta span { display: block; color: #666; font-size: 14px; margin-bottom: 3px; }
.detail-meta strong { font-size: 18px; }
.detail-table { width: 100%; border-collapse: collapse; background: white; font-size: 18px; }
.detail-table th, .detail-table td { border: 1px solid #ddd; padding: 10px 8px; text-align: left; }
.detail-table th { background: #F5F7FA; }
.detail-symbol { font-weight: bold; }
.detail-number { text-align: right; font-weight: bold; font-size: 20px; }

/* Print */
@media print {
  body { background: white; font-family: 'Hiragino Kaku Gothic Pro', 'Meiryo', sans-serif; }
  .no-print { display: none !important; }
  .print-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1px; border: 1px solid #000; }
  .print-cell { border: 1px solid #000; padding: 2px 4px; font-size: 10px; }
  .print-cell.header { background: #f0f0f0; font-weight: bold; text-align: center; }
}
